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: <1568338328-22458-2-git-send-email-megha.dey@linux.intel.com>
Date:   Thu, 12 Sep 2019 18:32:02 -0700
From:   Megha Dey <megha.dey@...ux.intel.com>
To:     linux-kernel@...r.kernel.org, x86@...nel.org,
        linux-pci@...r.kernel.org, maz@...nel.org, bhelgaas@...gle.com,
        rafael@...nel.org, gregkh@...uxfoundation.org, tglx@...utronix.de,
        hpa@...or.com, alex.williamson@...hat.com, jgg@...lanox.com
Cc:     ashok.raj@...el.com, megha.dey@...el.com, jacob.jun.pan@...el.com,
        Megha Dey <megha.dey@...ux.intel.com>
Subject: [RFC V1 1/7] genirq/msi: Differentiate between various MSI based interrupts

Since a device can support both MSI-X and IMS interrupts simultaneously,
do away with is_msix and introduce a new enum msi_desc_tag to
differentiate between the various types of msi_descs.

Signed-off-by: Megha Dey <megha.dey@...ux.intel.com>
---
 arch/mips/pci/msi-xlp.c    |  2 +-
 arch/s390/pci/pci_irq.c    |  2 +-
 arch/x86/kernel/apic/msi.c |  2 +-
 arch/x86/pci/xen.c         |  2 +-
 drivers/pci/msi.c          | 19 ++++++++++---------
 include/linux/msi.h        | 11 ++++++++++-
 kernel/irq/msi.c           |  2 +-
 7 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/arch/mips/pci/msi-xlp.c b/arch/mips/pci/msi-xlp.c
index bb14335..0f06ad1 100644
--- a/arch/mips/pci/msi-xlp.c
+++ b/arch/mips/pci/msi-xlp.c
@@ -457,7 +457,7 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc)
 	node = slot / 8;
 	lnkbase = nlm_get_pcie_base(node, link);
 
-	if (desc->msi_attrib.is_msix)
+	if (desc->tag == IRQ_MSI_TAG_MSIX)
 		return xlp_setup_msix(lnkbase, node, link, desc);
 	else
 		return xlp_setup_msi(lnkbase, node, link, desc);
diff --git a/arch/s390/pci/pci_irq.c b/arch/s390/pci/pci_irq.c
index d80616a..1938582 100644
--- a/arch/s390/pci/pci_irq.c
+++ b/arch/s390/pci/pci_irq.c
@@ -332,7 +332,7 @@ 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)
+		if (msi->tag == IRQ_MSI_TAG_MSIX)
 			__pci_msix_desc_mask_irq(msi, 1);
 		else
 			__pci_msi_desc_mask_irq(msi, 1, 1);
diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c
index 7f75334..435bcda 100644
--- a/arch/x86/kernel/apic/msi.c
+++ b/arch/x86/kernel/apic/msi.c
@@ -98,7 +98,7 @@ int pci_msi_prepare(struct irq_domain *domain, struct device *dev, int nvec,
 
 	init_irq_alloc_info(arg, NULL);
 	arg->msi_dev = pdev;
-	if (desc->msi_attrib.is_msix) {
+	if (desc->tag == IRQ_MSI_TAG_MSIX) {
 		arg->type = X86_IRQ_ALLOC_TYPE_MSIX;
 	} else {
 		arg->type = X86_IRQ_ALLOC_TYPE_MSI;
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 91220cc..5e850b8 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -382,7 +382,7 @@ static void xen_teardown_msi_irqs(struct pci_dev *dev)
 	struct msi_desc *msidesc;
 
 	msidesc = first_pci_msi_entry(dev);
-	if (msidesc->msi_attrib.is_msix)
+	if (msidesc->tag == IRQ_MSI_TAG_MSIX)
 		xen_pci_frontend_disable_msix(dev);
 	else
 		xen_pci_frontend_disable_msi(dev);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 0884bed..8a05416 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -235,7 +235,7 @@ static void msi_set_mask_bit(struct irq_data *data, u32 flag)
 {
 	struct msi_desc *desc = irq_data_get_msi_desc(data);
 
-	if (desc->msi_attrib.is_msix) {
+	if (desc->tag == IRQ_MSI_TAG_MSIX) {
 		msix_mask_irq(desc, flag);
 		readl(desc->mask_base);		/* Flush write to device */
 	} else {
@@ -278,7 +278,7 @@ void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
 
 	BUG_ON(dev->current_state != PCI_D0);
 
-	if (entry->msi_attrib.is_msix) {
+	if (entry->tag == IRQ_MSI_TAG_MSIX) {
 		void __iomem *base = pci_msix_desc_addr(entry);
 
 		if (!base) {
@@ -313,7 +313,7 @@ void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg)
 
 	if (dev->current_state != PCI_D0 || pci_dev_is_disconnected(dev)) {
 		/* Don't touch the hardware now */
-	} else if (entry->msi_attrib.is_msix) {
+	} else if (entry->tag == IRQ_MSI_TAG_MSIX) {
 		void __iomem *base = pci_msix_desc_addr(entry);
 
 		if (!base)
@@ -376,7 +376,7 @@ static void free_msi_irqs(struct pci_dev *dev)
 	pci_msi_teardown_msi_irqs(dev);
 
 	list_for_each_entry_safe(entry, tmp, msi_list, list) {
-		if (entry->msi_attrib.is_msix) {
+		if (entry->tag == IRQ_MSI_TAG_MSIX) {
 			if (list_is_last(&entry->list, msi_list))
 				iounmap(entry->mask_base);
 		}
@@ -471,7 +471,7 @@ static ssize_t msi_mode_show(struct device *dev, struct device_attribute *attr,
 	entry = irq_get_msi_desc(irq);
 	if (entry)
 		return sprintf(buf, "%s\n",
-				entry->msi_attrib.is_msix ? "msix" : "msi");
+			(entry->tag == IRQ_MSI_TAG_MSIX) ? "msix" : "msi");
 
 	return -ENODEV;
 }
@@ -570,7 +570,7 @@ msi_setup_entry(struct pci_dev *dev, int nvec, struct irq_affinity *affd)
 
 	pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control);
 
-	entry->msi_attrib.is_msix	= 0;
+	entry->tag			= IRQ_MSI_TAG_MSI;
 	entry->msi_attrib.is_64		= !!(control & PCI_MSI_FLAGS_64BIT);
 	entry->msi_attrib.is_virtual    = 0;
 	entry->msi_attrib.entry_nr	= 0;
@@ -714,7 +714,7 @@ static int msix_setup_entries(struct pci_dev *dev, void __iomem *base,
 			goto out;
 		}
 
-		entry->msi_attrib.is_msix	= 1;
+		entry->tag			= IRQ_MSI_TAG_MSIX;
 		entry->msi_attrib.is_64		= 1;
 		if (entries)
 			entry->msi_attrib.entry_nr = entries[i].entry;
@@ -1380,7 +1380,7 @@ irq_hw_number_t pci_msi_domain_calc_hwirq(struct pci_dev *dev,
 
 static inline bool pci_msi_desc_is_multi_msi(struct msi_desc *desc)
 {
-	return !desc->msi_attrib.is_msix && desc->nvec_used > 1;
+	return (desc->tag == IRQ_MSI_TAG_MSI) && desc->nvec_used > 1;
 }
 
 /**
@@ -1404,7 +1404,8 @@ int pci_msi_domain_check_cap(struct irq_domain *domain,
 	if (pci_msi_desc_is_multi_msi(desc) &&
 	    !(info->flags & MSI_FLAG_MULTI_PCI_MSI))
 		return 1;
-	else if (desc->msi_attrib.is_msix && !(info->flags & MSI_FLAG_PCI_MSIX))
+	else if ((desc->tag == IRQ_MSI_TAG_MSIX) &&
+					!(info->flags & MSI_FLAG_PCI_MSIX))
 		return -ENOTSUPP;
 
 	return 0;
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 8ad679e..22591b6 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -55,6 +55,15 @@ struct ti_sci_inta_msi_desc {
 	u16	dev_index;
 };
 
+enum msi_desc_tags {
+	IRQ_MSI_TAG_MSI,
+	IRQ_MSI_TAG_MSIX,
+	IRQ_MSI_TAG_IMS,
+	IRQ_MSI_TAG_PLAT,
+	IRQ_MSI_TAG_FSL,
+	IRQ_MSI_TAG_SCI,
+};
+
 /**
  * struct msi_desc - Descriptor structure for MSI based interrupts
  * @list:	List head for management
@@ -90,6 +99,7 @@ struct msi_desc {
 	struct device			*dev;
 	struct msi_msg			msg;
 	struct irq_affinity_desc	*affinity;
+	enum msi_desc_tags		tag;
 #ifdef CONFIG_IRQ_MSI_IOMMU
 	const void			*iommu_cookie;
 #endif
@@ -102,7 +112,6 @@ struct msi_desc {
 		struct {
 			u32 masked;
 			struct {
-				u8	is_msix		: 1;
 				u8	multiple	: 3;
 				u8	multi_cap	: 3;
 				u8	maskbit		: 1;
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index ad26fbc..0819395 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -384,7 +384,7 @@ static bool msi_check_reservation_mode(struct irq_domain *domain,
 	 * masking and MSI does so when the maskbit is set.
 	 */
 	desc = first_msi_entry(dev);
-	return desc->msi_attrib.is_msix || desc->msi_attrib.maskbit;
+	return (desc->tag == IRQ_MSI_TAG_MSIX) || desc->msi_attrib.maskbit;
 }
 
 /**
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ