|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v5 9/9] vpci: don't pass command value to modify_bars()
Now that writing the command register is no longer deferred, there's no
need to pass the cmd value to modify_bars(). Replace it with a bool to
indicate map/unmap.
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
v4->v5:
* adapted from: ("vpci: allow BAR map/unmap without affecting memory
decoding bit")
* significant rework
v3->v4:
* rebase on dynamically allocated map queue
v2->v3:
* use bool
* switch to task->map in more places
v1->v2:
* new patch
---
xen/drivers/vpci/header.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 99ce67053068..187de3a12abb 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -324,7 +324,7 @@ static void defer_map(struct map_task *task)
raise_softirq(SCHEDULE_SOFTIRQ);
}
-static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
+static int modify_bars(const struct pci_dev *pdev, bool map, bool rom_only)
{
struct vpci_header *header = &pdev->vpci->header;
struct pci_dev *tmp;
@@ -337,7 +337,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t
cmd, bool rom_only)
ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
- task = alloc_map_task(pdev, cmd & PCI_COMMAND_MEMORY, rom_only);
+ task = alloc_map_task(pdev, map, rom_only);
if ( !task )
return -ENOMEM;
@@ -369,7 +369,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t
cmd, bool rom_only)
(rom_only ? bar->type != VPCI_BAR_ROM
: (bar->type == VPCI_BAR_ROM && !header->rom_enabled))
||
/* Skip BARs already in the requested state. */
- bar->enabled == !!(cmd & PCI_COMMAND_MEMORY) )
+ bar->enabled == map )
continue;
if ( !pci_check_bar(pdev, _mfn(start), _mfn(end)) )
@@ -409,8 +409,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t
cmd, bool rom_only)
goto fail;
}
- rc = xsm_iomem_mapping_vpci(XSM_HOOK, pdev->domain, start, end,
- !!(cmd & PCI_COMMAND_MEMORY));
+ rc = xsm_iomem_mapping_vpci(XSM_HOOK, pdev->domain, start, end, map);
if ( rc )
{
printk(XENLOG_G_WARNING
@@ -555,7 +554,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t
cmd, bool rom_only)
for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
{
if ( bar_valid[i] )
- header->bars[i].enabled = cmd & PCI_COMMAND_MEMORY;
+ header->bars[i].enabled = map;
}
if ( system_state < SYS_STATE_active )
@@ -568,7 +567,7 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t
cmd, bool rom_only)
* be called iff the memory decoding bit is enabled, thus the operation
* will always be to establish mappings and process all the BARs.
*/
- ASSERT((cmd & PCI_COMMAND_MEMORY) && !rom_only);
+ ASSERT(map && !rom_only);
rc = apply_map(task);
destroy_map_task(task);
return rc;
@@ -607,7 +606,7 @@ static void cf_check cmd_write(
* handled above and by the rsvdp_mask.
*/
if ( header->bars_mapped != new_enabled &&
- modify_bars(pdev, cmd, false) )
+ modify_bars(pdev, new_enabled, false) )
/*
* Ignore the error. No memory has been added or removed from the p2m
* (because the actual p2m changes are deferred in defer_map) and the
@@ -784,12 +783,8 @@ static void cf_check rom_write(
rom->guest_addr = rom->addr;
}
- /*
- * Pass PCI_COMMAND_MEMORY or 0 to signal a map/unmap request, note that
- * this fabricated command is never going to be written to the register.
- */
if ( header->bars_mapped && rom->enabled != new_enabled &&
- modify_bars(pdev, new_enabled ? PCI_COMMAND_MEMORY : 0, true) )
+ modify_bars(pdev, new_enabled, true) )
/*
* No memory has been added or removed from the p2m (because the actual
* p2m changes are deferred in defer_map) and the ROM enable bit has
@@ -988,7 +983,7 @@ int vpci_init_header(struct pci_dev *pdev)
pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
}
- return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, cmd, false) : 0;
+ return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, true, false) : 0;
fail:
pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
--
2.54.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |