Alpha Patches for 1.3.39

Jay Estabrook - Alpha Migration Tools - LINUX Project (jestabro@brillig.amt.tay1.dec.com)
Fri, 10 Nov 95 20:17:31 -0500


Please find attached to the end of this mail, four small patches which I've
made to 1.3.39 for Alpha support.

As three are *VERY* important for anyone building Alpha kernels from 1.3.39,
I've described what they involve and why they are needed.

!!! HIGHEST PRIORITY !!!!
==========================

1. drivers/char/keyboard.c

the current Alpha code to init the keyboard is *SERIOUSLY* wrong; my fault.
this patch prevents the "unrecognized scancode" messages, that have plagued
many (or could when they installed the bogus code).

2. drivers/sound/soundcard.c

on the Alpha, virt_to_bus() *MUST* be used to provide the physical address
to be passed to the DMA engine, *NOT* virt_to_phys(). Only the former will
provide the appropriate "cookie" for the DMA engine to issue onto the bus
to get at host memory.

3. drivers/scsi/scsi.c

the SCSI DMA malloc code is *seriously* flawed; it was only allocating
4 bytes for a pointer, when the Alpha needs 8.

NOTE: the symptom for this would be kernel crashes during boot when more
than 4 SCSI hard disks and SCSI CDROMs are present in a system.

Please note that this patch only fixes the allocation of enough space to
hold the necessary number of pointers.

DMA PAGES ON THE ALPHA ARE ONLY HALF UTILIZED!!! This patch does *NOT*
fix the fact that an Alpha's 8K page allocated for DMA usage is only
filled with 8 sectors (8*512=4k) of DMA buffers.

LOW PRIORITY (cleanup)
======================

4. net/ipv4/tcp.c

this patch only completes the use of "sock_error()" where appropriate.

--Jay++

-------------------------------------------------------------------------------
American Non Sequitur Society: we don't make sense, but we do like pizza...

Jay A Estabrook Alpha Migration Tools
Mailstop: TAY1-2 (DTN) 227-4202
Digital Equipment Corp. (external) (508) 952-4202
151 Taylor Street enet: jestabro@amt.tay1.dec.com
Littleton, MA 01460-1407 decnet: tallis::jestabro
-------------------------------------------------------------------------------

diff -u --recursive -P old/drivers/char/keyboard.c new/drivers/char/keyboard.c
--- old/drivers/char/keyboard.c Tue Nov 7 07:18:35 1995
+++ new/drivers/char/keyboard.c Fri Nov 10 15:12:40 1995
@@ -1260,6 +1260,9 @@
* keyboard controller mode register bits
*/
#define KBD_EKI (unsigned int) 0x01
+#define KBD_SYS (unsigned int) 0x04
+#define KBD_DMS (unsigned int) 0x20
+#define KBD_KCC (unsigned int) 0x40

#define TIMEOUT_CONST 500000

@@ -1376,12 +1379,12 @@
}

/*
- * enable keyboard interrupt, operate in "real" mode,
- * Enable keyboard (by clearing the disable keyboard bit),
- * no conversion of keycodes.
+ * Enable keyboard interrupt, operate in "sys" mode,
+ * enable keyboard (by clearing the disable keyboard bit),
+ * disable mouse, do conversion of keycodes.
*/
kbd_write(KBD_CNTL_REG, KBD_WRITE_MODE);
- kbd_write(KBD_DATA_REG, KBD_EKI);
+ kbd_write(KBD_DATA_REG, KBD_EKI|KBD_SYS|KBD_DMS|KBD_KCC);

/*
* now ENABLE the keyboard to set it scanning...
diff -u --recursive -P old/drivers/scsi/scsi.c new/drivers/scsi/scsi.c
--- old/drivers/scsi/scsi.c Thu Nov 9 06:24:08 1995
+++ new/drivers/scsi/scsi.c Fri Nov 10 15:57:05 1995
@@ -2499,7 +2499,8 @@
for(i=0; i < dma_sectors >> 3; i++)
scsi_init_free(dma_malloc_pages[i], PAGE_SIZE);
if (dma_malloc_pages)
- scsi_init_free((char *) dma_malloc_pages, dma_sectors>>1);
+ scsi_init_free((char *) dma_malloc_pages,
+ (dma_sectors>>3)*sizeof(*dma_malloc_pages));
dma_malloc_pages = NULL;
if (dma_malloc_freelist)
scsi_init_free(dma_malloc_freelist, dma_sectors>>3);
@@ -2555,8 +2556,10 @@
memset(new_dma_malloc_freelist, 0, new_dma_sectors >> 3);

new_dma_malloc_pages = (unsigned char **)
- scsi_init_malloc(new_dma_sectors >> 1, GFP_ATOMIC);
- memset(new_dma_malloc_pages, 0, new_dma_sectors >> 1);
+ scsi_init_malloc((new_dma_sectors>>3)*sizeof(*new_dma_malloc_pages),
+ GFP_ATOMIC);
+ memset(new_dma_malloc_pages, 0,
+ (new_dma_sectors>>3)*sizeof(*new_dma_malloc_pages));
}

/*
@@ -2582,8 +2585,10 @@

if (dma_malloc_pages)
{
- memcpy(new_dma_malloc_pages, dma_malloc_pages, dma_sectors >> 1);
- scsi_init_free((char *) dma_malloc_pages, dma_sectors>>1);
+ memcpy(new_dma_malloc_pages, dma_malloc_pages,
+ (dma_sectors>>3)*sizeof(*dma_malloc_pages));
+ scsi_init_free((char *) dma_malloc_pages,
+ (dma_sectors>>3)*sizeof(*dma_malloc_pages));
}

dma_free_sectors += new_dma_sectors - dma_sectors;
@@ -3084,7 +3089,7 @@

/* One pointer per page for the page list */
dma_malloc_pages = (unsigned char **)
- scsi_init_malloc(dma_sectors >> 1, GFP_ATOMIC);
+ scsi_init_malloc((dma_sectors >> 3)*sizeof(*dma_malloc_pages), GFP_ATOMIC);
dma_malloc_pages[0] = (unsigned char *)
scsi_init_malloc(PAGE_SIZE, GFP_ATOMIC | GFP_DMA);
return 0;
diff -u --recursive -P old/drivers/sound/soundcard.c new/drivers/sound/soundcard.c
--- old/drivers/sound/soundcard.c Wed Nov 8 10:07:27 1995
+++ new/drivers/sound/soundcard.c Fri Nov 10 15:57:45 1995
@@ -604,7 +604,7 @@
}
}
dmap->raw_buf = start_addr;
- dmap->raw_buf_phys = virt_to_phys (start_addr);
+ dmap->raw_buf_phys = virt_to_bus (start_addr);

memset (dmap->raw_buf, 0x00, audio_devs[dev]->buffsize);

diff -u --recursive -P old/net/ipv4/tcp.c new/net/ipv4/tcp.c
--- old/net/ipv4/tcp.c Mon Nov 6 10:59:01 1995
+++ new/net/ipv4/tcp.c Fri Nov 10 15:12:13 1995
@@ -2306,7 +2306,7 @@

if (sk->err)
{
- copied = -xchg(&sk->err,0);
+ copied = sock_error(sk);
break;
}