linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: Clear both buffers when clearing a control transfer TT buffer.
@ 2013-06-27 23:10 William Gulland
  2013-06-28 13:54 ` Sergei Shtylyov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: William Gulland @ 2013-06-27 23:10 UTC (permalink / raw)
  To: Alan Stern, Sarah Sharp, Lan Tianyu, Ming Lei, linux-usb, linux-kernel
  Cc: William Gulland

    Control transfers have both IN and OUT (or SETUP) packets, so when
    clearing TT buffers for a control transfer it's necessary to send
    two HUB_CLEAR_TT_BUFFER requests to the hub.

Signed-off-by: William Gulland <wgulland@google.com>
---
 drivers/usb/core/hub.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index feef935..868ad74 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -668,6 +668,15 @@ resubmit:
 static inline int
 hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
 {
+	/* Need to clear both directions for control ep */
+	if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) ==
+			USB_ENDPOINT_XFER_CONTROL) {
+		int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
+				HUB_CLEAR_TT_BUFFER, USB_RT_PORT,
+				devinfo ^ 0x8000, tt, NULL, 0, 1000);
+		if (status)
+			return status;
+	}
 	return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
 			       HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo,
 			       tt, NULL, 0, 1000);
-- 
1.8.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: Clear both buffers when clearing a control transfer TT buffer.
  2013-06-27 23:10 [PATCH] usb: Clear both buffers when clearing a control transfer TT buffer William Gulland
@ 2013-06-28 13:54 ` Sergei Shtylyov
  2013-06-28 15:56 ` Alan Stern
  2013-07-01 20:41 ` Alan Stern
  2 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2013-06-28 13:54 UTC (permalink / raw)
  To: William Gulland
  Cc: Alan Stern, Sarah Sharp, Lan Tianyu, Ming Lei, linux-usb, linux-kernel

Hello.

On 28-06-2013 3:10, William Gulland wrote:

>      Control transfers have both IN and OUT (or SETUP) packets, so when
>      clearing TT buffers for a control transfer it's necessary to send
>      two HUB_CLEAR_TT_BUFFER requests to the hub.

> Signed-off-by: William Gulland <wgulland@google.com>
> ---
>   drivers/usb/core/hub.c | 9 +++++++++
>   1 file changed, 9 insertions(+)

> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index feef935..868ad74 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -668,6 +668,15 @@ resubmit:
>   static inline int
>   hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
>   {
> +	/* Need to clear both directions for control ep */
> +	if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) ==
> +			USB_ENDPOINT_XFER_CONTROL) {
> +		int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
> +				HUB_CLEAR_TT_BUFFER, USB_RT_PORT,
> +				devinfo ^ 0x8000, tt, NULL, 0, 1000);

    Could you use consistent indentation style with the below call?
Also, empty line wouldn't hurt after declaration...

> +		if (status)
> +			return status;
> +	}
>   	return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
>   			       HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo,
>   			       tt, NULL, 0, 1000);

WBR, Sergei


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: Clear both buffers when clearing a control transfer TT buffer.
  2013-06-27 23:10 [PATCH] usb: Clear both buffers when clearing a control transfer TT buffer William Gulland
  2013-06-28 13:54 ` Sergei Shtylyov
@ 2013-06-28 15:56 ` Alan Stern
  2013-07-01 20:41 ` Alan Stern
  2 siblings, 0 replies; 4+ messages in thread
From: Alan Stern @ 2013-06-28 15:56 UTC (permalink / raw)
  To: William Gulland
  Cc: Sarah Sharp, Lan Tianyu, Ming Lei, linux-usb, linux-kernel

On Thu, 27 Jun 2013, William Gulland wrote:

>     Control transfers have both IN and OUT (or SETUP) packets, so when
>     clearing TT buffers for a control transfer it's necessary to send
>     two HUB_CLEAR_TT_BUFFER requests to the hub.

What makes you think this is necessary?  Have you found any hardware 
that requires this?

Although the USB spec doesn't say much about Clear-TT-Buffer requests,
the text in section 11.17.1 and Figure 11-47 seems to indicate that a
second Clear-TT-Buffer shouldn't be needed.  The spec says that TT
buffers are matched based on the device address, endpoint number, and
endpoint direction -- but the direction is used only for bulk
endpoints, not for control endpoints.

In particular, a control endpoint uses only one TT buffer for both the
IN and OUT directions.  So I don't think two Clear-TT-Buffers are
needed.

Alan Stern


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: Clear both buffers when clearing a control transfer TT buffer.
  2013-06-27 23:10 [PATCH] usb: Clear both buffers when clearing a control transfer TT buffer William Gulland
  2013-06-28 13:54 ` Sergei Shtylyov
  2013-06-28 15:56 ` Alan Stern
@ 2013-07-01 20:41 ` Alan Stern
  2 siblings, 0 replies; 4+ messages in thread
From: Alan Stern @ 2013-07-01 20:41 UTC (permalink / raw)
  To: William Gulland
  Cc: Sarah Sharp, Lan Tianyu, Ming Lei, linux-usb, linux-kernel

On Thu, 27 Jun 2013, William Gulland wrote:

>     Control transfers have both IN and OUT (or SETUP) packets, so when
>     clearing TT buffers for a control transfer it's necessary to send
>     two HUB_CLEAR_TT_BUFFER requests to the hub.
> 
> Signed-off-by: William Gulland <wgulland@google.com>
> ---
>  drivers/usb/core/hub.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index feef935..868ad74 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -668,6 +668,15 @@ resubmit:
>  static inline int
>  hub_clear_tt_buffer (struct usb_device *hdev, u16 devinfo, u16 tt)
>  {
> +	/* Need to clear both directions for control ep */
> +	if (((devinfo >> 11) & USB_ENDPOINT_XFERTYPE_MASK) ==
> +			USB_ENDPOINT_XFER_CONTROL) {
> +		int status = usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
> +				HUB_CLEAR_TT_BUFFER, USB_RT_PORT,
> +				devinfo ^ 0x8000, tt, NULL, 0, 1000);
> +		if (status)
> +			return status;
> +	}
>  	return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
>  			       HUB_CLEAR_TT_BUFFER, USB_RT_PORT, devinfo,
>  			       tt, NULL, 0, 1000);

Well, this won't hurt much.  And since it does seem to fix a hardware
problem,

Acked-by: Alan Stern <stern@rowland.harvard.edu>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-01 20:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-27 23:10 [PATCH] usb: Clear both buffers when clearing a control transfer TT buffer William Gulland
2013-06-28 13:54 ` Sergei Shtylyov
2013-06-28 15:56 ` Alan Stern
2013-07-01 20:41 ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).