qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH qemu] spapr_pci: Create assigned properties for bridges


From: David Gibson
Subject: Re: [PATCH qemu] spapr_pci: Create assigned properties for bridges
Date: Wed, 29 Jan 2020 14:37:12 +1100

On Wed, Jan 29, 2020 at 01:31:11PM +1100, Alexey Kardashevskiy wrote:
> QEMU assigns bus numbers so tell the guest about assigned values.
> 
> This also adds an empty "ranges" to let the existing linux kernels proceed
> far enough to trigger resource reassignment (which is rather a
> hack).

That is rather a hack, but AIUI this makes things better than they
were before, so I've applied it to ppc-for-5.0.

What would a less hacky approach to this look like?

> 
> Signed-off-by: Alexey Kardashevskiy <address@hidden>
> ---
> 
> This is a part of the "kill CAS reboot" effort, the SLOF's side of it was
> posted as "[PATCH slof] fdt: Fix creating new nodes at H_CAS"
> 
> ---
>  hw/ppc/spapr_pci.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index 723373de732c..877ff1d0d5fa 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -1336,7 +1336,23 @@ static int spapr_dt_pci_bus(SpaprPhbState *sphb, 
> PCIBus *bus,
>      if (pci_bus_is_root(bus)) {
>          owner = OBJECT(sphb);
>      } else {
> -        owner = OBJECT(pci_bridge_get_device(bus));
> +        PCIDevice *pdev = pci_bridge_get_device(bus);
> +        uint8_t pri = pci_default_read_config(pdev, PCI_PRIMARY_BUS, 1);
> +        uint8_t sec  = pci_default_read_config(pdev, PCI_SECONDARY_BUS, 1);
> +        uint8_t sub  = pci_default_read_config(pdev, PCI_SUBORDINATE_BUS, 1);
> +        uint32_t range[] = { cpu_to_be32(sec), cpu_to_be32(sub) };
> +
> +        /*
> +         * Create these to get existing Linux kernels proceed far enough to
> +         * trigger resource reassignment. We creates these for vPHB already.
> +         */
> +        _FDT(fdt_setprop_cell(fdt, offset, "primary-bus", pri));
> +        _FDT(fdt_setprop_cell(fdt, offset, "secondary-bus", sec));
> +        _FDT(fdt_setprop_cell(fdt, offset, "subordinate-bus", sub));
> +        _FDT(fdt_setprop(fdt, offset, "bus-range", range, sizeof(range)));
> +        _FDT(fdt_setprop_string(fdt, offset, "device_type", "pci"));
> +        _FDT(fdt_setprop(fdt, offset, "ranges", NULL, 0));
> +        owner = OBJECT(pdev);
>      }
>  
>      ret = spapr_dt_drc(fdt, offset, owner,

-- 
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

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]