linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] xhci fixes for usb-linus
@ 2019-05-22 11:33 Mathias Nyman
  0 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2019-05-22 11:33 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

A few fixes for usb-linus, including regression fix for xhci IDT support
which was added to 5.2-rc1

-Mathias

Andrey Smirnov (1):
  xhci: Convert xhci_handshake() to use readl_poll_timeout_atomic()

Carsten Schmid (1):
  usb: xhci: avoid null pointer deref when bos field is NULL

Henry Lin (1):
  xhci: update bounce buffer with correct sg num

Jia-Ju Bai (1):
  usb: xhci: Fix a potential null pointer dereference in
    xhci_debugfs_create_endpoint()

Mathias Nyman (1):
  xhci: Fix immediate data transfer if buffer is already DMA mapped

 drivers/usb/host/xhci-debugfs.c |  3 +++
 drivers/usb/host/xhci-ring.c    | 26 +++++++++++++++++++-------
 drivers/usb/host/xhci.c         | 24 +++++++++++-------------
 drivers/usb/host/xhci.h         |  3 ++-
 4 files changed, 35 insertions(+), 21 deletions(-)

-- 
2.7.4


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

* [PATCH 0/5] xhci fixes for usb-linus
@ 2020-06-24 13:59 Mathias Nyman
  2020-06-24 13:59 ` [PATCH 1/5] xhci: Fix incorrect EP_STATE_MASK Mathias Nyman
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Mathias Nyman @ 2020-06-24 13:59 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

A few xhci fixes for usb-linus that resolve a couple power management
related issues, and a full-speed USB device enumeration problem.

-Mathias

Al Cooper (1):
  xhci: Fix enumeration issue when setting max packet size for FS
    devices.

Kai-Heng Feng (2):
  xhci: Return if xHCI doesn't support LPM
  xhci: Poll for U0 after disabling USB2 LPM

Macpaul Lin (1):
  usb: host: xhci-mtk: avoid runtime suspend when removing hcd

Mathias Nyman (1):
  xhci: Fix incorrect EP_STATE_MASK

 drivers/usb/host/xhci-mtk.c | 5 +++--
 drivers/usb/host/xhci.c     | 9 ++++++++-
 drivers/usb/host/xhci.h     | 2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)

-- 
2.17.1


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

* [PATCH 1/5] xhci: Fix incorrect EP_STATE_MASK
  2020-06-24 13:59 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
@ 2020-06-24 13:59 ` Mathias Nyman
  2020-06-24 13:59 ` [PATCH 2/5] xhci: Fix enumeration issue when setting max packet size for FS devices Mathias Nyman
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2020-06-24 13:59 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman, stable

EP_STATE_MASK should be 0x7 instead of 0xf

xhci spec 6.2.3 shows that the EP state field in the endpoint context data
structure consist of bits [2:0].
The old value included a bit from the next field which fortunately is a
 RsvdZ region. So hopefully this hasn't caused too much harm

Cc: stable@vger.kernel.org
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 2c6c4f8d1ee1..c295e8a7f5ae 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -716,7 +716,7 @@ struct xhci_ep_ctx {
  * 4 - TRB error
  * 5-7 - reserved
  */
-#define EP_STATE_MASK		(0xf)
+#define EP_STATE_MASK		(0x7)
 #define EP_STATE_DISABLED	0
 #define EP_STATE_RUNNING	1
 #define EP_STATE_HALTED		2
-- 
2.17.1


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

* [PATCH 2/5] xhci: Fix enumeration issue when setting max packet size for FS devices.
  2020-06-24 13:59 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
  2020-06-24 13:59 ` [PATCH 1/5] xhci: Fix incorrect EP_STATE_MASK Mathias Nyman
@ 2020-06-24 13:59 ` Mathias Nyman
  2020-06-24 13:59 ` [PATCH 3/5] usb: host: xhci-mtk: avoid runtime suspend when removing hcd Mathias Nyman
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2020-06-24 13:59 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Al Cooper, stable, Mathias Nyman

From: Al Cooper <alcooperx@gmail.com>

Unable to complete the enumeration of a USB TV Tuner device.

Per XHCI spec (4.6.5), the EP state field of the input context shall
be cleared for a set address command. In the special case of an FS
device that has "MaxPacketSize0 = 8", the Linux XHCI driver does
not do this before evaluating the context. With an XHCI controller
that checks the EP state field for parameter context error this
causes a problem in cases such as the device getting reset again
after enumeration.

When that field is cleared, the problem does not occur.

This was found and fixed by Sasi Kumar.

Cc: stable@vger.kernel.org
Signed-off-by: Al Cooper <alcooperx@gmail.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index bee5deccc83d..03b64b73eb99 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -1430,6 +1430,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
 				xhci->devs[slot_id]->out_ctx, ep_index);
 
 		ep_ctx = xhci_get_ep_ctx(xhci, command->in_ctx, ep_index);
+		ep_ctx->ep_info &= cpu_to_le32(~EP_STATE_MASK);/* must clear */
 		ep_ctx->ep_info2 &= cpu_to_le32(~MAX_PACKET_MASK);
 		ep_ctx->ep_info2 |= cpu_to_le32(MAX_PACKET(max_packet_size));
 
-- 
2.17.1


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

* [PATCH 3/5] usb: host: xhci-mtk: avoid runtime suspend when removing hcd
  2020-06-24 13:59 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
  2020-06-24 13:59 ` [PATCH 1/5] xhci: Fix incorrect EP_STATE_MASK Mathias Nyman
  2020-06-24 13:59 ` [PATCH 2/5] xhci: Fix enumeration issue when setting max packet size for FS devices Mathias Nyman
@ 2020-06-24 13:59 ` Mathias Nyman
  2020-06-24 13:59 ` [PATCH 4/5] xhci: Return if xHCI doesn't support LPM Mathias Nyman
  2020-06-24 13:59 ` [PATCH 5/5] xhci: Poll for U0 after disabling USB2 LPM Mathias Nyman
  4 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2020-06-24 13:59 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Macpaul Lin, stable, Mathias Nyman

From: Macpaul Lin <macpaul.lin@mediatek.com>

When runtime suspend was enabled, runtime suspend might happen
when xhci is removing hcd. This might cause kernel panic when hcd
has been freed but runtime pm suspend related handle need to
reference it.

Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
Reviewed-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci-mtk.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index bfbdb3ceed29..4311d4c9b68d 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -587,6 +587,9 @@ static int xhci_mtk_remove(struct platform_device *dev)
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	struct usb_hcd  *shared_hcd = xhci->shared_hcd;
 
+	pm_runtime_put_noidle(&dev->dev);
+	pm_runtime_disable(&dev->dev);
+
 	usb_remove_hcd(shared_hcd);
 	xhci->shared_hcd = NULL;
 	device_init_wakeup(&dev->dev, false);
@@ -597,8 +600,6 @@ static int xhci_mtk_remove(struct platform_device *dev)
 	xhci_mtk_sch_exit(mtk);
 	xhci_mtk_clks_disable(mtk);
 	xhci_mtk_ldos_disable(mtk);
-	pm_runtime_put_sync(&dev->dev);
-	pm_runtime_disable(&dev->dev);
 
 	return 0;
 }
-- 
2.17.1


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

* [PATCH 4/5] xhci: Return if xHCI doesn't support LPM
  2020-06-24 13:59 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
                   ` (2 preceding siblings ...)
  2020-06-24 13:59 ` [PATCH 3/5] usb: host: xhci-mtk: avoid runtime suspend when removing hcd Mathias Nyman
@ 2020-06-24 13:59 ` Mathias Nyman
  2020-06-24 13:59 ` [PATCH 5/5] xhci: Poll for U0 after disabling USB2 LPM Mathias Nyman
  4 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2020-06-24 13:59 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Kai-Heng Feng, stable, Mathias Nyman

From: Kai-Heng Feng <kai.heng.feng@canonical.com>

Just return if xHCI is quirked to disable LPM. We can save some time
from reading registers and doing spinlocks.

Add stable tag as we want this patch together with the next one,
"Poll for U0 after disabling USB2 LPM" which fixes a suspend issue
for some USB2 LPM devices

Cc: stable@vger.kernel.org
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 03b64b73eb99..f97106e2860f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4391,6 +4391,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
 	int		hird, exit_latency;
 	int		ret;
 
+	if (xhci->quirks & XHCI_HW_LPM_DISABLE)
+		return -EPERM;
+
 	if (hcd->speed >= HCD_USB3 || !xhci->hw_lpm_support ||
 			!udev->lpm_capable)
 		return -EPERM;
@@ -4413,7 +4416,7 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
 	xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n",
 			enable ? "enable" : "disable", port_num + 1);
 
-	if (enable && !(xhci->quirks & XHCI_HW_LPM_DISABLE)) {
+	if (enable) {
 		/* Host supports BESL timeout instead of HIRD */
 		if (udev->usb2_hw_lpm_besl_capable) {
 			/* if device doesn't have a preferred BESL value use a
-- 
2.17.1


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

* [PATCH 5/5] xhci: Poll for U0 after disabling USB2 LPM
  2020-06-24 13:59 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
                   ` (3 preceding siblings ...)
  2020-06-24 13:59 ` [PATCH 4/5] xhci: Return if xHCI doesn't support LPM Mathias Nyman
@ 2020-06-24 13:59 ` Mathias Nyman
  4 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2020-06-24 13:59 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Kai-Heng Feng, stable, Mathias Nyman

From: Kai-Heng Feng <kai.heng.feng@canonical.com>

USB2 devices with LPM enabled may interrupt the system suspend:
[  932.510475] usb 1-7: usb suspend, wakeup 0
[  932.510549] hub 1-0:1.0: hub_suspend
[  932.510581] usb usb1: bus suspend, wakeup 0
[  932.510590] xhci_hcd 0000:00:14.0: port 9 not suspended
[  932.510593] xhci_hcd 0000:00:14.0: port 8 not suspended
..
[  932.520323] xhci_hcd 0000:00:14.0: Port change event, 1-7, id 7, portsc: 0x400e03
..
[  932.591405] PM: pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16
[  932.591414] PM: dpm_run_callback(): pci_pm_suspend+0x0/0x160 returns -16
[  932.591418] PM: Device 0000:00:14.0 failed to suspend async: error -16

During system suspend, USB core will let HC suspends the device if it
doesn't have remote wakeup enabled and doesn't have any children.
However, from the log above we can see that the usb 1-7 doesn't get bus
suspended due to not in U0. After a while the port finished U2 -> U0
transition, interrupts the suspend process.

The observation is that after disabling LPM, port doesn't transit to U0
immediately and can linger in U2. xHCI spec 4.23.5.2 states that the
maximum exit latency for USB2 LPM should be BESL + 10us. The BESL for
the affected device is advertised as 400us, which is still not enough
based on my testing result.

So let's use the maximum permitted latency, 10000, to poll for U0
status to solve the issue.

Cc: stable@vger.kernel.org
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index f97106e2860f..ed468eed299c 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4475,6 +4475,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
 			mutex_lock(hcd->bandwidth_mutex);
 			xhci_change_max_exit_latency(xhci, udev, 0);
 			mutex_unlock(hcd->bandwidth_mutex);
+			readl_poll_timeout(ports[port_num]->addr, pm_val,
+					   (pm_val & PORT_PLS_MASK) == XDEV_U0,
+					   100, 10000);
 			return 0;
 		}
 	}
-- 
2.17.1


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

* [PATCH 0/5] xhci fixes for usb-linus
@ 2021-05-12  8:08 Mathias Nyman
  0 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2021-05-12  8:08 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

A few small xHCI fixes for usb-linus 5.13-rc.

Thanks
-Mathias


Abhijeet Rao (1):
  xhci-pci: Allow host runtime PM as default for Intel Alder Lake xHCI

Christophe JAILLET (1):
  xhci: Do not use GFP_KERNEL in (potentially) atomic context

Mathias Nyman (1):
  xhci: Fix giving back cancelled URBs even if halted endpoint can't
    reset

Maximilian Luz (1):
  usb: xhci: Increase timeout for HC halt

Sandeep Singh (1):
  xhci: Add reset resume quirk for AMD xhci controller.

 drivers/usb/host/xhci-ext-caps.h |  5 +++--
 drivers/usb/host/xhci-pci.c      |  8 ++++++--
 drivers/usb/host/xhci-ring.c     | 16 +++++++++++-----
 drivers/usb/host/xhci.c          |  6 +++---
 4 files changed, 23 insertions(+), 12 deletions(-)

-- 
2.25.1


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

* [PATCH 0/5] xhci fixes for usb-linus
@ 2021-10-08  9:25 Mathias Nyman
  2021-10-08 16:13 ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Mathias Nyman @ 2021-10-08  9:25 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

A few xhci fixes for 5.15-rc.
A couple races fixed, and quirks added for a couple hosts.

Thanks
-Mathias


Johan Hovold (1):
  USB: xhci: dbc: fix tty registration race

Jonathan Bell (2):
  xhci: guard accesses to ep_state in xhci_endpoint_reset()
  xhci: add quirk for host controllers that don't update endpoint DCS

Nikolay Martynov (1):
  xhci: Enable trust tx length quirk for Fresco FL11 USB controller

Pavankumar Kondeti (1):
  xhci: Fix command ring pointer corruption while aborting a command

 drivers/usb/host/xhci-dbgtty.c | 28 ++++++++++++------------
 drivers/usb/host/xhci-pci.c    |  6 +++++-
 drivers/usb/host/xhci-ring.c   | 39 +++++++++++++++++++++++++++++-----
 drivers/usb/host/xhci.c        |  5 +++++
 drivers/usb/host/xhci.h        |  1 +
 5 files changed, 58 insertions(+), 21 deletions(-)

-- 
2.25.1


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

* Re: [PATCH 0/5] xhci fixes for usb-linus
  2021-10-08  9:25 Mathias Nyman
@ 2021-10-08 16:13 ` Greg KH
  0 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2021-10-08 16:13 UTC (permalink / raw)
  To: Mathias Nyman; +Cc: linux-usb

On Fri, Oct 08, 2021 at 12:25:42PM +0300, Mathias Nyman wrote:
> Hi Greg
> 
> A few xhci fixes for 5.15-rc.
> A couple races fixed, and quirks added for a couple hosts.

I'll pick these up after Linus takes my latest pull request, these were
too late to get into linux-next this week for testing.

thanks,

greg k-h

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

* [PATCH 0/5] xhci fixes for usb-linus
@ 2025-04-10 15:18 Mathias Nyman
  0 siblings, 0 replies; 11+ messages in thread
From: Mathias Nyman @ 2025-04-10 15:18 UTC (permalink / raw)
  To: gregkh; +Cc: linux-usb, Mathias Nyman

Hi Greg

A few xhci fixes for usb-linus.
Revert the two patches in 6.15-rc1 that made sure xhci won't start
endpoints too early. Turns out they may now never start after
reset-resume.

Thanks
Mathias

Mathias Nyman (3):
  Revert "xhci: Avoid queuing redundant Stop Endpoint command for
    stalled endpoint"
  Revert "xhci: Prevent early endpoint restart when handling STALL
    errors."
  xhci: Limit time spent with xHC interrupts disabled during bus resume

Michal Pecio (2):
  usb: xhci: Fix Short Packet handling rework ignoring errors
  usb: xhci: Fix invalid pointer dereference in Etron workaround

 drivers/usb/host/xhci-hub.c  | 30 ++++++++++++++++--------------
 drivers/usb/host/xhci-ring.c | 11 ++++-------
 drivers/usb/host/xhci.c      | 18 +++++-------------
 drivers/usb/host/xhci.h      |  5 +++--
 4 files changed, 28 insertions(+), 36 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2025-04-10 15:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-24 13:59 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
2020-06-24 13:59 ` [PATCH 1/5] xhci: Fix incorrect EP_STATE_MASK Mathias Nyman
2020-06-24 13:59 ` [PATCH 2/5] xhci: Fix enumeration issue when setting max packet size for FS devices Mathias Nyman
2020-06-24 13:59 ` [PATCH 3/5] usb: host: xhci-mtk: avoid runtime suspend when removing hcd Mathias Nyman
2020-06-24 13:59 ` [PATCH 4/5] xhci: Return if xHCI doesn't support LPM Mathias Nyman
2020-06-24 13:59 ` [PATCH 5/5] xhci: Poll for U0 after disabling USB2 LPM Mathias Nyman
  -- strict thread matches above, loose matches on Subject: below --
2025-04-10 15:18 [PATCH 0/5] xhci fixes for usb-linus Mathias Nyman
2021-10-08  9:25 Mathias Nyman
2021-10-08 16:13 ` Greg KH
2021-05-12  8:08 Mathias Nyman
2019-05-22 11:33 Mathias Nyman

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).