public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Josue David Hernandez Gutierrez 
	<josue.d.hernandez.gutierrez@intel.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	mathias.nyman@intel.com, linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 6.3 08/24] xhci: Avoid PCI MSI/MSIX interrupt reinitialization at resume
Date: Sat,  6 May 2023 20:30:04 -0400	[thread overview]
Message-ID: <20230507003022.4070535-8-sashal@kernel.org> (raw)
In-Reply-To: <20230507003022.4070535-1-sashal@kernel.org>

From: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>

[ Upstream commit 944e7deb4238d10cd16905474574236ac8a8e847 ]

xhci MSI setup is currently done at the same time as xHC host is started
in xhci_run(). This couples the generic xhci code with PCI, and will
reconfigure MSI/MSIX interrupts every time xHC is started.

Decouple MSI/MSIX configuration from generic xhci code by moving MSI/MSIX
part to a PCI specific xhci_pci_run() function overriding xhci_run().

This allows us to remove unnecessay MSI/MSIX reconfiguration done every
time PCI xhci resumes from suspend. i.e. remove the xhci_cleanup_msix()
call from xhci_resume() and the xhci_try_enale_msi() call in xhci_run()
called a bit later by xhci_resume()

[minor changes and commit message rewrite -Mathias]

Signed-off-by: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20230317154715.535523-10-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/usb/host/xhci-pci.c | 15 +++++++++++++++
 drivers/usb/host/xhci.c     |  8 ++------
 drivers/usb/host/xhci.h     |  1 +
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 6db07ca419c31..8060782a2367d 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -78,14 +78,29 @@ static const char hcd_name[] = "xhci_hcd";
 static struct hc_driver __read_mostly xhci_pci_hc_driver;
 
 static int xhci_pci_setup(struct usb_hcd *hcd);
+static int xhci_pci_run(struct usb_hcd *hcd);
 static int xhci_pci_update_hub_device(struct usb_hcd *hcd, struct usb_device *hdev,
 				      struct usb_tt *tt, gfp_t mem_flags);
 
 static const struct xhci_driver_overrides xhci_pci_overrides __initconst = {
 	.reset = xhci_pci_setup,
+	.start = xhci_pci_run,
 	.update_hub_device = xhci_pci_update_hub_device,
 };
 
+static int xhci_pci_run(struct usb_hcd *hcd)
+{
+	int ret;
+
+	if (usb_hcd_is_primary_hcd(hcd)) {
+		ret = xhci_try_enable_msi(hcd);
+		if (ret)
+			return ret;
+	}
+
+	return xhci_run(hcd);
+}
+
 /* called after powerup, by probe or system-pm "wakeup" */
 static int xhci_pci_reinit(struct xhci_hcd *xhci, struct pci_dev *pdev)
 {
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6307bae9cddff..f498df6b02c80 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -436,7 +436,7 @@ static void __maybe_unused xhci_msix_sync_irqs(struct xhci_hcd *xhci)
 	}
 }
 
-static int xhci_try_enable_msi(struct usb_hcd *hcd)
+int xhci_try_enable_msi(struct usb_hcd *hcd)
 {
 	struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 	struct pci_dev  *pdev;
@@ -490,6 +490,7 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd)
 	hcd->irq = pdev->irq;
 	return 0;
 }
+EXPORT_SYMBOL_GPL(xhci_try_enable_msi);
 
 #else
 
@@ -705,10 +706,6 @@ int xhci_run(struct usb_hcd *hcd)
 
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_run");
 
-	ret = xhci_try_enable_msi(hcd);
-	if (ret)
-		return ret;
-
 	temp_64 = xhci_read_64(xhci, &ir->ir_set->erst_dequeue);
 	temp_64 &= ~ERST_PTR_MASK;
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
@@ -1250,7 +1247,6 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
 		spin_unlock_irq(&xhci->lock);
 		if (retval)
 			return retval;
-		xhci_cleanup_msix(xhci);
 
 		xhci_dbg(xhci, "// Disabling event ring interrupts\n");
 		temp = readl(&xhci->op_regs->status);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 786002bb35db0..26fccc8d90556 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -2143,6 +2143,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);
+int xhci_try_enable_msi(struct usb_hcd *hcd);
 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.39.2


  parent reply	other threads:[~2023-05-07  0:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-07  0:29 [PATCH AUTOSEL 6.3 01/24] ASoC: jack: allow multiple interrupt per gpio Sasha Levin
2023-05-07  0:29 ` [PATCH AUTOSEL 6.3 02/24] staging: rtl8192e: Replace macro RTL_PCI_DEVICE with PCI_DEVICE Sasha Levin
2023-05-07  0:29 ` [PATCH AUTOSEL 6.3 03/24] HID: apple: Set the tilde quirk flag on the Geyser 4 and later Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 04/24] iio: imu: st_lsm6dsx: discard samples during filters settling time Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 05/24] staging: axis-fifo: initialize timeouts in init only Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 06/24] ASoC: tegra: Support coupled mic-hp detection Sasha Levin
2023-05-07 23:38   ` Mark Brown
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 07/24] xhci: mem: Carefully calculate size for memory allocations Sasha Levin
2023-05-07  0:30 ` Sasha Levin [this message]
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 09/24] spi: intel-pci: Add support for Meteor Lake-S SPI serial flash Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 10/24] ASoC: amd: yc: Add DMI entries to support HP OMEN 16-n0xxx (8A42) Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 11/24] HID: logitech-hidpp: Don't use the USB serial for USB devices Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 12/24] HID: logitech-hidpp: Reconcile USB and Unifying serials Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 13/24] spi: spi-imx: fix MX51_ECSPI_* macros when cs > 3 Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 14/24] usb: typec: ucsi: acpi: add quirk for ASUS Zenbook UM325 Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 15/24] ALSA: hda: LNL: add HD Audio PCI ID Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 16/24] ASoC: amd: Add Dell G15 5525 to quirks list Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 17/24] ASoC: amd: yc: Add ThinkBook 14 G5+ ARP to quirks list for acp6x Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 18/24] ASoC: amd: Add check for acp config flags Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 19/24] HID: apple: Set the tilde quirk flag on the Geyser 3 Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 20/24] HID: Ignore battery for ELAN touchscreen on ROG Flow X13 GV301RA Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 21/24] HID: wacom: generic: Set battery quirk only when we see battery data Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 22/24] usb: typec: tcpm: fix multiple times discover svids error Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 23/24] serial: 8250: Reinit port->pm on port specific driver unbind Sasha Levin
2023-05-07  0:30 ` [PATCH AUTOSEL 6.3 24/24] mcb-pci: Reallocate memory region to avoid memory overlapping Sasha Levin
2023-05-07 23:38 ` [PATCH AUTOSEL 6.3 01/24] ASoC: jack: allow multiple interrupt per gpio Mark Brown
2023-05-18 17:09   ` Sasha Levin
2023-05-19  2:18     ` Mark Brown

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=20230507003022.4070535-8-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=josue.d.hernandez.gutierrez@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=stable@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