From: "tip-bot2 for Ahmed S. Darwish" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
"Ahmed S. Darwish" <darwi@linutronix.de>,
Bjorn Helgaas <bhelgaas@google.com>,
x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org
Subject: [tip: irq/core] PCI/MSI: Move pci_disable_msi() to api.c
Date: Thu, 17 Nov 2022 15:08:13 -0000 [thread overview]
Message-ID: <166869769325.4906.4999716857847805098.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20221111122014.696798036@linutronix.de>
The following commit has been merged into the irq/core branch of tip:
Commit-ID: b12d0bec385b7a58b9e83751e6cd9f04ec3b23a4
Gitweb: https://git.kernel.org/tip/b12d0bec385b7a58b9e83751e6cd9f04ec3b23a4
Author: Ahmed S. Darwish <darwi@linutronix.de>
AuthorDate: Fri, 11 Nov 2022 14:54:45 +01:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 17 Nov 2022 15:15:20 +01:00
PCI/MSI: Move pci_disable_msi() to api.c
msi.c is a maze of randomly sorted functions which makes the code
unreadable. As a first step split the driver visible API and the internal
implementation which also allows proper API documentation via one file.
Create drivers/pci/msi/api.c to group all exported device-driver PCI/MSI
APIs in one C file.
Begin by moving pci_disable_msi() there and add kernel-doc for the function
as appropriate.
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ahmed S. Darwish <darwi@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20221111122014.696798036@linutronix.de
---
drivers/pci/msi/Makefile | 3 +--
drivers/pci/msi/api.c | 37 +++++++++++++++++++++++++++++++++++++
drivers/pci/msi/msi.c | 22 +++++-----------------
drivers/pci/msi/msi.h | 4 ++++
4 files changed, 47 insertions(+), 19 deletions(-)
create mode 100644 drivers/pci/msi/api.c
diff --git a/drivers/pci/msi/Makefile b/drivers/pci/msi/Makefile
index 4e0a7e0..839ff72 100644
--- a/drivers/pci/msi/Makefile
+++ b/drivers/pci/msi/Makefile
@@ -2,6 +2,5 @@
#
# Makefile for the PCI/MSI
obj-$(CONFIG_PCI) += pcidev_msi.o
-obj-$(CONFIG_PCI_MSI) += msi.o
-obj-$(CONFIG_PCI_MSI) += irqdomain.o
+obj-$(CONFIG_PCI_MSI) += api.o msi.o irqdomain.o
obj-$(CONFIG_PCI_MSI_ARCH_FALLBACKS) += legacy.o
diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c
new file mode 100644
index 0000000..7485942
--- /dev/null
+++ b/drivers/pci/msi/api.c
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PCI MSI/MSI-X — Exported APIs for device drivers
+ *
+ * Copyright (C) 2003-2004 Intel
+ * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
+ * Copyright (C) 2016 Christoph Hellwig.
+ * Copyright (C) 2022 Linutronix GmbH
+ */
+
+#include <linux/export.h>
+
+#include "msi.h"
+
+/**
+ * pci_disable_msi() - Disable MSI interrupt mode on device
+ * @dev: the PCI device to operate on
+ *
+ * Legacy device driver API to disable MSI interrupt mode on device,
+ * free earlier allocated interrupt vectors, and restore INTx emulation.
+ * The PCI device Linux IRQ (@dev->irq) is restored to its default
+ * pin-assertion IRQ. This is the cleanup pair of pci_enable_msi().
+ *
+ * NOTE: The newer pci_alloc_irq_vectors() / pci_free_irq_vectors() API
+ * pair should, in general, be used instead.
+ */
+void pci_disable_msi(struct pci_dev *dev)
+{
+ if (!pci_msi_enabled() || !dev || !dev->msi_enabled)
+ return;
+
+ msi_lock_descs(&dev->dev);
+ pci_msi_shutdown(dev);
+ pci_free_msi_irqs(dev);
+ msi_unlock_descs(&dev->dev);
+}
+EXPORT_SYMBOL(pci_disable_msi);
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 5c310df..4a1300b 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -163,7 +163,7 @@ void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg)
}
EXPORT_SYMBOL_GPL(pci_write_msi_msg);
-static void free_msi_irqs(struct pci_dev *dev)
+void pci_free_msi_irqs(struct pci_dev *dev)
{
pci_msi_teardown_msi_irqs(dev);
@@ -413,7 +413,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec,
err:
pci_msi_unmask(entry, msi_multi_mask(entry));
- free_msi_irqs(dev);
+ pci_free_msi_irqs(dev);
fail:
dev->msi_enabled = 0;
unlock:
@@ -531,7 +531,7 @@ static int msix_setup_interrupts(struct pci_dev *dev, void __iomem *base,
goto out_unlock;
out_free:
- free_msi_irqs(dev);
+ pci_free_msi_irqs(dev);
out_unlock:
msi_unlock_descs(&dev->dev);
kfree(masks);
@@ -680,7 +680,7 @@ int pci_msi_vec_count(struct pci_dev *dev)
}
EXPORT_SYMBOL(pci_msi_vec_count);
-static void pci_msi_shutdown(struct pci_dev *dev)
+void pci_msi_shutdown(struct pci_dev *dev)
{
struct msi_desc *desc;
@@ -701,18 +701,6 @@ static void pci_msi_shutdown(struct pci_dev *dev)
pcibios_alloc_irq(dev);
}
-void pci_disable_msi(struct pci_dev *dev)
-{
- if (!pci_msi_enable || !dev || !dev->msi_enabled)
- return;
-
- msi_lock_descs(&dev->dev);
- pci_msi_shutdown(dev);
- free_msi_irqs(dev);
- msi_unlock_descs(&dev->dev);
-}
-EXPORT_SYMBOL(pci_disable_msi);
-
/**
* pci_msix_vec_count - return the number of device's MSI-X table entries
* @dev: pointer to the pci_dev data structure of MSI-X device function
@@ -797,7 +785,7 @@ void pci_disable_msix(struct pci_dev *dev)
msi_lock_descs(&dev->dev);
pci_msix_shutdown(dev);
- free_msi_irqs(dev);
+ pci_free_msi_irqs(dev);
msi_unlock_descs(&dev->dev);
}
EXPORT_SYMBOL(pci_disable_msix);
diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h
index d8f62d9..6348792 100644
--- a/drivers/pci/msi/msi.h
+++ b/drivers/pci/msi/msi.h
@@ -84,6 +84,10 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc)
return (1 << (1 << desc->pci.msi_attrib.multi_cap)) - 1;
}
+/* MSI internal functions invoked from the public APIs */
+void pci_msi_shutdown(struct pci_dev *dev);
+void pci_free_msi_irqs(struct pci_dev *dev);
+
/* Legacy (!IRQDOMAIN) fallbacks */
#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS
int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type);
next prev parent reply other threads:[~2022-11-17 15:10 UTC|newest]
Thread overview: 163+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 13:54 [patch 00/39] genirq, PCI/MSI: Support for per device MSI and PCI/IMS - Part 1 cleanups Thomas Gleixner
2022-11-11 13:54 ` [patch 01/39] PCI/MSI: Check for MSI enabled in __pci_msix_enable() Thomas Gleixner
2022-11-16 15:39 ` Ashok Raj
2022-11-17 13:07 ` Thomas Gleixner
2022-11-17 14:00 ` Ashok Raj
2022-11-16 16:35 ` Bjorn Helgaas
2022-11-16 17:43 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-18 7:35 ` [patch 01/39] " Tian, Kevin
2022-11-11 13:54 ` [patch 02/39] iommu/vt-d: Remove bogus check for multi MSI-X Thomas Gleixner
2022-11-16 15:52 ` Ashok Raj
2022-11-16 17:02 ` Thomas Gleixner
2022-11-16 17:39 ` Ashok Raj
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 03/39] iommu/amd: " Thomas Gleixner
2022-11-16 16:02 ` Ashok Raj
2022-11-16 17:03 ` Thomas Gleixner
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 04/39] genirq/msi: Use MSI_DESC_ALL in msi_add_simple_msi_descs() Thomas Gleixner
2022-11-16 16:12 ` Ashok Raj
2022-11-16 17:43 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 05/39] genirq/msi: Remove filter from msi_free_descs_free_range() Thomas Gleixner
2022-11-16 17:43 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2023-03-01 10:55 ` [patch 05/39] " Miquel Raynal
2023-03-01 21:07 ` Thomas Gleixner
2023-03-02 14:43 ` Miquel Raynal
2023-03-02 17:22 ` [tip: irq/urgent] genirq/msi, platform-msi: Ensure that MSI descriptors are unreferenced tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 06/39] genirq/msi: Add missing kernel doc to msi_next_desc() Thomas Gleixner
2022-11-16 17:44 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 07/39] genirq/msi: Make __msi_domain_alloc_irqs() static Thomas Gleixner
2022-11-16 17:44 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 08/39] genirq/msi: Provide msi_domain_ops::post_free() Thomas Gleixner
2022-11-16 17:44 ` Jason Gunthorpe
2022-11-16 22:48 ` Thomas Gleixner
2022-11-17 15:08 ` [tip: irq/core] genirq/msi: Provide msi_domain_ops:: Post_free() tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 09/39] powerpc/pseries/msi: Use msi_domain_ops::msi_post_free() Thomas Gleixner
2022-11-16 17:45 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] powerpc/pseries/msi: Use msi_domain_ops:: Msi_post_free() tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 10/39] genirq/msi: Make __msi_domain_free_irqs() static Thomas Gleixner
2022-11-16 17:46 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 11/39] genirq/irqdomain: Move bus token enum into a seperate header Thomas Gleixner
2022-11-16 17:02 ` Ashok Raj
2022-11-16 17:48 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 12/39] genirq/msi: Add bus token to struct msi_domain_info Thomas Gleixner
2022-11-16 17:49 ` Jason Gunthorpe
2022-11-16 22:50 ` Thomas Gleixner
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 13/39] PCI/MSI: Use msi_domain_info::bus_token Thomas Gleixner
2022-11-16 16:14 ` Bjorn Helgaas
2022-11-16 17:51 ` Jason Gunthorpe
2022-11-16 22:51 ` Thomas Gleixner
2022-11-17 15:08 ` [tip: irq/core] PCI/MSI: Use msi_domain_info:: Bus_token tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 14/39] PCI/MSI: Let the MSI core free descriptors Thomas Gleixner
2022-11-16 16:15 ` Bjorn Helgaas
2022-11-16 17:53 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 15/39] PCI/MSI: Get rid of PCI_MSI_IRQ_DOMAIN Thomas Gleixner
2022-11-16 16:12 ` Bjorn Helgaas
2022-11-16 17:04 ` Thomas Gleixner
2022-11-16 17:53 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:54 ` [patch 16/39] genirq: Get rid of GENERIC_MSI_IRQ_DOMAIN Thomas Gleixner
2022-11-16 17:54 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2023-01-13 12:17 ` [PATCH] irqchip/imx: Do not unconditionally enable GENERIC_MSI_IRQ Ingo Molnar
2023-01-17 9:25 ` Thomas Gleixner
2022-11-11 13:54 ` [patch 17/39] PCI/MSI: Get rid of externs in msi.h Thomas Gleixner
2022-11-16 16:15 ` Bjorn Helgaas
2022-11-16 17:54 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 18/39] PCI/MSI: Move mask and unmask helpers to msi.h Thomas Gleixner
2022-11-16 16:16 ` Bjorn Helgaas
2022-11-16 17:55 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 19/39] PCI/MSI: Move pci_disable_msi() to api.c Thomas Gleixner
2022-11-16 16:16 ` Bjorn Helgaas
2022-11-17 15:08 ` tip-bot2 for Ahmed S. Darwish [this message]
2022-11-11 13:54 ` [patch 20/39] PCI/MSI: Move pci_enable_msi() API " Thomas Gleixner
2022-11-16 16:18 ` Bjorn Helgaas
2022-11-16 17:05 ` Thomas Gleixner
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 21/39] PCI/MSI: Move pci_enable_msix_range() " Thomas Gleixner
2022-11-16 16:20 ` Bjorn Helgaas
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 22/39] PCI/MSI: Move pci_alloc_irq_vectors() " Thomas Gleixner
2022-11-16 16:22 ` Bjorn Helgaas
2022-11-16 17:06 ` Thomas Gleixner
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 23/39] PCI/MSI: Move pci_alloc_irq_vectors_affinity() " Thomas Gleixner
2022-11-16 16:23 ` Bjorn Helgaas
2022-11-16 17:07 ` Thomas Gleixner
2022-11-18 12:34 ` Ahmed S. Darwish
2022-11-18 12:58 ` Peter Zijlstra
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 24/39] PCI/MSI: Move pci_irq_vector() " Thomas Gleixner
2022-11-16 16:23 ` Bjorn Helgaas
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 25/39] PCI/MSI: Move pci_free_irq_vectors() " Thomas Gleixner
2022-11-16 16:24 ` Bjorn Helgaas
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 26/39] PCI/MSI: Move pci_msix_vec_count() " Thomas Gleixner
2022-11-16 16:24 ` Bjorn Helgaas
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 27/39] PCI/MSI: Move pci_disable_msix() " Thomas Gleixner
2022-11-16 16:26 ` Bjorn Helgaas
2022-11-16 17:09 ` Thomas Gleixner
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:54 ` [patch 28/39] PCI/MSI: Move pci_irq_get_affinity() " Thomas Gleixner
2022-11-16 16:35 ` Bjorn Helgaas
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:55 ` [patch 29/39] PCI/MSI: Move pci_msi_enabled() " Thomas Gleixner
2022-11-16 16:26 ` Bjorn Helgaas
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:55 ` [patch 30/39] PCI/MSI: Move pci_msi_restore_state() " Thomas Gleixner
2022-11-16 16:27 ` Bjorn Helgaas
2022-11-16 17:42 ` Jason Gunthorpe
2022-11-17 15:08 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:55 ` [patch 31/39] Documentation: PCI: Add reference to PCI/MSI device driver APIs Thomas Gleixner
2022-11-16 16:27 ` Bjorn Helgaas
2022-11-16 17:31 ` Jason Gunthorpe
2022-11-17 15:07 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:55 ` [patch 32/39] PCI/MSI: Reorder functions in msi.c Thomas Gleixner
2022-11-16 16:28 ` Bjorn Helgaas
2022-11-16 17:10 ` Thomas Gleixner
2022-11-17 15:07 ` [tip: irq/core] " tip-bot2 for Ahmed S. Darwish
2022-11-11 13:55 ` [patch 33/39] PCI/MSI: Sanitize MSI-X checks Thomas Gleixner
2022-11-16 16:29 ` Bjorn Helgaas
2022-11-16 17:57 ` Jason Gunthorpe
2022-11-17 15:07 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-18 7:38 ` [patch 33/39] " Tian, Kevin
2022-11-11 13:55 ` [patch 34/39] PCI/MSI: Reject multi-MSI early Thomas Gleixner
2022-11-16 16:31 ` Bjorn Helgaas
2022-11-17 8:22 ` Thomas Gleixner
2022-11-16 17:59 ` Jason Gunthorpe
2022-11-17 15:07 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:55 ` [patch 35/39] PCI/MSI: Reject MSI-X early Thomas Gleixner
2022-11-16 16:31 ` Bjorn Helgaas
2022-11-16 18:00 ` Jason Gunthorpe
2022-11-17 15:07 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2023-01-15 22:14 ` [PATCH] x86/xen: Set MSI_FLAG_PCI_MSIX support in Xen MSI domain David Woodhouse
2023-01-16 19:43 ` [tip: x86/urgent] x86/pci/xen: " tip-bot2 for David Woodhouse
2022-11-11 13:55 ` [patch 36/39] PCI/MSI: Validate MSIX contiguous restriction early Thomas Gleixner
2022-11-16 16:33 ` Bjorn Helgaas
2022-11-16 18:00 ` Jason Gunthorpe
2022-11-17 15:07 ` [tip: irq/core] PCI/MSI: Validate MSI-X " tip-bot2 for Thomas Gleixner
2022-11-11 13:55 ` [patch 37/39] PCI/MSI: Remove redundant msi_check() callback Thomas Gleixner
2022-11-16 16:34 ` Bjorn Helgaas
2022-11-16 18:01 ` Jason Gunthorpe
2022-11-17 15:07 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-11 13:55 ` [patch 38/39] genirq/msi: Remove msi_domain_ops::msi_check() Thomas Gleixner
2022-11-16 18:01 ` Jason Gunthorpe
2022-11-17 15:07 ` [tip: irq/core] genirq/msi: Remove msi_domain_ops:: Msi_check() tip-bot2 for Thomas Gleixner
2022-11-11 13:55 ` [patch 39/39] x86/apic: Remove X86_IRQ_ALLOC_CONTIGUOUS_VECTORS Thomas Gleixner
2022-11-16 18:05 ` Jason Gunthorpe
2022-11-17 15:00 ` Thomas Gleixner
2022-11-17 15:07 ` [tip: irq/core] " tip-bot2 for Thomas Gleixner
2022-11-18 7:40 ` [patch 00/39] genirq, PCI/MSI: Support for per device MSI and PCI/IMS - Part 1 cleanups Tian, Kevin
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=166869769325.4906.4999716857847805098.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bhelgaas@google.com \
--cc=darwi@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=maz@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@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).