From: Shmulik Ladkani <shmulik.ladkani@ravellosystems.com>
To: Marcel Apfelbaum <marcel@redhat.com>, mst@redhat.com
Cc: qemu-devel@nongnu.org, ehabkost@redhat.com, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH V5] hw/virtio: Add PCIe capability to virtio devices
Date: Tue, 1 Dec 2015 12:29:00 +0200 [thread overview]
Message-ID: <20151201122900.530ef562@pixies> (raw)
In-Reply-To: <1447155689-26230-1-git-send-email-marcel@redhat.com>
Hi,
On Tue, 10 Nov 2015 13:41:29 +0200, marcel@redhat.com wrote:
> The virtio devices are converted to PCI-Express
> if they are plugged into a PCI-Express bus and
> the 'modern' protocol is enabled.
>
> @@ -1592,6 +1592,26 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
>
> + if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE)
> + && !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN)
> + && pci_bus_is_express(pci_dev->bus)
> + && !pci_bus_is_root(pci_dev->bus)) {
> + int pos;
> +
> + pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
Setting QEMU_PCI_CAP_EXPRESS here in 'virtio_pci_realize' is too late.
This is since 'pci_qdev_realize' (DeviceClass.realize of TYPE_PCI_DEVICE)
is invoked prior the PCIDeviceClass's specific 'realize' method
(virtio_pci_realize in this case).
During 'pci_qdev_realize' (specifically, within do_pci_register_device),
the QEMU_PCI_CAP_EXPRESS gets tested indirectly, when pci_is_express
and pci_config_size helpers are called.
For example: 'pci_config_alloc' uses 'pci_config_size' which relies on
QEMU_PCI_CAP_EXPRESS property.
Since virtio_pci sets QEMU_PCI_CAP_EXPRESS *after* pci_qdev_realize
has finished, we end up having an insufficient pci config space
allocated for the virtio "pcie" device.
May I suggest the following:
- Expose 'pci_qdev_realize'
- Have 'virtio_pci_class_init' arm it's own dc->realize,
which will first set 'QEMU_PCI_CAP_EXPRESS' flag as needed,
and then call 'pci_qdev_realize'
- Now, in 'virtio_pci_realize' we may use 'pci_is_express' instead of
directly checking the proxy->flags
If this sounds ok, I'll submit a fix.
Regards,
Shmulik
next prev parent reply other threads:[~2015-12-01 10:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 11:41 [Qemu-devel] [PATCH V5] hw/virtio: Add PCIe capability to virtio devices Marcel Apfelbaum
2015-12-01 10:29 ` Shmulik Ladkani [this message]
2015-12-01 11:48 ` Marcel Apfelbaum
2015-12-01 13:18 ` Shmulik Ladkani
2015-12-01 14:01 ` Marcel Apfelbaum
2015-12-01 14:19 ` Shmulik Ladkani
2015-12-01 14:25 ` Marcel Apfelbaum
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=20151201122900.530ef562@pixies \
--to=shmulik.ladkani@ravellosystems.com \
--cc=ehabkost@redhat.com \
--cc=kraxel@redhat.com \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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.