Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1516460

[PATCH 5/7] pci/msi: Provide pci_alloc_irq_vectors_affinity()

From Christoph Hellwig <hch@lst.de>
Newsgroups linux.kernel
Subject [PATCH 5/7] pci/msi: Provide pci_alloc_irq_vectors_affinity()
Date 2016-11-07 19:50 +0100
Message-ID <sAX9w-71s-9@gated-at.bofh.it> (permalink)
References <sAX9w-71s-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Christogh Hellwig <hch@lst.de>

This is a variant of pci_alloc_irq_vectors() that allows passing a
struct irq_affinity to provide fine-grainded IRQ affinity control.
For now this means being able to exclude vectors at the beginning or
end of the MSI vector space, but it could also be used for any other
quirks needed in the future (e.g. more vectors than CPUs, or exluding
CPUs from the spreading).

Signed-off-by: Christogh Hellwig <hch@lst.de>
---
 drivers/pci/msi.c   | 20 +++++++++++++-------
 include/linux/pci.h | 24 +++++++++++++++++++-----
 2 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 512f388..dd27f73 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1179,11 +1179,12 @@ int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries,
 EXPORT_SYMBOL(pci_enable_msix_range);
 
 /**
- * pci_alloc_irq_vectors - allocate multiple IRQs for a device
+ * pci_alloc_irq_vectors_affinity - allocate multiple IRQs for a device
  * @dev:		PCI device to operate on
  * @min_vecs:		minimum number of vectors required (must be >= 1)
  * @max_vecs:		maximum (desired) number of vectors
  * @flags:		flags or quirks for the allocation
+ * @affd:		optional description of the affinity requirements
  *
  * Allocate up to @max_vecs interrupt vectors for @dev, using MSI-X or MSI
  * vectors if available, and fall back to a single legacy vector
@@ -1195,15 +1196,20 @@ EXPORT_SYMBOL(pci_enable_msix_range);
  * To get the Linux IRQ number used for a vector that can be passed to
  * request_irq() use the pci_irq_vector() helper.
  */
-int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
-		unsigned int max_vecs, unsigned int flags)
+int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
+				   unsigned int max_vecs, unsigned int flags,
+				   const struct irq_affinity *affd)
 {
 	static const struct irq_affinity msi_default_affd;
-	const struct irq_affinity *affd = NULL;
 	int vecs = -ENOSPC;
 
-	if (flags & PCI_IRQ_AFFINITY)
-		affd = &msi_default_affd;
+	if (flags & PCI_IRQ_AFFINITY) {
+		if (!affd)
+			affd = &msi_default_affd;
+	} else {
+		if (WARN_ON(affd))
+			affd = NULL;
+	}
 
 	if (flags & PCI_IRQ_MSIX) {
 		vecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs,
@@ -1226,7 +1232,7 @@ int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
 
 	return vecs;
 }
-EXPORT_SYMBOL(pci_alloc_irq_vectors);
+EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity);
 
 /**
  * pci_free_irq_vectors - free previously allocated IRQs for a device
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 0e49f70..7090f5f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -244,6 +244,7 @@ struct pci_cap_saved_state {
 	struct pci_cap_saved_data cap;
 };
 
+struct irq_affinity;
 struct pcie_link_state;
 struct pci_vpd;
 struct pci_sriov;
@@ -1310,8 +1311,10 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev,
 		return rc;
 	return 0;
 }
-int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
-		unsigned int max_vecs, unsigned int flags);
+int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
+				   unsigned int max_vecs, unsigned int flags,
+				   const struct irq_affinity *affd);
+
 void pci_free_irq_vectors(struct pci_dev *dev);
 int pci_irq_vector(struct pci_dev *dev, unsigned int nr);
 const struct cpumask *pci_irq_get_affinity(struct pci_dev *pdev, int vec);
@@ -1339,14 +1342,17 @@ static inline int pci_enable_msix_range(struct pci_dev *dev,
 static inline int pci_enable_msix_exact(struct pci_dev *dev,
 		      struct msix_entry *entries, int nvec)
 { return -ENOSYS; }
-static inline int pci_alloc_irq_vectors(struct pci_dev *dev,
-		unsigned int min_vecs, unsigned int max_vecs,
-		unsigned int flags)
+
+static inline int
+pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
+			       unsigned int max_vecs, unsigned int flags,
+			       const struct irq_affinity *aff_desc)
 {
 	if (min_vecs > 1)
 		return -EINVAL;
 	return 1;
 }
+
 static inline void pci_free_irq_vectors(struct pci_dev *dev)
 {
 }
@@ -1364,6 +1370,14 @@ static inline const struct cpumask *pci_irq_get_affinity(struct pci_dev *pdev,
 }
 #endif
 
+static inline int
+pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs,
+		      unsigned int max_vecs, unsigned int flags)
+{
+	return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags,
+					      NULL);
+}
+
 #ifdef CONFIG_PCIEPORTBUS
 extern bool pcie_ports_disabled;
 extern bool pcie_ports_auto;
-- 
2.1.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

support for partial irq affinity assignment Christoph Hellwig <hch@lst.de> - 2016-11-07 19:50 +0100
  [PATCH 1/7] genirq/affinity: Introduce struct irq_affinity Christoph Hellwig <hch@lst.de> - 2016-11-07 19:50 +0100
    Re: [PATCH 1/7] genirq/affinity: Introduce struct irq_affinity Johannes Thumshirn <jthumshirn@suse.de> - 2016-11-08 09:20 +0100
    Re: [PATCH 1/7] genirq/affinity: Introduce struct irq_affinity Hannes Reinecke <hare@suse.de> - 2016-11-08 09:20 +0100
    Re: [PATCH 1/7] genirq/affinity: Introduce struct irq_affinity Bjorn Helgaas <helgaas@kernel.org> - 2016-11-08 22:30 +0100
      Re: [PATCH 1/7] genirq/affinity: Introduce struct irq_affinity Christoph Hellwig <hch@lst.de> - 2016-11-08 23:40 +0100
  [PATCH 5/7] pci/msi: Provide pci_alloc_irq_vectors_affinity() Christoph Hellwig <hch@lst.de> - 2016-11-07 19:50 +0100
    Re: [PATCH 5/7] pci/msi: Provide pci_alloc_irq_vectors_affinity() Hannes Reinecke <hare@suse.de> - 2016-11-08 09:20 +0100
      Re: [PATCH 5/7] pci/msi: Provide pci_alloc_irq_vectors_affinity() Johannes Thumshirn <jthumshirn@suse.de> - 2016-11-08 09:30 +0100
    Re: [PATCH 5/7] pci/msi: Provide pci_alloc_irq_vectors_affinity() Bjorn Helgaas <helgaas@kernel.org> - 2016-11-08 22:20 +0100
      Re: [PATCH 5/7] pci/msi: Provide pci_alloc_irq_vectors_affinity() Christoph Hellwig <hch@lst.de> - 2016-11-08 22:30 +0100
  [PATCH 4/7] pci/msi: Propagate irq affinity description through the MSI code Christoph Hellwig <hch@lst.de> - 2016-11-07 19:50 +0100
    Re: [PATCH 4/7] pci/msi: Propagate irq affinity description through  the MSI code Hannes Reinecke <hare@suse.de> - 2016-11-08 09:20 +0100
    Re: [PATCH 4/7] pci/msi: Propagate irq affinity description through  the MSI code Johannes Thumshirn <jthumshirn@suse.de> - 2016-11-08 09:30 +0100
    Re: [PATCH 4/7] pci/msi: Propagate irq affinity description through  the MSI code Bjorn Helgaas <helgaas@kernel.org> - 2016-11-08 22:20 +0100
  [PATCH 7/7] blk-mq: add a first_vec argument to blk_mq_pci_map_queues Christoph Hellwig <hch@lst.de> - 2016-11-07 19:50 +0100
    Re: [PATCH 7/7] blk-mq: add a first_vec argument to  blk_mq_pci_map_queues Johannes Thumshirn <jthumshirn@suse.de> - 2016-11-08 09:30 +0100
  [PATCH 2/7] genirq/affinity: Handle pre/post vectors in irq_calc_affinity_vectors() Christoph Hellwig <hch@lst.de> - 2016-11-07 19:50 +0100
    Re: [PATCH 2/7] genirq/affinity: Handle pre/post vectors in  irq_calc_affinity_vectors() Hannes Reinecke <hare@suse.de> - 2016-11-08 09:20 +0100
      Re: [PATCH 2/7] genirq/affinity: Handle pre/post vectors in  irq_calc_affinity_vectors() Thomas Gleixner <tglx@linutronix.de> - 2016-11-08 15:50 +0100
  [PATCH 3/7] genirq/affinity: Handle pre/post vectors in irq_create_affinity_masks() Christoph Hellwig <hch@lst.de> - 2016-11-07 19:50 +0100
    Re: [PATCH 3/7] genirq/affinity: Handle pre/post vectors in  irq_create_affinity_masks() Hannes Reinecke <hare@suse.de> - 2016-11-08 09:20 +0100
      Re: [PATCH 3/7] genirq/affinity: Handle pre/post vectors in         irq_create_affinity_masks() Christoph Hellwig <hch@lst.de> - 2016-11-08 16:00 +0100
        Re: [PATCH 3/7] genirq/affinity: Handle pre/post vectors in  irq_create_affinity_masks() Hannes Reinecke <hare@suse.de> - 2016-11-08 16:00 +0100
          Re: [PATCH 3/7] genirq/affinity: Handle pre/post vectors in         irq_create_affinity_masks() Christoph Hellwig <hch@lst.de> - 2016-11-08 16:10 +0100
            Re: [PATCH 3/7] genirq/affinity: Handle pre/post vectors in         irq_create_affinity_masks() Christoph Hellwig <hch@lst.de> - 2016-11-08 17:40 +0100
            Re: [PATCH 3/7] genirq/affinity: Handle pre/post vectors in  irq_create_affinity_masks() Thomas Gleixner <tglx@linutronix.de> - 2016-11-08 17:40 +0100
    Re: [PATCH 3/7] genirq/affinity: Handle pre/post vectors in  irq_create_affinity_masks() Bjorn Helgaas <helgaas@kernel.org> - 2016-11-08 22:30 +0100
  [PATCH 6/7] pci: Remove the irq_affinity mask from struct pci_dev Christoph Hellwig <hch@lst.de> - 2016-11-07 20:00 +0100
    Re: [PATCH 6/7] pci: Remove the irq_affinity mask from struct pci_dev Hannes Reinecke <hare@suse.de> - 2016-11-08 09:20 +0100
    Re: [PATCH 6/7] pci: Remove the irq_affinity mask from struct pci_dev Johannes Thumshirn <jthumshirn@suse.de> - 2016-11-08 09:30 +0100
    Re: [PATCH 6/7] pci: Remove the irq_affinity mask from struct pci_dev Bjorn Helgaas <helgaas@kernel.org> - 2016-11-08 22:10 +0100

csiph-web