Re: Associating nodes with phandles for pci devices

Chris Packham
2015-03-08T23:03:26Z

On 03/09/2015 11:42 AM, Arnd Bergmann wrote:
> On Sunday 08 March 2015 22:01:17 Chris Packham wrote:
>>
>>>
>>> BTW, one thing that is high in my TODO list regarding DSA is to stop
>>> using this platform device/driver architecture and use the actual device
>>> driver model. Your switch driver entry point would be a pci_drive
>>> probe's function where you end-up registering a switch the DSA. This
>>> should solve portions of your problem although this is a long shot as we
>>> need to convert existing drivers as well.
>>>
>>
>> My current problem is that of_find_device_by_node() (called by
>> dsa_of_probe) can't find the device. After a bit of debugging I can see
>> that the populated platform bus only goes as far as
>> /soc/pcie-controller, anything beyond that seems to be missing. I can't
>> see anything obvious in of_platform_bus_create() that would actually
>> stop it from continuing down the pcie-controller branch provided the dts
>> actually enumerates the children.
>>
>> Any suggestions?
>
> The PCI devices are not populated by of_platform_bus_create. Instead,
> pci_scan_device() calls pci_set_of_node() to set the of_node
> pointer for each PCI device.
>
> This would fail for instance if the root bus does not have a correct
> of_node pointer.
>

Hmm. I instrumented pci_set_of_node and I do see my 2 network devices.

devfn = 00000000
of_node = bfff3f90 /soc/pcie-controller/pcie@1,0/tg3@01,0

devfn = 00000001
of_node = bfff4118 /soc/pcie-controller/pcie@1,0/tg3@01,1

So at least that's happening. I guess the problem is that ultimately
they are devices on the pci bus as opposed to the platform bus and
of_find_device_by_node() only looks at the platform bus

dev = bus_find_device(&platform_bus_type, NULL, np, of_dev_node_match);

What I might have to do for now is get the DSA driver code to go looking
on the pci bus if of_find_device_by_node() fails to find the named node.
Florian mentioned making the DSA code use the device driver model which
would help me but I'm kinda stuck with the kernel version I'm using for
now at least.