public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: dwc2: hcd: fix periodic transfer schedule sequence
@ 2015-11-16 15:25 Yunzhi Li
  2015-11-16 18:27 ` Doug Anderson
  2015-11-16 22:41 ` Caesar Wang
  0 siblings, 2 replies; 4+ messages in thread
From: Yunzhi Li @ 2015-11-16 15:25 UTC (permalink / raw)
  To: John.Youn, dianders, jwerner, linux-usb, linux-kernel, wulf,
	kever.yang, frank.wang, huangtao, caesar.wang
  Cc: Yunzhi Li

When checking dwc2 host channel interrupts, handle qh in
periodic_sched_queued list at first, then we could make sure CSPLIT
packets scheduled in the same order as SSPLIT packets.

Signed-off-by: Yunzhi Li <lyz@rock-chips.com>
---
 drivers/usb/dwc2/hcd_intr.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
index bda0b21..e8e8970 100644
--- a/drivers/usb/dwc2/hcd_intr.c
+++ b/drivers/usb/dwc2/hcd_intr.c
@@ -2115,6 +2115,8 @@ static void dwc2_hc_intr(struct dwc2_hsotg *hsotg)
 {
 	u32 haint;
 	int i;
+	int hc_num;
+	struct dwc2_qh *qh, *qh_tmp;
 
 	haint = dwc2_readl(hsotg->regs + HAINT);
 	if (dbg_perio()) {
@@ -2123,6 +2125,26 @@ static void dwc2_hc_intr(struct dwc2_hsotg *hsotg)
 		dev_vdbg(hsotg->dev, "HAINT=%08x\n", haint);
 	}
 
+	/*
+	 * According to USB 2.0 spec section 11.18.8, a host must
+	 * issue complete-split transactions in a microframe for a
+	 * set of full-/low-speed endpoints in the same relative
+	 * order as the start-splits were issued in a microframe for.
+	 * So here we should at first picking up host channels
+	 * from periodic_sched_queued list and checking if there is
+	 * any start-split have already finished then schedule
+	 * complete-split in the same order.
+	 */
+	list_for_each_entry_safe(qh, qh_tmp,
+				 &hsotg->periodic_sched_queued,
+				 qh_list_entry) {
+		hc_num = qh->channel->hc_num;
+		if (haint & (1 << hc_num)) {
+			dwc2_hc_n_intr(hsotg, hc_num);
+			haint &= ~(1 << hc_num);
+		}
+	}
+
 	for (i = 0; i < hsotg->core_params->host_channels; i++) {
 		if (haint & (1 << i))
 			dwc2_hc_n_intr(hsotg, i);
-- 
1.9.1



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

* Re: [PATCH] usb: dwc2: hcd: fix periodic transfer schedule sequence
  2015-11-16 15:25 [PATCH] usb: dwc2: hcd: fix periodic transfer schedule sequence Yunzhi Li
@ 2015-11-16 18:27 ` Doug Anderson
  2015-11-16 22:41 ` Caesar Wang
  1 sibling, 0 replies; 4+ messages in thread
From: Doug Anderson @ 2015-11-16 18:27 UTC (permalink / raw)
  To: Yunzhi Li
  Cc: John Youn, Julius Werner, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, wulf, Kever Yang, frank.wang,
	Tao Huang, caesar

Yunzhi

On Mon, Nov 16, 2015 at 7:25 AM, Yunzhi Li <lyz@rock-chips.com> wrote:
> When checking dwc2 host channel interrupts, handle qh in
> periodic_sched_queued list at first, then we could make sure CSPLIT
> packets scheduled in the same order as SSPLIT packets.
>
> Signed-off-by: Yunzhi Li <lyz@rock-chips.com>
> ---
>  drivers/usb/dwc2/hcd_intr.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)

This seems like a very reasonable fix to me.  I also bought the same
keyboard you were debugging with (The Das Keyboard 4 Ultimate Clicky)
and confirmed that problems are fixed by this patch on the
rk3288-based veyron-jerry sitting on my desk.


Reviewed-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>

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

* Re: [PATCH] usb: dwc2: hcd: fix periodic transfer schedule sequence
  2015-11-16 15:25 [PATCH] usb: dwc2: hcd: fix periodic transfer schedule sequence Yunzhi Li
  2015-11-16 18:27 ` Doug Anderson
@ 2015-11-16 22:41 ` Caesar Wang
  2016-01-21  0:23   ` Doug Anderson
  1 sibling, 1 reply; 4+ messages in thread
From: Caesar Wang @ 2015-11-16 22:41 UTC (permalink / raw)
  To: Yunzhi Li
  Cc: John.Youn, dianders, jwerner, linux-usb, linux-kernel, wulf,
	kever.yang, frank.wang, huangtao

Hi,

在 2015年11月16日 23:25, Yunzhi Li 写道:
> When checking dwc2 host channel interrupts, handle qh in
> periodic_sched_queued list at first, then we could make sure CSPLIT
> packets scheduled in the same order as SSPLIT packets.
>
> Signed-off-by: Yunzhi Li <lyz@rock-chips.com>

This patch can fix some usb issues on my hand machine.

Says:
(1) The usb hub can't normal work (KB, mouse ...) when SB 
headset/Speaker is connected to USB2.0 travel HUB.
(2)  The music have the wonder noise when we are use some usb speak.
......

So, you can free add my test tag:

Tested-by: Caesar Wang <wxt@rock-chips.com>

> ---
>   drivers/usb/dwc2/hcd_intr.c | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)
>
> diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
> index bda0b21..e8e8970 100644
> --- a/drivers/usb/dwc2/hcd_intr.c
> +++ b/drivers/usb/dwc2/hcd_intr.c
> @@ -2115,6 +2115,8 @@ static void dwc2_hc_intr(struct dwc2_hsotg *hsotg)
>   {
>   	u32 haint;
>   	int i;
> +	int hc_num;
> +	struct dwc2_qh *qh, *qh_tmp;
>   
>   	haint = dwc2_readl(hsotg->regs + HAINT);
>   	if (dbg_perio()) {
> @@ -2123,6 +2125,26 @@ static void dwc2_hc_intr(struct dwc2_hsotg *hsotg)
>   		dev_vdbg(hsotg->dev, "HAINT=%08x\n", haint);
>   	}
>   
> +	/*
> +	 * According to USB 2.0 spec section 11.18.8, a host must
> +	 * issue complete-split transactions in a microframe for a
> +	 * set of full-/low-speed endpoints in the same relative
> +	 * order as the start-splits were issued in a microframe for.
> +	 * So here we should at first picking up host channels
> +	 * from periodic_sched_queued list and checking if there is
> +	 * any start-split have already finished then schedule
> +	 * complete-split in the same order.
> +	 */
> +	list_for_each_entry_safe(qh, qh_tmp,
> +				 &hsotg->periodic_sched_queued,
> +				 qh_list_entry) {
> +		hc_num = qh->channel->hc_num;
> +		if (haint & (1 << hc_num)) {
> +			dwc2_hc_n_intr(hsotg, hc_num);
> +			haint &= ~(1 << hc_num);
> +		}
> +	}
> +
>   	for (i = 0; i < hsotg->core_params->host_channels; i++) {
>   		if (haint & (1 << i))
>   			dwc2_hc_n_intr(hsotg, i);

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

* Re: [PATCH] usb: dwc2: hcd: fix periodic transfer schedule sequence
  2015-11-16 22:41 ` Caesar Wang
@ 2016-01-21  0:23   ` Doug Anderson
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Anderson @ 2016-01-21  0:23 UTC (permalink / raw)
  To: John Youn
  Cc: Julius Werner, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, wulf, Kever Yang, frank.wang,
	Tao Huang, Caesar Wang

John,

On Mon, Nov 16, 2015 at 2:41 PM, Caesar Wang <caesar.upstream@gmail.com> wrote:
> Hi,
>
> 在 2015年11月16日 23:25, Yunzhi Li 写道:
>>
>> When checking dwc2 host channel interrupts, handle qh in
>> periodic_sched_queued list at first, then we could make sure CSPLIT
>> packets scheduled in the same order as SSPLIT packets.
>>
>> Signed-off-by: Yunzhi Li <lyz@rock-chips.com>
>
>
> This patch can fix some usb issues on my hand machine.
>
> Says:
> (1) The usb hub can't normal work (KB, mouse ...) when SB headset/Speaker is
> connected to USB2.0 travel HUB.
> (2)  The music have the wonder noise when we are use some usb speak.
> ......
>
> So, you can free add my test tag:
>
> Tested-by: Caesar Wang <wxt@rock-chips.com>
>
>
>> ---
>>   drivers/usb/dwc2/hcd_intr.c | 22 ++++++++++++++++++++++
>>   1 file changed, 22 insertions(+)

Just FYI that I'm planning to send up a new version of this patch.
Though we've been carrying it in our Chrome OS tree and it's been
helping, in my reboot tests I did just find a crash right in the code
that this patch is adding.  Apparently "qh->channel" is NULL in at
least some case in the loop.  This seems like something that could
have happened if dwc2_deactivate_qh() was called and then we got an
interrupt after.

I also realized that it's probably important to get order right even
for non-periodic splits.  lyz's patch only handled periodic splits...


-Doug

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

end of thread, other threads:[~2016-01-21  0:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-16 15:25 [PATCH] usb: dwc2: hcd: fix periodic transfer schedule sequence Yunzhi Li
2015-11-16 18:27 ` Doug Anderson
2015-11-16 22:41 ` Caesar Wang
2016-01-21  0:23   ` Doug Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox