svn commit: r260575 - in stable/9/sys/dev/usb: . storage wlan

Hans Petter Selasky hselasky at FreeBSD.org
Sun Jan 12 21:21:20 UTC 2014


Author: hselasky
Date: Sun Jan 12 21:21:19 2014
New Revision: 260575
URL: http://svnweb.freebsd.org/changeset/base/260575

Log:
  MFC r244607 and r244650:
  Fix regression issues after r244503.
  
  PR:	usb/185628

Modified:
  stable/9/sys/dev/usb/storage/ustorage_fs.c
  stable/9/sys/dev/usb/usb_msctest.c
  stable/9/sys/dev/usb/wlan/if_urtw.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/storage/ustorage_fs.c
==============================================================================
--- stable/9/sys/dev/usb/storage/ustorage_fs.c	Sun Jan 12 21:19:49 2014	(r260574)
+++ stable/9/sys/dev/usb/storage/ustorage_fs.c	Sun Jan 12 21:21:19 2014	(r260575)
@@ -603,6 +603,8 @@ tr_setup:
 			usbd_xfer_set_stall(xfer);
 			DPRINTF("stall pipe\n");
 		}
+		usbd_xfer_set_frame_len(xfer, 0,
+		    sizeof(ustorage_fs_bbb_cbw_t));
 		usbd_transfer_submit(xfer);
 		break;
 
@@ -827,6 +829,8 @@ tr_setup:
 			sc->sc_transfer.data_error = 0;
 			usbd_xfer_set_stall(xfer);
 		}
+		usbd_xfer_set_frame_len(xfer, 0,
+		    sizeof(ustorage_fs_bbb_csw_t));
 		usbd_transfer_submit(xfer);
 		break;
 

Modified: stable/9/sys/dev/usb/usb_msctest.c
==============================================================================
--- stable/9/sys/dev/usb/usb_msctest.c	Sun Jan 12 21:19:49 2014	(r260574)
+++ stable/9/sys/dev/usb/usb_msctest.c	Sun Jan 12 21:21:19 2014	(r260575)
@@ -83,7 +83,7 @@ enum {
 	DIR_NONE,
 };
 
-#define	SCSI_MAX_LEN	0x100
+#define	SCSI_MAX_LEN	MAX(0x100, BULK_SIZE)
 #define	SCSI_INQ_LEN	0x24
 #define	SCSI_SENSE_LEN	0xFF
 
@@ -150,6 +150,7 @@ struct bbb_transfer {
 	usb_size_t data_rem;		/* bytes */
 	usb_timeout_t data_timeout;	/* ms */
 	usb_frlength_t actlen;		/* bytes */
+	usb_frlength_t buffer_size;    	/* bytes */
 
 	uint8_t	cmd_len;		/* bytes */
 	uint8_t	dir;
@@ -192,7 +193,7 @@ static const struct usb_config bbb_confi
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
-		.bufsize = MAX(SCSI_MAX_LEN, BULK_SIZE),
+		.bufsize = SCSI_MAX_LEN,
 		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1,},
 		.callback = &bbb_data_read_callback,
 		.timeout = 4 * USB_MS_HZ,	/* 4 seconds */
@@ -211,7 +212,7 @@ static const struct usb_config bbb_confi
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
-		.bufsize = BULK_SIZE,
+		.bufsize = SCSI_MAX_LEN,
 		.flags = {.ext_buffer = 1,.proxy_buffer = 1,},
 		.callback = &bbb_data_write_callback,
 		.timeout = 4 * USB_MS_HZ,	/* 4 seconds */
@@ -299,6 +300,8 @@ bbb_command_callback(struct usb_xfer *xf
 			sc->cbw->bCDBLength = sizeof(sc->cbw->CBWCDB);
 			DPRINTFN(0, "Truncating long command\n");
 		}
+		usbd_xfer_set_frame_len(xfer, 0,
+		    sizeof(struct bbb_cbw));
 		usbd_transfer_submit(xfer);
 		break;
 
@@ -385,7 +388,7 @@ bbb_data_write_callback(struct usb_xfer 
 
 		if (sc->data_rem == 0) {
 			bbb_transfer_start(sc, ST_STATUS);
-			return;
+			break;
 		}
 		if (max_bulk > sc->data_rem) {
 			max_bulk = sc->data_rem;
@@ -393,7 +396,7 @@ bbb_data_write_callback(struct usb_xfer 
 		usbd_xfer_set_timeout(xfer, sc->data_timeout);
 		usbd_xfer_set_frame_data(xfer, 0, sc->data_ptr, max_bulk);
 		usbd_transfer_submit(xfer);
-		return;
+		break;
 
 	default:			/* Error */
 		if (error == USB_ERR_CANCELLED) {
@@ -401,8 +404,7 @@ bbb_data_write_callback(struct usb_xfer 
 		} else {
 			bbb_transfer_start(sc, ST_DATA_WR_CS);
 		}
-		return;
-
+		break;
 	}
 }
 
@@ -437,6 +439,8 @@ bbb_status_callback(struct usb_xfer *xfe
 		break;
 
 	case USB_ST_SETUP:
+		usbd_xfer_set_frame_len(xfer, 0,
+		    sizeof(struct bbb_csw));
 		usbd_transfer_submit(xfer);
 		break;
 
@@ -548,6 +552,8 @@ bbb_attach(struct usb_device *udev, uint
 	/* store pointer to DMA buffers */
 	sc->buffer = usbd_xfer_get_frame_buffer(
 	    sc->xfer[ST_DATA_RD], 0);
+	sc->buffer_size =
+	    usbd_xfer_max_len(sc->xfer[ST_DATA_RD]);
 	sc->cbw = usbd_xfer_get_frame_buffer(
 	    sc->xfer[ST_COMMAND], 0);
 	sc->csw = usbd_xfer_get_frame_buffer(
@@ -828,8 +834,8 @@ usb_msc_eject(struct usb_device *udev, u
 		 * TCTMobile needs DIR_IN flag. To get it, we
 		 * supply a dummy data with the command.
 		 */
-		err = bbb_command_start(sc, DIR_IN, 0, &sc->buffer,
-		    sizeof(sc->buffer), &scsi_tct_eject,
+		err = bbb_command_start(sc, DIR_IN, 0, sc->buffer,
+		    sc->buffer_size, &scsi_tct_eject,
 		    sizeof(scsi_tct_eject), USB_MS_HZ);
 		break;
 	default:

Modified: stable/9/sys/dev/usb/wlan/if_urtw.c
==============================================================================
--- stable/9/sys/dev/usb/wlan/if_urtw.c	Sun Jan 12 21:19:49 2014	(r260574)
+++ stable/9/sys/dev/usb/wlan/if_urtw.c	Sun Jan 12 21:21:19 2014	(r260575)
@@ -4179,6 +4179,7 @@ urtw_bulk_tx_status_callback(struct usb_
 	case USB_ST_SETUP:
 setup:
 		memcpy(dma_buf, &sc->sc_txstatus, sizeof(uint64_t));
+		usbd_xfer_set_frame_len(xfer, 0, sizeof(uint64_t));
 		usbd_transfer_submit(xfer);
 		break;
 	default:


More information about the svn-src-stable-9 mailing list