
Where do i get the patches ?
----------------------------
These kernel-patches as well as patches for gcc are available at:
http://www.pfrst.de/download.html


Sep 24 2018

Added IP28 Impact patches for linux-4.17.6.


Nov 01 2011

Optional (superfluous ;-) add-on patch to make use of SGI's startup screen.


Jun 06 2011

Added a cache-flush utility for the XImpact's DMA-refresh (privately
used for a longer time now) to the Impact-driver - implemented by
abusing ioctl(/dev/fb?,TCFLSH)  ;-)
Since the attitude towards sys_cacheflush(), which otherwise is the
only way to do a cache-flush in userspace, seems to be to get rid of
it, not to extend it (for DCACHE), it is well justified to implement 
this specialized cache-flush system-call locally in the Impact-driver.
(A patch for the XImpact Xserver, to make use of it, is available)


Mar 20 / Apr  9 2011

- Impact framebuffer-console/kernel-interface patches for 2.6.36.
- Some enhancements to the Impact driver (for all versions).


May 21/31 2009

There is basic support for the IP28 in the linux-mips kernel-tree now
(somewhere above 2.6.20), but graphics support ist still missing there.
So here are the patches, which provide the Impact framebuffer-console
and kernel-interface for the XImpact Xserver. (As of this writing for
2.6.29.2, 2.6.30-rc7)


May 31 2009

Enable the Impact-driver's early console, which allows to show kernel
messages almost from the beginning of the boot process until the
framebuffer-console takes over, by
- building the kernel with CONFIG_EARLY_PRINTK or at runtime by
- "setenv OSLoadOptions impact=early" in PROM's command-monitor.

Unconditionally disable the Impact-driver's early console by
- "setenv OSLoadOptions impact=noearly" in PROM's command-monitor.


Apr 17 2007

Updated/Added patches for 2.6.14, 2.6.17, 2.6.18, 2.6.19, 2.6.20.

- Modifications to enable FastSCSI and other enhancments on the WD33C93
  scsi driver are included in sgiwd93.diff. (See comments in the patch)
  These were already independently comitted and are expected to become
  commonly available in 2.6.21.

- A patch (mainly a backport of a 2.6.21 feature) to adjust the memory
  map to the start of physical memory is added. Since IP28 memory starts
  at 512MB, this saves 7MB. (See comments in the patch)


Jan 11 2006

Added patches for HAL2 driver (preventing it from uncached writes, which
would crash the machine).

Dec 12 2005

Changes to Impact-driver's DMA setup to get rid of nasty "dmabusy"-hangs,
which sometimes (too often) occured, when starting the Xserver.

Oct 15 2005
Sep 25 2005

1) (Re-)enabled extended mmap in drivers/video/impact.c to allow for
   frame-buffer-DMA.  More changes to support DMA-Xserver.
2) Bus-error counters in /proc/cpuinfo (removed register dumps).

Jul 27 2005

1) Enabled mmap in drivers/video/impact.c.
2) Workaround in drivers/input/serio/i8042.c to make driver accept
   the PS/2-AUX-device (mouse).


Jun 13 2005

New features added:

1) A extended bus error handler (ip28-berr.c to replace ip22-berr.c),
   which allows to get rid of the myriads of cache-barriers before
   potentially dangerous load instructions. (This handler may appear a
   bit too verbose though, if you tend to run into "speculated" bus
   errors often :)

   You can get rid of the now obsolete cache-barriers by changing the
   body of `check_pattern_for_store' in final.c (or in the compiler
   patch):

	--- final.c Wed Apr  6 23:58:23 2005
	+++ final.c Wed Apr  6 23:58:23 2005
	@@ -4299,7 +4299,7 @@
	
	   if (body && GET_CODE (body) == SET)
	     {
	-      rtx x = find_mem_expr (body);
	+      rtx x = find_mem_expr (SET_DEST (body));
	
	       if (x && check_mem_expr (x))
	         return 1;

   (This is for 3.4.2, other versions have different line numbers).

2) It's now possible to operate the machine in "standalone" fashion,
   since Stanislaw Skowronek's Impact-graphics driver is now adapted to
   Indigo2.  A lot is still unclear, but it works so far.
   Note, that the driver relies on the PROM to properly initialize the
   impact-board. To achieve this, the machine must be booted with
   graphics console (`setenv console g') selected.

3) Switching between "normal" and "slow" (allowing uncached memory
   writes) is now contained.


Apr 27 2005

Updated patches to Mips-CVS's 2.6.12-rc2 (20050419) and 2.4.30 (20050424).
Some minor cleanups.  2.6.12 patches should fit to 2.6.11 as well (?).


Feb 12 2005

2.6.10 [Read README+2.6.10]

It's recommended to apply the patches in the respective linux-2.[46].*
directory by doing a "patch --ignore-whitespace -p1<patch-file".
(the patch files have any trailing whitespace removed)

Jan  6 2005

[sgiwd93.c]  It seems, there is no way around intercepting all scsi
input-buffers.  Otherwise one or another will be corrupted, possibly by
the user process, which passed it down to the driver, but the culprit
could not (yet?) be found. (In most cases the buffer-page doesn't appear
in the TLB).
It's not even sure, that in this case a feasible protection scheme is
more effective than copying back from a intermediate (bounce-) buffer.
So we just make this fixed buffer big enough (2kB in 2.4, PAGE_SIZE in
2.6) and do all scsi-input through it.

========================================================================

Nov 21 2004


Linux port to SiliconGraphics Indigo2 R10000 (IP28)
---------------------------------------------------


Starting points for the port are:

* Debian 3.1 (sarge), kernel-source 2.4.22-6 with mips kernel-patch,
  Version: 2.4.22-0.030928.3 applied, while (at least) the ip28-modified
  files are taken from the current linux-mips.org/cvsweb/linux_2_4 revision,
  whenever possible.  (arch/mips64)

* Kernel source 2.6.6 form kernel.org, while (at least) the ip28-modified
  files are taken from the current linux-mips.org/cvsweb/linux revision,
  whenever possible.  (arch/mips)


The kernels were built with gcc-2.95.4-1 and binutils-2.13.2.1 from
ftp.linux-mips.org/pub/linux/mips/crossdev. This applies to cross-build
on iX86 as well as to native-build only) on IP28.


How well does it work ?
-----------------------
While the 2.4 kernel behaved pretty well and stable (with hardhat 5.1 from
MIPS), during the recent weeks, the 2.6 system still slowly falls to sleep,
while working through rc.sysinit (with nfs-root as with on-disk-root).
Couldn't find the reason yet.  May be, someone will give it a try and will
have better luck ;-)
(kumba@gentoo.org has tested the 2.4 version with gcc 3.x on Gentoo Linux
more or less succesfully)


Difficulties and pitfalls on IP28:
----------------------------------
In the current state of affairs, there is no guarantee, that the kernel
will run stable  (You've been warned ;-).

There are two related main "inconveniencies" with IP28:
1. Non-cache-coherent operation due to the IP28-design in general and
2. side effects of R10000's speculative instruction execution.
(See the R10000 User's Manual and IRIX Device Driver Manuals)

These problems can (must) partially be solved on a per driver basis:
Each device driver that does DMA, must write back and invalidate the cache
corresponding to output buffers before DMA operation.  Input buffers must be
cache-aligned (by address and size !), their corresponding - maybe dirty -
cache must be invalidated before the operation and invalidated after, to
avoid, that read data are shadowed by the effects of speculative loads.

Speculative stores, which may induce damaging write backs, can not completely
be solved at the source code level.  To be save, the compiler's assistance is
needed, which must insert appropriate cache barriers at basic blocks with
stores to memory.
Patches for gcc 2.95.4 and 3.4.2 to achieve this are now available at the
same site, where you find this readme.
Moreover we can protect the DMA input by appropriate locating the buffers.
Though this only locally gives protection, the result seems quite satisfying
(so far...)

Damage by speculative stores is not merely theoretical, it does happen.
Examples:

* Corrupted input buffers:
 When compiling the kernel on the Indigo2 sooner or later a compiler
 error message appeared, complaining about a corrupted source file.
 The "defect" was always a well aligned (multiple of) 128 Byte region.
 It did not reside on disk, just in memory, disappearing, (e.g.) when the
 machine was rebooted. The problem was solved by intercepting all scsi
 input buffers, passed to the driver, and redirecting DMA to a "save place".
 (Copying the input to these buffers only after DMA completed).

* Memory access beyond ram:
 tcp_init() inits the bind hash buckets in a loop:
 for (i = 0; i < tcp_bhash_size; i++) {
   tcp_bhash[i].lock = SPIN_LOCK_UNLOCKED;
   tcp_bhash[i].chain = NULL;
 }
 Under certain configurations tcp_bhash will be allocated just below the
 end of ram, and we get a bus error at the first address beyond ram. It can
 be seen, by a cache barrier as first statement in the loop, which let's the
 bus error disappear, that the culprit indeed is a speculative store.
 The problem was solved by reserving (making unavailable for allocation) the
 last page of ram

* Store to an invalid address:
 vsprintf calls vsnprintf(buf, 0xFFFFFFFFUL, fmt, args).  Here we can get
 a bus error at &buf[0xFFFFFFFFUL], although the condition, which would
 induce storing the trailing zero there always is false.
 This is the kind of problem, that can only be solved by a local cache
 barrier, i.e. it's the compiler's task to put these barriers everywhere
 they might be needed.



Other open questions and problems:
----------------------------------

* Find out, why we may not switch on parity error reporting, neither on GIO64
  nor on main memory, but leave it disabled as we take over the settings from
  PROM (see arch/mips/sgi-ip22/ip22-mc.c).  Must this remain so ? Is this
  caused by the ECC-architecture of the IP28 ?

* There is not enough publically available information to implement the
  ip2[68]_ucmem functions, switching between normal and slow mode (see
  Device Driver Prog. Guide 007-2490-001, or IRIX' man ip26_ucmem(D3))
  Only slow mode allows uncached writes to main memory. However, we can
  do these writes, since the PROM leaves the machine in slow mode.


Aug 19 2004
