USB: MAX3421: Handle USB NAK correctly
authorMark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
Fri, 27 Jan 2023 02:47:34 +0000 (15:47 +1300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 31 Jan 2023 09:38:05 +0000 (10:38 +0100)
A USB peripheral can respond with a NAK if it is not yet ready to
send/receive data. In this case, the transaction should be retried. The
MAX3421 driver did do this, and switched to a different type of retry
after a number of 'fast' retries. On at least some USB flash devices,
this second type of retry never succeeds. This patch changes the
behaviour so that 'fast' retries continue.

Signed-off-by: Mark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20230127024734.8777-1-mark.tomlinson@alliedtelesis.co.nz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/max3421-hcd.c

index 352e3ac..9a87056 100644 (file)
 #define USB_MAX_FRAME_NUMBER   0x7ff
 #define USB_MAX_RETRIES                3 /* # of retries before error is reported */
 
-/*
- * Max. # of times we're willing to retransmit a request immediately in
- * resposne to a NAK.  Afterwards, we fall back on trying once a frame.
- */
-#define NAK_MAX_FAST_RETRANSMITS       2
-
 #define POWER_BUDGET   500     /* in mA; use 8 for low-power port testing */
 
 /* Port-change mask: */
@@ -924,11 +918,8 @@ max3421_handle_error(struct usb_hcd *hcd, u8 hrsl)
                 * Device wasn't ready for data or has no data
                 * available: retry the packet again.
                 */
-               if (max3421_ep->naks++ < NAK_MAX_FAST_RETRANSMITS) {
-                       max3421_next_transfer(hcd, 1);
-                       switch_sndfifo = 0;
-               } else
-                       max3421_slow_retransmit(hcd);
+               max3421_next_transfer(hcd, 1);
+               switch_sndfifo = 0;
                break;
        }
        if (switch_sndfifo)