[185] in linux-scsi channel archive
Re: SCSI disk SPIN-UP on pwr-up ?
daemon@ATHENA.MIT.EDU (Eric Youngdale)
Fri May 19 20:51:07 1995
From: "Eric Youngdale" <eric@aib.com>
Date: Fri, 19 May 1995 20:17:13 -0400
In-Reply-To: Drew Eckhardt <drew@boulder.openware.com>
"Re: SCSI disk SPIN-UP on pwr-up ?" (May 19, 2:59pm)
To: Drew Eckhardt <drew@boulder.openware.com>,
Andreas.Koppenhoefer@studbox.uni-stuttgart.de (Andreas Koppenhoefer)
Cc: linux-scsi@vger.rutgers.edu, pe1chl@wab-tis.rabobank.nl
On May 19, 2:59pm, Drew Eckhardt wrote:
>> >What's the difference between loading scsi driver as module versus
> >using as compiled in kernel driver?
>
> In sd_init_onedisk() this if clause
>
> if (current == task[0]){
> ...
>
> will get executed at startup, but not when the disk driver is installed
> as a module, since current will point to some user process and not the
> swapper process.
>
> IMHO, it would probably be a good idea to allways execute the code inside
> the if clause, since this will handle drives that were powered up after
> the system booted - ie, on a laptop with a pcmcia SCSI.
Actually this is fixed in the patchkit that Michael Neuffer has
been maintaining. The idea is that we do not want to attempt to do this
unless we have loaded a new driver, or we are at boot time. Otherwise
we don't want to do this.
I guess the reason is that people might conceivably want to spin
down disk drives on their systems, and it would probably be a bad idea
to forcibly spin them up whenever there is a media change on some other
drive.
This being said, it appears that we need to retry the
TEST_UNIT_READY if we get a UNIT_ATTENTION back the first time. I would
suggest that
we not retry indefinitely - we should limit this to a maximum of 2 or 3
attempts, just for safety.
I have gotten into this bad habit of sending out completely
untested patches, and I am about to do so again. It should in theory
do the right thing. As far as the modules stuff is concerned, we might just
as well wait until after 1.3 starts, and the big patchkit is installed.
-Eric
--- sd.c.~1~ Mon May 15 10:11:03 1995
+++ sd.c Fri May 19 19:34:23 1995
@@ -867,23 +867,31 @@
/* Spin up drives, as required. Only do this at boot time */
if (current == task[0]){
do{
- cmd[0] = TEST_UNIT_READY;
- cmd[1] = (rscsi_disks[i].device->lun << 5) & 0xe0;
- memset ((void *) &cmd[2], 0, 8);
- SCpnt->request.dev = 0xffff; /* Mark as really busy again */
- SCpnt->cmd_len = 0;
- SCpnt->sense_buffer[0] = 0;
- SCpnt->sense_buffer[2] = 0;
-
- scsi_do_cmd (SCpnt,
- (void *) cmd, (void *) buffer,
- 512, sd_init_done, SD_TIMEOUT,
- MAX_RETRIES);
-
- while(SCpnt->request.dev != 0xfffe) barrier();
-
- the_result = SCpnt->result;
-
+ retries = 0;
+ while(retries < 3)
+ {
+ cmd[0] = TEST_UNIT_READY;
+ cmd[1] = (rscsi_disks[i].device->lun << 5) & 0xe0;
+ memset ((void *) &cmd[2], 0, 8);
+ SCpnt->request.dev = 0xffff; /* Mark as really busy again */
+ SCpnt->cmd_len = 0;
+ SCpnt->sense_buffer[0] = 0;
+ SCpnt->sense_buffer[2] = 0;
+
+ scsi_do_cmd (SCpnt,
+ (void *) cmd, (void *) buffer,
+ 512, sd_init_done, SD_TIMEOUT,
+ MAX_RETRIES);
+
+ while(SCpnt->request.dev != 0xfffe) barrier();
+
+ the_result = SCpnt->result;
+ retries++;
+ if( the_result == 0
+ || SCpnt->sense_buffer[2] != UNIT_ATTENTION)
+ break;
+ }
+
/* Look for non-removable devices that return NOT_READY. Issue
command
to spin up drive for these cases. */
if(the_result && !rscsi_disks[i].device->removable &&
--
"The woods are lovely, dark and deep. But I have promises to keep,
And lines to code before I sleep, And lines to code before I sleep."