On Tue, 27 Apr 2004, Gustaf Gunnarsson wrote:

> Right now, I believe there is something strange going on in the
> usb-storage module, the only time when there has been different results
> and expected, were when I forced the usb-storage module not to be loaded
> on hotplug. This way I could plug in and remove the device as many times
> as I wished and the kernel always detected them appropriate.

Working on that hypothesis, I've attached three patches for you to try.  
They all modify the usb-storage driver.  Patch1 prevents the driver from 
communicating with the device.  Patch2 prevents the SCSI module from 
scanning for devices.  Patch3 prevents usb-storage from registering itself 
with SCSI in the first place.  So the successive patches stop more and 
more code from executing.

Try each of these patches in turn and see what happens.  Also (I just
thought of this) when you are testing, see if you get the same behavior if
you leave the device plugged in and do "rmmod usb-storage" as you do if
you unplug the device.  It's worth trying that even with none of the
patches installed.

> It seems my responses will be quite slow through-out the entire week. I 
> hope this does not disturb you, I really want this solved but I cannot 
> make the globe spin any slower.. 

I quite understand; I've been very busy myself this week.

Alan Stern
===== drivers/usb/storage/transport.c 1.130 vs edited =====
--- 1.130/drivers/usb/storage/transport.c       Sat Apr 24 22:25:32 2004
+++ edited/drivers/usb/storage/transport.c      Thu Apr 29 10:52:03 2004
@@ -527,6 +527,12 @@
        int need_auto_sense;
        int result;
 
+       srb->result = SAM_STAT_CHECK_CONDITION;
+       srb->sense_buffer[0] = 0x70;
+       srb->sense_buffer[2] = 0x06;
+       srb->sense_buffer[12] = 0x29;
+       return;
+
        /* send the command to the transport layer */
        srb->resid = 0;
        result = us->transport(srb, us);
===== drivers/usb/storage/usb.c 1.116 vs edited =====
--- 1.116/drivers/usb/storage/usb.c     Sat Apr 24 22:25:23 2004
+++ edited/drivers/usb/storage/usb.c    Thu Apr 29 11:17:39 2004
@@ -950,7 +950,7 @@
                goto BadDevice;
        }
 
-       scsi_scan_host(us->host);
+//     scsi_scan_host(us->host);
 
        printk(KERN_DEBUG 
               "USB Mass Storage device found at %d\n", us->pusb_dev->devnum);
===== drivers/usb/storage/usb.c 1.116 vs edited =====
--- 1.116/drivers/usb/storage/usb.c     Sat Apr 24 22:25:23 2004
+++ edited/drivers/usb/storage/usb.c    Thu Apr 29 11:25:44 2004
@@ -781,6 +781,7 @@
         * Since this is a new device, we need to register a SCSI
         * host definition with the higher SCSI layers.
         */
+#if 0
        us->host = scsi_host_alloc(&usb_stor_host_template, sizeof(us));
        if (!us->host) {
                printk(KERN_WARNING USB_STORAGE
@@ -790,6 +791,7 @@
 
        /* Set the hostdata to prepare for scanning */
        us->host->hostdata[0] = (unsigned long) us;
+#endif
 
        return 0;
 }
@@ -943,14 +945,14 @@
                goto BadDevice;
 
        /* Finally, add the host (this does SCSI device scanning) */
-       result = scsi_add_host(us->host, &intf->dev);
+//     result = scsi_add_host(us->host, &intf->dev);
        if (result) {
                printk(KERN_WARNING USB_STORAGE
                        "Unable to add the scsi host\n");
                goto BadDevice;
        }
 
-       scsi_scan_host(us->host);
+//     scsi_scan_host(us->host);
 
        printk(KERN_DEBUG 
               "USB Mass Storage device found at %d\n", us->pusb_dev->devnum);
@@ -978,7 +980,7 @@
        /* Dissociate from the USB device */
        dissociate_dev(us);
 
-       scsi_remove_host(us->host);
+//     scsi_remove_host(us->host);
 
        /* TODO: somehow, wait for the device to
         * be 'idle' (tasklet completion) */

Reply via email to