Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Sep 2011 16:39:37 +0200
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        Kostik Belousov <kostikbel@gmail.com>
Cc:        "src-committers@freebsd.org" <src-committers@freebsd.org>, "re@freebsd.org" <re@freebsd.org>, "svn-src-stable@freebsd.org" <svn-src-stable@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "Robert N. M. Watson" <rwatson@freebsd.org>, "svn-src-stable-8@freebsd.org" <svn-src-stable-8@freebsd.org>
Subject:   Re: Request for patch approval (Re: svn commit: r225458 - in stable/8/sys: dev/usb dev/usb/quirk dev/usb/storage sys)
Message-ID:  <201109101639.37581.hselasky@c2i.net>
In-Reply-To: <20110910142812.GO17489@deviant.kiev.zoral.com.ua>
References:  <201109101540.16656.hselasky@c2i.net> <20110910142812.GO17489@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
--Boundary-00=_pa3aOWOl7VtjcsR
Content-Type: Text/Plain;
  charset="iso-8859-15"
Content-Transfer-Encoding: 7bit

On Saturday 10 September 2011 16:28:12 Kostik Belousov wrote:
> On Sat, Sep 10, 2011 at 03:40:16PM +0200, Hans Petter Selasky wrote:
> > > Right -- exactly my point. If this change breaks third-party compiled
> > > USB device drivers, then our current approach to device driver KBIs
> > > does not allow it to be MFC'd in this form. Are there ways you can
> > > reformulate the change to avoid breaking those drivers? Sometimes this
> > > can be done by adding new symbols, rather than replacing currently
> > > symbols, although mileage varies.
> > 
> > Hi,
> > 
> > Here is my proposal:
> > 
> > Implement test for automatic quirks in function which has access to the
> > USB device structure. This decouples the structure change in "struct
> > usbd_lookup_info".
> > 
> > The only structure which needs change is "struct usb_device". In
> > 9-current this structure will be kept as is. In 8-stable the new element
> > will be moved to the end of the structure like suggested, and then there
> > shouldn't be any problems.
> > 
> > Please find patches attached.
> > 
> > --HPS
> > 
> > Commit message:
> > 
> > Refactor auto-quirk solution so that we break as few external
> > drivers as possible.
> > 
> > PR:             usb/160299
> > Approved by:    re (kib)
> > Suggested by:   rwatson
> > MFC after:      0 days
> 
> First, can you, please, regenerate the diff for stable/8 against the
> code before r225458 ? I want to read diff to see ABI change, assuming
> r225458 was not done at all.
> 
> Second, you cannot decrement __FreeBSD_version. In fact, you shall
> increment it once more in the patch for stable/8.

Ok.

Please find attached output from:

svn diff -r 225457 sys/

--HPS

--Boundary-00=_pa3aOWOl7VtjcsR
Content-Type: text/plain; charset="iso-8859-15";
	name="msc_auto_quirk_8_stable_against_r225457.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
	filename="msc_auto_quirk_8_stable_against_r225457.txt"

Index: sys/dev/usb/usb_msctest.h
===================================================================
--- sys/dev/usb/usb_msctest.h	(revision 225457)
+++ sys/dev/usb/usb_msctest.h	(working copy)
@@ -40,5 +40,7 @@
 	    uint8_t iface_index);
 usb_error_t usb_msc_eject(struct usb_device *udev,
 	    uint8_t iface_index, int method);
+usb_error_t usb_msc_auto_quirk(struct usb_device *udev,
+	    uint8_t iface_index);
 
 #endif					/* _USB_MSCTEST_H_ */
Index: sys/dev/usb/quirk/usb_quirk.c
===================================================================
--- sys/dev/usb/quirk/usb_quirk.c	(revision 225457)
+++ sys/dev/usb/quirk/usb_quirk.c	(working copy)
@@ -148,12 +148,10 @@
 	    UQ_MSC_FORCE_PROTO_SCSI),
 	USB_QUIRK(AIPTEK, POCKETCAM3M, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI),
-	USB_QUIRK(AIPTEK2, SUNPLUS_TECH, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(ALCOR, SDCR_6335, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY,
 	    UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(ALCOR, SDCR_6362, 0x0000, 0xffff, UQ_MSC_NO_TEST_UNIT_READY,
 	    UQ_MSC_NO_SYNC_CACHE),
-	USB_QUIRK(ALCOR, AU6390, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(ALCOR, UMCR_9361, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_GETMAXLUN),
 	USB_QUIRK(ALCOR, TRANSCEND, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN,
@@ -173,14 +171,12 @@
 	USB_QUIRK(CENTURY, EX35QUAT, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ,
 	    UQ_MSC_NO_START_STOP, UQ_MSC_IGNORE_RESIDUE),
-	USB_QUIRK(CENTURY, EX35SW4_SB4, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(CYPRESS, XX6830XX, 0x0000, 0xffff, UQ_MSC_NO_GETMAXLUN,
 	    UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(DESKNOTE, UCR_61S2B, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI),
 	USB_QUIRK(DMI, CFSM_RW, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI,
 	    UQ_MSC_NO_GETMAXLUN),
-	USB_QUIRK(DMI, DISK, 0x000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(EPSON, STYLUS_875DC, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY),
 	USB_QUIRK(EPSON, STYLUS_895, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
@@ -188,7 +184,6 @@
 	USB_QUIRK(FEIYA, 5IN1, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI),
 	USB_QUIRK(FREECOM, DVD, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_SCSI),
-	USB_QUIRK(FREECOM, HDD, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(FUJIPHOTO, MASS0100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI_I,
 	    UQ_MSC_FORCE_PROTO_ATAPI, UQ_MSC_NO_RS_CLEAR_UA, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(GENESYS, GL641USB2IDE, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
@@ -232,7 +227,6 @@
 	USB_QUIRK(IOMEGA, ZIP100, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI,
 	    UQ_MSC_NO_TEST_UNIT_READY), /* XXX ZIP drives can also use ATAPI */
-	USB_QUIRK(JMICRON, JM20336, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(JMICRON, JM20337, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI,
 	    UQ_MSC_NO_SYNC_CACHE),
@@ -279,8 +273,6 @@
 	    UQ_MSC_FORCE_PROTO_ATAPI),
 	USB_QUIRK(MYSON, HEDEN, 0x0000, 0xffff, UQ_MSC_IGNORE_RESIDUE,
 	    UQ_MSC_NO_SYNC_CACHE),
-	USB_QUIRK(MYSON, HEDEN_8813, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
-	USB_QUIRK(MYSON, STARREADER, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(NEODIO, ND3260, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_FORCE_SHORT_INQ),
 	USB_QUIRK(NETAC, CF_CARD, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
@@ -317,7 +309,6 @@
 	USB_QUIRK(PANASONIC, KXLCB35AN, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI),
 	USB_QUIRK(PANASONIC, LS120CAM, 0x0000, 0xffff, UQ_MSC_FORCE_PROTO_UFI),
-	USB_QUIRK(PHILIPS, SPE3030CC, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(PLEXTOR, 40_12_40U, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_TEST_UNIT_READY),
 	USB_QUIRK(PNY, ATTACHE2, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
@@ -328,7 +319,6 @@
 	USB_QUIRK_VP(USB_VENDOR_SAMSUNG_TECHWIN,
 	    USB_PRODUCT_SAMSUNG_TECHWIN_DIGIMAX_410, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY),
-	USB_QUIRK(SAMSUNG, YP_U4, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 	USB_QUIRK(SANDISK, SDDR05A, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_CBI,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_READ_CAP_OFFBY1,
 	    UQ_MSC_NO_GETMAXLUN),
@@ -448,12 +438,6 @@
 	    UQ_MSC_FORCE_PROTO_ATAPI),
 	USB_QUIRK(MEIZU, M6_SL, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
 	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_INQUIRY, UQ_MSC_NO_SYNC_CACHE),
-	USB_QUIRK(ACTIONS, MP4, 0x0000, 0xffff, UQ_MSC_FORCE_WIRE_BBB,
-	    UQ_MSC_FORCE_PROTO_SCSI, UQ_MSC_NO_SYNC_CACHE),
-	USB_QUIRK(ASUS, GMSC, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
-	USB_QUIRK(CHIPSBANK, USBMEMSTICK, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
-	USB_QUIRK(CHIPSBANK, USBMEMSTICK1, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
-	USB_QUIRK(NEWLINK, USB2IDEBRIDGE, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE),
 
 	/* Non-standard USB MIDI devices */
 	USB_QUIRK(ROLAND, UM1, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS),
@@ -567,9 +551,9 @@
 	uint16_t x;
 	uint16_t y;
 
-	if (quirk == UQ_NONE) {
-		return (0);
-	}
+	if (quirk == UQ_NONE)
+		goto done;
+
 	mtx_lock(&usb_quirk_mtx);
 
 	for (x = 0; x != USB_DEV_QUIRKS_MAX; x++) {
@@ -603,7 +587,8 @@
 		break;
 	}
 	mtx_unlock(&usb_quirk_mtx);
-	return (0);
+done:
+	return (0);			/* no quirk match */
 }
 
 static struct usb_quirk_entry *
Index: sys/dev/usb/usbdi.h
===================================================================
--- sys/dev/usb/usbdi.h	(revision 225457)
+++ sys/dev/usb/usbdi.h	(working copy)
@@ -475,6 +475,8 @@
 void	usb_pause_mtx(struct mtx *mtx, int _ticks);
 usb_error_t	usbd_set_pnpinfo(struct usb_device *udev,
 			uint8_t iface_index, const char *pnpinfo);
+usb_error_t	usbd_add_dynamic_quirk(struct usb_device *udev,
+			uint16_t quirk);
 
 const struct usb_device_id *usbd_lookup_id_by_info(
 	    const struct usb_device_id *id, usb_size_t sizeof_id,
Index: sys/dev/usb/storage/umass.c
===================================================================
--- sys/dev/usb/storage/umass.c	(revision 225457)
+++ sys/dev/usb/storage/umass.c	(working copy)
@@ -1025,12 +1025,6 @@
 	sc->cam_scsi_sense.opcode = REQUEST_SENSE;
 	sc->cam_scsi_test_unit_ready.opcode = TEST_UNIT_READY;
 
-	/*
-	 * some devices need a delay after that the configuration value is
-	 * set to function properly:
-	 */
-	usb_pause_mtx(NULL, hz);
-
 	/* register the SIM */
 	err = umass_cam_attach_sim(sc);
 	if (err) {
Index: sys/dev/usb/usb_freebsd.h
===================================================================
--- sys/dev/usb/usb_freebsd.h	(revision 225457)
+++ sys/dev/usb/usb_freebsd.h	(working copy)
@@ -60,6 +60,8 @@
 #define	USB_EP0_BUFSIZE		1024	/* bytes */
 #define	USB_CS_RESET_LIMIT	20	/* failures = 20 * 50 ms = 1sec */
 
+#define	USB_MAX_AUTO_QUIRK	4	/* maximum number of dynamic quirks */
+
 typedef uint32_t usb_timeout_t;		/* milliseconds */
 typedef uint32_t usb_frlength_t;	/* bytes */
 typedef uint32_t usb_frcount_t;		/* units */
Index: sys/dev/usb/usb_device.c
===================================================================
--- sys/dev/usb/usb_device.c	(revision 225457)
+++ sys/dev/usb/usb_device.c	(working copy)
@@ -1239,7 +1239,7 @@
 usb_init_attach_arg(struct usb_device *udev,
     struct usb_attach_arg *uaa)
 {
-	bzero(uaa, sizeof(*uaa));
+	memset(uaa, 0, sizeof(*uaa));
 
 	uaa->device = udev;
 	uaa->usb_mode = udev->flags.usb_mode;
@@ -1850,7 +1850,21 @@
 			}
 		}
 	}
+	if (set_config_failed == 0 && config_index == 0 &&
+	    usb_test_quirk(&uaa, UQ_MSC_NO_SYNC_CACHE) == 0) {
 
+		/*
+		 * Try to figure out if there are any MSC quirks we
+		 * should apply automatically:
+		 */
+		err = usb_msc_auto_quirk(udev, 0);
+
+		if (err != 0) {
+			set_config_failed = 1;
+			goto repeat_set_config;
+		}
+	}
+
 config_done:
 	DPRINTF("new dev (addr %d), udev=%p, parent_hub=%p\n",
 	    udev->address, udev, udev->parent_hub);
@@ -2370,8 +2384,22 @@
 usb_test_quirk(const struct usb_attach_arg *uaa, uint16_t quirk)
 {
 	uint8_t found;
+	uint8_t x;
 
+	if (quirk == UQ_NONE)
+		return (0);
+
+	/* search the automatic per device quirks first */
+
+	for (x = 0; x != USB_MAX_AUTO_QUIRK; x++) {
+		if (uaa->device->autoQuirk[x] == quirk)
+			return (1);
+	}
+
+	/* search global quirk table, if any */
+
 	found = (usb_test_quirk_p) (&uaa->info, quirk);
+
 	return (found);
 }
 
@@ -2773,3 +2801,17 @@
 	return (0);			/* success */
 }
 
+usb_error_t
+usbd_add_dynamic_quirk(struct usb_device *udev, uint16_t quirk)
+{
+	uint8_t x;
+
+	for (x = 0; x != USB_MAX_AUTO_QUIRK; x++) {
+		if (udev->autoQuirk[x] == 0 ||
+		    udev->autoQuirk[x] == quirk) {
+			udev->autoQuirk[x] = quirk;
+			return (0);	/* success */
+		}
+	}
+	return (USB_ERR_NOMEM);
+}
Index: sys/dev/usb/usb_device.h
===================================================================
--- sys/dev/usb/usb_device.h	(revision 225457)
+++ sys/dev/usb/usb_device.h	(working copy)
@@ -190,6 +190,8 @@
 #endif
 
 	uint32_t clear_stall_errors;	/* number of clear-stall failures */
+
+	uint16_t autoQuirk[USB_MAX_AUTO_QUIRK];		/* dynamic quirks */
 };
 
 /* globals */
Index: sys/dev/usb/usb_msctest.c
===================================================================
--- sys/dev/usb/usb_msctest.c	(revision 225457)
+++ sys/dev/usb/usb_msctest.c	(working copy)
@@ -1,6 +1,6 @@
 /* $FreeBSD$ */
 /*-
- * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2008,2011 Hans Petter Selasky. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -84,7 +84,10 @@
 	DIR_NONE,
 };
 
+#define	SCSI_MAX_LEN	0x100
 #define	SCSI_INQ_LEN	0x24
+#define	SCSI_SENSE_LEN	0xFF
+
 static uint8_t scsi_test_unit_ready[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 static uint8_t scsi_inquiry[] = { 0x12, 0x00, 0x00, 0x00, SCSI_INQ_LEN, 0x00 };
 static uint8_t scsi_rezero_init[] =     { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
@@ -97,6 +100,10 @@
 					  0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 					  0x00, 0x00, 0x00, 0x00 };
 static uint8_t scsi_tct_eject[] =	{ 0x06, 0xf5, 0x04, 0x02, 0x52, 0x70 };
+static uint8_t scsi_sync_cache[] =	{ 0x35, 0x00, 0x00, 0x00, 0x00, 0x00,
+					  0x00, 0x00, 0x00, 0x00 };
+static uint8_t scsi_request_sense[] =	{ 0x03, 0x00, 0x00, 0x00, 0x12, 0x00,
+					  0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
 
 #define	BULK_SIZE		64	/* dummy */
 #define	ERR_CSW_FAILED		-1
@@ -150,7 +157,7 @@
 	uint8_t	status_try;
 	int	error;
 
-	uint8_t	buffer[256];
+	uint8_t	buffer[SCSI_MAX_LEN] __aligned(4);
 };
 
 static usb_callback_t bbb_command_callback;
@@ -164,7 +171,7 @@
 static void	bbb_transfer_start(struct bbb_transfer *, uint8_t);
 static void	bbb_data_clear_stall_callback(struct usb_xfer *, uint8_t,
 		    uint8_t);
-static uint8_t bbb_command_start(struct bbb_transfer *, uint8_t, uint8_t,
+static int	bbb_command_start(struct bbb_transfer *, uint8_t, uint8_t,
 		    void *, size_t, void *, size_t, usb_timeout_t);
 static struct bbb_transfer *bbb_attach(struct usb_device *, uint8_t);
 static void	bbb_detach(struct bbb_transfer *);
@@ -455,7 +462,7 @@
  * 0: Success
  * Else: Failure
  *------------------------------------------------------------------------*/
-static uint8_t
+static int
 bbb_command_start(struct bbb_transfer *sc, uint8_t dir, uint8_t lun,
     void *data_ptr, size_t data_len, void *cmd_ptr, size_t cmd_len,
     usb_timeout_t data_timeout)
@@ -567,9 +574,10 @@
 usb_iface_is_cdrom(struct usb_device *udev, uint8_t iface_index)
 {
 	struct bbb_transfer *sc;
-	usb_error_t err;
-	uint8_t timeout, is_cdrom;
+	uint8_t timeout;
+	uint8_t is_cdrom;
 	uint8_t sid_type;
+	int err;
 
 	sc = bbb_attach(udev, iface_index);
 	if (sc == NULL)
@@ -596,6 +604,114 @@
 }
 
 usb_error_t
+usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index)
+{
+	struct bbb_transfer *sc;
+	uint8_t timeout;
+	uint8_t is_no_direct;
+	uint8_t sid_type;
+	int err;
+
+	sc = bbb_attach(udev, iface_index);
+	if (sc == NULL)
+		return (0);
+
+	/*
+	 * Some devices need a delay after that the configuration
+	 * value is set to function properly:
+	 */
+	usb_pause_mtx(NULL, hz);
+
+	is_no_direct = 1;
+	for (timeout = 4; timeout; timeout--) {
+		err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
+		    SCSI_INQ_LEN, &scsi_inquiry, sizeof(scsi_inquiry),
+		    USB_MS_HZ);
+
+		if (err == 0 && sc->actlen > 0) {
+			sid_type = sc->buffer[0] & 0x1F;
+			if (sid_type == 0x00)
+				is_no_direct = 0;
+			break;
+		} else if (err != ERR_CSW_FAILED)
+			break;	/* non retryable error */
+		usb_pause_mtx(NULL, hz);
+	}
+
+	if (is_no_direct) {
+		DPRINTF("Device is not direct access.\n");
+		goto done;
+	}
+
+	err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
+	    &scsi_test_unit_ready, sizeof(scsi_test_unit_ready),
+	    USB_MS_HZ);
+
+	if (err != 0) {
+
+		if (err != ERR_CSW_FAILED)
+			goto error;
+	}
+
+	err = bbb_command_start(sc, DIR_IN, 0, NULL, 0,
+	    &scsi_sync_cache, sizeof(scsi_sync_cache),
+	    USB_MS_HZ);
+
+	if (err != 0) {
+
+		if (err != ERR_CSW_FAILED)
+			goto error;
+
+		DPRINTF("Device doesn't handle synchronize cache\n");
+
+		usbd_add_dynamic_quirk(udev, UQ_MSC_NO_SYNC_CACHE);
+	}
+
+	/* clear sense status of any failed commands on the device */
+
+	err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
+	    SCSI_INQ_LEN, &scsi_inquiry, sizeof(scsi_inquiry),
+	    USB_MS_HZ);
+
+	DPRINTF("Inquiry = %d\n", err);
+
+	if (err != 0) {
+
+		if (err != ERR_CSW_FAILED)
+			goto error;
+	}
+
+	err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
+	    SCSI_SENSE_LEN, &scsi_request_sense,
+	    sizeof(scsi_request_sense), USB_MS_HZ);
+
+	DPRINTF("Request sense = %d\n", err);
+
+	if (err != 0) {
+
+		if (err != ERR_CSW_FAILED)
+			goto error;
+	}
+
+done:
+	bbb_detach(sc);
+	return (0);
+
+error:
+ 	bbb_detach(sc);
+
+	DPRINTF("Device did not respond, enabling all quirks\n");
+
+	usbd_add_dynamic_quirk(udev, UQ_MSC_NO_SYNC_CACHE);
+	usbd_add_dynamic_quirk(udev, UQ_MSC_NO_TEST_UNIT_READY);
+
+	/* Need to re-enumerate the device */
+	usbd_req_re_enumerate(udev, NULL);
+
+	return (USB_ERR_STALLED);
+}
+
+usb_error_t
 usb_msc_eject(struct usb_device *udev, uint8_t iface_index, int method)
 {
 	struct bbb_transfer *sc;

Property changes on: sys/contrib/pf
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /head/sys/contrib/pf:r225350,225400


Property changes on: sys/contrib/dev/acpica
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /head/sys/contrib/dev/acpica:r225350,225400


Property changes on: sys/cddl/contrib/opensolaris
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /head/sys/cddl/contrib/opensolaris:r225350,225400


Property changes on: sys/amd64/include/xen
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /head/sys/amd64/include/xen:r225350,225400

Index: sys/sys/param.h
===================================================================
--- sys/sys/param.h	(revision 225457)
+++ sys/sys/param.h	(working copy)
@@ -58,7 +58,7 @@
  *		in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 802510	/* Master, propagated to newvers */
+#define __FreeBSD_version 802512	/* Master, propagated to newvers */
 
 #ifdef _KERNEL
 #define	P_OSREL_SIGSEGV		700004

Property changes on: sys
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /head/sys:r225350,225400


--Boundary-00=_pa3aOWOl7VtjcsR--



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