qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-devel@nongnu.org, aliguori@amazon.com
Subject: Re: [Qemu-devel] [PATCH 3/4] hw:acpi:pcihp: assume root PCI bus if bus has no ACPI_PCIHP_PROP_BSEL property
Date: Mon, 27 Jan 2014 17:38:00 +0200	[thread overview]
Message-ID: <20140127153800.GC12689@redhat.com> (raw)
In-Reply-To: <20140127150112.7bce6d66@nial.usersys.redhat.com>

On Mon, Jan 27, 2014 at 03:01:12PM +0100, Igor Mammedov wrote:
> On Sun, 26 Jan 2014 12:02:23 +0200
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > On Tue, Jan 21, 2014 at 03:40:05PM +0100, Igor Mammedov wrote:
> > > when running with machine types older than 1.7 (i.e. without ACPI
> > > builtin tables), PCI bus won't have ACPI_PCIHP_PROP_BSEL property
> > > set.
> > > Taking in account that acpi hotplug handler in 1.7 and older
> > > machines is called only for root PCI bus, to make pcihp code
> > > compatible with legacy machine types assume that bus without
> > > ACPI_PCIHP_PROP_BSEL property has it equal to 0 and bail out
> > > if it's not root bus.
> > > 
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > 
> > I think that's not the best way to do this.
> > If bsel 0 *is* set on some bus, it should select it.
> > Fallback to bus 0 only if bsel value 0 is not set anywhere.
> > See e.g. how acpi_pcihp_find_hotplug_bus does it:
> > 
> >     if (!bsel && !find.bus) {
> >         find.bus = s->root;
> >     }
> > 
> > otherwise we introduce dependency on the logic that sets
> > bsel, this makes code fragile.
> Or to avoid touching PCIHP code, as an alternative
> we can add BSEL property to root bus and set it to 0 when
> running in compatibility mode (!use_acpi_pci_hotplug).

I didn't think too deeply about it, but on the surface
this seems fine too.

> > 
> > > ---
> > >  hw/acpi/pcihp.c |   10 +++-------
> > >  1 files changed, 3 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> > > index 6d34fe9..76dce8d 100644
> > > --- a/hw/acpi/pcihp.c
> > > +++ b/hw/acpi/pcihp.c
> > > @@ -63,14 +63,10 @@ static int acpi_pcihp_get_bsel(PCIBus *bus)
> > >  {
> > >      QObject *o = object_property_get_qobject(OBJECT(bus),
> > >                                               ACPI_PCIHP_PROP_BSEL, NULL);
> > > -    int64_t bsel = -1;
> > >      if (o) {
> > > -        bsel = qint_get_int(qobject_to_qint(o));
> > > +        return qint_get_int(qobject_to_qint(o));
> > >      }
> > > -    if (bsel < 0) {
> > > -        return -1;
> > > -    }
> > > -    return bsel;
> > > +    return 0;
> > >  }
> > >  
> > >  static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque)
> > > @@ -190,7 +186,7 @@ int acpi_pcihp_device_hotplug(AcpiPciHpState *s, PCIDevice *dev,
> > >  {
> > >      int slot = PCI_SLOT(dev->devfn);
> > >      int bsel = acpi_pcihp_get_bsel(dev->bus);
> > > -    if (bsel < 0) {
> > > +    if ((bsel == 0) && (dev->bus != s->root)) {
> > >          return -1;
> > >      }
> > >  
> > > -- 
> > > 1.7.1

  reply	other threads:[~2014-01-27 15:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 14:40 [Qemu-devel] [PATCH 0/4] pc: make ACPI pcihp more reusable Igor Mammedov
2014-01-21 14:40 ` [Qemu-devel] [PATCH 1/4] hw:piix4:acpi: replace enable|disable_device() with oneliners Igor Mammedov
2014-01-21 14:40 ` [Qemu-devel] [PATCH 2/4] hw:piix4:acpi: make PCI hotplug mmio handlers indifferent to PCI_HOTPLUG_ADDR Igor Mammedov
2014-01-21 14:40 ` [Qemu-devel] [PATCH 3/4] hw:acpi:pcihp: assume root PCI bus if bus has no ACPI_PCIHP_PROP_BSEL property Igor Mammedov
2014-01-26 10:02   ` Michael S. Tsirkin
2014-01-27 14:01     ` Igor Mammedov
2014-01-27 15:38       ` Michael S. Tsirkin [this message]
2014-01-21 14:40 ` [Qemu-devel] [PATCH 4/4] hw:piix4:acpi: reuse pcihp code for legacy PCI hotplug Igor Mammedov
2014-01-26 10:38   ` Michael S. Tsirkin

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=20140127153800.GC12689@redhat.com \
    --to=mst@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=imammedo@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).