From avg@kiev.net.ua Tue Feb 12 22:12:23 2008 Return-Path: Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E234916A41B for ; Tue, 12 Feb 2008 22:12:23 +0000 (UTC) (envelope-from avg@kiev.net.ua) Received: from hosted.kievnet.com (hosted.kievnet.com [193.138.144.10]) by mx1.freebsd.org (Postfix) with ESMTP id 9BC7813C448 for ; Tue, 12 Feb 2008 22:12:23 +0000 (UTC) (envelope-from avg@kiev.net.ua) Received: from [10.74.70.239] (helo=edge) by hosted.kievnet.com with esmtpa (Exim 4.62) (envelope-from ) id 1JP1rV-0007nd-Lx for FreeBSD-gnats-submit@freebsd.org; Tue, 12 Feb 2008 22:36:17 +0200 Received: from edge (localhost [127.0.0.1]) by edge (8.14.2/8.14.2) with ESMTP id m1CKaG43006417 for ; Tue, 12 Feb 2008 22:36:16 +0200 (EET) (envelope-from avg@edge) Received: (from avg@localhost) by edge (8.14.2/8.14.2/Submit) id m1CKaFNq006416; Tue, 12 Feb 2008 22:36:15 +0200 (EET) (envelope-from avg) Message-Id: <200802122036.m1CKaFNq006416@edge> Date: Tue, 12 Feb 2008 22:36:15 +0200 (EET) From: Andriy Gapon To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: quirk to support ASUS P535 as umass (and inquiry fixup) X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 120572 >Category: usb >Synopsis: [usb67] [umass] [patch] quirk to support ASUS P535 as umass (and inquiry fixup) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-usb >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Feb 12 22:20:00 UTC 2008 >Closed-Date: Sat Apr 09 20:23:44 UTC 2011 >Last-Modified: Sat Apr 09 20:23:44 UTC 2011 >Originator: Andriy Gapon >Release: FreeBSD 7.0-RC1 i386 >Organization: >Environment: System: FreeBSD 7.0-RC1 i386 >Description: History and details of the issue can be found in the following post: http://docs.freebsd.org/cgi/mid.cgi?47AEFFAF.1010403 Short summary: ASUS P535 smart phone configured to act as a umass storage requires DA_Q_NO_SYNC_CACHE quirk in da(4). The problem is that da(4) quirks are set based on inquiry information, but the device in question provides entirely empty inquiry information (bytes for vendor, product and revision are all zeroes). The only way in current infrastructure to provide a quirk for such a device is to have a wildcard quirk ("*", "*", "*"). But that quirk would be applied to all da(4) devices, which can not be good. Proposed patch has two parts. umass part detects inquiry responses that have empty vendor and product info and sets product and vendor info to the corresponding USB device parameters (as hexadecimal numbers). scsi_da part provides the quirk for the ASUS device in question. Note that the umass.c part of teh patch might provide help to supporting more similarly impaired devices. >How-To-Repeat: 1. Get ASUS P535 device with miniSD memory card 2. configure the device to act as umass for USB connection (Setting/Connection/USB) 3. plug into PC 4. observe info and error messages like the following: kernel: umass0: ASUS Generic Mass Storage, rev 2.00/0.00, addr 3 kernel: da0 at umass-sim0 bus 0 target 0 lun 0 kernel: da0: < > Removable Direct Access SCSI-0 device kernel: da0: 1.000MB/s transfers kernel: da0: 1952MB (3998720 512 byte sectors: 255H 63S/T 248C) umass0: Invalid CSW: tag 7 should be 8 (da0:umass-sim0:0:0:0): Synchronize cache failed, status == 0x0, scsi status == 0x4 >Fix: --- p535.diff begins here --- --- sys/dev/usb/umass.c 2008-02-10 15:30:23.000000000 +0200 +++ sys/dev/usb/umass.c 2008-02-10 15:02:43.000000000 +0200 @@ -3063,6 +3059,12 @@ maxsector = scsi_4btoul(rcap->addr) - 1; scsi_ulto4b(maxsector, rcap->addr); } + else if (csio->cdb_io.cdb_bytes[0] == INQUIRY && + csio->data_ptr[8] == '\0' && csio->data_ptr[16] == '\0') { + usb_device_descriptor_t *dd = usbd_get_device_descriptor(sc->sc_udev); + sprintf(&csio->data_ptr[8], "%04x", UGETW(dd->idVendor)); + sprintf(&csio->data_ptr[16], "%04x", UGETW(dd->idProduct)); + } xpt_done(ccb); break; --- sys/cam/scsi/scsi_da.c 2008-02-10 12:40:43.000000000 +0200 +++ sys/cam/scsi/scsi_da.c 2008-02-10 15:09:05.000000000 +0200 @@ -535,6 +535,13 @@ {T_DIRECT, SIP_MEDIA_REMOVABLE, "ChipsBnk", "USB*", "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE }, + { + /* + * ASUS P535 in umass device mode + */ + {T_DIRECT, SIP_MEDIA_REMOVABLE, "0b05*", "422f*", + "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE + }, }; static disk_strategy_t dastrategy; --- p535.diff ends here --- >Release-Note: >Audit-Trail: State-Changed-From-To: open->closed State-Changed-By: avg State-Changed-When: Sat Apr 9 20:20:24 UTC 2011 State-Changed-Why: This is no longer an issue for me. New USB has synchronize cache quirks of its own and doesn't depend on da(4) quirks. The patch for fabricating inquiry data may still have some merits beyond this issue, but I am not sure about that. http://www.freebsd.org/cgi/query-pr.cgi?pr=120572 >Unformatted: