Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Aug 2008 00:01:27 +0300
From:      Gleb Kurtsou <gleb.kurtsou@gmail.com>
To:        Oliver Fromme <olli@lurza.secnetix.de>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: USB key && kernel: da0: Attempt to query device size failed: UNIT ?ATTENTION, Medium not present
Message-ID:  <20080806210127.GA1367@h1.d>
In-Reply-To: <200808061729.m76HTVVh003285@lurza.secnetix.de>
References:  <20080806125719.GA8008@rebelion.Sisis.de> <200808061729.m76HTVVh003285@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On (06/08/2008 19:29), Oliver Fromme wrote:
> Matthias Apitz wrote:
>  > I've updated usb/80361, see
>  > http://www.freebsd.org/cgi/query-pr.cgi?pr=80361
>  > because I have the same problem as well that an USB key attaches fine
>  > when plugged in at boot time, but not later:
Situation here is somewhat opposite. Device doesn't attach at boot or
attaches some times. And needs special patch to attach later.

% usbdevs -v
 port 1 addr 2: high speed, power 300 mA, config 1, USB DRIVE(0x0111), 0(0x04e8), rev 2.00


> 
> I'm just wondering what happens if you enforce a rescan
> on the (virtual) SCSI bus.  That is, after you have
> plugged in the USB stick and the problem occured, type
> "camcontrol rescan 0".
> 
> If that doesn't help, please try this patch:
> 
> ===============================================================================
> --- src/sys/dev/usb/umass.c.orig	2008-05-21 16:22:03.000000000 +0200
> +++ src/sys/dev/usb/umass.c	2008-08-06 19:23:01.000000000 +0200
> @@ -2690,7 +2690,7 @@
>  		 * completed, when interrupts have been enabled.
>  		 */
>  
> -		callout_reset(&sc->cam_scsi_rescan_ch, MS_TO_TICKS(200),
> +		callout_reset(&sc->cam_scsi_rescan_ch, MS_TO_TICKS(2000),
>  		    umass_cam_rescan, sc);
>  	}
With this patch it gives following error:
Aug  6 23:33:44 h1 kernel: umass0: <0 USB DRIVE, class 0/0, rev 2.00/2.00, addr 2> on uhub2
Aug  6 23:33:46 h1 kernel: da0 at umass-sim0 bus 0 target 0 lun 0
Aug  6 23:33:46 h1 kernel: da0: < USB DRIVE 2.00> Removable Direct Access SCSI-2 device 
Aug  6 23:33:46 h1 kernel: da0: 40.000MB/s transfers
Aug  6 23:33:46 h1 kernel: da0: Attempt to query device size failed: UNIT ATTENTION, Not ready to ready change,

I've tried to increase delay up to 4000, nothing changed.

Without patch error message is different. Can reproduce it if somebody
is interested in it.

But what surprises is that with this patch device attaches during boot.

> Note that this patch is not a solution.  It's purpose is
> to find out if the cause of your problem is the same as
> the one in PR usb/80361.  If it is, the patch from the PR
> should be committed (it introduces a quirk for cases like
> this), and your USB stick should be added to the quirks
> list.

I've been using another homemade patch for >2 years. Hope it can help to
find a real solution. I have no idea what it does, I'm not sure a had
one during writing it back then. Anyway key attaches and just works.


diff -r 24788dc12d11 -r 519a067f2475 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c	Sat Jun 03 13:05:16 2006 +0300
+++ b/sys/dev/usb/umass.c	Sat Jun 03 13:08:35 2006 +0300
@@ -2514,7 +2514,7 @@ umass_cam_action(struct cam_sim *sim, un
 				sense->extra_len = 10;
  				ccb->csio.scsi_status = SCSI_STATUS_CHECK_COND;
 				ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR |
-				    CAM_AUTOSNS_VALID;
+				    /* CAM_AUTOSNS_VALID */ 0;
 				xpt_done(ccb);
 				return;
 			}
@@ -2805,7 +2805,7 @@ umass_cam_sense_cb(struct umass_softc *s
 			 */
 
 			ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR
-					    | CAM_AUTOSNS_VALID;
+					    | /* CAM_AUTOSNS_VALID */ 0;
 			csio->scsi_status = SCSI_STATUS_CHECK_COND;
 
 #if 0
@@ -2836,7 +2836,7 @@ umass_cam_sense_cb(struct umass_softc *s
 			break;
 		} else {
 			ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR
-					    | CAM_AUTOSNS_VALID;
+					    | /* CAM_AUTOSNS_VALID */ 0;
 			csio->scsi_status = SCSI_STATUS_CHECK_COND;
 		}
 		xpt_done(ccb);
@@ -2872,7 +2872,7 @@ umass_cam_quirk_cb(struct umass_softc *s
 	ccb->ccb_h.status = CAM_REQ_CMP;
 #endif
 	ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR
-			    | CAM_AUTOSNS_VALID;
+			    | /* CAM_AUTOSNS_VALID */ 0;
 	ccb->csio.scsi_status = SCSI_STATUS_CHECK_COND;
 	xpt_done(ccb);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080806210127.GA1367>