Skip to contentSkip to conversation

Oops in scsi_send_eh_cmnd 2.6.21-rc5-git6,7,10,13

DISCUSSION Andrew Burgess 3 participants 4 messages Apr 6, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 12 lines · James Bottomley

It's actually a long standing bug in the 3w-xxxx driver. Apparently it assumes request sense is always the use_sg == 0 case. This is what it does on a request sense:

static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id)

{
       dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_request_sense()\n");

       /* For now we just zero the request buffer */
       memset(tw_dev->srb[request_id]->request_buffer, 0, tw_dev->srb[request_id]->request_bufflen);
       tw_dev->state[request_id] = TW_S_COMPLETED;
       tw_state_request_finish(tw_dev, request_id);
Quoted 3 lines

....

Note that it's clearing the request buffer, which is actually zeroing the scatterlist, hence the problem.

OK. Is there a quick workaround or should I just wait for Adam & Company to make a patch?

You said your earlier patch would hide it, and then said you had a length wrong in it and I'm not sure what length you mean.

Thanks for yours and Chuck's and Dave's time.

#1 lore raw
Quoted 16 lines · Andrew Burgess
Quoted 13 lines · James Bottomley

It's actually a long standing bug in the 3w-xxxx driver. Apparently it assumes request sense is always the use_sg == 0 case. This is what it does on a request sense:

static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id)

{
       dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_request_sense()\n");

       /* For now we just zero the request buffer */
       memset(tw_dev->srb[request_id]->request_buffer, 0, tw_dev->srb[request_id]->request_bufflen);
       tw_dev->state[request_id] = TW_S_COMPLETED;
       tw_state_request_finish(tw_dev, request_id);

....

Quoted 4 lines
Quoted 1 line

Note that it's clearing the request buffer, which is actually zeroing the scatterlist, hence the problem.

OK. Is there a quick workaround or should I just wait for Adam & Company to make a patch?

Try this ... I think it's roughly the correct fix.

Quoted 3 lines

You said your earlier patch would hide it, and then said you had a length wrong in it and I'm not sure what length you mean.

It's the length specifier in the error handler request sense command ... I'll fix it up and redo my patch through scsi-misc, since it's not going to fix the root cause of the problem.

James

drivers/scsi/3w-xxxx.c +9 -2
index bf5d63e..6b303ba 100644
@@ -1864,10 +1864,17 @@ static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id)
 /* This function will handle the request sense scsi command */
 static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id)
 {
+	char request_buffer[18];
+
 	dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_request_sense()\n");
 
-	/* For now we just zero the request buffer */
-	memset(tw_dev->srb[request_id]->request_buffer, 0, tw_dev->srb[request_id]->request_bufflen);
+	memset(request_buffer, 0, sizeof(request_buffer));
+	request_buffer[0] = 0x70; /* Immediate fixed format */
+	request_buffer[7] = 11;	/* minimum size per SPC: 18 bytes */
+	/* leave all other fields zero, giving effectively NO_SENSE return */
+	tw_transfer_internal(tw_dev, request_id, request_buffer,
+			     sizeof(request_buffer));
+	
 	tw_dev->state[request_id] = TW_S_COMPLETED;
 	tw_state_request_finish(tw_dev, request_id);
 
#2 lore raw
Quoted 37 lines · James Bottomley
Quoted 14 lines · Andrew Burgess
Quoted 4 lines · James Bottomley

It's actually a long standing bug in the 3w-xxxx driver. Apparently it assumes request sense is always the use_sg == 0 case. This is what it does on a request sense:
static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id)

Quoted 8 lines
{
       dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_request_sense()\n");
       /* For now we just zero the request buffer */
       memset(tw_dev->srb[request_id]->request_buffer, 0, tw_dev->srb[request_id]->request_bufflen);
       tw_dev->state[request_id] = TW_S_COMPLETED;
       tw_state_request_finish(tw_dev, request_id);

....
Note that it's clearing the request buffer, which is actually zeroing the scatterlist, hence the problem.

Quoted 2 lines

OK. Is there a quick workaround or should I just wait for Adam & Company to make a patch?

Try this ... I think it's roughly the correct fix.

Quoted 3 lines

You said your earlier patch would hide it, and then said you had a length wrong in it and I'm not sure what length you mean.

It's the length specifier in the error handler request sense command ... I'll fix it up and redo my patch through scsi-misc, since it's not going to fix the root cause of the problem.

James

drivers/scsi/3w-xxxx.c +0 -0
index bf5d63e..6b303ba 100644
@@ -1864,10 +1864,17 @@ static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id)
 /* This function will handle the request sense scsi command */
 static int tw_scsiop_request_sense(TW_Device_Extension *tw_dev, int request_id)

drivers/scsi/3w-xxxx.c static int tw_scsiop_read_write(TW_Device_Extension *tw_dev, int request_id) · line 1873

Quoted 10 lines
drivers/scsi/3w-xxxx.c +5 -2
 {
+	char request_buffer[18];
+
 	dprintk(KERN_NOTICE "3w-xxxx: tw_scsiop_request_sense()\n");
 
-	/* For now we just zero the request buffer */
-	memset(tw_dev->srb[request_id]->request_buffer, 0, tw_dev->srb[request_id]->request_bufflen);
+	memset(request_buffer, 0, sizeof(request_buffer));
+	request_buffer[0] = 0x70; /* Immediate fixed format */
+	request_buffer[7] = 11;	/* minimum size per SPC: 18 bytes */

James,
That last line should be:

        request_buffer[7] = 10;	/* minimum size per SPC: 18 bytes */

Doug Gilbert

#3 lore raw
Quoted 2 lines · Douglas Gilbert

That last line should be:

        request_buffer[7] = 10;	/* minimum size per SPC: 18 bytes */

Er, yes, I'm afraid when I see n-7 I always think n is the lenght, not n is the last byte ...

James