+++ /dev/null
-From a4b03f82e4bd552b03b5be90dd9585d8454a138c Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 11 Jul 2024 15:45:27 +0200
-Subject: s390/pci: Allow allocation of more than 1 MSI interrupt
-
-From: Gerd Bayer <gbayer@linux.ibm.com>
-
-[ Upstream commit ab42fcb511fd9d241bbab7cc3ca04e34e9fc0666 ]
-
-On a PCI adapter that provides up to 8 MSI interrupt sources the s390
-implementation of PCI interrupts rejected to accommodate them, although
-the underlying hardware is able to support that.
-
-For MSI-X it is sufficient to allocate a single irq_desc per msi_desc,
-but for MSI multiple irq descriptors are attached to and controlled by
-a single msi descriptor. Add the appropriate loops to maintain multiple
-irq descriptors and tie/untie them to/from the appropriate AIBV bit, if
-a device driver allocates more than 1 MSI interrupt.
-
-Common PCI code passes on requests to allocate a number of interrupt
-vectors based on the device drivers' demand and the PCI functions'
-capabilities. However, the root-complex of s390 systems support just a
-limited number of interrupt vectors per PCI function.
-Produce a kernel log message to inform about any architecture-specific
-capping that might be done.
-
-With this change, we had a PCI adapter successfully raising
-interrupts to its device driver via all 8 sources.
-
-Fixes: a384c8924a8b ("s390/PCI: Fix single MSI only check")
-Signed-off-by: Gerd Bayer <gbayer@linux.ibm.com>
-Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
-Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/pci/pci_irq.c | 62 ++++++++++++++++++++++++++++-------------
- 1 file changed, 42 insertions(+), 20 deletions(-)
-
-diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
-index b36f5ef34a6c1..690f6999287bc 100644
---- a/arch/s390/pci/pci_irq.c
-+++ b/arch/s390/pci/pci_irq.c
-@@ -262,8 +262,8 @@ static int __alloc_airq(struct zpci_dev *zdev, int msi_vecs,
-
- int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
- {
-+ unsigned int hwirq, msi_vecs, irqs_per_msi, i, cpu;
- struct zpci_dev *zdev = to_zpci(pdev);
-- unsigned int hwirq, msi_vecs, cpu;
- struct msi_desc *msi;
- struct msi_msg msg;
- unsigned long bit;
-@@ -273,30 +273,46 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
- zdev->aisb = -1UL;
- zdev->msi_first_bit = -1U;
-
-- if (type == PCI_CAP_ID_MSI && nvec > 1)
-- return 1;
- msi_vecs = min_t(unsigned int, nvec, zdev->max_msi);
-+ if (msi_vecs < nvec) {
-+ pr_info("%s requested %d irqs, allocate system limit of %d",
-+ pci_name(pdev), nvec, zdev->max_msi);
-+ }
-
- rc = __alloc_airq(zdev, msi_vecs, &bit);
- if (rc < 0)
- return rc;
-
-- /* Request MSI interrupts */
-+ /*
-+ * Request MSI interrupts:
-+ * When using MSI, nvec_used interrupt sources and their irq
-+ * descriptors are controlled through one msi descriptor.
-+ * Thus the outer loop over msi descriptors shall run only once,
-+ * while two inner loops iterate over the interrupt vectors.
-+ * When using MSI-X, each interrupt vector/irq descriptor
-+ * is bound to exactly one msi descriptor (nvec_used is one).
-+ * So the inner loops are executed once, while the outer iterates
-+ * over the MSI-X descriptors.
-+ */
- hwirq = bit;
- msi_for_each_desc(msi, &pdev->dev, MSI_DESC_NOTASSOCIATED) {
-- rc = -EIO;
- if (hwirq - bit >= msi_vecs)
- break;
-- irq = __irq_alloc_descs(-1, 0, 1, 0, THIS_MODULE,
-- (irq_delivery == DIRECTED) ?
-- msi->affinity : NULL);
-+ irqs_per_msi = min_t(unsigned int, msi_vecs, msi->nvec_used);
-+ irq = __irq_alloc_descs(-1, 0, irqs_per_msi, 0, THIS_MODULE,
-+ (irq_delivery == DIRECTED) ?
-+ msi->affinity : NULL);
- if (irq < 0)
- return -ENOMEM;
-- rc = irq_set_msi_desc(irq, msi);
-- if (rc)
-- return rc;
-- irq_set_chip_and_handler(irq, &zpci_irq_chip,
-- handle_percpu_irq);
-+
-+ for (i = 0; i < irqs_per_msi; i++) {
-+ rc = irq_set_msi_desc_off(irq, i, msi);
-+ if (rc)
-+ return rc;
-+ irq_set_chip_and_handler(irq + i, &zpci_irq_chip,
-+ handle_percpu_irq);
-+ }
-+
- msg.data = hwirq - bit;
- if (irq_delivery == DIRECTED) {
- if (msi->affinity)
-@@ -309,19 +325,22 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
- msg.address_lo |= (cpu_addr << 8);
-
- for_each_possible_cpu(cpu) {
-- airq_iv_set_data(zpci_ibv[cpu], hwirq, irq);
-+ for (i = 0; i < irqs_per_msi; i++)
-+ airq_iv_set_data(zpci_ibv[cpu],
-+ hwirq + i, irq + i);
- }
- } else {
- msg.address_lo = zdev->msi_addr & 0xffffffff;
-- airq_iv_set_data(zdev->aibv, hwirq, irq);
-+ for (i = 0; i < irqs_per_msi; i++)
-+ airq_iv_set_data(zdev->aibv, hwirq + i, irq + i);
- }
- msg.address_hi = zdev->msi_addr >> 32;
- pci_write_msi_msg(irq, &msg);
-- hwirq++;
-+ hwirq += irqs_per_msi;
- }
-
- zdev->msi_first_bit = bit;
-- zdev->msi_nr_irqs = msi_vecs;
-+ zdev->msi_nr_irqs = hwirq - bit;
-
- if (irq_delivery == DIRECTED)
- rc = zpci_set_directed_irq(zdev);
-@@ -330,13 +349,14 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
- if (rc)
- return rc;
-
-- return (msi_vecs == nvec) ? 0 : msi_vecs;
-+ return (zdev->msi_nr_irqs == nvec) ? 0 : zdev->msi_nr_irqs;
- }
-
- void arch_teardown_msi_irqs(struct pci_dev *pdev)
- {
- struct zpci_dev *zdev = to_zpci(pdev);
- struct msi_desc *msi;
-+ unsigned int i;
- int rc;
-
- /* Disable interrupts */
-@@ -349,8 +369,10 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev)
-
- /* Release MSI interrupts */
- msi_for_each_desc(msi, &pdev->dev, MSI_DESC_ASSOCIATED) {
-- irq_set_msi_desc(msi->irq, NULL);
-- irq_free_desc(msi->irq);
-+ for (i = 0; i < msi->nvec_used; i++) {
-+ irq_set_msi_desc(msi->irq + i, NULL);
-+ irq_free_desc(msi->irq + i);
-+ }
- msi->msg.address_lo = 0;
- msi->msg.address_hi = 0;
- msi->msg.data = 0;
---
-2.43.0
-
+++ /dev/null
-From 5639e6dc7a8ec92b75a3234c92fd9825cb0dfc96 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 29 Jul 2021 23:51:51 +0200
-Subject: s390/pci: Do not mask MSI[-X] entries on teardown
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 3998527d2e3ee2bfdf710a45b7b90968ff87babc ]
-
-The PCI core already ensures that the MSI[-X] state is correct when MSI[-X]
-is disabled. For MSI the reset state is all entries unmasked and for MSI-X
-all vectors are masked.
-
-S390 masks all MSI entries and masks the already masked MSI-X entries
-again. Remove it and let the device in the correct state.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
-Tested-by: Marc Zyngier <maz@kernel.org>
-Reviewed-by: Marc Zyngier <maz@kernel.org>
-Acked-by: Niklas Schnelle <schnelle@linux.ibm.com>
-Link: https://lore.kernel.org/r/20210729222542.939798136@linutronix.de
-Stable-dep-of: ab42fcb511fd ("s390/pci: Allow allocation of more than 1 MSI interrupt")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/pci/pci_irq.c | 4 ----
- drivers/pci/msi.c | 4 ++--
- include/linux/msi.h | 2 --
- 3 files changed, 2 insertions(+), 8 deletions(-)
-
-diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
-index 75217fb63d7b3..5036e00b7ec1b 100644
---- a/arch/s390/pci/pci_irq.c
-+++ b/arch/s390/pci/pci_irq.c
-@@ -341,10 +341,6 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev)
- for_each_pci_msi_entry(msi, pdev) {
- if (!msi->irq)
- continue;
-- if (msi->msi_attrib.is_msix)
-- __pci_msix_desc_mask_irq(msi, 1);
-- else
-- __pci_msi_desc_mask_irq(msi, 1, 1);
- irq_set_msi_desc(msi->irq, NULL);
- irq_free_desc(msi->irq);
- msi->msg.address_lo = 0;
-diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
-index 1701d3de24da7..a37e3541c9377 100644
---- a/drivers/pci/msi.c
-+++ b/drivers/pci/msi.c
-@@ -170,7 +170,7 @@ static inline __attribute_const__ u32 msi_mask(unsigned x)
- * reliably as devices without an INTx disable bit will then generate a
- * level IRQ which will never be cleared.
- */
--void __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
-+static void __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag)
- {
- raw_spinlock_t *lock = &desc->dev->msi_lock;
- unsigned long flags;
-@@ -207,7 +207,7 @@ static void __iomem *pci_msix_desc_addr(struct msi_desc *desc)
- * file. This saves a few milliseconds when initialising devices with lots
- * of MSI-X interrupts.
- */
--u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag)
-+static u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag)
- {
- u32 mask_bits = desc->masked;
- void __iomem *desc_addr;
-diff --git a/include/linux/msi.h b/include/linux/msi.h
-index 758e32f0d4434..31193305807d0 100644
---- a/include/linux/msi.h
-+++ b/include/linux/msi.h
-@@ -193,8 +193,6 @@ void free_msi_entry(struct msi_desc *entry);
- void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
- void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg);
-
--u32 __pci_msix_desc_mask_irq(struct msi_desc *desc, u32 flag);
--void __pci_msi_desc_mask_irq(struct msi_desc *desc, u32 mask, u32 flag);
- void pci_msi_mask_irq(struct irq_data *data);
- void pci_msi_unmask_irq(struct irq_data *data);
-
---
-2.43.0
-
+++ /dev/null
-From eb1570b580a005bd5c3a2e2076b4919d5b482af9 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 26 Nov 2020 18:00:37 +0100
-Subject: s390/pci: fix CPU address in MSI for directed IRQ
-
-From: Alexander Gordeev <agordeev@linux.ibm.com>
-
-[ Upstream commit a2bd4097b3ec242f4de4924db463a9c94530e03a ]
-
-The directed MSIs are delivered to CPUs whose address is
-written to the MSI message address. The current code assumes
-that a CPU logical number (as it is seen by the kernel)
-is also the CPU address.
-
-The above assumption is not correct, as the CPU address
-is rather the value returned by STAP instruction. That
-value does not necessarily match the kernel logical CPU
-number.
-
-Fixes: e979ce7bced2 ("s390/pci: provide support for CPU directed interrupts")
-Cc: <stable@vger.kernel.org> # v5.2+
-Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
-Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
-Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
-Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
-Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
-Stable-dep-of: ab42fcb511fd ("s390/pci: Allow allocation of more than 1 MSI interrupt")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/pci/pci_irq.c | 14 +++++++++++---
- 1 file changed, 11 insertions(+), 3 deletions(-)
-
-diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
-index 743f257cf2cbd..75217fb63d7b3 100644
---- a/arch/s390/pci/pci_irq.c
-+++ b/arch/s390/pci/pci_irq.c
-@@ -103,9 +103,10 @@ static int zpci_set_irq_affinity(struct irq_data *data, const struct cpumask *de
- {
- struct msi_desc *entry = irq_get_msi_desc(data->irq);
- struct msi_msg msg = entry->msg;
-+ int cpu_addr = smp_cpu_get_cpu_address(cpumask_first(dest));
-
- msg.address_lo &= 0xff0000ff;
-- msg.address_lo |= (cpumask_first(dest) << 8);
-+ msg.address_lo |= (cpu_addr << 8);
- pci_write_msi_msg(data->irq, &msg);
-
- return IRQ_SET_MASK_OK;
-@@ -238,6 +239,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
- unsigned long bit;
- struct msi_desc *msi;
- struct msi_msg msg;
-+ int cpu_addr;
- int rc, irq;
-
- zdev->aisb = -1UL;
-@@ -287,9 +289,15 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
- handle_percpu_irq);
- msg.data = hwirq - bit;
- if (irq_delivery == DIRECTED) {
-+ if (msi->affinity)
-+ cpu = cpumask_first(&msi->affinity->mask);
-+ else
-+ cpu = 0;
-+ cpu_addr = smp_cpu_get_cpu_address(cpu);
-+
- msg.address_lo = zdev->msi_addr & 0xff0000ff;
-- msg.address_lo |= msi->affinity ?
-- (cpumask_first(&msi->affinity->mask) << 8) : 0;
-+ msg.address_lo |= (cpu_addr << 8);
-+
- for_each_possible_cpu(cpu) {
- airq_iv_set_data(zpci_ibv[cpu], hwirq, irq);
- }
---
-2.43.0
-
+++ /dev/null
-From 712d01b388700377d93ded50ada7eeb7d69a9530 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 11 Jul 2024 15:45:26 +0200
-Subject: s390/pci: Refactor arch_setup_msi_irqs()
-
-From: Gerd Bayer <gbayer@linux.ibm.com>
-
-[ Upstream commit 5fd11b96b43708f2f6e3964412c301c1bd20ec0f ]
-
-Factor out adapter interrupt allocation from arch_setup_msi_irqs() in
-preparation for enabling registration of multiple MSIs. Code movement
-only, no change of functionality intended.
-
-Signed-off-by: Gerd Bayer <gbayer@linux.ibm.com>
-Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
-Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
-Stable-dep-of: ab42fcb511fd ("s390/pci: Allow allocation of more than 1 MSI interrupt")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/pci/pci_irq.c | 54 ++++++++++++++++++++++++-----------------
- 1 file changed, 32 insertions(+), 22 deletions(-)
-
-diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
-index 9ed76fa9391cb..b36f5ef34a6c1 100644
---- a/arch/s390/pci/pci_irq.c
-+++ b/arch/s390/pci/pci_irq.c
-@@ -232,33 +232,20 @@ static void zpci_floating_irq_handler(struct airq_struct *airq, bool floating)
- }
- }
-
--int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
-+static int __alloc_airq(struct zpci_dev *zdev, int msi_vecs,
-+ unsigned long *bit)
- {
-- struct zpci_dev *zdev = to_zpci(pdev);
-- unsigned int hwirq, msi_vecs, cpu;
-- unsigned long bit;
-- struct msi_desc *msi;
-- struct msi_msg msg;
-- int cpu_addr;
-- int rc, irq;
--
-- zdev->aisb = -1UL;
-- zdev->msi_first_bit = -1U;
-- if (type == PCI_CAP_ID_MSI && nvec > 1)
-- return 1;
-- msi_vecs = min_t(unsigned int, nvec, zdev->max_msi);
--
- if (irq_delivery == DIRECTED) {
- /* Allocate cpu vector bits */
-- bit = airq_iv_alloc(zpci_ibv[0], msi_vecs);
-- if (bit == -1UL)
-+ *bit = airq_iv_alloc(zpci_ibv[0], msi_vecs);
-+ if (*bit == -1UL)
- return -EIO;
- } else {
- /* Allocate adapter summary indicator bit */
-- bit = airq_iv_alloc_bit(zpci_sbv);
-- if (bit == -1UL)
-+ *bit = airq_iv_alloc_bit(zpci_sbv);
-+ if (*bit == -1UL)
- return -EIO;
-- zdev->aisb = bit;
-+ zdev->aisb = *bit;
-
- /* Create adapter interrupt vector */
- zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK);
-@@ -266,10 +253,33 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
- return -ENOMEM;
-
- /* Wire up shortcut pointer */
-- zpci_ibv[bit] = zdev->aibv;
-+ zpci_ibv[*bit] = zdev->aibv;
- /* Each function has its own interrupt vector */
-- bit = 0;
-+ *bit = 0;
- }
-+ return 0;
-+}
-+
-+int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
-+{
-+ struct zpci_dev *zdev = to_zpci(pdev);
-+ unsigned int hwirq, msi_vecs, cpu;
-+ struct msi_desc *msi;
-+ struct msi_msg msg;
-+ unsigned long bit;
-+ int cpu_addr;
-+ int rc, irq;
-+
-+ zdev->aisb = -1UL;
-+ zdev->msi_first_bit = -1U;
-+
-+ if (type == PCI_CAP_ID_MSI && nvec > 1)
-+ return 1;
-+ msi_vecs = min_t(unsigned int, nvec, zdev->max_msi);
-+
-+ rc = __alloc_airq(zdev, msi_vecs, &bit);
-+ if (rc < 0)
-+ return rc;
-
- /* Request MSI interrupts */
- hwirq = bit;
---
-2.43.0
-
+++ /dev/null
-From 099f3562e9d7e56da6367d64319cca12107afdae Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 6 Dec 2021 23:51:23 +0100
-Subject: s390/pci: Rework MSI descriptor walk
-
-From: Thomas Gleixner <tglx@linutronix.de>
-
-[ Upstream commit 2ca5e908d0f4cde61d9d3595e8314adca5d914a1 ]
-
-Replace the about to vanish iterators and make use of the filtering.
-
-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-Tested-by: Niklas Schnelle <schnelle@linux.ibm.com>
-Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
-Acked-by: Niklas Schnelle <schnelle@linux.ibm.com>
-Link: https://lore.kernel.org/r/20211206210748.305656158@linutronix.de
-Stable-dep-of: ab42fcb511fd ("s390/pci: Allow allocation of more than 1 MSI interrupt")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/s390/pci/pci_irq.c | 6 ++----
- 1 file changed, 2 insertions(+), 4 deletions(-)
-
-diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
-index 5036e00b7ec1b..9ed76fa9391cb 100644
---- a/arch/s390/pci/pci_irq.c
-+++ b/arch/s390/pci/pci_irq.c
-@@ -273,7 +273,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
-
- /* Request MSI interrupts */
- hwirq = bit;
-- for_each_pci_msi_entry(msi, pdev) {
-+ msi_for_each_desc(msi, &pdev->dev, MSI_DESC_NOTASSOCIATED) {
- rc = -EIO;
- if (hwirq - bit >= msi_vecs)
- break;
-@@ -338,9 +338,7 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev)
- return;
-
- /* Release MSI interrupts */
-- for_each_pci_msi_entry(msi, pdev) {
-- if (!msi->irq)
-- continue;
-+ msi_for_each_desc(msi, &pdev->dev, MSI_DESC_ASSOCIATED) {
- irq_set_msi_desc(msi->irq, NULL);
- irq_free_desc(msi->irq);
- msi->msg.address_lo = 0;
---
-2.43.0
-
asoc-intel-convert-to-new-x86-cpu-match-macros.patch
asoc-intel-move-soc_intel_is_foo-helpers-to-a-generi.patch
asoc-intel-use-soc_intel_is_byt_cr-only-when-iosf_mb.patch
-s390-pci-fix-cpu-address-in-msi-for-directed-irq.patch
-s390-pci-do-not-mask-msi-x-entries-on-teardown.patch
-s390-pci-rework-msi-descriptor-walk.patch
-s390-pci-refactor-arch_setup_msi_irqs.patch
-s390-pci-allow-allocation-of-more-than-1-msi-interru.patch
nvme-pci-add-missing-condition-check-for-existence-o.patch
mm-avoid-overflows-in-dirty-throttling-logic.patch
pci-rockchip-make-ep-gpios-dt-property-optional.patch