* [PATCH] EHCI: Update qTD next pointer in QH overlay region during unlink
[not found] <504969C9.2070209@codeaurora.org>
@ 2012-09-07 5:53 ` Pavankumar Kondeti
2012-09-07 15:52 ` Alan Stern
0 siblings, 1 reply; 4+ messages in thread
From: Pavankumar Kondeti @ 2012-09-07 5:53 UTC (permalink / raw)
To: stern, gregkh, linux-usb; +Cc: linux-arm-msm, Pavankumar Kondeti
There is a possibility of QH overlay region having reference to a stale
qTD pointer during unlink.
Consider an endpoint having two pending qTD before unlink process begins.
The endpoint's QH queue looks like this.
qTD1 --> qTD2 --> Dummy
To unlink qTD2, QH is removed from asynchronous list and Asynchronous
Advance Doorbell is programmed. The qTD1's next qTD pointer is set to
qTD2'2 next qTD pointer and qTD2 is retired upon controller's doorbell
interrupt. If QH's current qTD pointer points to qTD1, transfer overlay
region still have reference to qTD2. But qtD2 is just unlinked and freed.
This may cause EHCI system error. Fix this by updating qTD next pointer
in QH overlay region with the qTD next pointer of the current qTD.
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
---
drivers/usb/host/ehci-q.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 9bc39ca..4b66374 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -128,9 +128,17 @@ qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
else {
qtd = list_entry (qh->qtd_list.next,
struct ehci_qtd, qtd_list);
- /* first qtd may already be partially processed */
- if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current)
+ /*
+ * first qtd may already be partially processed.
+ * If we come here during unlink, the QH overlay region
+ * might have reference to the just unlinked qtd. The
+ * qtd is updated in qh_completions(). Update the QH
+ * overlay here.
+ */
+ if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current) {
+ qh->hw->hw_qtd_next = qtd->hw_next;
qtd = NULL;
+ }
}
if (qtd)
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation.
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] EHCI: Update qTD next pointer in QH overlay region during unlink
2012-09-07 5:53 ` [PATCH] EHCI: Update qTD next pointer in QH overlay region during unlink Pavankumar Kondeti
@ 2012-09-07 15:52 ` Alan Stern
2012-09-07 15:58 ` Pavan Kondeti
[not found] ` <Pine.LNX.4.44L0.1209071151130.1674-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
0 siblings, 2 replies; 4+ messages in thread
From: Alan Stern @ 2012-09-07 15:52 UTC (permalink / raw)
To: Pavankumar Kondeti; +Cc: gregkh, linux-usb, linux-arm-msm
On Fri, 7 Sep 2012, Pavankumar Kondeti wrote:
> There is a possibility of QH overlay region having reference to a stale
> qTD pointer during unlink.
>
> Consider an endpoint having two pending qTD before unlink process begins.
> The endpoint's QH queue looks like this.
>
> qTD1 --> qTD2 --> Dummy
>
> To unlink qTD2, QH is removed from asynchronous list and Asynchronous
> Advance Doorbell is programmed. The qTD1's next qTD pointer is set to
> qTD2'2 next qTD pointer and qTD2 is retired upon controller's doorbell
> interrupt. If QH's current qTD pointer points to qTD1, transfer overlay
> region still have reference to qTD2. But qtD2 is just unlinked and freed.
> This may cause EHCI system error. Fix this by updating qTD next pointer
> in QH overlay region with the qTD next pointer of the current qTD.
>
> Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
> ---
> drivers/usb/host/ehci-q.c | 12 ++++++++++--
> 1 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
> index 9bc39ca..4b66374 100644
> --- a/drivers/usb/host/ehci-q.c
> +++ b/drivers/usb/host/ehci-q.c
> @@ -128,9 +128,17 @@ qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
> else {
> qtd = list_entry (qh->qtd_list.next,
> struct ehci_qtd, qtd_list);
> - /* first qtd may already be partially processed */
> - if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current)
> + /*
> + * first qtd may already be partially processed.
> + * If we come here during unlink, the QH overlay region
> + * might have reference to the just unlinked qtd. The
> + * qtd is updated in qh_completions(). Update the QH
> + * overlay here.
> + */
> + if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current) {
> + qh->hw->hw_qtd_next = qtd->hw_next;
> qtd = NULL;
> + }
> }
>
> if (qtd)
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Have you been able to determine that this eliminates your host system
errors?
Alan Stern
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] EHCI: Update qTD next pointer in QH overlay region during unlink
2012-09-07 15:52 ` Alan Stern
@ 2012-09-07 15:58 ` Pavan Kondeti
[not found] ` <Pine.LNX.4.44L0.1209071151130.1674-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
1 sibling, 0 replies; 4+ messages in thread
From: Pavan Kondeti @ 2012-09-07 15:58 UTC (permalink / raw)
To: Alan Stern; +Cc: gregkh, linux-usb, linux-arm-msm
On 9/7/2012 9:22 PM, Alan Stern wrote:
> On Fri, 7 Sep 2012, Pavankumar Kondeti wrote:
>
>> There is a possibility of QH overlay region having reference to a stale
>> qTD pointer during unlink.
>>
>> Consider an endpoint having two pending qTD before unlink process begins.
>> The endpoint's QH queue looks like this.
>>
>> qTD1 --> qTD2 --> Dummy
>>
>> To unlink qTD2, QH is removed from asynchronous list and Asynchronous
>> Advance Doorbell is programmed. The qTD1's next qTD pointer is set to
>> qTD2'2 next qTD pointer and qTD2 is retired upon controller's doorbell
>> interrupt. If QH's current qTD pointer points to qTD1, transfer overlay
>> region still have reference to qTD2. But qtD2 is just unlinked and freed.
>> This may cause EHCI system error. Fix this by updating qTD next pointer
>> in QH overlay region with the qTD next pointer of the current qTD.
>>
>> Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
>> ---
>> drivers/usb/host/ehci-q.c | 12 ++++++++++--
>> 1 files changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
>> index 9bc39ca..4b66374 100644
>> --- a/drivers/usb/host/ehci-q.c
>> +++ b/drivers/usb/host/ehci-q.c
>> @@ -128,9 +128,17 @@ qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
>> else {
>> qtd = list_entry (qh->qtd_list.next,
>> struct ehci_qtd, qtd_list);
>> - /* first qtd may already be partially processed */
>> - if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current)
>> + /*
>> + * first qtd may already be partially processed.
>> + * If we come here during unlink, the QH overlay region
>> + * might have reference to the just unlinked qtd. The
>> + * qtd is updated in qh_completions(). Update the QH
>> + * overlay here.
>> + */
>> + if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current) {
>> + qh->hw->hw_qtd_next = qtd->hw_next;
>> qtd = NULL;
>> + }
>> }
>>
>> if (qtd)
>
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
>
Thanks Alan for reviewing the patch.
> Have you been able to determine that this eliminates your host system
> errors?
Yes. We are able to determine that this patch is fixing the EHCI system
error.
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] EHCI: Update qTD next pointer in QH overlay region during unlink
[not found] ` <Pine.LNX.4.44L0.1209071151130.1674-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
@ 2012-09-07 16:16 ` Alan Stern
0 siblings, 0 replies; 4+ messages in thread
From: Alan Stern @ 2012-09-07 16:16 UTC (permalink / raw)
To: Pavankumar Kondeti
Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA
On Fri, 7 Sep 2012, Alan Stern wrote:
> On Fri, 7 Sep 2012, Pavankumar Kondeti wrote:
>
> > There is a possibility of QH overlay region having reference to a stale
> > qTD pointer during unlink.
> >
> > Consider an endpoint having two pending qTD before unlink process begins.
> > The endpoint's QH queue looks like this.
> >
> > qTD1 --> qTD2 --> Dummy
> >
> > To unlink qTD2, QH is removed from asynchronous list and Asynchronous
> > Advance Doorbell is programmed. The qTD1's next qTD pointer is set to
> > qTD2'2 next qTD pointer and qTD2 is retired upon controller's doorbell
> > interrupt. If QH's current qTD pointer points to qTD1, transfer overlay
> > region still have reference to qTD2. But qtD2 is just unlinked and freed.
> > This may cause EHCI system error. Fix this by updating qTD next pointer
> > in QH overlay region with the qTD next pointer of the current qTD.
> >
> > Signed-off-by: Pavankumar Kondeti <pkondeti-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
> > ---
> > drivers/usb/host/ehci-q.c | 12 ++++++++++--
> > 1 files changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
> > index 9bc39ca..4b66374 100644
> > --- a/drivers/usb/host/ehci-q.c
> > +++ b/drivers/usb/host/ehci-q.c
> > @@ -128,9 +128,17 @@ qh_refresh (struct ehci_hcd *ehci, struct ehci_qh *qh)
> > else {
> > qtd = list_entry (qh->qtd_list.next,
> > struct ehci_qtd, qtd_list);
> > - /* first qtd may already be partially processed */
> > - if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current)
> > + /*
> > + * first qtd may already be partially processed.
> > + * If we come here during unlink, the QH overlay region
> > + * might have reference to the just unlinked qtd. The
> > + * qtd is updated in qh_completions(). Update the QH
> > + * overlay here.
> > + */
> > + if (cpu_to_hc32(ehci, qtd->qtd_dma) == qh->hw->hw_current) {
> > + qh->hw->hw_qtd_next = qtd->hw_next;
> > qtd = NULL;
> > + }
> > }
> >
> > if (qtd)
>
> Acked-by: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
I forgot to mention: This patch should be included in the next 3.6-rc
release and marked for -stable.
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-07 16:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <504969C9.2070209@codeaurora.org>
2012-09-07 5:53 ` [PATCH] EHCI: Update qTD next pointer in QH overlay region during unlink Pavankumar Kondeti
2012-09-07 15:52 ` Alan Stern
2012-09-07 15:58 ` Pavan Kondeti
[not found] ` <Pine.LNX.4.44L0.1209071151130.1674-100000-IYeN2dnnYyZXsRXLowluHWD2FQJk+8+b@public.gmane.org>
2012-09-07 16:16 ` Alan Stern
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.