Patchwork [PATCHv3,1/4] pci_bridge: user-friendly default bus name

login
register
mail settings
Submitter Michael S. Tsirkin
Date Feb. 20, 2012, 10:52 p.m.
Message ID <57300b99e60a939c6b9c5c27066a4970f167dfc0.1329778092.git.mst@redhat.com>
Download mbox | patch
Permalink /patch/142201/
State New
Headers show

Comments

Michael S. Tsirkin - Feb. 20, 2012, 10:52 p.m.
For a pci bridge device, if we don't override
the name with custom code, the bus will be addressed as
<id>.0, where id is the id specified by the user.

Since PCI Bridge devices have a single bus each, we don't need
the index: address the bus using the parent device name.
This is better since this way users don't care about
our internal bus/device distinctions.

As far as I could see, we only have built-in
bridges at this point which always override the
name. So this change will only affect ioh3420.c.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci_bridge.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
Anthony Liguori - Feb. 22, 2012, 6:59 p.m.
On 02/20/2012 04:52 PM, Michael S. Tsirkin wrote:
> For a pci bridge device, if we don't override
> the name with custom code, the bus will be addressed as
> <id>.0, where id is the id specified by the user.
>
> Since PCI Bridge devices have a single bus each, we don't need
> the index: address the bus using the parent device name.
> This is better since this way users don't care about
> our internal bus/device distinctions.
>
> As far as I could see, we only have built-in
> bridges at this point which always override the
> name. So this change will only affect ioh3420.c.
>
> Signed-off-by: Michael S. Tsirkin<mst@redhat.com>

Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>

I think we're safe here from a compatibility perspective.

Regards,

Anthony Liguori

> ---
>   hw/pci_bridge.c |   10 ++++++++++
>   1 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c
> index fea3873..eeee8a6 100644
> --- a/hw/pci_bridge.c
> +++ b/hw/pci_bridge.c
> @@ -314,6 +314,16 @@ int pci_bridge_initfn(PCIDevice *dev)
>       pci_set_word(dev->config + PCI_SEC_STATUS,
>                    PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK);
>
> +    /*
> +     * If we don't specify the name, the bus will be addressed as<id>.0, where
> +     * id is the device id.
> +     * Since PCI Bridge devices have a single bus each, we don't need the index:
> +     * let users address the bus using the device name.
> +     */
> +    if (!br->bus_name&&  dev->qdev.id&&  *dev->qdev.id) {
> +	    br->bus_name = dev->qdev.id;
> +    }
> +
>       qbus_create_inplace(&sec_bus->qbus,&pci_bus_info,&dev->qdev,
>                           br->bus_name);
>       sec_bus->parent_dev = dev;

Patch

diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c
index fea3873..eeee8a6 100644
--- a/hw/pci_bridge.c
+++ b/hw/pci_bridge.c
@@ -314,6 +314,16 @@  int pci_bridge_initfn(PCIDevice *dev)
     pci_set_word(dev->config + PCI_SEC_STATUS,
                  PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK);
 
+    /*
+     * If we don't specify the name, the bus will be addressed as <id>.0, where
+     * id is the device id.
+     * Since PCI Bridge devices have a single bus each, we don't need the index:
+     * let users address the bus using the device name.
+     */
+    if (!br->bus_name && dev->qdev.id && *dev->qdev.id) {
+	    br->bus_name = dev->qdev.id;
+    }
+
     qbus_create_inplace(&sec_bus->qbus, &pci_bus_info, &dev->qdev,
                         br->bus_name);
     sec_bus->parent_dev = dev;