[PATCHv4 1/2] ppc64: perform proper max_bus_speed detection

Kleber Sacilotto de Souza klebers at linux.vnet.ibm.com
Thu May 2 08:21:37 PDT 2013


On 04/25/2013 02:34 PM, Lucas Kannebley Tavares wrote:
> On 04/24/2013 08:48 PM, Tony Breeds wrote:
>>> diff --git a/arch/powerpc/platforms/pseries/pci.c
>>> b/arch/powerpc/platforms/pseries/pci.c
>>> index 0b580f4..7f9c956 100644
>>> --- a/arch/powerpc/platforms/pseries/pci.c
>>> +++ b/arch/powerpc/platforms/pseries/pci.c
>>> @@ -108,3 +108,54 @@ static void fixup_winbond_82c105(struct pci_dev*
>>> dev)
>>>   }
>>>   DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_WINBOND,
>>> PCI_DEVICE_ID_WINBOND_82C105,
>>>                fixup_winbond_82c105);
>>> +
>>> +int pseries_root_bridge_prepare(struct pci_host_bridge *bridge)
>>> +{
>>> +    struct device_node *dn, *pdn;
>>> +    struct pci_bus *bus;
>>> +    const uint32_t *pcie_link_speed_stats;
>>> +
>>> +    bus = bridge->bus;
>>> +
>>> +    dn = pcibios_get_phb_of_node(bus);
>>> +    if (!dn)
>>> +        return 0;
>>> +
>>> +    for (pdn = dn; pdn != NULL; pdn = pdn->parent) {
>>> +        pcie_link_speed_stats = (const uint32_t *) of_get_property(dn,
>>> +            "ibm,pcie-link-speed-stats", NULL);
>>> +        if (pcie_link_speed_stats)
>>> +            break;
>>> +    }
>>
>> Please use the helpers in include/linux/of.h rather than open coding
>> this.
>>
>> Yours Tony
> 
> 
> Hi Tony,
> 
> 
> This is what I can find as an equivalent code:
> 
>     for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
>         pcie_link_speed_stats = (const uint32_t *)
>             of_get_property(dn,
>                 "ibm,pcie-link-speed-stats", NULL);
>         if (pcie_link_speed_stats)
>             break;
>     }
> 
> is this your suggestion, or was it another approach that will have the
> same result?
> 
> Thanks,
> 

Hi Tony,

It seems Lucas' change is a bit incomplete and is not handling the reference counter to
the device_node correctly. Is the following change what you had in mind?


	dn = pcibios_get_phb_of_node(bus);
	if (!dn)
		return 0;

	for (pdn = dn; pdn != NULL; pdn = of_get_next_parent(pdn)) {
		pcie_link_speed_stats = (const uint32_t *) of_get_property(pdn,
			"ibm,pcie-link-speed-stats", NULL);
		if (pcie_link_speed_stats)
			break;
	}

	of_node_put(pdn);


Thanks,

-- 
Kleber Sacilotto de Souza
IBM Linux Technology Center



More information about the dri-devel mailing list