[233] in linux-scsi channel archive
bug report and fix: generic scsi
daemon@ATHENA.MIT.EDU (Heiko Eissfeldt)
Tue Jun 6 14:06:57 1995
From: heiko@colossus.escape.de (Heiko Eissfeldt)
To: linux-scsi@vger.rutgers.edu
Date: Tue, 6 Jun 1995 18:29:11 +0200 (MET DST)
Cc: eric@aib.com, drew@Colorado.EDU
Hi dear Linuxers,
In Patch 1.1.77 Eric found the parameter transfer size in sg_write()
to be incorrect and changed
>@@ -291,7 +311,8 @@
> printk("do cmd\n");
> #endif
> scsi_do_cmd (SCpnt,(void *) cmnd,
>- (void *) device->buff,amt,sg_command_done,device->timeout,SG_DEFAULT_RETRIES);
>+ (void *) device->buff,device->header.pack_len-size-sizeof(struct sg_header),
>+ sg_command_done,device->timeout,SG_DEFAULT_RETRIES);
> #ifdef DEBUG
> printk("done cmd\n");
> #endif
which cuts output buffer size down to input buffer size. It was changed
back to the previous state.
Since I got 'unexpected command completion phase' messages from the u14-34
driver when using the generic interface only (no problem when using the scsi_ioctl
interface), I did some research. I tracked it down to different buffer
lengths in the scsi_do_cmd call (generic versus scsi_ioctl interface).
For mode select commands, the buffer length parameter was too big.
The command bytes had to be subtracted from the input buffer size (in case of
dominant input buffer size as for mode selects).
After being patched the messages disappeared and everything worked fine.
I patched this with a one-liner. More readable would be an earlier
distinction in the code whether input or output buffer size is dominant.
This would mean more changes, though.
Here is the patch (versus 1.2.8) to correct it:
--- sg.c.org Thu Jun 1 01:14:47 1995
+++ sg.c Thu Jun 1 01:39:15 1995
@@ -293,6 +293,7 @@
size=COMMAND_SIZE(opcode);
if (opcode >= 0xc0 && device->header.twelve_byte) size = 12;
SCpnt->cmd_len = size;
+ amt-=device->header.pack_len>device->header.reply_len ? size : 0;
/*
* Verify that the user has actually passed enough bytes for this command.
*/
Cheers, Heiko
--
Bye | computers are more dumb than
Heiko Eissfeldt | humans, but smarter than
heiko@colossus.escape.de | programmers.