[PATCH v4] powerpc/pci: Assign fixed PHB number based on device-tree properties
    Ian Munsie 
    imunsie at au1.ibm.com
       
    Thu Apr  7 05:38:55 AEST 2016
    
    
  
Excerpts from Guilherme G. Piccoli's message of 2016-03-18 16:49:06 -0500:
> +static int get_phb_number(struct device_node *dn)
...
> +    /* try fixed PHB numbering first, by checking archs and reading
> +     * the respective device-tree property. */
> +    if (machine_is(pseries)) {
> +        regs = of_get_property(dn, "reg", NULL);
> +        if (regs)
> +            return (int)(be32_to_cpu(regs[1]) & 0xFFFF);
> +    } else if (machine_is(powernv)) {
> +        prop64 = of_get_property(dn, "ibm,opal-phbid", NULL);
> +        if (prop64)
> +            return (int)(be64_to_cpup(prop64) & 0xFFFF);
> +    }
I think these cases should still set the bit in phb_bitmap, otherwise a
virtual PHB (e.g. as used in cxl/cxlflash) will be assigned PHB 0, and
since that is already taken it will fail - we're already seeing a
failure in Ubuntu Xenial since Canonical picked this patch up already
(though have not confirmed that this is definitely the cause yet).
There might also be some interesting races to think about here if a
virtual PHB grabs a PHB number before the real one gets a chance.
> +
> +    /* if not pSeries nor PowerNV, fallback to dynamic PHB numbering */
> +    phb_id = find_first_zero_bit(phb_bitmap, MAX_PHBS);
> +    BUG_ON(phb_id >= MAX_PHBS); /* reached maximum number of PHBs */
> +    set_bit(phb_id, phb_bitmap);
-Ian
    
    
More information about the Linuxppc-dev
mailing list