qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: qemu-devel@nongnu.org, ehabkost@redhat.com, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH V3] hw/virtio: Add PCIe capability to virtio devices
Date: Sun, 8 Nov 2015 20:13:19 +0200	[thread overview]
Message-ID: <563F90BF.6040603@redhat.com> (raw)
In-Reply-To: <20151108190623-mutt-send-email-mst@redhat.com>

On 11/08/2015 07:10 PM, Michael S. Tsirkin wrote:
> On Thu, Oct 29, 2015 at 01:56:28PM +0200, Marcel Apfelbaum wrote:
>> The virtio devices are converted to PCI-Express
>> if they are plugged into a PCI-Express bus and
>> the 'modern' protocol is enabled.
>>
>> Devices plugged directly into the Root Complex as
>> Integrated Endpoints remain PCI.
>>
>> Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>
>
> Looks ok. Two comments:
>
>> ---
>> v2 -> v3:
>>   - Addressed Michael S. Tsirkin's comments:
>>     - enable pcie only for 2.5+ machines.
>>
>> v1 -> v2:
>>   - Addressed Michael S. Tsirkin's comments:
>>     - Added the minimum required capabilities for PCIe devices
>>     - Integrated Endpoints remain PCI
>>
>>   - Use pcie_endpoint_cap_init instead of manually creating the pcie capability.
>>
>>   - Regarding Gerd Hoffman's comments:
>>     - Creating virtio-pcie devices:
>>       For the moment I prefer to not duplicate the virtio definitions,
>>       at least until we don't have a consensus (Personally I don't like it)
>>     - Removing the IO bar:
>>       This would be my next patch on the "virtio to express" series, I plan
>>       to remove it only for "modern" devices.
>>
>> Thanks,
>> Marcel
>>
>>   hw/virtio/virtio-pci.c | 22 ++++++++++++++++++++++
>>   hw/virtio/virtio-pci.h |  2 ++
>>   include/hw/compat.h    | 46 +++++++++++++++++++++++++++++++++++++++++++++-
>>   3 files changed, 69 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
>> index f55dd2b..a288d8b 100644
>> --- a/hw/virtio/virtio-pci.c
>> +++ b/hw/virtio/virtio-pci.c
>> @@ -1592,6 +1592,26 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
>>
>>       address_space_init(&proxy->modern_as, &proxy->modern_cfg, "virtio-pci-cfg-as");
>>
>> +    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;
>> +        pos = pcie_endpoint_cap_init(pci_dev, 0);
>> +        assert(pos > 0);
>> +
>> +        pos = pci_add_capability(pci_dev, PCI_CAP_ID_PM, 0, PCI_PM_SIZEOF);
>> +        assert(pos > 0);
>> +
>> +        /*
>> +         * Indicates that this function complies with revision 1.2 of the
>> +         * PCI Power Management Interface Specification.
>> +         */
>> +        pci_set_word(pci_dev->config + pos + PCI_PM_PMC, 0x3);
>> +    }
>> +
>>       virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy);
>>       if (k->realize) {
>>           k->realize(proxy, errp);
>> @@ -1622,6 +1642,8 @@ static Property virtio_pci_properties[] = {
>>                       VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT, false),
>>       DEFINE_PROP_BIT("disable-modern", VirtIOPCIProxy, flags,
>>                       VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT, true),
>> +    DEFINE_PROP_BIT("disable-pcie", VirtIOPCIProxy, flags,
>> +                    VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT, false),
>
> It's preferable to call this one x-disable-pcie - this
> is the convention to mark it as "not for user".

Sure, I'll change it.

>
>>       DEFINE_PROP_END_OF_LIST(),
>>   };
>>
>> diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
>> index 801c23a..1a487fc 100644
>> --- a/hw/virtio/virtio-pci.h
>> +++ b/hw/virtio/virtio-pci.h
>> @@ -72,8 +72,10 @@ typedef struct VirtioBusClass VirtioPCIBusClass;
>>   /* virtio version flags */
>>   #define VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT 2
>>   #define VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT 3
>> +#define VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT 4
>>   #define VIRTIO_PCI_FLAG_DISABLE_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT)
>>   #define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT)
>> +#define VIRTIO_PCI_FLAG_DISABLE_PCIE (1 << VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT)
>>
>>   typedef struct {
>>       MSIMessage msg;
>> diff --git a/include/hw/compat.h b/include/hw/compat.h
>> index 095de5d..0a08531 100644
>> --- a/include/hw/compat.h
>> +++ b/include/hw/compat.h
>> @@ -2,7 +2,51 @@
>>   #define HW_COMPAT_H
>>
>>   #define HW_COMPAT_2_4 \
>> -        /* empty */
>> +        {\
>> +            .driver   = "virtio-blk-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-scsi-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-net-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-input-host-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-keyboard-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-mouse-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-serial-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-tablet-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-gpu-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-balloon-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },{\
>> +            .driver   = "virtio-rng-pci",\
>> +            .property = "disable-pcie",\
>> +            .value    = "on",\
>> +        },
>
> Can't these properties be defined for type virtio-pci?
> If no - why not?

You are right, I changed this in V4:
https://patchwork.ozlabs.org/patch/538709/

Thanks,
Marcel

>
>>
>>   #define HW_COMPAT_2_3 \
>>           {\
>> --
>> 2.1.0

      reply	other threads:[~2015-11-08 18:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29 11:56 [Qemu-devel] [PATCH V3] hw/virtio: Add PCIe capability to virtio devices Marcel Apfelbaum
2015-10-30 15:20 ` Eduardo Habkost
2015-11-01  9:15   ` Marcel Apfelbaum
2015-11-02  9:07     ` Cornelia Huck
2015-11-02  9:20       ` Marcel Apfelbaum
2015-11-02  9:54         ` Cornelia Huck
2015-11-02 10:01           ` Marcel Apfelbaum
2015-11-02 12:05             ` Cornelia Huck
2015-11-02 12:12               ` Marcel Apfelbaum
2015-11-05 17:42                 ` Eduardo Habkost
2015-11-05 18:22                   ` Dr. David Alan Gilbert
2015-11-05 18:44                     ` Marcel Apfelbaum
2015-11-05 18:51                       ` Dr. David Alan Gilbert
2015-11-02  9:42 ` Greg Kurz
2015-11-02  9:53   ` Marcel Apfelbaum
2015-11-08 17:10 ` Michael S. Tsirkin
2015-11-08 18:13   ` Marcel Apfelbaum [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=563F90BF.6040603@redhat.com \
    --to=marcel@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kraxel@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 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).