From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: <gregkh@linuxfoundation.org>
Cc: <linux-usb@vger.kernel.org>,
Josue David Hernandez Gutierrez
<josue.d.hernandez.gutierrez@intel.com>,
Mathias Nyman <mathias.nyman@linux.intel.com>
Subject: [PATCH 11/14] xhci: move PCI specific MSI/MSIX cleanup away from generic xhci functions
Date: Fri, 17 Mar 2023 17:47:12 +0200 [thread overview]
Message-ID: <20230317154715.535523-12-mathias.nyman@linux.intel.com> (raw)
In-Reply-To: <20230317154715.535523-1-mathias.nyman@linux.intel.com>
From: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>
Call the PCI specific MSI/MSIX interrupt freeing code from the xhci-pci
callbacks instead of generic xhci code, decoupling PCI parts from
generic xhci functions.
Adds xhci_pci_stop() that overrides xhci_stop() for PCI xHC controllers.
This will free MSIX interrupts a bit later in the hc_driver stop
callback, but is still earlier than usb core frees "legacy" interrupts,
or interrupts for other hosts.
Signed-off-by: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
drivers/usb/host/xhci-pci.c | 12 ++++++++++++
drivers/usb/host/xhci.c | 10 ++++------
drivers/usb/host/xhci.h | 2 ++
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 2d56b7477fcd..b6cfc028f8f7 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -230,6 +230,16 @@ static int xhci_pci_run(struct usb_hcd *hcd)
return xhci_run(hcd);
}
+static void xhci_pci_stop(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+
+ xhci_stop(hcd);
+
+ if (usb_hcd_is_primary_hcd(hcd))
+ xhci_cleanup_msix(xhci);
+}
+
/* called after powerup, by probe or system-pm "wakeup" */
static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
{
@@ -868,6 +878,7 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
xhci_shutdown(hcd);
+ xhci_cleanup_msix(xhci);
/* Yet another workaround for spurious wakeups at shutdown with HSW */
if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
@@ -932,6 +943,7 @@ static int __init xhci_pci_init(void)
xhci_pci_hc_driver.pci_poweroff_late = xhci_pci_poweroff_late;
xhci_pci_hc_driver.shutdown = xhci_pci_shutdown;
#endif
+ xhci_pci_hc_driver.stop = xhci_pci_stop;
return pci_register_driver(&xhci_pci_driver);
}
module_init(xhci_pci_init);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 9be84e635e1b..cf90751125ed 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -321,7 +321,7 @@ static int xhci_disable_interrupter(struct xhci_interrupter *ir)
#ifdef CONFIG_USB_PCI
/* Free any IRQs and disable MSI-X */
-static void xhci_cleanup_msix(struct xhci_hcd *xhci)
+void xhci_cleanup_msix(struct xhci_hcd *xhci)
{
struct usb_hcd *hcd = xhci_to_hcd(xhci);
struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
@@ -345,6 +345,7 @@ static void xhci_cleanup_msix(struct xhci_hcd *xhci)
pci_free_irq_vectors(pdev);
hcd->msix_enabled = 0;
}
+EXPORT_SYMBOL_GPL(xhci_cleanup_msix);
static void __maybe_unused xhci_msix_sync_irqs(struct xhci_hcd *xhci)
{
@@ -617,7 +618,7 @@ EXPORT_SYMBOL_GPL(xhci_run);
* Disable device contexts, disable IRQs, and quiesce the HC.
* Reset the HC, finish any completed transactions, and cleanup memory.
*/
-static void xhci_stop(struct usb_hcd *hcd)
+void xhci_stop(struct usb_hcd *hcd)
{
u32 temp;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
@@ -640,8 +641,6 @@ static void xhci_stop(struct usb_hcd *hcd)
xhci_reset(xhci, XHCI_RESET_SHORT_USEC);
spin_unlock_irq(&xhci->lock);
- xhci_cleanup_msix(xhci);
-
/* Deleting Compliance Mode Recovery Timer */
if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
(!(xhci_all_ports_seen_u0(xhci)))) {
@@ -668,6 +667,7 @@ static void xhci_stop(struct usb_hcd *hcd)
readl(&xhci->op_regs->status));
mutex_unlock(&xhci->mutex);
}
+EXPORT_SYMBOL_GPL(xhci_stop);
/*
* Shutdown HC (not bus-specific)
@@ -709,8 +709,6 @@ void xhci_shutdown(struct usb_hcd *hcd)
spin_unlock_irq(&xhci->lock);
- xhci_cleanup_msix(xhci);
-
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"xhci_shutdown completed - status = %x",
readl(&xhci->op_regs->status));
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 786002bb35db..a9111260632c 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -2125,6 +2125,7 @@ int xhci_reset(struct xhci_hcd *xhci, u64 timeout_us);
int xhci_run(struct usb_hcd *hcd);
int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks);
void xhci_shutdown(struct usb_hcd *hcd);
+void xhci_stop(struct usb_hcd *hcd);
void xhci_init_driver(struct hc_driver *drv,
const struct xhci_driver_overrides *over);
int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
@@ -2143,6 +2144,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated);
irqreturn_t xhci_irq(struct usb_hcd *hcd);
irqreturn_t xhci_msi_irq(int irq, void *hcd);
+void xhci_cleanup_msix(struct xhci_hcd *xhci);
int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev);
int xhci_alloc_tt_info(struct xhci_hcd *xhci,
struct xhci_virt_device *virt_dev,
--
2.25.1
next prev parent reply other threads:[~2023-03-17 15:46 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 15:47 [PATCH 00/14] xhci features for usb-next Mathias Nyman
2023-03-17 15:47 ` [PATCH 01/14] xhci: mem: Carefully calculate size for memory allocations Mathias Nyman
2023-03-17 15:47 ` [PATCH 02/14] xhci: mem: Use dma_poll_zalloc() instead of explicit memset() Mathias Nyman
2023-03-17 15:47 ` [PATCH 03/14] xhci: mem: Get rid of redundant 'else' Mathias Nyman
2023-03-17 15:47 ` [PATCH 04/14] xhci: mem: Drop useless return:s Mathias Nyman
2023-03-17 15:47 ` [PATCH 05/14] xhci: mem: Use while (i--) pattern to clean up Mathias Nyman
2023-03-17 15:47 ` [PATCH 06/14] xhci: mem: Replace explicit castings with appropriate specifiers Mathias Nyman
2023-03-17 15:47 ` [PATCH 07/14] xhci: mem: Join string literals back Mathias Nyman
2023-03-17 15:47 ` [PATCH 08/14] xhci: dbc: Provide sysfs option to configure dbc descriptors Mathias Nyman
2023-03-17 15:47 ` [PATCH 09/14] xhci: Avoid PCI MSI/MSIX interrupt reinitialization at resume Mathias Nyman
2023-03-17 15:47 ` [PATCH 10/14] xhci: Move functions to setup msi to xhci-pci Mathias Nyman
2023-03-17 15:47 ` Mathias Nyman [this message]
2023-03-17 15:47 ` [PATCH 12/14] xhci: Move functions to cleanup MSI " Mathias Nyman
2023-03-17 15:47 ` [PATCH 13/14] xhci: Call MSI sync function from xhci-pci instead of generic xhci code Mathias Nyman
2023-03-17 15:47 ` [PATCH 14/14] xhci: Move xhci MSI sync function to to xhci-pci Mathias Nyman
2023-03-17 15:53 ` [PATCH 00/14] xhci features for usb-next Mathias Nyman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230317154715.535523-12-mathias.nyman@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=josue.d.hernandez.gutierrez@intel.com \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).