scsi_do_cmd question

Jon Evans (jon@evansoft.demon.co.uk)
Thu, 21 Jan 1999 16:27:24 +0000 (GMT)


Hi All,

I've recently been messing with the scsi-idle patch and converted it so
that it works with 2.2.0 kernels.

I have a question about the scsi_do_cmd() function.

I have to pass a buffer as the 3rd argument to scsi_do_cmd, like this:

[...]
unsigned char *buffer = (unsigned char *) scsi_malloc(512);
[...]
scsi_do_cmd(SCpnt, (void *) cmd, (void *) buffer, 512,
sd_start_done, SD_TIMEOUT, MAX_RETRIES);
[...]

The original patch passed NULL for the buffer, and 0 for the length. But
that caused an oops on my system when I did:

/sbin/scsi-stop /dev/sda
ls /var/spool/news (mount point of sda2)

The oops was in swapper, so the system locked. By passing a 512 byte
buffer to the system call, the oops is avoided and the scsi-idle patch
works great.

Now the questions are:

1) Am I right, you have to pass a buffer?
2) If the answer to (1) is yes, take a look at this code from
scsi_ioctl.c:ioctl_internal_command()

{
struct semaphore sem = MUTEX_LOCKED;
SCpnt->request.sem = &sem;
scsi_do_cmd(SCpnt, cmd, NULL, 0, scsi_ioctl_done, timeout,
retries);
spin_unlock_irqrestore(&io_request_lock, flags);
down(&sem);
spin_lock_irqsave(&io_request_lock, flags);
SCpnt->request.sem = NULL;
}

scsi_do_cmd is called with a NULL buffer there. Why does that instance
work OK? (I'm presuming it *does* work OK?)

Jon.

-- 
Jon Evans

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/