All of lore.kernel.org
 help / color / mirror / Atom feed
* hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND
@ 2004-06-29  9:37 Bart Hartgers
  2004-06-29  9:45 ` Kurt Garloff
  2004-06-29  9:52 ` hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND Bart Hartgers
  0 siblings, 2 replies; 6+ messages in thread
From: Bart Hartgers @ 2004-06-29  9:37 UTC (permalink / raw)
  To: linux-kernel; +Cc: Kurt Garloff

My apologies if this is not really a kernel issue, but

I've recently upgraded to SUSE9.1,  and now I am having trouble with
automatically hotplugging my USB2 harddisk. This is because the
userspace hotplug magic runs a prog called hwscan. If I disable the
userspace stuff, everything works fine. Also my USB1 pendrive works fine
with the userspace hotplug.

The problem is that both hwscan and usb-storage get stuck in the 'D"
state until I unplug the harddisk.

A strace of hwscan shows:

21141 open("/dev/sda", O_RDONLY|O_NONBLOCK) = 3
21141 ioctl(3, 0x301, 0xbfffeba0)       = 0
21141 ioctl(3, BLKSSZGET, 0xbfffeb9c)   = 0
21141 ioctl(3, 0x80041272, 0xbfffeb90)  = 0
21141 ioctl(3, FIBMAP, 0xbfffec40)      = 0  <--- hwscan gets stuck here

The last ioctl corresponds to this bit of code in
hwinfo-8.38/src/hd/block.c:

#ifndef SCSI_IOCTL_SEND_COMMAND
#define SCSI_IOCTL_SEND_COMMAND 1
#endif

...

      memset(scsi_cmd_buf, 0, sizeof scsi_cmd_buf);
      // ###### FIXME: smaller!
      *((unsigned *) (scsi_cmd_buf + 4)) = sizeof scsi_cmd_buf - 0x100;
      scsi_cmd_buf[8 + 0] = 0x12;
      scsi_cmd_buf[8 + 1] = 0x01;
      scsi_cmd_buf[8 + 2] = 0x80;
      scsi_cmd_buf[8 + 4] = 0xff;

      k = ioctl(fd, SCSI_IOCTL_SEND_COMMAND, scsi_cmd_buf);

So it appears that the driver hangs because of a SCSI command. Is this
kernel bug, and if so, where do I fix it?

TIA,
Bart
-- 
Bart Hartgers - TUE Eindhoven 
http://plasimo.phys.tue.nl/bart/contact.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND
  2004-06-29  9:37 hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND Bart Hartgers
@ 2004-06-29  9:45 ` Kurt Garloff
  2004-06-29 10:53   ` Steffen Winterfeldt
                     ` (2 more replies)
  2004-06-29  9:52 ` hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND Bart Hartgers
  1 sibling, 3 replies; 6+ messages in thread
From: Kurt Garloff @ 2004-06-29  9:45 UTC (permalink / raw)
  To: Bart Hartgers; +Cc: linux-kernel

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

Hi Bart,

On Tue, Jun 29, 2004 at 11:37:36AM +0200, Bart Hartgers wrote:
> The problem is that both hwscan and usb-storage get stuck in the 'D"
> state until I unplug the harddisk.
> 
> A strace of hwscan shows:
> 
> 21141 open("/dev/sda", O_RDONLY|O_NONBLOCK) = 3
> 21141 ioctl(3, 0x301, 0xbfffeba0)       = 0
> 21141 ioctl(3, BLKSSZGET, 0xbfffeb9c)   = 0
> 21141 ioctl(3, 0x80041272, 0xbfffeb90)  = 0
> 21141 ioctl(3, FIBMAP, 0xbfffec40)      = 0  <--- hwscan gets stuck here
> 
> The last ioctl corresponds to this bit of code in
> hwinfo-8.38/src/hd/block.c:
> 
> #ifndef SCSI_IOCTL_SEND_COMMAND
> #define SCSI_IOCTL_SEND_COMMAND 1
> #endif
> 
> ...
> 
>       memset(scsi_cmd_buf, 0, sizeof scsi_cmd_buf);
>       // ###### FIXME: smaller!
>       *((unsigned *) (scsi_cmd_buf + 4)) = sizeof scsi_cmd_buf - 0x100;
>       scsi_cmd_buf[8 + 0] = 0x12;
>       scsi_cmd_buf[8 + 1] = 0x01;
>       scsi_cmd_buf[8 + 2] = 0x80;
>       scsi_cmd_buf[8 + 4] = 0xff;
> 
>       k = ioctl(fd, SCSI_IOCTL_SEND_COMMAND, scsi_cmd_buf);
> 
> So it appears that the driver hangs because of a SCSI command. Is this
> kernel bug, and if so, where do I fix it?

To me it looks like a bug in the USB stick.
It probably locks up when you ask for VPD page 0x80 (serial number)
of the device with INQUIRY. 
Some shitty USB devices lock up when you ask for more than 36 bytes
with INQUIRY. See code in scsi_scan.c and the BLIST_INQUIRY_36 and
_58 flags.
Your device may even do so when you don't ask for standard INQUIRY 
data but for EVPD page 0x80 :-(

Does it work if you send the INQUIRY with 36 bytes allocation length?
scsi_cmd_buf[8 + 4] = 0x26;
-- 
Kurt Garloff  <garloff@suse.de>                            Cologne, DE 
SUSE LINUX AG / Novell, Nuernberg, DE               Director SUSE Labs

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND
  2004-06-29  9:37 hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND Bart Hartgers
  2004-06-29  9:45 ` Kurt Garloff
@ 2004-06-29  9:52 ` Bart Hartgers
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Hartgers @ 2004-06-29  9:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: garloff

Sorry, I forgot to mention that the problem remains under 2.6.7.


-- 
Bart Hartgers - TUE Eindhoven 
http://plasimo.phys.tue.nl/bart/contact.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND
  2004-06-29  9:45 ` Kurt Garloff
@ 2004-06-29 10:53   ` Steffen Winterfeldt
  2004-06-29 11:45   ` Kurt Garloff
  2004-06-30  9:37   ` hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND - SOLVED Bart Hartgers
  2 siblings, 0 replies; 6+ messages in thread
From: Steffen Winterfeldt @ 2004-06-29 10:53 UTC (permalink / raw)
  To: Kurt Garloff; +Cc: Bart Hartgers, linux-kernel

Hi,

On Tue, 29 Jun 2004, Kurt Garloff wrote:

> On Tue, Jun 29, 2004 at 11:37:36AM +0200, Bart Hartgers wrote:
> > The problem is that both hwscan and usb-storage get stuck in the 'D"
> > state until I unplug the harddisk.
> > 
> > A strace of hwscan shows:
> > 
> > 21141 open("/dev/sda", O_RDONLY|O_NONBLOCK) = 3
> > 21141 ioctl(3, 0x301, 0xbfffeba0)       = 0
> > 21141 ioctl(3, BLKSSZGET, 0xbfffeb9c)   = 0
> > 21141 ioctl(3, 0x80041272, 0xbfffeb90)  = 0
> > 21141 ioctl(3, FIBMAP, 0xbfffec40)      = 0  <--- hwscan gets stuck here

[...]

> Does it work if you send the INQUIRY with 36 bytes allocation length?
> scsi_cmd_buf[8 + 4] = 0x26;

It's indeed the inquiry size, sticking to the minium 36 bytes helps. 
That's fixed in sles9. Update for 9.1 planned.


Steffen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND
  2004-06-29  9:45 ` Kurt Garloff
  2004-06-29 10:53   ` Steffen Winterfeldt
@ 2004-06-29 11:45   ` Kurt Garloff
  2004-06-30  9:37   ` hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND - SOLVED Bart Hartgers
  2 siblings, 0 replies; 6+ messages in thread
From: Kurt Garloff @ 2004-06-29 11:45 UTC (permalink / raw)
  To: Bart Hartgers, linux-kernel

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

On Tue, Jun 29, 2004 at 11:45:57AM +0200, Kurt Garloff wrote:
> Does it work if you send the INQUIRY with 36 bytes allocation length?
> scsi_cmd_buf[8 + 4] = 0x26;

I mean 0x24 of course ...
-- 
Kurt Garloff  <garloff@suse.de>                            Cologne, DE 
SUSE LINUX AG / Novell, Nuernberg, DE               Director SUSE Labs

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND - SOLVED
  2004-06-29  9:45 ` Kurt Garloff
  2004-06-29 10:53   ` Steffen Winterfeldt
  2004-06-29 11:45   ` Kurt Garloff
@ 2004-06-30  9:37   ` Bart Hartgers
  2 siblings, 0 replies; 6+ messages in thread
From: Bart Hartgers @ 2004-06-30  9:37 UTC (permalink / raw)
  To: garloff; +Cc: linux-kernel

Kurt,

I tried both 0x26 and 0x24, but the problem persists. Guess I bought
crappy hardware (again). For now, I've removed the offending ioctl, and 
everything sort of works.

Thanks,
Bart

On 29 Jun, Kurt Garloff wrote:
> Hi Bart,
> 
> On Tue, Jun 29, 2004 at 11:37:36AM +0200, Bart Hartgers wrote:
>> The problem is that both hwscan and usb-storage get stuck in the 'D"
>> state until I unplug the harddisk.
>> 
>> A strace of hwscan shows:
>> 
>> 21141 open("/dev/sda", O_RDONLY|O_NONBLOCK) = 3
>> 21141 ioctl(3, 0x301, 0xbfffeba0)       = 0
>> 21141 ioctl(3, BLKSSZGET, 0xbfffeb9c)   = 0
>> 21141 ioctl(3, 0x80041272, 0xbfffeb90)  = 0
>> 21141 ioctl(3, FIBMAP, 0xbfffec40)      = 0  <--- hwscan gets stuck
>> here
>> 
>> The last ioctl corresponds to this bit of code in
>> hwinfo-8.38/src/hd/block.c:
>> 
>> #ifndef SCSI_IOCTL_SEND_COMMAND
>> #define SCSI_IOCTL_SEND_COMMAND 1
>> #endif
>> 
>> ...
>> 
>>       memset(scsi_cmd_buf, 0, sizeof scsi_cmd_buf);
>>       // ###### FIXME: smaller!
>>       *((unsigned *) (scsi_cmd_buf + 4)) = sizeof scsi_cmd_buf - 0x100;
>>       scsi_cmd_buf[8 + 0] = 0x12;
>>       scsi_cmd_buf[8 + 1] = 0x01;
>>       scsi_cmd_buf[8 + 2] = 0x80;
>>       scsi_cmd_buf[8 + 4] = 0xff;
>> 
>>       k = ioctl(fd, SCSI_IOCTL_SEND_COMMAND, scsi_cmd_buf);
>> 
>> So it appears that the driver hangs because of a SCSI command. Is
>> this kernel bug, and if so, where do I fix it?
> 
> To me it looks like a bug in the USB stick.
> It probably locks up when you ask for VPD page 0x80 (serial number)
> of the device with INQUIRY. 
> Some shitty USB devices lock up when you ask for more than 36 bytes
> with INQUIRY. See code in scsi_scan.c and the BLIST_INQUIRY_36 and
> _58 flags.
> Your device may even do so when you don't ask for standard INQUIRY 
> data but for EVPD page 0x80 :-(
> 
> Does it work if you send the INQUIRY with 36 bytes allocation length?
> scsi_cmd_buf[8 + 4] = 0x26;


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-06-30  9:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-29  9:37 hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND Bart Hartgers
2004-06-29  9:45 ` Kurt Garloff
2004-06-29 10:53   ` Steffen Winterfeldt
2004-06-29 11:45   ` Kurt Garloff
2004-06-30  9:37   ` hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND - SOLVED Bart Hartgers
2004-06-29  9:52 ` hwscan hangs on USB2 disk - SCSI_IOCTL_SEND_COMMAND Bart Hartgers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.