public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable
@ 2016-03-18 12:33 Roger Quadros
  2016-03-18 12:33 ` [PATCH 1/5] usb: xhci: add quirk flag for broken PED bits Roger Quadros
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 12:33 UTC (permalink / raw)
  To: balbi, mathias.nyman; +Cc: nsekhar, linux-usb, linux-kernel, Roger Quadros

Hi,

Some devices from Texas Instruments suffer from
a silicon bug where XHCI Port Enabled/Disabled bit
should not be used to silence an erroneous device.
    
The bug is so that if port is disabled with PED
bit, an IRQ for device removal (or attachment)
will never fire.
    
Just for the sake of completeness, the actual
problem lies with SNPS DWC3 USB IP and this affects
all known versions up to 3.00a

We add a BROKEN_PE quirk in xhci.h to deal with this issue
and add a corresponding bit in xhci platform_data.

I've only updated Felipe's e-mail id in the patches
and re-based them to v4.5 + balbi/next.

--
cheers,
-roger

Felipe Balbi (5):
  usb: xhci: add quirk flag for broken PED bits
  usb: dwc3: core: define macros for newest revisions
  usb: host: xhci: add broken pe quirk flag to pdata
  usb: host: xhci-plat: enable BROKEN_PE quirk if platform requested
  usb: dwc3: host: pass BROKEN_PE flag for known broken revisions

 drivers/usb/dwc3/core.h          |  2 ++
 drivers/usb/dwc3/host.c          | 12 ++++++++++++
 drivers/usb/host/xhci-hub.c      |  6 ++++++
 drivers/usb/host/xhci-plat.c     |  3 +++
 drivers/usb/host/xhci.h          |  2 ++
 include/linux/usb/xhci_pdriver.h |  2 ++
 6 files changed, 27 insertions(+)

-- 
2.5.0

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

* [PATCH 1/5] usb: xhci: add quirk flag for broken PED bits
  2016-03-18 12:33 [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Roger Quadros
@ 2016-03-18 12:33 ` Roger Quadros
  2016-03-18 12:33 ` [PATCH 2/5] usb: dwc3: core: define macros for newest revisions Roger Quadros
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 12:33 UTC (permalink / raw)
  To: balbi, mathias.nyman; +Cc: nsekhar, linux-usb, linux-kernel, Roger Quadros

From: Felipe Balbi <balbi@kernel.org>

Some devices from Texas Instruments suffer from
a silicon bug where Port Enabled/Disabled bit
should not be used to silence an erroneous device.

The bug is so that if port is disabled with PED
bit, an IRQ for device removal (or attachment)
will never fire.

Just for the sake of completeness, the actual
problem lies with SNPS USB IP and this affects
all known versions up to 3.00a. A separate
patch will be added to dwc3 to enabled this
quirk flag if version is <= 3.00a.

Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/host/xhci-hub.c | 6 ++++++
 drivers/usb/host/xhci.h     | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index d61fcc4..1649a21 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -455,6 +455,12 @@ static void xhci_disable_port(struct usb_hcd *hcd, struct xhci_hcd *xhci,
 		return;
 	}
 
+	if (xhci->quirks & XHCI_BROKEN_PORT_PE) {
+		xhci_dbg(xhci, "Broken Port Enabled/Disabled, ignoring "
+				"port disable request.\n");
+		return;
+	}
+
 	/* Write 1 to disable the port */
 	writel(port_status | PORT_PE, addr);
 	port_status = readl(addr);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index e293e09..371a64f 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1641,6 +1641,8 @@ struct xhci_hcd {
 #define XHCI_PME_STUCK_QUIRK	(1 << 20)
 #define XHCI_MTK_HOST		(1 << 21)
 #define XHCI_SSIC_PORT_UNUSED	(1 << 22)
+/* For controller with a broken Port Disable implementation */
+#define XHCI_BROKEN_PORT_PE	(1 << 23)
 	unsigned int		num_active_eps;
 	unsigned int		limit_active_eps;
 	/* There are two roothubs to keep track of bus suspend info for */
-- 
2.5.0

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

* [PATCH 2/5] usb: dwc3: core: define macros for newest revisions
  2016-03-18 12:33 [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Roger Quadros
  2016-03-18 12:33 ` [PATCH 1/5] usb: xhci: add quirk flag for broken PED bits Roger Quadros
@ 2016-03-18 12:33 ` Roger Quadros
  2016-03-18 12:33 ` [PATCH 3/5] usb: host: xhci: add broken pe quirk flag to pdata Roger Quadros
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 12:33 UTC (permalink / raw)
  To: balbi, mathias.nyman; +Cc: nsekhar, linux-usb, linux-kernel, Roger Quadros

From: Felipe Balbi <balbi@kernel.org>

dwc3 has released two other versions (2.90a and 3.00a),
this patch just adds revision macros.

Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/dwc3/core.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 6254b2f..640ecde 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -812,6 +812,8 @@ struct dwc3 {
 #define DWC3_REVISION_260A	0x5533260a
 #define DWC3_REVISION_270A	0x5533270a
 #define DWC3_REVISION_280A	0x5533280a
+#define DWC3_REVISION_290A	0x5533290a
+#define DWC3_REVISION_300A	0x5533300a
 
 /*
  * NOTICE: we're using bit 31 as a "is usb 3.1" flag. This is really
-- 
2.5.0

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

* [PATCH 3/5] usb: host: xhci: add broken pe quirk flag to pdata
  2016-03-18 12:33 [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Roger Quadros
  2016-03-18 12:33 ` [PATCH 1/5] usb: xhci: add quirk flag for broken PED bits Roger Quadros
  2016-03-18 12:33 ` [PATCH 2/5] usb: dwc3: core: define macros for newest revisions Roger Quadros
@ 2016-03-18 12:33 ` Roger Quadros
  2016-03-18 12:33 ` [PATCH 4/5] usb: host: xhci-plat: enable BROKEN_PE quirk if platform requested Roger Quadros
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 12:33 UTC (permalink / raw)
  To: balbi, mathias.nyman; +Cc: nsekhar, linux-usb, linux-kernel, Roger Quadros

From: Felipe Balbi <balbi@kernel.org>

Let platform_data users pass broken pe flag to
xhci driver.

Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 include/linux/usb/xhci_pdriver.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h
index 376654b..81b15ea 100644
--- a/include/linux/usb/xhci_pdriver.h
+++ b/include/linux/usb/xhci_pdriver.h
@@ -18,10 +18,12 @@
  *
  * @usb3_lpm_capable:	determines if this xhci platform supports USB3
  *			LPM capability
+ * @quirk_port_broken_pe: If true, XHCI will not use Port Disable.
  *
  */
 struct usb_xhci_pdata {
 	unsigned	usb3_lpm_capable:1;
+	unsigned	quirk_port_broken_pe:1;
 };
 
 #endif /* __USB_CORE_XHCI_PDRIVER_H */
-- 
2.5.0

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

* [PATCH 4/5] usb: host: xhci-plat: enable BROKEN_PE quirk if platform requested
  2016-03-18 12:33 [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Roger Quadros
                   ` (2 preceding siblings ...)
  2016-03-18 12:33 ` [PATCH 3/5] usb: host: xhci: add broken pe quirk flag to pdata Roger Quadros
@ 2016-03-18 12:33 ` Roger Quadros
  2016-03-18 12:33 ` [PATCH 5/5] usb: dwc3: host: pass BROKEN_PE flag for known broken revisions Roger Quadros
  2016-03-18 13:07 ` [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Felipe Balbi
  5 siblings, 0 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 12:33 UTC (permalink / raw)
  To: balbi, mathias.nyman; +Cc: nsekhar, linux-usb, linux-kernel, Roger Quadros

From: Felipe Balbi <balbi@kernel.org>

In case a broken pe flag is passed in via pdata,
we should enable the corresponding BROKEN_PE quirk
flag for XHCI core.

Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/host/xhci-plat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d39d6bf..637d1ae 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -209,6 +209,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
 			(pdata && pdata->usb3_lpm_capable))
 		xhci->quirks |= XHCI_LPM_SUPPORT;
 
+	if (pdata && pdata->quirk_port_broken_pe)
+		xhci->quirks |= XHCI_BROKEN_PORT_PE;
+
 	if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
 		xhci->shared_hcd->can_do_streams = 1;
 
-- 
2.5.0

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

* [PATCH 5/5] usb: dwc3: host: pass BROKEN_PE flag for known broken revisions
  2016-03-18 12:33 [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Roger Quadros
                   ` (3 preceding siblings ...)
  2016-03-18 12:33 ` [PATCH 4/5] usb: host: xhci-plat: enable BROKEN_PE quirk if platform requested Roger Quadros
@ 2016-03-18 12:33 ` Roger Quadros
  2016-03-18 13:07 ` [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Felipe Balbi
  5 siblings, 0 replies; 7+ messages in thread
From: Roger Quadros @ 2016-03-18 12:33 UTC (permalink / raw)
  To: balbi, mathias.nyman; +Cc: nsekhar, linux-usb, linux-kernel, Roger Quadros

From: Felipe Balbi <balbi@kernel.org>

Now that we have a broken pe quirk flag, dwc3
can tell XHCI core about it.

Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/usb/dwc3/host.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index c679f63..db9347b 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -51,6 +51,18 @@ int dwc3_host_init(struct dwc3 *dwc)
 
 	pdata.usb3_lpm_capable = dwc->usb3_lpm_capable;
 
+	/**
+	 * WORKAROUND: dwc3 revisions <=3.00a have a limitation
+	 * where Port Disable command doesn't work.
+	 *
+	 * The suggested workaround is that we avoid Port Disable
+	 * completely.
+	 *
+	 * This following flag tells XHCI to do just that.
+	 */
+	if (dwc->revision <= DWC3_REVISION_300A)
+		pdata.quirk_port_broken_pe = true;
+
 	ret = platform_device_add_data(xhci, &pdata, sizeof(pdata));
 	if (ret) {
 		dev_err(dwc->dev, "couldn't add platform data to xHCI device\n");
-- 
2.5.0

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

* Re: [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable
  2016-03-18 12:33 [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Roger Quadros
                   ` (4 preceding siblings ...)
  2016-03-18 12:33 ` [PATCH 5/5] usb: dwc3: host: pass BROKEN_PE flag for known broken revisions Roger Quadros
@ 2016-03-18 13:07 ` Felipe Balbi
  5 siblings, 0 replies; 7+ messages in thread
From: Felipe Balbi @ 2016-03-18 13:07 UTC (permalink / raw)
  To: Roger Quadros, mathias.nyman
  Cc: nsekhar, linux-usb, linux-kernel, Roger Quadros

[-- Attachment #1: Type: text/plain, Size: 1171 bytes --]


Mathias,

Roger Quadros <rogerq@ti.com> writes:
> Some devices from Texas Instruments suffer from
> a silicon bug where XHCI Port Enabled/Disabled bit
> should not be used to silence an erroneous device.
>     
> The bug is so that if port is disabled with PED
> bit, an IRQ for device removal (or attachment)
> will never fire.
>     
> Just for the sake of completeness, the actual
> problem lies with SNPS DWC3 USB IP and this affects
> all known versions up to 3.00a
>
> We add a BROKEN_PE quirk in xhci.h to deal with this issue
> and add a corresponding bit in xhci platform_data.
>
> I've only updated Felipe's e-mail id in the patches
> and re-based them to v4.5 + balbi/next.
>
> --
> cheers,
> -roger
>
> Felipe Balbi (5):
>   usb: xhci: add quirk flag for broken PED bits
>   usb: dwc3: core: define macros for newest revisions
>   usb: host: xhci: add broken pe quirk flag to pdata
>   usb: host: xhci-plat: enable BROKEN_PE quirk if platform requested
>   usb: dwc3: host: pass BROKEN_PE flag for known broken revisions

this series has changes on both dwc3 and xhci. Let me know how you wanna
handle these.

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

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

end of thread, other threads:[~2016-03-18 13:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-18 12:33 [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Roger Quadros
2016-03-18 12:33 ` [PATCH 1/5] usb: xhci: add quirk flag for broken PED bits Roger Quadros
2016-03-18 12:33 ` [PATCH 2/5] usb: dwc3: core: define macros for newest revisions Roger Quadros
2016-03-18 12:33 ` [PATCH 3/5] usb: host: xhci: add broken pe quirk flag to pdata Roger Quadros
2016-03-18 12:33 ` [PATCH 4/5] usb: host: xhci-plat: enable BROKEN_PE quirk if platform requested Roger Quadros
2016-03-18 12:33 ` [PATCH 5/5] usb: dwc3: host: pass BROKEN_PE flag for known broken revisions Roger Quadros
2016-03-18 13:07 ` [PATCH 0/5] usb: dwc3: xhci: Add quirk for defective Port Enable/disable Felipe Balbi

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