From owner-freebsd-usb@FreeBSD.ORG Sat Oct 29 06:54:21 2011 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AAAA2106566C; Sat, 29 Oct 2011 06:54:21 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe04.c2i.net [212.247.154.98]) by mx1.freebsd.org (Postfix) with ESMTP id C5EDA8FC08; Sat, 29 Oct 2011 06:54:20 +0000 (UTC) X-T2-Spam-Status: No, hits=-1.0 required=5.0 tests=ALL_TRUSTED, BAYES_40 Received: from [188.126.198.129] (account mc467741@c2i.net HELO laptop002.hselasky.homeunix.org) by mailfe04.swip.net (CommuniGate Pro SMTP 5.2.19) with ESMTPA id 196701766; Sat, 29 Oct 2011 08:54:18 +0200 From: Hans Petter Selasky To: Gustau =?iso-8859-1?q?P=E9rez?= Date: Sat, 29 Oct 2011 08:51:15 +0200 User-Agent: KMail/1.13.5 (FreeBSD/8.2-STABLE; KDE/4.4.5; amd64; ; ) References: <4EA9127E.80504@entel.upc.edu> <201110281549.15561.hselasky@c2i.net> <4EAAC562.3000201@entel.upc.edu> In-Reply-To: <4EAAC562.3000201@entel.upc.edu> X-Face: *nPdTl_}RuAI6^PVpA02T?$%Xa^>@hE0uyUIoiha$pC:9TVgl.Oq,NwSZ4V" =?iso-8859-1?q?=7CLR=2E+tj=7Dg5=0A=09=25V?=,x^qOs~mnU3]Gn; cQLv&.N>TrxmSFf+p6(30a/{)KUU!s}w\IhQBj}[g}bj0I3^glmC( =?iso-8859-1?q?=0A=09=3AAuzV9=3A=2EhESm-x4h240C=609=3Dw?= MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_jJ6qOcgvAd4Xy7t" Message-Id: <201110290851.15130.hselasky@c2i.net> Cc: Pawel Jakub Dawidek , freebsd-usb@freebsd.org Subject: Re: Quirk for a USB mass storage device X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Oct 2011 06:54:21 -0000 --Boundary-00=_jJ6qOcgvAd4Xy7t Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable On Friday 28 October 2011 17:08:18 Gustau P=E9rez wrote: > >> Do you want the patch? I can generate it in a second if you wish. > >=20 > > Yes, please do. >=20 > This one applies over both current and 9.0RC1. >=20 > Gus Hi Pawel and Gustau, Can you both clean out your own patches and try the attached one? =2D-HPS --Boundary-00=_jJ6qOcgvAd4Xy7t Content-Type: text/x-patch; charset="iso-8859-15"; name="no_get_max_lun.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="no_get_max_lun.diff" === sys/dev/usb/usb_device.c ================================================================== --- sys/dev/usb/usb_device.c (revision 226805) +++ sys/dev/usb/usb_device.c (local) @@ -1851,7 +1851,8 @@ } } if (set_config_failed == 0 && config_index == 0 && - usb_test_quirk(&uaa, UQ_MSC_NO_SYNC_CACHE) == 0) { + usb_test_quirk(&uaa, UQ_MSC_NO_SYNC_CACHE) == 0 && + usb_test_quirk(&uaa, UQ_MSC_NO_GETMAXLUN) == 0) { /* * Try to figure out if there are any MSC quirks we === sys/dev/usb/usb_msctest.c ================================================================== --- sys/dev/usb/usb_msctest.c (revision 226805) +++ sys/dev/usb/usb_msctest.c (local) @@ -603,6 +603,29 @@ return (is_cdrom); } +static uint8_t +usb_msc_get_max_lun(struct usb_device *udev, uint8_t iface_index) +{ + struct usb_device_request req; + usb_error_t err; + uint8_t buf = 0; + + + /* The Get Max Lun command is a class-specific request. */ + req.bmRequestType = UT_READ_CLASS_INTERFACE; + req.bRequest = 0xFE; /* GET_MAX_LUN */ + USETW(req.wValue, 0); + req.wIndex[0] = iface_index; + req.wIndex[1] = 0; + USETW(req.wLength, 1); + + err = usbd_do_request(udev, NULL, &req, &buf); + if (err) + buf = 0; + + return (buf); +} + usb_error_t usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index) { @@ -622,6 +645,11 @@ */ usb_pause_mtx(NULL, hz); + if (usb_msc_get_max_lun(udev, iface_index) == 0) { + DPRINTF("Device has only got one LUN.\n"); + usbd_add_dynamic_quirk(udev, UQ_MSC_NO_GETMAXLUN); + } + is_no_direct = 1; for (timeout = 4; timeout; timeout--) { err = bbb_command_start(sc, DIR_IN, 0, sc->buffer, --Boundary-00=_jJ6qOcgvAd4Xy7t--