PERFORCE change 118839 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Thu Apr 26 18:46:09 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=118839
Change 118839 by hselasky at hselasky_mini_itx on 2007/04/26 18:45:16
Improve handling of zero length BULK transfers.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/ehci.c#28 edit
.. //depot/projects/usb/src/sys/dev/usb/ohci.c#22 edit
.. //depot/projects/usb/src/sys/dev/usb/uhci.c#23 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/ehci.c#28 (text+ko) ====
@@ -1538,6 +1538,7 @@
htole32(EHCI_QTD_SET_CERR(3));
u_int8_t isread;
u_int8_t shortpkt = 0;
+ u_int8_t force_short;
ehci_qtd_t *td;
ehci_qtd_t *td_last = NULL;
ehci_qh_t *qh;
@@ -1552,6 +1553,8 @@
buf_offset = 0;
usbd_get_page(&(xfer->buf_data), buf_offset, &buf_res);
+ force_short = (xfer->flags & USBD_FORCE_SHORT_XFER) ? 1 : 0;
+
if(xfer->pipe->methods == &ehci_device_ctrl_methods)
{
/* the first byte is "bmRequestType" */
@@ -1603,14 +1606,14 @@
{
isread = (UE_GET_DIR(xfer->endpoint) == UE_DIR_IN);
- if(xfer->length == 0)
- {
- /* must allow access to "td_last",
- * so xfer->length cannot be zero!
+ if (xfer->length == 0) {
+ /* When the length is zero we
+ * queue a short packet!
+ * This also makes "td_last"
+ * non-zero.
*/
- printf("%s: setting USBD_FORCE_SHORT_XFER!\n",
- __FUNCTION__);
- xfer->flags |= USBD_FORCE_SHORT_XFER;
+ DPRINTFN(0, ("short transfer!\n"));
+ force_short = 1;
}
}
@@ -1631,7 +1634,7 @@
{
if(len == 0)
{
- if(xfer->flags & USBD_FORCE_SHORT_XFER)
+ if (force_short)
{
if(shortpkt)
{
==== //depot/projects/usb/src/sys/dev/usb/ohci.c#22 (text+ko) ====
@@ -1265,6 +1265,7 @@
u_int32_t len = xfer->length;
u_int8_t isread;
u_int8_t shortpkt = 0;
+ u_int8_t force_short;
ohci_td_t *td;
ohci_td_t *td_last = NULL;
ohci_ed_t *ed;
@@ -1278,6 +1279,8 @@
buf_offset = 0;
usbd_get_page(&(xfer->buf_data), buf_offset, &buf_res);
+ force_short = (xfer->flags & USBD_FORCE_SHORT_XFER) ? 1 : 0;
+
if(xfer->pipe->methods == &ohci_device_ctrl_methods)
{
/* the first byte is "bmRequestType" */
@@ -1323,14 +1326,14 @@
{
isread = (UE_GET_DIR(xfer->endpoint) == UE_DIR_IN);
- if(xfer->length == 0)
- {
- /* must allow access to "td_last",
- * so xfer->length cannot be zero!
+ if (xfer->length == 0) {
+ /* When the length is zero we
+ * queue a short packet!
+ * This also makes "td_last"
+ * non-zero.
*/
- printf("%s: setting USBD_FORCE_SHORT_XFER!\n",
- __FUNCTION__);
- xfer->flags |= USBD_FORCE_SHORT_XFER;
+ DPRINTFN(0, ("short transfer!\n"));
+ force_short = 1;
}
}
@@ -1361,7 +1364,7 @@
{
if(len == 0)
{
- if(xfer->flags & USBD_FORCE_SHORT_XFER)
+ if (force_short)
{
if(shortpkt)
{
==== //depot/projects/usb/src/sys/dev/usb/uhci.c#23 (text+ko) ====
@@ -1362,6 +1362,7 @@
u_int32_t len = xfer->length;
u_int8_t isread;
u_int8_t shortpkt = 0;
+ u_int8_t force_short;
uhci_td_t *td;
uhci_td_t *td_last = NULL;
@@ -1389,6 +1390,8 @@
td_status |= htole32(UHCI_TD_SPD);
}
+ force_short = (xfer->flags & USBD_FORCE_SHORT_XFER) ? 1 : 0;
+
if(xfer->pipe->methods == &uhci_device_ctrl_methods)
{
/* the first byte is "bmRequestType" */
@@ -1433,13 +1436,14 @@
{
isread = (UE_GET_DIR(xfer->endpoint) == UE_DIR_IN);
- if(xfer->length == 0)
- {
- /* must allow access to "td_last",
- * so xfer->length cannot be zero!
+ if (xfer->length == 0) {
+ /* When the length is zero we
+ * queue a short packet!
+ * This also makes "td_last"
+ * non-zero.
*/
- printf("%s: setting USBD_FORCE_SHORT_XFER!\n", __FUNCTION__);
- xfer->flags |= USBD_FORCE_SHORT_XFER;
+ DPRINTFN(0, ("short transfer!\n"));
+ force_short = 1;
}
}
@@ -1458,7 +1462,7 @@
{
if(len == 0)
{
- if(xfer->flags & USBD_FORCE_SHORT_XFER)
+ if (force_short)
{
if(shortpkt)
{
More information about the p4-projects
mailing list