mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Unit attention in USB storage
@ 2001-06-05  1:58 Andries.Brouwer
  2001-06-05  2:07 ` Matthew Dharm
  0 siblings, 1 reply; 3+ messages in thread
From: Andries.Brouwer @ 2001-06-05  1:58 UTC (permalink / raw)
  To: linux-kernel, linux-usb-devel, mdharm-usb

Last month my CF reader read CF cards happily.
Now that I returned from Denmark, I find that it no longer works
(with the same 2.4.3 kernel). Indeed, it is not properly detected.

The reason seems to be slightly different timing at bootup -
maybe because I connected a wheelmouse this time -
and now this device comes with Unit Attention
	(code 70, key 6, ASC 28, ASCQ 0: not ready to ready transit)
and this is regarded as an error return and the initial INQUIRY fails.

Thus, since this code actually occurs in real life, we should
probably add

	case 0x2800: what="not ready to ready transtion (media change?)";
		break;

in debug.c:usb_stor_show_sense().
I have not really thought about the proper treatment of this Unit Attention.
However, if one decides that really nothing at all is wrong when a device
tells us that it is ready now, then

                if ((srb->sense_buffer[2] & 0xf) == 0x6 /* unit attention */
                    && srb->sense_buffer[12] == 0x28
                    && srb->sense_buffer[13] == 0 /* not ready -> ready */)
                        srb->result = GOOD << 1;

is perhaps not too unreasonable. (This is in usb/storage/transport.c,
usb_stor_invoke_transport(), at the end of the need autosense part.)
Anyway, with this addition (to 2.4.3) all works for me again.

Andries

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: Unit attention in USB storage
@ 2001-06-05  3:39 Andries.Brouwer
  0 siblings, 0 replies; 3+ messages in thread
From: Andries.Brouwer @ 2001-06-05  3:39 UTC (permalink / raw)
  To: Andries.Brouwer, mdharm-kernel; +Cc: linux-kernel, linux-usb-devel

>> [things work better when "Unit Attention: not ready to ready transition"
>> is not regarded as an error]

> I suggest trying this with 2.4.5 -- several people report that kernel
> works much better than previous ones with usb-storage.

The details of the behaviour are a bit different, but the essence
is unchanged: with the same .config as the 2.4.3 I reported on,
2.4.5 failed. (With a different one it was successful. It is a
matter of timing.) Again adding the patch:

diff -r -u ../linux-2.4.5/linux/drivers/usb/storage/debug.c linux/drivers/usb/storage/debug.c
--- ../linux-2.4.5/linux/drivers/usb/storage/debug.c    Sat Sep  9 01:39:12 2000
+++ linux/drivers/usb/storage/debug.c   Tue Jun  5 05:23:46 2001
@@ -302,6 +302,8 @@
        case 0x1C00: what="defect list not found"; break;
        case 0x2400: what="invalid field in CDB"; break;
        case 0x2703: what="associated write protect"; break;
+       case 0x2800: what="not ready to ready transtion (media change?)";
+               break;
        case 0x2903: what="bus device reset function occurred"; break;
        case 0x2904: what="device internal reset"; break;
        case 0x2B00: what="copy can't execute since host can't disconnect"; 
diff -r -u ../linux-2.4.5/linux/drivers/usb/storage/transport.c linux/drivers/usb/storage/transport.c
--- ../linux-2.4.5/linux/drivers/usb/storage/transport.c        Wed Apr 18 20:49:12 2001
+++ linux/drivers/usb/storage/transport.c       Tue Jun  5 05:23:13 2001
@@ -793,6 +793,15 @@
                /* If things are really okay, then let's show that */
                if ((srb->sense_buffer[2] & 0xf) == 0x0)
                        srb->result = GOOD << 1;
+
+               /* A transition from non-ready to ready sounds OK. */
+               if ((srb->sense_buffer[2] & 0xf) == 0x6 /* unit attention */
+                   && srb->sense_buffer[12] == 0x28
+                   && srb->sense_buffer[13] == 0 /* not ready -> ready */) {
+                       srb->result = GOOD << 1;
+                       srb->sense_buffer[0] = 0;
+               }
+
        } else /* if (need_auto_sense) */
                srb->result = GOOD << 1;
 
makes things work.

Andries

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

end of thread, other threads:[~2001-06-05  3:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-05  1:58 Unit attention in USB storage Andries.Brouwer
2001-06-05  2:07 ` Matthew Dharm
2001-06-05  3:39 Andries.Brouwer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®