sgiwd93.c fix for multiple disks
PATCH 1/1 sgiwd93.c fix for multiple disks
Hi,
the attached patch fixes part of the DMA problems we see with multiple disks and the sgiwd93.c with DISCONNECTs. Klaus patch formerly just disabled all DMA replacing it with PIO which is a major performance hit.
This patch simply deletes all the HPC Scatter/Gather stuff thus we will see a couple more interrupts due to all segments beeing transferred individually. The transfer itself still happens with the HPC DMA thus the performance impact will not be that large. I am running a test right now but it seems the error is gone.
This also touches the wd33c93.c generic part which brings us closer to mainstream as these to lines are a difference between the sgi/mips tree and the mainline kernel as we would need this kind of modification if we would do the scatter-gather DMA.
Index: sgiwd93.c
===================================================================
RCS file: /cvs/linux/drivers/scsi/sgiwd93.c,v
retrieving revision 1.28
sgiwd93.c +10 -74
@@ -115,42 +115,16 @@ hdata->dma_dir = datainp; -if (cmd->SCp.buffers_residual) { -struct scatterlist *slp = cmd->SCp.buffer; -int i, totlen =0 ; - -#ifdef DEBUG_DMA -printk ("SCLIST<" ); -#endif -for (i =0 ; i <= cmd->SCp.buffers_residual; i++) { -#ifdef DEBUG_DMA -printk ("[%p,%d]" , slp[i].address, slp[i].length); -#endif -fill_hpc_entries (&hcp, slp[i].address, slp[i].length); - totlen += slp[i].length; - } -#ifdef DEBUG_DMA -printk (">tlen<%d>" , totlen); -#endif - hdata->dma_bounce_len = totlen;/* a trick... */ -write_wd33c93_count (regs, totlen); - }else { -/* Non-scattered dma. */ -#ifdef DEBUG_DMA -printk ("ONEBUF<%p,%d>" , cmd->SCp.ptr, cmd->SCp.this_residual); -#endif -/* -* wd33c93 shouldn't pass us bogus dma_setups, but -* it does:-( The other wd33c93 drivers deal with -* it the same way (which isn't that obvious). -* IMHO a better fix would be, not to do these -* dma setups in the first place -*/ -if (cmd->SCp.ptr ==NULL ) -return 1 ; -fill_hpc_entries (&hcp, cmd->SCp.ptr,cmd->SCp.this_residual); -write_wd33c93_count (regs, cmd->SCp.this_residual); - } +/* +* wd33c93 shouldn't pass us bogus dma_setups, but +* it does:-( The other wd33c93 drivers deal with +* it the same way (which isn't that obvious). +* IMHO a better fix would be, not to do these +* dma setups in the first place +*/ +if (cmd->SCp.ptr ==NULL ) +return 1 ; +fill_hpc_entries (&hcp, cmd->SCp.ptr,cmd->SCp.this_residual);/* To make sure, if we trip an HPC bug, that we transfer * every single byte, we tag on an extra zero length dma
@@ -196,44 +170,6 @@ } hregs->ctrl =0 ; -/* See how far we got and update scatterlist state if necessary. */ -if (SCpnt->SCp.buffers_residual) { -struct scatterlist *slp = SCpnt->SCp.buffer; -int totlen, wd93_residual, transferred, i; - -/* Yep, we were doing the scatterlist thang. */ - totlen = hdata->dma_bounce_len; - wd93_residual =read_wd33c93_count (regp); - transferred = totlen - wd93_residual; - -#ifdef DEBUG_DMA -printk ("tlen<%d>resid<%d>transf<%d> " , - totlen, wd93_residual, transferred); -#endif - -/* Avoid long winded partial-transfer search for common case. */ -if (transferred != totlen) { -/* This is the nut case. */ -#ifdef DEBUG_DMA -printk ("Jed was here..." ); -#endif -for (i =0 ; i <= SCpnt->SCp.buffers_residual; i++) { -if (slp[i].length >= transferred) -break ; - transferred -= slp[i].length; - } - }else { -/* This is the common case. */ -#ifdef DEBUG_DMA -printk ("did it all..." ); -#endif - i = SCpnt->SCp.buffers_residual; - } - SCpnt->SCp.buffer = &slp[i]; - SCpnt->SCp.buffers_residual = SCpnt->SCp.buffers_residual - i; - SCpnt->SCp.ptr = (char *) slp[i].address; - SCpnt->SCp.this_residual = slp[i].length; - }#ifdef DEBUG_DMA printk ("\n" );#endif
Index: wd33c93.c
===================================================================
RCS file: /cvs/linux/drivers/scsi/wd33c93.c,v
retrieving revision 1.19
wd33c93.c +2 -0
@@ -612,6 +612,7 @@ (is_dir_out(cmd))?DATA_OUT_DIR:DATA_IN_DIR)) write_wd33c93_count(regs, 0); /* guarantee a DATA_PHASE interrupt */ else { +write_wd33c93_count (regs, cmd->SCp.this_residual);write_wd33c93 (regs,WD_CONTROL ,CTRL_IDI |CTRL_EDI |CTRL_DMA ); hostdata->dma =D_DMA_RUNNING ; }
@@ -733,6 +734,7 @@ hostdata->dma_cnt++;#endif write_wd33c93 (regs,WD_CONTROL ,CTRL_IDI |CTRL_EDI |CTRL_DMA ); +write_wd33c93_count (regs, cmd->SCp.this_residual);if ((hostdata->level2 >=L2_DATA ) || (hostdata->level2 ==L2_BASIC && cmd->SCp.phase ==0 )) {
Flo
Signature · 2 lines
Florian Lohoff [email protected] +49-5201-669912 Nine nineth on september the 9th Welcome to the new billenium
Quoted 10 lines · Florian Lohoff
Hi,
the attached patch fixes part of the DMA problems we see with multiple disks and thesgiwd93.cwith DISCONNECTs. Klaus patch formerly just disabled all DMA replacing it with PIO which is a major performance hit.This patch simply deletes all the HPC Scatter/Gather stuff thus we will see a couple more interrupts due to all segments beeing transferred individually. The transfer itself still happens with the HPC DMA thus the performance impact will not be that large. I am running a test right now but it seems the error is gone.
Ok - I am running the attached script right now which copies a kernel source tree from one disk to another disk in a loop. I ran this on the a 133Mhz R4600 Indy with 2 SCSI Disks on the same SCSI bus. Without the patch not a single cycle in this script made it through as on page in the binarys would be corrupted. Also a whole bunch of files of the source tree would be broken, mangled truncated - Whatever might happen. Nothing of this now happened while running the test for the last 5 hours. The machine is still up and running and kind of responsive.
I am unsure if we should put this into CVS as it brings us correctness for the price of some performance penalty.
#!/bin/sh
TMP=tempfile
MD5OUT=tempfile
LOG=/home/flo/break/log
SRC=/home/flo/break/
DST=/mnt/break/
[ ! -d $DST ] && mkdir $DST
[ ! -d $DST ] && exit 1
while [ 1 ]; do
[ -d $DST/linux.bak ] && rm -rf $DST/linux.bak
[ -d $DST/linux ] && mv $DST/linux $DST/linux.bak
[ -d $DST/linux.bak.md5sum ] && rm -f $DST/linux.bak.md5sum
[ -f $DST/linux.md5sum ] && mv $DST/linux.md5sum $DST/linux.bak.md5sum
rm -f $TMP $MD5OUT
printf "Starting copy %s - " "`date +\"%y-%m-%d %H:%M:%S\"`" >$TMP
(cd $SRC ; tar -cf - linux* ) | ( cd /$DST ; tar -xf - ; sync )
printf "Finished %s\n" "`date +\"%y-%m-%d %H:%M:%S\"`" >>$TMP
printf "Checking md5sum %s - " "`date +\"%y-%m-%d %H:%M:%S\"`" >>$TMP
md5sum -cv $DST/linux.md5sum >$MD5OUT 2>&1
totlines=`wc -l $MD5OUT | awk '{ print $1 }'`
failedlines=`grep -v OK $MD5OUT | wc -l | awk '{ print $1 }'`
printf "Finished %s\n" "`date +\"%y-%m-%d %H:%M:%S\"`" >>$TMP
printf "%d files failed out of %d\n" $failedlines $totlines >>$TMP
grep -v OK $MD5OUT >>$TMP
cat $TMP >>$LOGdone
Flo
Signature · 2 lines
Florian Lohoff [email protected] +49-5201-669912 Nine nineth on september the 9th Welcome to the new billenium
Quoted 21 lines · Florian Lohoff
Quoted 10 lines · Florian Lohoff
Hi,
the attached patch fixes part of the DMA problems we see with multiple disks and thesgiwd93.cwith DISCONNECTs. Klaus patch formerly just disabled all DMA replacing it with PIO which is a major performance hit.This patch simply deletes all the HPC Scatter/Gather stuff thus we will see a couple more interrupts due to all segments beeing transferred individually. The transfer itself still happens with the HPC DMA thus the performance impact will not be that large. I am running a test right now but it seems the error is gone.
Ok - I am running the attached script right now which copies a kernel source tree from one disk to another disk in a loop. I ran this on the a 133Mhz R4600 Indy with 2 SCSI Disks on the same SCSI bus. Without the patch not a single cycle in this script made it through as on page in the binarys would be corrupted. Also a whole bunch of files of the source tree would be broken, mangled truncated - Whatever might happen. Nothing of this now happened while running the test for the last 5 hours. The machine is still up and running and kind of responsive.
Quoted 2 lines
I am unsure if we should put this into CVS as it brings us correctness for the price of some performance penalty.
Can you very roughly estimate the performance hit - let's say the slow down when copying the whole kernel-tree once?
-- Guido
Quoted 6 lines
Quoted 3 lines
I am unsure if we should put this into CVS as it brings us correctness for the price of some performance penalty.
Can you very roughly estimate the performance hit - let's say the slow down when copying the whole kernel-tree once?
-- Guido
Hi all,
I've done some bonnie++ tests and everything looks good IMHO. See attachments (new_speed is with lolo's patch and old_speed without). I vote for commit. Cool work !
Cya, Klaus
Signature · 4 lines
Full Name : Klaus Naumann | (http://www.mgnet.de/) (Germany) Nickname : Spock | Org.: Mad Guys Network Phone / FAX : ++49/177/7862964 | E-Mail: ([email protected]) PGP Key : www.mgnet.de/keys/key_spock.txt
Version 1.02 ------Sequential Output------ --Sequential Input- --Random-
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
ivy 368M 1415 95 2437 7 1003 4 1208 81 2298 6 90.7 2
------Sequential Create------ --------Random Create--------
-Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
16 235 99 +++++ +++ 13871 98 242 99 +++++ +++ 898 99ivy,368M,1415,95,2437,7,1003,4,1208,81,2298,6,90.7,2,16,235,99,+++++,+++,13871,98,242,99,+++++,+++,898,99
Version 1.02 ------Sequential Output------ --Sequential Input- --Random-
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
ivy 368M 1348 91 2468 7 836 3 1297 87 2178 5 91.0 2
------Sequential Create------ --------Random Create--------
-Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
16 220 99 +++++ +++ 13440 98 232 99 +++++ +++ 780 99ivy,368M,1348,91,2468,7,836,3,1297,87,2178,5,91.0,2,16,220,99,+++++,+++,13440,98,232,99,+++++,+++,780,99
Quoted 5 lines · Klaus Naumann
Hi all,
I've done some bonnie++ tests and everything looks good IMHO. See attachments (
new_speedis with lolo's patch andold_speedwithout). I vote for commit. Cool work !
It looks like this is statistical distortion as some numbers went up. It looks at least that there is no real difference ...
Quoted 11 lines
Version 1.02 ------Sequential Output------ --Sequential Input- --Random-
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP ivy 368M 1415 95 2437 7 1003 4 1208 81 2298 6 90.7 2 ------Sequential Create------ --------Random Create-------- -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 235 99 +++++ +++ 13871 98 242 99 +++++ +++ 898 99ivy,368M,1415,95,2437,7,1003,4,1208,81,2298,6,90.7,2,16,235,99,+++++,+++,13871,98,242,99,+++++,+++,898,99
Version 1.02 ------Sequential Output------ --Sequential Input- --Random-
Quoted 8 lines
-Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks-- Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP ivy 368M 1348 91 2468 7 836 3 1297 87 2178 5 91.0 2 ------Sequential Create------ --------Random Create-------- -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete-- files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP 16 220 99 +++++ +++ 13440 98 232 99 +++++ +++ 780 99ivy,368M,1348,91,2468,7,836,3,1297,87,2178,5,91.0,2,16,220,99,+++++,+++,13440,98,232,99,+++++,+++,780,99
I would commit that too with some additional comments that the HPC is capable of doing scatter-gather but this does not mix with the wd33 framwork which has no support for that.
Flo
Signature · 2 lines
Florian Lohoff [email protected] +49-5201-669912 Nine nineth on september the 9th Welcome to the new billenium
Quoted 2 lines · Florian Lohoff
It looks like this is statistical distortion as some numbers went up. It looks at least that there is no real difference ...
Yeah it looks the same to me (BTW, before someone asks - the machine was bootet freshly before each test ;) )
Quoted 3 lines
I would commit that too with some additional comments that the HPC is capable of doing scatter-gather but this does not mix with the wd33 framwork which has no support for that.
While you're at it could you also change the wrong comment in wd33c93 stating that the first interrupt after DMA init is always the DMA complete int ?
Also killing the Amiga reference might be good as more drivers depend on this framework - not only amiga (i.e. ppc-something).
Cya, Klaus
Signature · 4 lines
Full Name : Klaus Naumann | (http://www.mgnet.de/) (Germany) Nickname : Spock | Org.: Mad Guys Network Phone / FAX : ++49/177/7862964 | E-Mail: ([email protected]) PGP Key : www.mgnet.de/keys/key_spock.txt