From: Rahul Singh <rahul.singh@arm.com>
To: xen-devel@lists.xenproject.org
Cc: bertrand.marquis@arm.com, rahul.singh@arm.com,
"Jan Beulich" <jbeulich@suse.com>, "Paul Durrant" <paul@xen.org>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>,
"Ian Jackson" <iwj@xenproject.org>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
"Daniel De Graaf" <dgdegra@tycho.nsa.gov>
Subject: [PATCH 2/2] xen/pci: Gate all MSI code in common code with CONFIG_HAS_PCI_MSI
Date: Tue, 6 Apr 2021 12:39:11 +0100 [thread overview]
Message-ID: <4471ba4fffc8a0cef24cc11314fc788334f85ccc.1617702520.git.rahul.singh@arm.com> (raw)
In-Reply-To: <cover.1617702520.git.rahul.singh@arm.com>
In-Reply-To: <cover.1617702520.git.rahul.singh@arm.com>
MSI support is not implemented for ARM architecture but it is enabled
for x86 architecture and referenced in common passthrough/pci.c code.
Therefore introducing the new flag to gate the MSI code for ARM in
common code to avoid compilation error when HAS_PCI is enabled for ARM.
Signed-off-by: Rahul Singh <rahul.singh@arm.com>
---
xen/drivers/passthrough/pci.c | 17 +++++++++++++++++
xen/drivers/pci/Kconfig | 4 ++++
xen/drivers/vpci/Makefile | 3 ++-
| 6 ++++++
xen/drivers/vpci/vpci.c | 2 ++
xen/include/xen/vpci.h | 4 ++++
xen/xsm/flask/hooks.c | 6 +++---
7 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 705137f8be..390b960d83 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -33,7 +33,9 @@
#include <xen/tasklet.h>
#include <xen/vpci.h>
#include <xsm/xsm.h>
+#ifdef CONFIG_HAS_PCI_MSI
#include <asm/msi.h>
+#endif
#include "ats.h"
struct pci_seg {
@@ -327,6 +329,8 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn)
*((u8*) &pdev->bus) = bus;
*((u8*) &pdev->devfn) = devfn;
pdev->domain = NULL;
+
+#ifdef CONFIG_HAS_PCI_MSI
INIT_LIST_HEAD(&pdev->msi_list);
pos = pci_find_cap_offset(pseg->nr, bus, PCI_SLOT(devfn), PCI_FUNC(devfn),
@@ -357,6 +361,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn)
pdev->msix = msix;
}
+#endif
list_add(&pdev->alldevs_list, &pseg->alldevs_list);
@@ -449,7 +454,9 @@ static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev)
}
list_del(&pdev->alldevs_list);
+#ifdef CONFIG_HAS_PCI_MSI
xfree(pdev->msix);
+#endif
xfree(pdev);
}
@@ -827,7 +834,9 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list )
if ( pdev->bus == bus && pdev->devfn == devfn )
{
+#ifdef CONFIG_HAS_PCI_MSI
pci_cleanup_msi(pdev);
+#endif
ret = iommu_remove_device(pdev);
if ( pdev->domain )
list_del(&pdev->domain_list);
@@ -1271,7 +1280,9 @@ bool_t pcie_aer_get_firmware_first(const struct pci_dev *pdev)
static int _dump_pci_devices(struct pci_seg *pseg, void *arg)
{
struct pci_dev *pdev;
+#ifdef CONFIG_HAS_PCI_MSI
struct msi_desc *msi;
+#endif
printk("==== segment %04x ====\n", pseg->nr);
@@ -1280,8 +1291,10 @@ static int _dump_pci_devices(struct pci_seg *pseg, void *arg)
printk("%pp - %pd - node %-3d - MSIs < ",
&pdev->sbdf, pdev->domain,
(pdev->node != NUMA_NO_NODE) ? pdev->node : -1);
+#ifdef CONFIG_HAS_PCI_MSI
list_for_each_entry ( msi, &pdev->msi_list, list )
printk("%d ", msi->irq);
+#endif
printk(">\n");
}
@@ -1303,12 +1316,14 @@ static int __init setup_dump_pcidevs(void)
}
__initcall(setup_dump_pcidevs);
+#ifdef CONFIG_HAS_PCI_MSI
int iommu_update_ire_from_msi(
struct msi_desc *msi_desc, struct msi_msg *msg)
{
return iommu_intremap
? iommu_call(&iommu_ops, update_ire_from_msi, msi_desc, msg) : 0;
}
+#endif
static int iommu_add_device(struct pci_dev *pdev)
{
@@ -1429,6 +1444,7 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
ASSERT(pdev && (pdev->domain == hardware_domain ||
pdev->domain == dom_io));
+#ifdef CONFIG_HAS_PCI_MSI
if ( pdev->msix )
{
rc = pci_reset_msix_state(pdev);
@@ -1436,6 +1452,7 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
goto done;
msixtbl_init(d);
}
+#endif
pdev->fault.count = 0;
diff --git a/xen/drivers/pci/Kconfig b/xen/drivers/pci/Kconfig
index 7da03fa13b..695781ce3a 100644
--- a/xen/drivers/pci/Kconfig
+++ b/xen/drivers/pci/Kconfig
@@ -1,3 +1,7 @@
config HAS_PCI
bool
+
+config HAS_PCI_MSI
+ def_bool y
+ depends on X86 && HAS_PCI
diff --git a/xen/drivers/vpci/Makefile b/xen/drivers/vpci/Makefile
index 55d1bdfda0..1a1413b93e 100644
--- a/xen/drivers/vpci/Makefile
+++ b/xen/drivers/vpci/Makefile
@@ -1 +1,2 @@
-obj-y += vpci.o header.o msi.o msix.o
+obj-y += vpci.o header.o
+obj-$(CONFIG_HAS_PCI_MSI) += msi.o msix.o
--git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index ba9a036202..b90c345612 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -96,8 +96,10 @@ static void modify_decoding(const struct pci_dev *pdev, uint16_t cmd,
* FIXME: punching holes after the p2m has been set up might be racy for
* DomU usage, needs to be revisited.
*/
+#ifdef CONFIG_HAS_PCI_MSI
if ( map && !rom_only && vpci_make_msix_hole(pdev) )
return;
+#endif
for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
{
@@ -206,7 +208,9 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
struct vpci_header *header = &pdev->vpci->header;
struct rangeset *mem = rangeset_new(NULL, NULL, 0);
struct pci_dev *tmp, *dev = NULL;
+#ifdef CONFIG_HAS_PCI_MSI
const struct vpci_msix *msix = pdev->vpci->msix;
+#endif
unsigned int i;
int rc;
@@ -243,6 +247,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
}
}
+#ifdef CONFIG_HAS_PCI_MSI
/* Remove any MSIX regions if present. */
for ( i = 0; msix && i < ARRAY_SIZE(msix->tables); i++ )
{
@@ -260,6 +265,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
return rc;
}
}
+#endif /* CONFIG_HAS_PCI_MSI */
/*
* Check for overlaps with other BARs. Note that only BARs that are
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index cbd1bac7fc..474eb2f0ac 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -48,8 +48,10 @@ void vpci_remove_device(struct pci_dev *pdev)
xfree(r);
}
spin_unlock(&pdev->vpci->lock);
+#ifdef CONFIG_HAS_PCI_MSI
xfree(pdev->vpci->msix);
xfree(pdev->vpci->msi);
+#endif
xfree(pdev->vpci);
pdev->vpci = NULL;
}
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index 9f5b5d52e1..d81588ba64 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -91,6 +91,7 @@ struct vpci {
/* FIXME: currently there's no support for SR-IOV. */
} header;
+#ifdef CONFIG_HAS_PCI_MSI
/* MSI data. */
struct vpci_msi {
/* Address. */
@@ -136,6 +137,7 @@ struct vpci {
struct vpci_arch_msix_entry arch;
} entries[];
} *msix;
+#endif /* CONFIG_HAS_PCI_MSI */
#endif
};
@@ -148,6 +150,7 @@ struct vpci_vcpu {
};
#ifdef __XEN__
+#ifdef CONFIG_HAS_PCI_MSI
void vpci_dump_msi(void);
/* Make sure there's a hole in the p2m for the MSIX mmio areas. */
@@ -208,6 +211,7 @@ static inline unsigned int vmsix_entry_nr(const struct vpci_msix *msix,
{
return entry - msix->entries;
}
+#endif /* CONFIG_HAS_PCI_MSI */
#endif /* __XEN__ */
#else /* !CONFIG_HAS_VPCI */
diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
index 3b7313b949..df594c80a9 100644
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -21,7 +21,7 @@
#include <xen/guest_access.h>
#include <xen/xenoprof.h>
#include <xen/iommu.h>
-#ifdef CONFIG_HAS_PCI
+#ifdef CONFIG_HAS_PCI_MSI
#include <asm/msi.h>
#endif
#include <public/xen.h>
@@ -114,7 +114,7 @@ static int get_irq_sid(int irq, u32 *sid, struct avc_audit_data *ad)
}
return security_irq_sid(irq, sid);
}
-#ifdef CONFIG_HAS_PCI
+#ifdef CONFIG_HAS_PCI_MSI
{
struct irq_desc *desc = irq_to_desc(irq);
if ( desc->msi_desc && desc->msi_desc->dev ) {
@@ -868,7 +868,7 @@ static int flask_map_domain_pirq (struct domain *d)
static int flask_map_domain_msi (struct domain *d, int irq, const void *data,
u32 *sid, struct avc_audit_data *ad)
{
-#ifdef CONFIG_HAS_PCI
+#ifdef CONFIG_HAS_PCI_MSI
const struct msi_info *msi = data;
u32 machine_bdf = (msi->seg << 16) | (msi->bus << 8) | msi->devfn;
--
2.17.1
next prev parent reply other threads:[~2021-04-06 11:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 11:39 [PATCH 0/2] xen/pci: Make PCI passthrough code non-x86 specific Rahul Singh
2021-04-06 11:39 ` [PATCH 1/2] xen/pci: Move PCI ATS code to common directory Rahul Singh
2021-04-06 15:16 ` Jan Beulich
2021-04-06 11:39 ` Rahul Singh [this message]
2021-04-06 14:13 ` [PATCH 2/2] xen/pci: Gate all MSI code in common code with CONFIG_HAS_PCI_MSI Roger Pau Monné
2021-04-06 14:30 ` Julien Grall
2021-04-06 14:59 ` Roger Pau Monné
2021-04-06 15:09 ` Julien Grall
2021-04-06 15:58 ` Roger Pau Monné
2021-04-07 17:52 ` Rahul Singh
2021-04-06 15:25 ` Jan Beulich
2021-04-07 18:06 ` Julien Grall
2021-04-08 6:00 ` Jan Beulich
2021-04-08 8:45 ` Rahul Singh
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=4471ba4fffc8a0cef24cc11314fc788334f85ccc.1617702520.git.rahul.singh@arm.com \
--to=rahul.singh@arm.com \
--cc=andrew.cooper3@citrix.com \
--cc=bertrand.marquis@arm.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=george.dunlap@citrix.com \
--cc=iwj@xenproject.org \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=paul@xen.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.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).