All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: "Wuzongyong (Euler Dept)" <cordius.wu@huawei.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"libvir-list@redhat.com" <libvir-list@redhat.com>,
	"Chenhaiwu (Euler)" <chenhaiwu1@huawei.com>,
	"Wanzongshun (Vincent)" <wanzongshun@huawei.com>
Subject: Re: [Qemu-devel] The results of lspci are inconsistent between vfio reset pci devices and reset devices by sysfs interafce
Date: Tue, 9 Oct 2018 21:18:02 -0600	[thread overview]
Message-ID: <20181009211802.531df951@t450s.home> (raw)
In-Reply-To: <9BD73EA91F8E404F851CF3F519B14AA80180A6E0@DGGEMI521-MBX.china.huawei.com>

On Wed, 10 Oct 2018 01:47:10 +0000
"Wuzongyong (Euler Dept)" <cordius.wu@huawei.com> wrote:
> 
> You're right. The initial states are not identical.
> I found the function vfio_pci_pre_reset in qemu.
>     /*
>      * Stop any ongoing DMA by disconecting 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);
> 
> So the behaviors between the two reset are inconsistent.
> 
> Then I wonder whether the operation is necessary here?
> Could I enable the Memory bit in the Command register in vfio_pci_post_reset,
> because I want to write regions of PCI devices after reset.

One reset is done by the kernel to try to put the device into a known
clean state before allowing the user access to it, the other is done by
QEMU as part of the initial machine reset.  I suppose we could special
case the initial machine reset, but it seems perhaps risky and
unnecessary.

QEMU is the driver here, it can certainly enable MMIO on the device and
there are some examples in the QEMU code where MMIO is enabled to
interact with the device, see vfio_radeon_reset() for example.  The
device driver in the guest or the VM firmware should be the one to
enable the device for VM usage though, QEMU should provide the device
to the VM in a power-on default state, or as close as we can reasonably
get to that.  Thanks,

Alex

      reply	other threads:[~2018-10-10  3:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 12:11 [Qemu-devel] The results of lspci are inconsistent between vfio reset pci devices and reset devices by sysfs interafce Wuzongyong (Euler Dept)
2018-10-09 15:08 ` Alex Williamson
2018-10-10  1:26   ` Wuzongyong (Euler Dept)
2018-10-10  1:47   ` Wuzongyong (Euler Dept)
2018-10-10  3:18     ` Alex Williamson [this message]

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=20181009211802.531df951@t450s.home \
    --to=alex.williamson@redhat.com \
    --cc=chenhaiwu1@huawei.com \
    --cc=cordius.wu@huawei.com \
    --cc=libvir-list@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wanzongshun@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.