mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 09:43:56 -06:00
hw/vfio/pci: Re-order pre-reset
We want the device in the D0 power state going into reset, but the config write can enable the BARs in the address space, which are then removed from the address space once we clear the memory enable bit in the command register. Re-order to clear the command bit first, so the power state change doesn't enable the BARs. Cc: Cédric Le Goater <clg@redhat.com> Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Link: https://lore.kernel.org/qemu-devel/20250225215237.3314011-6-alex.williamson@redhat.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
8b8d08cf29
commit
518a69a598
1 changed files with 9 additions and 9 deletions
|
@ -2410,6 +2410,15 @@ void vfio_pci_pre_reset(VFIOPCIDevice *vdev)
|
|||
|
||||
vfio_disable_interrupts(vdev);
|
||||
|
||||
/*
|
||||
* Stop any ongoing DMA by disconnecting I/O, MMIO, and bus master.
|
||||
* Also put INTx Disable in known state.
|
||||
*/
|
||||
cmd = vfio_pci_read_config(pdev, PCI_COMMAND, 2);
|
||||
cmd &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
|
||||
PCI_COMMAND_INTX_DISABLE);
|
||||
vfio_pci_write_config(pdev, PCI_COMMAND, cmd, 2);
|
||||
|
||||
/* Make sure the device is in D0 */
|
||||
if (pdev->pm_cap) {
|
||||
uint16_t pmcsr;
|
||||
|
@ -2429,15 +2438,6 @@ void vfio_pci_pre_reset(VFIOPCIDevice *vdev)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop any ongoing DMA by disconnecting I/O, MMIO, and bus master.
|
||||
* Also put INTx Disable in known state.
|
||||
*/
|
||||
cmd = vfio_pci_read_config(pdev, PCI_COMMAND, 2);
|
||||
cmd &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
|
||||
PCI_COMMAND_INTX_DISABLE);
|
||||
vfio_pci_write_config(pdev, PCI_COMMAND, cmd, 2);
|
||||
}
|
||||
|
||||
void vfio_pci_post_reset(VFIOPCIDevice *vdev)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue