From owner-svn-src-all@FreeBSD.ORG Mon Jul 15 16:40:48 2013 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D86F29CA; Mon, 15 Jul 2013 16:40:48 +0000 (UTC) (envelope-from ken@kdm.org) Received: from nargothrond.kdm.org (nargothrond.kdm.org [70.56.43.81]) by mx1.freebsd.org (Postfix) with ESMTP id A5368935; Mon, 15 Jul 2013 16:40:48 +0000 (UTC) Received: from nargothrond.kdm.org (localhost [127.0.0.1]) by nargothrond.kdm.org (8.14.2/8.14.2) with ESMTP id r6FGegfV062817; Mon, 15 Jul 2013 10:40:42 -0600 (MDT) (envelope-from ken@nargothrond.kdm.org) Received: (from ken@localhost) by nargothrond.kdm.org (8.14.2/8.14.2/Submit) id r6FGegtS062816; Mon, 15 Jul 2013 10:40:42 -0600 (MDT) (envelope-from ken) Date: Mon, 15 Jul 2013 10:40:42 -0600 From: "Kenneth D. Merry" To: Ulrich Sp??rlein , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Subject: Re: svn commit: r253274 - head/sys/cam/scsi Message-ID: <20130715164042.GA62202@nargothrond.kdm.org> References: <201307121709.r6CH9oZr078053@svn.freebsd.org> <20130715151400.GB9092@acme.spoerlein.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130715151400.GB9092@acme.spoerlein.net> User-Agent: Mutt/1.4.2i X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jul 2013 16:40:48 -0000 On Mon, Jul 15, 2013 at 17:14:00 +0200, Ulrich Sp??rlein wrote: > On Fri, 2013-07-12 at 17:09:50 +0000, Kenneth D. Merry wrote: > > Author: ken > > Date: Fri Jul 12 17:09:50 2013 > > New Revision: 253274 > > URL: http://svnweb.freebsd.org/changeset/base/253274 > > > > Log: > > Fix a problem with READ ELEMENT STATUS that occurs on some > > changers that don't support the DVCID and CURDATA bits that were > > introduced in the SMC spec. > > > > These changers will return an Illegal Request type error if the > > bits are set. This causes "chio status" to fail. > > > > The fix is two-fold. First, for changers that claim to be SCSI-2 > > or older, don't set the DVCID and CURDATA bits for READ ELEMENT > > STATUS. For newer changers (SCSI-3 and newer), we default to > > setting the new bits, but back off and try the READ ELEMENT STATUS > > without the bits if we get an Illegal Request type error. > > > > This has been tested on a Qualstar TLS-8211, which is a SCSI-2 > > changer that does not support the new bits, and a Spectra T-380, > > which is a SCSI-3 changer that does support the new bits. In the > > absence of a SCSI-3 changer that does not support the bits, I > > tested that with some error injection code. (The SMC spec says > > that support for CURDATA is mandatory, and DVCID is optional.) > > > > scsi_ch.c: Add a new quirk, CH_Q_NO_DVCID that gets set for > > SCSI-2 and older libraries, or newer libraries that > > report errors when the DVCID/CURDATA bits are set. > > > > In chgetelemstatus(), use the new quirk to > > determine whether or not to set DVCID and CURDATA. > > If we get an error with the bits set, back off and > > try without the bits. Set the quirk flag if the > > read element status succeeds without the bits set. > > > > Increase the READ ELEMENT STATUS timeout to 60 > > seconds after testing with a Spectra T-380. The > > previous value was 10 seconds, and too short for > > the T-380. This may be decreased later after > > some additional testing and investigation. > > > > Tested by: Andre Albsmeier > > Sponsored by: Spectra Logic > > MFC after: 3 days > > > > Modified: > > head/sys/cam/scsi/scsi_ch.c > > > > Modified: head/sys/cam/scsi/scsi_ch.c > > ============================================================================== > > --- head/sys/cam/scsi/scsi_ch.c Fri Jul 12 16:41:58 2013 (r253273) > > +++ head/sys/cam/scsi/scsi_ch.c Fri Jul 12 17:09:50 2013 (r253274) > > @@ -1284,8 +1342,8 @@ chgetelemstatus(struct cam_periph *perip > > /* voltag */ want_voltags, > > /* sea */ softc->sc_firsts[chet] > > + cesr->cesr_element_base, > > - /* dvcid */ 1, > > - /* curdata */ 1, > > + /* dvcid */ dvcid, > > + /* curdata */ curdata, > > /* count */ cesr->cesr_element_count, > > /* data_ptr */ data, > > /* dxfer_len */ size, > > Are you sure? Coverity flags this as being in the wrong argument order > (there's no CID for this yet). > > CID null (#2 of 2): Arguments in wrong order (SWAPPED_ARGUMENTS) > swapped_arguments: The positions of arguments curdata and dvcid are inconsistent with the positions of the corresponding parameters for "scsi_read_element_status(struct ccb_scsiio *, u_int32_t, void (*)(struct cam_periph *, union ccb *), u_int8_t, int, u_int32_t, int, int, u_int32_t, u_int8_t *, u_int32_t, u_int8_t, u_int32_t)". [show details] > 1338 scsi_read_element_status(&ccb->csio, > 1339 /* retries */ 1, > 1340 /* cbfcnp */ chdone, > 1341 /* tag_action */ MSG_SIMPLE_Q_TAG, > 1342 /* voltag */ want_voltags, > 1343 /* sea */ softc->sc_firsts[chet] > 1344 + cesr->cesr_element_base, > 1345 /* dvcid */ dvcid, > 1346 /* curdata */ curdata, > 1347 /* count */ cesr->cesr_element_count, > 1348 /* data_ptr */ data, > 1349 /* dxfer_len */ size, > 1350 /* sense_len */ SSD_FULL_SIZE, > 1351 /* timeout */ CH_TIMEOUT_READ_ELEMENT_STATUS); > > And this is the definition: > > 1860void > 1861scsi_read_element_status(struct ccb_scsiio *csio, u_int32_t retries, > 1862 void (*cbfcnp)(struct cam_periph *, union ccb *), > 1863 u_int8_t tag_action, int voltag, u_int32_t sea, > 1864 int curdata, int dvcid, > 1865 u_int32_t count, u_int8_t *data_ptr, > 1866 u_int32_t dxfer_len, u_int8_t sense_len, > 1867 u_int32_t timeout) > > Looks like you want to swap those two lines above, thanks! Oops, you're right! Thanks for pointing it out! I just committed a fix. How does Coverity detect something like that? Using the comment, or the variable name? Ken -- Kenneth Merry ken@FreeBSD.ORG