diff mbox

[v4,14/17] spapr_pci: populate DRC dt entries for PHBs

Message ID 1419337831-16552-15-git-send-email-mdroth@linux.vnet.ibm.com
State New
Headers show

Commit Message

Michael Roth Dec. 23, 2014, 12:30 p.m. UTC
Reserve 32 entries of type PCI in each PHB's initial FDT. This
advertises to guests that each PHB is DR-capable device with
physical hotpluggable slots. This is necessary for allowing
hotplugging of devices to it later via bus rescan or guest rpaphp
hotplug module.

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 hw/ppc/spapr_pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

David Gibson Jan. 19, 2015, 5:22 a.m. UTC | #1
On Tue, Dec 23, 2014 at 06:30:28AM -0600, Michael Roth wrote:
> Reserve 32 entries of type PCI in each PHB's initial FDT. This
> advertises to guests that each PHB is DR-capable device with
> physical hotpluggable slots. This is necessary for allowing
> hotplugging of devices to it later via bus rescan or guest rpaphp
> hotplug module.
> 
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  hw/ppc/spapr_pci.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 73e86a4..a5d7791 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -47,6 +47,8 @@
>  #define RTAS_TYPE_MSI           1
>  #define RTAS_TYPE_MSIX          2
>  
> +#define FDT_MAX_SIZE            0x10000

This define doesn't appear to be used in the new code.

>  #include "hw/ppc/spapr_drc.h"
>  
>  static sPAPRPHBState *find_phb(sPAPREnvironment *spapr, uint64_t buid)
> @@ -872,7 +874,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
>                            uint32_t xics_phandle,
>                            void *fdt)
>  {
> -    int bus_off, i, j;
> +    int bus_off, i, j, ret;
>      char nodename[256];
>      uint32_t bus_range[] = { cpu_to_be32(0), cpu_to_be32(0xff) };
>      struct {
> @@ -951,6 +953,11 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
>      object_child_foreach(OBJECT(phb), spapr_phb_children_dt,
>                           &((sPAPRTCEDT){ .fdt = fdt, .node_off = bus_off }));
>  
> +    ret = spapr_drc_populate_dt(fdt, bus_off, SPAPR_DR_CONNECTOR_TYPE_PCI);

AFAICT this will add information for all PCI connectors in the
system.  Shouldn't it only add the ones belonging to this PHB?
Michael Roth Jan. 26, 2015, 8:44 p.m. UTC | #2
Quoting David Gibson (2015-01-18 23:22:54)
> On Tue, Dec 23, 2014 at 06:30:28AM -0600, Michael Roth wrote:
> > Reserve 32 entries of type PCI in each PHB's initial FDT. This
> > advertises to guests that each PHB is DR-capable device with
> > physical hotpluggable slots. This is necessary for allowing
> > hotplugging of devices to it later via bus rescan or guest rpaphp
> > hotplug module.
> > 
> > Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> > ---
> >  hw/ppc/spapr_pci.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> > index 73e86a4..a5d7791 100644
> > --- a/hw/ppc/spapr_pci.c
> > +++ b/hw/ppc/spapr_pci.c
> > @@ -47,6 +47,8 @@
> >  #define RTAS_TYPE_MSI           1
> >  #define RTAS_TYPE_MSIX          2
> >  
> > +#define FDT_MAX_SIZE            0x10000
> 
> This define doesn't appear to be used in the new code.
> 
> >  #include "hw/ppc/spapr_drc.h"
> >  
> >  static sPAPRPHBState *find_phb(sPAPREnvironment *spapr, uint64_t buid)
> > @@ -872,7 +874,7 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
> >                            uint32_t xics_phandle,
> >                            void *fdt)
> >  {
> > -    int bus_off, i, j;
> > +    int bus_off, i, j, ret;
> >      char nodename[256];
> >      uint32_t bus_range[] = { cpu_to_be32(0), cpu_to_be32(0xff) };
> >      struct {
> > @@ -951,6 +953,11 @@ int spapr_populate_pci_dt(sPAPRPHBState *phb,
> >      object_child_foreach(OBJECT(phb), spapr_phb_children_dt,
> >                           &((sPAPRTCEDT){ .fdt = fdt, .node_off = bus_off }));
> >  
> > +    ret = spapr_drc_populate_dt(fdt, bus_off, SPAPR_DR_CONNECTOR_TYPE_PCI);
> 
> AFAICT this will add information for all PCI connectors in the
> system.  Shouldn't it only add the ones belonging to this PHB?

Argh, yes indeed. Since we pass in the parent device during
spapr_dr_connector_new() I think I can simply have this pass in the parent PHB
we want to generate entries for as a filter. Will add this for v5 and do some
testing with multiple PHBs.

> 
> -- 
> David Gibson                    | I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
>                                 | _way_ _around_!
> http://www.ozlabs.org/~dgibson
diff mbox

Patch

diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 73e86a4..a5d7791 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -47,6 +47,8 @@ 
 #define RTAS_TYPE_MSI           1
 #define RTAS_TYPE_MSIX          2
 
+#define FDT_MAX_SIZE            0x10000
+
 #include "hw/ppc/spapr_drc.h"
 
 static sPAPRPHBState *find_phb(sPAPREnvironment *spapr, uint64_t buid)
@@ -872,7 +874,7 @@  int spapr_populate_pci_dt(sPAPRPHBState *phb,
                           uint32_t xics_phandle,
                           void *fdt)
 {
-    int bus_off, i, j;
+    int bus_off, i, j, ret;
     char nodename[256];
     uint32_t bus_range[] = { cpu_to_be32(0), cpu_to_be32(0xff) };
     struct {
@@ -951,6 +953,11 @@  int spapr_populate_pci_dt(sPAPRPHBState *phb,
     object_child_foreach(OBJECT(phb), spapr_phb_children_dt,
                          &((sPAPRTCEDT){ .fdt = fdt, .node_off = bus_off }));
 
+    ret = spapr_drc_populate_dt(fdt, bus_off, SPAPR_DR_CONNECTOR_TYPE_PCI);
+    if (ret) {
+        return ret;
+    }
+
     return 0;
 }