linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xhci: stop polling roothubs after shutdown
@ 2022-04-01 11:59 Henry Lin
  2022-04-05 15:15 ` Mathias Nyman
  0 siblings, 1 reply; 2+ messages in thread
From: Henry Lin @ 2022-04-01 11:59 UTC (permalink / raw)
  To: Mathias Nyman; +Cc: Henry Lin, Greg Kroah-Hartman, linux-usb, linux-kernel

While rebooting, XHCI controller and its bus device will be shut down
in order by .shutdown callback. Stopping roothubs polling in
xhci_shutdown() can prevent XHCI driver from accessing port status
after its bus device shutdown.

Take PCIe XHCI controller as example, if XHCI driver doesn't stop roothubs
polling, XHCI driver may access PCIe BAR register for port status after
parent PCIe root port driver is shutdown and cause PCIe bus error.

Signed-off-by: Henry Lin <henryl@nvidia.com>
---
 drivers/usb/host/xhci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2d378543bc3a..e7ae6766220e 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -780,6 +780,14 @@ void xhci_shutdown(struct usb_hcd *hcd)
 	if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
 		usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
 
+	/* Don't poll the roothubs after shutdown. */
+	xhci_dbg(xhci, "%s: stopping usb%d port polling.\n",
+			__func__, hcd->self.busnum);
+	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
+	del_timer_sync(&hcd->rh_timer);
+	clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
+	del_timer_sync(&xhci->shared_hcd->rh_timer);
+
 	spin_lock_irq(&xhci->lock);
 	xhci_halt(xhci);
 	/* Workaround for spurious wakeups at shutdown with HSW */
-- 
2.17.1


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

* Re: [PATCH] xhci: stop polling roothubs after shutdown
  2022-04-01 11:59 [PATCH] xhci: stop polling roothubs after shutdown Henry Lin
@ 2022-04-05 15:15 ` Mathias Nyman
  0 siblings, 0 replies; 2+ messages in thread
From: Mathias Nyman @ 2022-04-05 15:15 UTC (permalink / raw)
  To: Henry Lin, Mathias Nyman; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On 1.4.2022 14.59, Henry Lin wrote:
> While rebooting, XHCI controller and its bus device will be shut down
> in order by .shutdown callback. Stopping roothubs polling in
> xhci_shutdown() can prevent XHCI driver from accessing port status
> after its bus device shutdown.
> 
> Take PCIe XHCI controller as example, if XHCI driver doesn't stop roothubs
> polling, XHCI driver may access PCIe BAR register for port status after
> parent PCIe root port driver is shutdown and cause PCIe bus error.
> 
> Signed-off-by: Henry Lin <henryl@nvidia.com>
> ---
>  drivers/usb/host/xhci.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 2d378543bc3a..e7ae6766220e 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -780,6 +780,14 @@ void xhci_shutdown(struct usb_hcd *hcd)
>  	if (xhci->quirks & XHCI_SPURIOUS_REBOOT)
>  		usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev));
>  
> +	/* Don't poll the roothubs after shutdown. */
> +	xhci_dbg(xhci, "%s: stopping usb%d port polling.\n",
> +			__func__, hcd->self.busnum);
> +	clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
> +	del_timer_sync(&hcd->rh_timer);
> +	clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags);
> +	del_timer_sync(&xhci->shared_hcd->rh_timer);
> +
>  	spin_lock_irq(&xhci->lock);
>  	xhci_halt(xhci);
>  	/* Workaround for spurious wakeups at shutdown with HSW */
> 

Thanks, adding to queue

-Mathias

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

end of thread, other threads:[~2022-04-06  0:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 11:59 [PATCH] xhci: stop polling roothubs after shutdown Henry Lin
2022-04-05 15:15 ` 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).