public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luca Montecchiani <luca.montecchiani@teamfab.it>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Paul Gortmaker <p_gortmaker@yahoo.com>,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	dledford@redhat.com
Subject: [PATCH 2.2.x] Remove TEST_UNIT_READY from scsi.c (Was 2.2.x SCSI dat  problem)
Date: Thu, 10 Jan 2002 16:16:25 +0100	[thread overview]
Message-ID: <3C3DB049.B86E0CD9@teamfab.it> (raw)

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

Hi!

I've FINALLY find out why 2.2.x kernel always fail on first time access
to my scsi DAT 20/40 [1][2] .

 2.2.x: sense key Illegal Request, then halt with I/O error
 2.4.x: sense key Unit Attention,  but works

After too many hours spent reading linux scsi code I've decided to apply
a "brute force" method to discover why 2.4.x works and why 2.2.x not.
I've dicotomically test too many kernels from 2.3.51 to 2.4.17
to catch the breakpoint, and boom it's on patch-2.4.0-test2, before
that release we have the same error as 2.2.x .
Reading the scsi changes of patch-2.4.0-test2 [3] I've also find
that the "TEST_UNIT_READ removal" from scsi_scan.c cure the problem!

I've made a patch [4] against 2.2.20 that can be applied without
major problems also to 2.2.19,2.2.21pre2.

Comments, bug reports, suggestions welcome,
luca

[1] http://marc.theaimsgroup.com/?l=linux-scsi&m=100876196731096&w=2
[2] http://marc.theaimsgroup.com/?l=linux-scsi&m=100902910327577&w=2
[3] http://www.uwsg.iu.edu/hypermail/linux/kernel/0005.3/0688.html
[4] see attach

[-- Attachment #2: remove_TUR.diff --]
[-- Type: text/plain, Size: 2827 bytes --]

--- linux/drivers/scsi_orig/scsi.c	Tue Jan  8 10:50:48 2002
+++ linux/drivers/scsi/scsi.c	Thu Jan 10 15:16:31 2002
@@ -34,6 +34,10 @@
  *  Jiffies wrap fixes (host->resetting), 3 Dec 1998 Andrea Arcangeli
  *
  *  out_of_space + add-single-device work, D. Gilbert (dpg) 990612
+ *
+ *  Remove TEST_UNIT_READY, backported from patch-2.4.0-test2
+ *  Wed Jan 9 18:34:51 CET 2002 Luca Montecchiani <luca.montecchiani@teamfab.it>
+ *
  */
 
 #include <linux/config.h>
@@ -697,46 +701,21 @@
   SDpnt->was_reset = 0;
   SDpnt->expecting_cc_ua = 0;
 
-  scsi_cmd[0] = TEST_UNIT_READY;
-  scsi_cmd[1] = lun << 5;
-  scsi_cmd[2] = scsi_cmd[3] = scsi_cmd[4] = scsi_cmd[5] = 0;
-
   SCpnt->host = SDpnt->host;
   SCpnt->device = SDpnt;
   SCpnt->target = SDpnt->id;
   SCpnt->lun = SDpnt->lun;
   SCpnt->channel = SDpnt->channel;
-  {
-    struct semaphore sem = MUTEX_LOCKED;
-    SCpnt->request.sem = &sem;
-    SCpnt->request.rq_status = RQ_SCSI_BUSY;
-    spin_lock_irq(&io_request_lock);
-    scsi_do_cmd (SCpnt, (void *) scsi_cmd,
-                 (void *) scsi_result,
-                 256, scan_scsis_done, SCSI_TIMEOUT + 4 * HZ, 5);
-    spin_unlock_irq(&io_request_lock);
-    down (&sem);
-    SCpnt->request.sem = NULL;
-  }
 
-  SCSI_LOG_SCAN_BUS(3,  printk ("scsi: scan_scsis_single id %d lun %d. Return code 0x%08x\n",
-          dev, lun, SCpnt->result));
-  SCSI_LOG_SCAN_BUS(3,print_driverbyte(SCpnt->result));
-  SCSI_LOG_SCAN_BUS(3,print_hostbyte(SCpnt->result));
-  SCSI_LOG_SCAN_BUS(3,printk("\n"));
-
-  if (SCpnt->result) {
-    if (((driver_byte (SCpnt->result) & DRIVER_SENSE) ||
-         (status_byte (SCpnt->result) & CHECK_CONDITION)) &&
-        ((SCpnt->sense_buffer[0] & 0x70) >> 4) == 7) {
-      if (((SCpnt->sense_buffer[2] & 0xf) != NOT_READY) &&
-          ((SCpnt->sense_buffer[2] & 0xf) != UNIT_ATTENTION) &&
-          ((SCpnt->sense_buffer[2] & 0xf) != ILLEGAL_REQUEST || lun > 0))
-        return 1;
-    }
-    else
-      return 0;
-  }
+  /*
+   * We used to do a TEST_UNIT_READY before the INQUIRY but that was 
+   * not really necessary.  Spec recommends using INQUIRY to scan for
+   * devices (and TEST_UNIT_READY to poll for media change). - Paul G.
+   * 
+   * Wed Jan 9 18:34:51 CET 2002 Luca Montecchiani <luca.montecchiani@teamfab.it>
+   * backported to 2.2.20 from patch-2.4.0-test2
+   * to fix "the first use error" on 20/40gbyte Seagate dat
+   */
 
   SCSI_LOG_SCAN_BUS(3,printk ("scsi: performing INQUIRY\n"));
   /*
@@ -756,7 +735,7 @@
     spin_lock_irq(&io_request_lock);
     scsi_do_cmd (SCpnt, (void *) scsi_cmd,
                  (void *) scsi_result,
-                 256, scan_scsis_done, SCSI_TIMEOUT, 3);
+                 256, scan_scsis_done, SCSI_TIMEOUT+4*HZ, 3);
     spin_unlock_irq(&io_request_lock);
     down (&sem);
     SCpnt->request.sem = NULL;



                 reply	other threads:[~2002-01-10 15:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C3DB049.B86E0CD9@teamfab.it \
    --to=luca.montecchiani@teamfab.it \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dledford@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=p_gortmaker@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox