qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Marcel Apfelbaum <marcel.a@redhat.com>
Cc: Marcel Apfelbaum <marcel@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH RFC] hw/virtio: Add PCIe capability to virtio devices
Date: Tue, 13 Oct 2015 17:47:22 +0300	[thread overview]
Message-ID: <20151013174558-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <CAC_L=vXxh+jDoMvbwi7BjwoHiMk=DgAwSbbs_ejpniNbh9WznA@mail.gmail.com>

On Tue, Oct 13, 2015 at 05:31:27PM +0300, Marcel Apfelbaum wrote:
> 
> 
> On Monday, October 12, 2015, Michael S. Tsirkin <mst@redhat.com> wrote:
> 
>     On Mon, Oct 12, 2015 at 06:17:54PM +0300, 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.
>     >
>     > Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
>     > ---
>     >
>     > This is an RFC because all it does it adds the PCIe capability and
>     nothing more.
> 
>     Express capability is easy.
>     But if you go over express space you will see that a bunch of
>     other capabilities are required, such as PM capability etc.
>     These might need more work.
> 
> 
> Sure, I'll look on the PCIe spec for the minimum requirements.
>  
> 
> 
>     > I post it early so I can get feedbacks on what is the best way to
>     continue it.
>     >
>     > Any comments would be appreciated,
>     > Thanks,
>     > Marcel
>     >
>     >  hw/virtio/virtio-pci.c | 11 +++++++++++
>     >  1 file changed, 11 insertions(+)
>     >
>     > diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
>     > index 6703806..f7c93d9 100644
>     > --- a/hw/virtio/virtio-pci.c
>     > +++ b/hw/virtio/virtio-pci.c
>     > @@ -1591,6 +1591,17 @@ 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_MODERN)
>     > +        && pci_bus_is_express(pci_dev->bus)) {
> 
>     One point: we probably want to avoid doing this for integrated
>     devices on root bus. Does pci_bus_is_express return true there?
> 
> 
> Hmm, I'll check, but I think it does. Is this a must? 

It's probably a smart thing to do because you can't e.g.
hot-unplug them. So supporting PCI E capability for
integrated devices is probably more work than just making
the PCI devices (which is not spec compliant but very popular
so guests support this).

> 
> 
>     > +        int pos = pci_add_capability(pci_dev, PCI_CAP_ID_EXP, 0,
>     > +                                     PCI_EXP_VER2_SIZEOF);
>     > +
>     > +        if (pos > 0) {
> 
>     We probably want to assert on pos < 0 instead.
>     That implies a code bug.
> 
> 
> 
> I was wondering what to do here, thanks for the idea!
> 
> Thanks,
> Marcel
> 
>  
> 
> 
>     > +            pci_dev->exp.exp_cap = pos;
>     > +            pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;
>     > +        }
>     > +    }
>     > +
>     >      virtio_pci_bus_new(&proxy->bus, sizeof(proxy->bus), proxy);
>     >      if (k->realize) {
>     >          k->realize(proxy, errp);
>     > --
>     > 2.1.0
> 
> 

  reply	other threads:[~2015-10-13 14:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 15:17 [Qemu-devel] [PATCH RFC] hw/virtio: Add PCIe capability to virtio devices Marcel Apfelbaum
2015-10-12 15:42 ` Michael S. Tsirkin
2015-10-13  8:13   ` Gerd Hoffmann
2015-10-13  8:44     ` Michael S. Tsirkin
2015-10-13 14:31   ` Marcel Apfelbaum
2015-10-13 14:47     ` Michael S. Tsirkin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-10-13  8:41 [Qemu-devel] [PATCH v3 0/2] PCI-e device multi-function hot-add support Cao jin
2015-10-13  8:41 ` [Qemu-devel] [PATCH v3 2/2] remove function during multi-function hot-add Cao jin
2015-10-13  8:48   ` [Qemu-devel] [PATCH RFC] hw/virtio: Add PCIe capability to virtio devices Michael S. Tsirkin
2015-10-13 12:19     ` Cao jin

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=20151013174558-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=marcel.a@redhat.com \
    --cc=marcel@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).