|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 2/3] vpci/msix: move msix region removal to msix.c
From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
This code won't be used on Arm.
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
---
xen/drivers/vpci/header.c | 30 +++++-------------------------
xen/drivers/vpci/msix.c | 35 +++++++++++++++++++++++++++++++++++
xen/drivers/vpci/private.h | 2 ++
3 files changed, 42 insertions(+), 25 deletions(-)
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 7e5f4b8a00..9e19e41d0a 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -310,7 +310,6 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t
cmd, bool rom_only)
struct vpci_header *header = &pdev->vpci->header;
struct pci_dev *tmp;
const struct domain *d;
- const struct vpci_msix *msix = pdev->vpci->msix;
unsigned int i, j;
int rc;
@@ -405,30 +404,11 @@ static int modify_bars(const struct pci_dev *pdev,
uint16_t cmd, bool rom_only)
}
}
- /* Remove any MSIX regions if present. */
- for ( i = 0; msix && i < ARRAY_SIZE(msix->tables); i++ )
- {
- unsigned long start = PFN_DOWN(vmsix_table_addr(pdev->vpci, i));
- unsigned long end = PFN_DOWN(vmsix_table_addr(pdev->vpci, i) +
- vmsix_table_size(pdev->vpci, i) - 1);
-
- for ( j = 0; j < ARRAY_SIZE(header->bars); j++ )
- {
- const struct vpci_bar *bar = &header->bars[j];
-
- if ( rangeset_is_empty(bar->mem) )
- continue;
-
- rc = rangeset_remove_range(bar->mem, start, end);
- if ( rc )
- {
- gprintk(XENLOG_WARNING,
- "%pp: failed to remove MSIX table [%lx, %lx]: %d\n",
- &pdev->sbdf, start, end, rc);
- return rc;
- }
- }
- }
+#ifdef CONFIG_HAS_PCI_MSI
+ rc = vpci_remove_msix_regions(pdev);
+ if ( rc )
+ return rc;
+#endif
/*
* Check for overlaps with other BARs. Note that only BARs that are
diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c
index 05056b5ea1..4a1e7561f6 100644
--- a/xen/drivers/vpci/msix.c
+++ b/xen/drivers/vpci/msix.c
@@ -590,6 +590,41 @@ static const struct hvm_mmio_ops vpci_msix_table_ops = {
.write = msix_write,
};
+int vpci_remove_msix_regions(const struct pci_dev *pdev)
+{
+ const struct vpci_msix *msix = pdev->vpci->msix;
+ struct vpci_header *header = &pdev->vpci->header;
+ unsigned int i, j;
+ int rc;
+
+ /* Remove any MSIX regions if present. */
+ for ( i = 0; msix && i < ARRAY_SIZE(msix->tables); i++ )
+ {
+ unsigned long start = PFN_DOWN(vmsix_table_addr(pdev->vpci, i));
+ unsigned long end = PFN_DOWN(vmsix_table_addr(pdev->vpci, i) +
+ vmsix_table_size(pdev->vpci, i) - 1);
+
+ for ( j = 0; j < ARRAY_SIZE(header->bars); j++ )
+ {
+ const struct vpci_bar *bar = &header->bars[j];
+
+ if ( rangeset_is_empty(bar->mem) )
+ continue;
+
+ rc = rangeset_remove_range(bar->mem, start, end);
+ if ( rc )
+ {
+ gprintk(XENLOG_WARNING,
+ "%pp: failed to remove MSIX table [%lx, %lx]: %d\n",
+ &pdev->sbdf, start, end, rc);
+ return rc;
+ }
+ }
+ }
+
+ return 0;
+}
+
int vpci_make_msix_hole(const struct pci_dev *pdev)
{
struct domain *d = pdev->domain;
diff --git a/xen/drivers/vpci/private.h b/xen/drivers/vpci/private.h
index 2907f6b40f..a163efe8ff 100644
--- a/xen/drivers/vpci/private.h
+++ b/xen/drivers/vpci/private.h
@@ -87,6 +87,8 @@ void cf_check vpci_hw_write16(
const struct pci_dev *pdev, unsigned int reg, uint32_t val, void *data);
#ifdef __XEN__
+int vpci_remove_msix_regions(const struct pci_dev *pdev);
+
/* Make sure there's a hole in the p2m for the MSIX mmio areas. */
int vpci_make_msix_hole(const struct pci_dev *pdev);
--
2.55.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |