mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
vpci: const-ify some pdev instances
Since 622bdd9628 ("vpci/header: handle p2m range sets per BAR"), a
non-const pdev is no longer needed for error handling in
vpci_process_pending(). Const-ify pdev in vpci_process_pending(),
defer_map(), and struct vpci_vcpu.
Get rid of const-removal workaround in modify_bars().
Take the opportunity to remove an unused parameter in defer_map().
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
This commit is contained in:
1 parent
c9bd8b322e
commit
86198c5a18
2 files changed
+10
-21
No files matched your search
@@ -175,7 +175,7 @@ static void modify_decoding(const struct pci_dev *pdev, uint16_t cmd,
|
||||
|
||||
bool vpci_process_pending(struct vcpu *v)
|
||||
{
|
||||
struct pci_dev *pdev = v->vpci.pdev;
|
||||
const struct pci_dev *pdev = v->vpci.pdev;
|
||||
struct vpci_header *header = NULL;
|
||||
unsigned int i;
|
||||
|
||||
@@ -283,8 +283,7 @@ static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void defer_map(struct domain *d, struct pci_dev *pdev,
|
||||
uint16_t cmd, bool rom_only)
|
||||
static void defer_map(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
|
||||
{
|
||||
struct vcpu *curr = current;
|
||||
|
||||
@@ -308,7 +307,7 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
|
||||
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, *dev = NULL;
|
||||
struct pci_dev *tmp;
|
||||
const struct domain *d;
|
||||
const struct vpci_msix *msix = pdev->vpci->msix;
|
||||
unsigned int i, j;
|
||||
@@ -448,21 +447,13 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
|
||||
*/
|
||||
continue;
|
||||
|
||||
if ( tmp == pdev )
|
||||
{
|
||||
if ( tmp == pdev && !rom_only )
|
||||
/*
|
||||
* Need to store the device so it's not constified and defer_map
|
||||
* can modify it in case of error.
|
||||
* If memory decoding is toggled avoid checking against the
|
||||
* same device, or else all regions will be removed from the
|
||||
* memory map in the unmap case.
|
||||
*/
|
||||
dev = tmp;
|
||||
if ( !rom_only )
|
||||
/*
|
||||
* If memory decoding is toggled avoid checking against the
|
||||
* same device, or else all regions will be removed from the
|
||||
* memory map in the unmap case.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
for ( i = 0; i < ARRAY_SIZE(tmp->vpci->header.bars); i++ )
|
||||
{
|
||||
@@ -507,8 +498,6 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
|
||||
d = dom_xen;
|
||||
}
|
||||
|
||||
ASSERT(dev);
|
||||
|
||||
if ( system_state < SYS_STATE_active )
|
||||
{
|
||||
/*
|
||||
@@ -523,7 +512,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
|
||||
return apply_map(pdev->domain, pdev, cmd);
|
||||
}
|
||||
|
||||
defer_map(dev->domain, dev, cmd, rom_only);
|
||||
defer_map(pdev, cmd, rom_only);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ struct vpci {
|
||||
|
||||
struct vpci_vcpu {
|
||||
/* Per-vcpu structure to store state while {un}mapping of PCI BARs. */
|
||||
struct pci_dev *pdev;
|
||||
const struct pci_dev *pdev;
|
||||
uint16_t cmd;
|
||||
bool rom_only : 1;
|
||||
};
|
||||
|
||||