lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1470158617-7022-10-git-send-email-eric.auger@redhat.com>
Date:	Tue,  2 Aug 2016 17:23:35 +0000
From:	Eric Auger <eric.auger@...hat.com>
To:	eric.auger@...hat.com, eric.auger.pro@...il.com,
	christoffer.dall@...aro.org, marc.zyngier@....com,
	robin.murphy@....com, alex.williamson@...hat.com,
	will.deacon@....com, joro@...tes.org, tglx@...utronix.de,
	jason@...edaemon.net, linux-arm-kernel@...ts.infradead.org
Cc:	kvm@...r.kernel.org, drjones@...hat.com,
	linux-kernel@...r.kernel.org, Bharat.Bhushan@...escale.com,
	pranav.sawargaonkar@...il.com, p.fedin@...sung.com,
	iommu@...ts.linux-foundation.org, Jean-Philippe.Brucker@....com,
	yehuday@...vell.com, Manish.Jaggi@...iumnetworks.com,
	robert.richter@...iumnetworks.com, dennis.chen@....com
Subject: [PATCH v12 09/11] genirq/msi: Introduce msi_desc flags

This new flags member is meant to store additional information about
the msi descriptor, starting with allocation status information.

MSI_DESC_FLAG_ALLOCATED bit tells the associated base IRQ is allocated.
This information is currently used at deallocation time. We also
introduce MSI_DESC_FLAG_FUNCTIONAL telling the MSIs are functional.

For the time being ALLOCATED and FUNCTIONAL are set at the same time
but this is going to change in subsequent patch. Indeed in some situations
some additional tasks need to be carried out for the MSI to be functional.
For instance the MSI doorbell may need to be mapped in an IOMMU.

FUNCTIONAL value already gets used when enumerating the usable MSIs in
msix_capability_init.

Signed-off-by: Eric Auger <eric.auger@...hat.com>

---

v12: new
---
 drivers/pci/msi.c   |  2 +-
 include/linux/msi.h | 14 ++++++++++++++
 kernel/irq/msi.c    |  7 ++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index a080f44..d7733ea 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -793,7 +793,7 @@ out_avail:
 		int avail = 0;
 
 		for_each_pci_msi_entry(entry, dev) {
-			if (entry->irq != 0)
+			if (entry->flags & MSI_DESC_FLAG_FUNCTIONAL)
 				avail++;
 		}
 		if (avail != 0)
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 8b425c6..18f894f 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -47,6 +47,7 @@ struct fsl_mc_msi_desc {
  * @nvec_used:	The number of vectors used
  * @dev:	Pointer to the device which uses this descriptor
  * @msg:	The last set MSI message cached for reuse
+ * @flags:	flags to describe the MSI descriptor status or features
  *
  * @masked:	[PCI MSI/X] Mask bits
  * @is_msix:	[PCI MSI/X] True if MSI-X
@@ -67,6 +68,7 @@ struct msi_desc {
 	unsigned int			nvec_used;
 	struct device			*dev;
 	struct msi_msg			msg;
+	u32						flags;
 
 	union {
 		/* PCI MSI/X specific data */
@@ -99,6 +101,18 @@ struct msi_desc {
 	};
 };
 
+/* Flags for msi_desc */
+enum {
+	/* the base IRQ is allocated */
+	MSI_DESC_FLAG_ALLOCATED	=	(1 << 0),
+	/**
+	 * the MSI is functional; in some cases the fact the base IRQ is
+	 * allocated is not sufficient for the MSIs to be functional: for
+	 * example the MSI doorbell(s) may need to be IOMMU mapped.
+	 */
+	MSI_DESC_FLAG_FUNCTIONAL =	(1 << 1),
+};
+
 /* Helpers to hide struct msi_desc implementation details */
 #define msi_desc_to_dev(desc)		((desc)->dev)
 #define dev_to_msi_list(dev)		(&(dev)->msi_list)
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 72bf4d6..9b93766 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -361,6 +361,9 @@ int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev,
 			return ret;
 		}
 
+		desc->flags |= MSI_DESC_FLAG_ALLOCATED;
+		desc->flags |= MSI_DESC_FLAG_FUNCTIONAL;
+
 		for (i = 0; i < desc->nvec_used; i++)
 			irq_set_msi_desc_off(virq, i, desc);
 	}
@@ -395,9 +398,11 @@ void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev)
 		 * enough that there is no IRQ associated to this
 		 * entry. If that's the case, don't do anything.
 		 */
-		if (desc->irq) {
+		if (desc->flags & MSI_DESC_FLAG_ALLOCATED) {
 			irq_domain_free_irqs(desc->irq, desc->nvec_used);
 			desc->irq = 0;
+			desc->flags &= ~MSI_DESC_FLAG_ALLOCATED;
+			desc->flags &= ~MSI_DESC_FLAG_FUNCTIONAL;
 		}
 	}
 }
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ