2023-01-27 02:47:47

by Mark Tomlinson

[permalink] [raw]
Subject: [PATCH] USB: MAX3421: Handle USB NAK correctly

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 <[email protected]>
---
drivers/usb/host/max3421-hcd.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
index 352e3ac2b377..9a87056fc738 100644
--- a/drivers/usb/host/max3421-hcd.c
+++ b/drivers/usb/host/max3421-hcd.c
@@ -72,12 +72,6 @@
#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)
--
2.39.1



2023-01-27 06:23:38

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] USB: MAX3421: Handle USB NAK correctly

On Fri, Jan 27, 2023 at 03:47:34PM +1300, Mark Tomlinson wrote:
> 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 <[email protected]>
> ---
> drivers/usb/host/max3421-hcd.c | 13 ++-----------
> 1 file changed, 2 insertions(+), 11 deletions(-)

What commit id does this fix? And should it be backported to older
kernel trees?

thanks,

greg k-h

2023-01-29 22:06:00

by Mark Tomlinson

[permalink] [raw]
Subject: Re: [PATCH] USB: MAX3421: Handle USB NAK correctly

On Fri, 2023-01-27 at 07:22 +0100, Greg KH wrote:
>
> What commit id does this fix? And should it be backported to older
> kernel trees?
>
> thanks,
>
> greg k-h

The code in question has been unchanged since the original commit
2d53139f3. I'm sure that the behaviour is the same in all kernels since
this driver existed, but also wonder how many people would be affected by
it. I would be happy if this only went into the current tree.

- Mark