From: Eduardo Habkost <ehabkost@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: mst@redhat.com, marcel@redhat.com, qemu-devel@nongnu.org,
alex.williamson@redhat.com
Subject: Re: [Qemu-devel] [RFC 4/5] pci: Simplify pci_bus_is_root()
Date: Tue, 3 Oct 2017 11:42:59 -0300 [thread overview]
Message-ID: <20171003144259.GK17385@localhost.localdomain> (raw)
In-Reply-To: <20171003091423.28704-5-david@gibson.dropbear.id.au>
On Tue, Oct 03, 2017 at 08:14:22PM +1100, David Gibson wrote:
> pci_bus_is_root() currently relies on a method in the PCIBusClass.
> But it's always known if a PCI bus is a root bus when we create it, so
> using a dynamic method is overkill.
>
> This replaces it with an IS_ROOT bit in a new flags field, which is set on
> root buses and otherwise clear. As a bonus this removes the special
> is_root logic from pci_expander_bridge, since it already creates its bus
> as a root bus.
>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
>
> # Conflicts:
> # include/hw/pci/pci_bus.h
Should this be part of the commit message?
> ---
[...]
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 77d92a3dc4..cbb3386207 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -404,6 +404,11 @@ typedef AddressSpace *(*PCIIOMMUFunc)(PCIBus *, void *, int);
> #define PCI_BUS_GET_CLASS(obj) OBJECT_GET_CLASS(PCIBusClass, (obj), TYPE_PCI_BUS)
> #define TYPE_PCIE_BUS "PCIE"
>
> +enum PCIBusFlags {
> + /* This bus is the root of a PCI domain */
> + PCI_BUS_IS_ROOT = 0x0001,
> +};
> +
> typedef struct PCIBusClass {
> /*< private >*/
> BusClass parent_class;
> @@ -416,6 +421,7 @@ typedef struct PCIBusClass {
>
> struct PCIBus {
> BusState qbus;
> + enum PCIBusFlags flags;
Why not a simple boolean field? If we want to keep the struct
size smaller when adding more flags, we can use bit-fields.
> PCIIOMMUFunc iommu_fn;
> void *iommu_opaque;
> uint8_t devfn_min;
> @@ -440,8 +446,12 @@ struct PCIBus {
> Notifier machine_done;
> };
>
> +static inline bool pci_bus_is_root(PCIBus *bus)
> +{
> + return !!(bus->flags & PCI_BUS_IS_ROOT);
> +}
> +
> bool pci_bus_is_express(PCIBus *bus);
> -bool pci_bus_is_root(PCIBus *bus);
> void pci_root_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
> const char *name,
> MemoryRegion *address_space_mem,
> --
> 2.13.6
>
--
Eduardo
next prev parent reply other threads:[~2017-10-03 14:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-03 9:14 [Qemu-devel] [RFC 0/5] Assorted PCI/PCIe cleanups cleanups David Gibson
2017-10-03 9:14 ` [Qemu-devel] [RFC 1/5] pci: Rename root bus initialization functions for clarity David Gibson
2017-10-03 9:14 ` [Qemu-devel] [RFC 2/5] pci: Move bridge data structures from pci_bus.h to pci_bridge.h David Gibson
2017-10-03 9:14 ` [Qemu-devel] [RFC 3/5] pci: Fold pci_bus.h into pci.h David Gibson
2017-10-03 9:14 ` [Qemu-devel] [RFC 4/5] pci: Simplify pci_bus_is_root() David Gibson
2017-10-03 14:42 ` Eduardo Habkost [this message]
2017-10-04 6:03 ` David Gibson
2017-10-03 9:14 ` [Qemu-devel] [RFC 5/5] pcie: Don't allow extended config space access via conventional PCI bridges David Gibson
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=20171003144259.GK17385@localhost.localdomain \
--to=ehabkost@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--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 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).