|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 07/15] pci: Use pci_sbdf_t in pci_ro_device()
That has the indirect effect of properly considering segments
other than 0 in xhci-dbc.
Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
xen/drivers/char/ns16550.c | 3 +--
xen/drivers/char/xhci-dbc.c | 4 ++--
xen/drivers/passthrough/amd/iommu_detect.c | 7 +------
xen/drivers/passthrough/pci.c | 8 ++++----
xen/include/xen/pci.h | 2 +-
5 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index fa2d0e5991..8396e5fb84 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -450,8 +450,7 @@ static void __init cf_check ns16550_init_postirq(struct
serial_port *port)
PFN_UP(uart->io_base + uart->io_size) - 1) )
printk(XENLOG_INFO "Error while adding MMIO range of device to
mmio_ro_ranges\n");
- if ( pci_ro_device(uart->pci_device.seg, uart->pci_device.bus,
- uart->pci_device.devfn) )
+ if ( pci_ro_device(uart->pci_device) )
printk(XENLOG_INFO
"Could not mark config space of %pp read-only.\n",
&uart->pci_device);
diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
index c7fd554be0..3a8b086a93 100644
--- a/xen/drivers/char/xhci-dbc.c
+++ b/xen/drivers/char/xhci-dbc.c
@@ -1196,7 +1196,7 @@ static void __init cf_check dbc_uart_init_postirq(struct
serial_port *port)
switch ( uart->dbc.share )
{
case XHCI_SHARE_NONE:
- if ( pci_ro_device(0, uart->dbc.sbdf.bus, uart->dbc.sbdf.devfn) )
+ if ( pci_ro_device(uart->dbc.sbdf) )
printk(XENLOG_WARNING
"Failed to mark read-only %pp used for XHCI console\n",
&uart->dbc.sbdf);
@@ -1221,7 +1221,7 @@ static void __init cf_check dbc_uart_init_postirq(struct
serial_port *port)
"Error while marking MMIO range of XHCI console as R/O, "
"making the whole device R/O (share=no)\n");
uart->dbc.share = XHCI_SHARE_NONE;
- if ( pci_ro_device(0, uart->dbc.sbdf.bus, uart->dbc.sbdf.devfn) )
+ if ( pci_ro_device(uart->dbc.sbdf) )
printk(XENLOG_WARNING
"Failed to mark read-only %pp used for XHCI console\n",
&uart->dbc.sbdf);
diff --git a/xen/drivers/passthrough/amd/iommu_detect.c
b/xen/drivers/passthrough/amd/iommu_detect.c
index 94ee297424..df75d6fbc0 100644
--- a/xen/drivers/passthrough/amd/iommu_detect.c
+++ b/xen/drivers/passthrough/amd/iommu_detect.c
@@ -136,7 +136,6 @@ int __init amd_iommu_detect_one_acpi(
const struct acpi_ivrs_hardware *ivhd_block)
{
struct amd_iommu *iommu;
- u8 bus, dev, func;
int rt = 0;
if ( ivhd_block->header.length < sizeof(*ivhd_block) )
@@ -210,10 +209,6 @@ int __init amd_iommu_detect_one_acpi(
/* override IOMMU HT flags */
iommu->ht_flags = ivhd_block->header.flags;
- bus = PCI_BUS(iommu->sbdf.bdf);
- dev = PCI_SLOT(iommu->sbdf.bdf);
- func = PCI_FUNC(iommu->sbdf.bdf);
-
rt = get_iommu_capabilities(iommu->sbdf, iommu->cap_offset, iommu);
if ( rt )
goto out;
@@ -227,7 +222,7 @@ int __init amd_iommu_detect_one_acpi(
if ( !iommu->domid_map )
goto out;
- rt = pci_ro_device(iommu->sbdf.seg, bus, PCI_DEVFN(dev, func));
+ rt = pci_ro_device(iommu->sbdf);
if ( rt )
printk(XENLOG_ERR "Could not mark config space of %pp read-only
(%d)\n",
&iommu->sbdf, rt);
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index f222da8879..94a86d3639 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -499,14 +499,14 @@ int __init pci_hide_device(unsigned int seg, unsigned int
bus,
return rc;
}
-int __init pci_ro_device(int seg, int bus, int devfn)
+int __init pci_ro_device(pci_sbdf_t sbdf)
{
- struct pci_seg *pseg = alloc_pseg(seg);
+ struct pci_seg *pseg = alloc_pseg(sbdf.seg);
struct pci_dev *pdev;
if ( !pseg )
return -ENOMEM;
- pdev = alloc_pdev(pseg, bus, devfn);
+ pdev = alloc_pdev(pseg, sbdf.bus, sbdf.devfn);
if ( !pdev )
return -ENOMEM;
@@ -520,7 +520,7 @@ int __init pci_ro_device(int seg, int bus, int devfn)
memset(pseg->ro_map, 0, sz);
}
- __set_bit(PCI_BDF(bus, devfn), pseg->ro_map);
+ __set_bit(sbdf.bdf, pseg->ro_map);
_pci_hide_device(pdev);
return 0;
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index d816dcad05..bc59010cbe 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -232,7 +232,7 @@ const unsigned long *pci_get_ro_map(u16 seg);
int pci_add_device(u16 seg, u8 bus, u8 devfn,
const struct pci_dev_info *info, nodeid_t node);
int pci_remove_device(u16 seg, u8 bus, u8 devfn);
-int pci_ro_device(int seg, int bus, int devfn);
+int pci_ro_device(pci_sbdf_t sbdf);
int pci_hide_device(unsigned int seg, unsigned int bus, unsigned int devfn);
struct pci_dev *pci_get_pdev(const struct domain *d, pci_sbdf_t sbdf);
struct pci_dev *pci_get_real_pdev(pci_sbdf_t sbdf);
--
2.54.0
--
Teddy Astie | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |