Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Jan 2009 10:16:02 +0000 (UTC)
From:      Rafal Jaworowski <raj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r186891 - head/sys/cam
Message-ID:  <200901081016.n08AG3Np019652@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: raj
Date: Thu Jan  8 10:16:02 2009
New Revision: 186891
URL: http://svn.freebsd.org/changeset/base/186891

Log:
  cam: Retry TEST UNIT READY command if not successful.
  
  This fixes problems with discovering some USB devices that are very slow to
  respond during initialisation.
  
  When a USB device is inserted, CAM performs the sequence:
    1) INQUIRY
    2) INQUIRY (second time with other parameters)
    3) TEST UNIT READY
    4) READ CAPACITY
  
  Before this change CAM didn't check if TEST UNIT READY was successful and went
  on blindly to the next state and sent READ CAPACITY. If the device was still
  not ready by then, CAM ended with error message. This patch adds checking for the
  status of TEST UNIT READY command and retrying up to 10 times with 0.5 sec
  interval.
  
  Submitted by:	Grzegorz Bernacki gjb ! semihalf dot com
  Reviewed by:	scottl

Modified:
  head/sys/cam/cam_xpt.c

Modified: head/sys/cam/cam_xpt.c
==============================================================================
--- head/sys/cam/cam_xpt.c	Thu Jan  8 09:50:20 2009	(r186890)
+++ head/sys/cam/cam_xpt.c	Thu Jan  8 10:16:02 2009	(r186891)
@@ -5611,7 +5611,7 @@ probestart(struct cam_periph *periph, un
 	case PROBE_DV_EXIT:
 	{
 		scsi_test_unit_ready(csio,
-				     /*retries*/4,
+				     /*retries*/10,
 				     probedone,
 				     MSG_SIMPLE_Q_TAG,
 				     SSD_FULL_SIZE,
@@ -6218,6 +6218,13 @@ probedone(struct cam_periph *periph, uni
 		break;
 	}
 	case PROBE_TUR_FOR_NEGOTIATION:
+		if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
+			DELAY(500000);
+			if (cam_periph_error(done_ccb, 0, SF_RETRY_UA,
+			    NULL) == ERESTART)
+				return;
+		}
+	/* FALLTHROUGH */
 	case PROBE_DV_EXIT:
 		if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) {
 			/* Don't wedge the queue */



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