Re: [PATCH] [v2] aha152x cmnd->device oops

Juergen E. Fischer
2003-10-29T17:59:52Z

[-- Attachment #1: Type: text/plain, Size: 2482 bytes --]

Hi James,

On Wed, Oct 29, 2003 at 08:58:28 -0600, James Bottomley wrote:
> You don't actually need a new command for this. The struct scsi_cmnd
> layout is designed to allow you to reuse the current command for
> clearing contingent allegiance conditions (the fields you need to alter
> all have copies stored somewhere which you can restore when you have the
> sense data. See for example how the 53c700 does this, or aic7xxx_old)

Why not? It's a new command after all and if the initialization is
done correctly (ie. ->device is setup) it works the way it is now.

> > The second it when the controller needs to be resetted. Both are purely
> > internal to the driver.

> As a rule of thumb: as long as the command is never seen outside the
> driver, then using kmalloc is fine. If it is ever seen outside the
> driver (like in requeueing conditions) then you should use
> scsi_get_command().

using it now anyway. Following patch fixes the problem. Works here.

--- aha152x.c.orig 2003-10-29 18:53:59.000000000 +0100
+++ aha152x.c 2003-10-29 18:38:20.000000000 +0100
@@ -450,7 +450,8 @@
/* host lock */

#if defined(AHA152X_DEBUG)
- char *locker; /* which function has the lock */
+ const char *locker;
+ /* which function has the lock */
int lockerl; /* where did it get it */

int debug; /* current debugging setting */
@@ -1991,7 +1992,7 @@
SETPORT(PORTA, 0); /* turn led off */

kfree(ptr->host_scribble);
- kfree(ptr);
+ scsi_put_command(ptr);
} else if(DONE_SC->SCp.Status==0x02) {
#if defined(AHA152X_STAT)
HOSTDATA(shpnt)->busfree_with_check_condition++;
@@ -2001,7 +2002,7 @@
#endif

if(!(DONE_SC->SCp.Status & not_issued)) {
- Scsi_Cmnd *cmnd = kmalloc(sizeof(Scsi_Cmnd), GFP_ATOMIC);
+ Scsi_Cmnd *cmnd = scsi_get_command(DONE_SC->device, GFP_ATOMIC);

if(cmnd) {
Scsi_Cmnd *ptr=DONE_SC;
@@ -2018,9 +2019,6 @@
cmnd->cmnd[4] = sizeof(ptr->sense_buffer);
cmnd->cmnd[5] = 0;
cmnd->cmd_len = 6;
- cmnd->device->host = ptr->device->host;
- cmnd->device->id = ptr->device->id;
- cmnd->device->lun = ptr->device->lun;
cmnd->use_sg = 0;
cmnd->request_buffer = ptr->sense_buffer;
cmnd->request_bufflen = sizeof(ptr->sense_buffer);

Jürgen

--
"If Bill Gates had a nickel for every time Windows crashed....
Oh, wait, he does!"
-- Gary Oliver

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]