From owner-svn-src-head@FreeBSD.ORG Thu Jan 8 10:16:03 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31AFC106567E; Thu, 8 Jan 2009 10:16:03 +0000 (UTC) (envelope-from raj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1F3C48FC1F; Thu, 8 Jan 2009 10:16:03 +0000 (UTC) (envelope-from raj@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n08AG3C6019653; Thu, 8 Jan 2009 10:16:03 GMT (envelope-from raj@svn.freebsd.org) Received: (from raj@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n08AG3Np019652; Thu, 8 Jan 2009 10:16:03 GMT (envelope-from raj@svn.freebsd.org) Message-Id: <200901081016.n08AG3Np019652@svn.freebsd.org> From: Rafal Jaworowski Date: Thu, 8 Jan 2009 10:16:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186891 - head/sys/cam X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jan 2009 10:16:04 -0000 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 */