From: Eric Auger <eric.auger@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>, qemu-devel@nongnu.org
Cc: eric.auger.pro@gmail.com, clg@redhat.com,
zhenzhong.duan@intel.com, mst@redhat.com,
marcel.apfelbaum@gmail.com
Subject: Re: [PATCH 5/5] hw/vfio/pci: Re-order pre-reset
Date: Mon, 24 Feb 2025 21:16:02 +0100 [thread overview]
Message-ID: <241a5dbe-1c22-4369-84af-8127a9ed9328@redhat.com> (raw)
In-Reply-To: <20250220224918.2520417-6-alex.williamson@redhat.com>
On 2/20/25 11:48 PM, Alex Williamson wrote:
> 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>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Eric
> ---
> hw/vfio/pci.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index ba4ef65b16fa..fcc5f118bf90 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2405,6 +2405,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;
> @@ -2424,15 +2433,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)
next prev parent reply other threads:[~2025-02-24 20:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 22:48 [PATCH 0/5] PCI: Implement basic PCI PM capability backing Alex Williamson
2025-02-20 22:48 ` [PATCH 1/5] hw/pci: Basic support for PCI power management Alex Williamson
2025-02-24 19:03 ` Eric Auger
2025-02-25 5:24 ` Alex Williamson
2025-02-25 9:45 ` Eric Auger
2025-02-20 22:48 ` [PATCH 2/5] pci: Use PCI PM capability initializer Alex Williamson
2025-02-24 18:37 ` Eric Auger
2025-02-24 19:03 ` Alex Williamson
2025-02-20 22:48 ` [PATCH 3/5] vfio/pci: Delete local pm_cap Alex Williamson
2025-02-24 18:38 ` Eric Auger
2025-02-20 22:48 ` [PATCH 4/5] pcie, virtio: Remove redundant pm_cap Alex Williamson
2025-02-21 6:12 ` Duan, Zhenzhong
2025-02-22 6:00 ` Cédric Le Goater
2025-02-24 1:45 ` Duan, Zhenzhong
2025-02-24 18:40 ` Eric Auger
2025-02-20 22:48 ` [PATCH 5/5] hw/vfio/pci: Re-order pre-reset Alex Williamson
2025-02-24 20:16 ` Eric Auger [this message]
2025-02-20 22:54 ` [PATCH 0/5] PCI: Implement basic PCI PM capability backing Michael S. Tsirkin
2025-02-24 8:21 ` Cédric Le Goater
2025-02-24 1:43 ` Duan, Zhenzhong
2025-02-24 8:14 ` Cédric Le Goater
2025-02-24 15:09 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=241a5dbe-1c22-4369-84af-8127a9ed9328@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhenzhong.duan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).