[U-Boot] [PATCH 4/5] x86: Explicitly trigger pci bus configuration with driver model

Simon Glass sjg at chromium.org
Thu Aug 6 04:52:58 CEST 2015


Hi Bin,

On 5 August 2015 at 20:41, Bin Meng <bmeng.cn at gmail.com> wrote:
> Hi Simon,
>
> On Thu, Aug 6, 2015 at 10:36 AM, Simon Glass <sjg at chromium.org> wrote:
>> Hi Bin,
>>
>> On 5 August 2015 at 20:22, Bin Meng <bmeng.cn at gmail.com> wrote:
>>> Hi Simon,
>>>
>>> On Wed, Aug 5, 2015 at 10:40 PM, Simon Glass <sjg at chromium.org> wrote:
>>>> Hi Bin,
>>>>
>>>> On 2 August 2015 at 19:54, Bin Meng <bmeng.cn at gmail.com> wrote:
>>>>> Hi Simon,
>>>>>
>>>>> On Mon, Aug 3, 2015 at 6:31 AM, Simon Glass <sjg at chromium.org> wrote:
>>>>>> Hi Bin,
>>>>>>
>>>>>> On 27 July 2015 at 01:33, Bin Meng <bmeng.cn at gmail.com> wrote:
>>>>>>> With driver model, probing pci bus is all done on a lazy basis,
>>>>>>> as needed. On x86, pci bus is the fundamental device that needs
>>>>>>> to work before any other peripherals. In order to have a working
>>>>>>> pci before any other pci devices can be initialized, we need
>>>>>>> explicitly trigger the pci bus configuration.
>>>>>>>
>>>>>>> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
>>>>>>> ---
>>>>>>>
>>>>>>>  common/board_r.c | 16 ++++++++++++++++
>>>>>>>  1 file changed, 16 insertions(+)
>>>>>>>
>>>>>>> diff --git a/common/board_r.c b/common/board_r.c
>>>>>>> index bf6c725..4263e47 100644
>>>>>>> --- a/common/board_r.c
>>>>>>> +++ b/common/board_r.c
>>>>>>> @@ -233,6 +233,22 @@ static int initr_pci(void)
>>>>>>>  {
>>>>>>>  #ifndef CONFIG_DM_PCI
>>>>>>>         pci_init();
>>>>>>> +#else
>>>>>>> +#ifdef CONFIG_X86
>>>>>>> +       /*
>>>>>>> +        * With driver model, probing pci bus is all done on a lazy basis,
>>>>>>> +        * as needed. On x86, pci bus is the fundamental device that needs
>>>>>>> +        * to work before any other peripherals. In order to have a working
>>>>>>> +        * pci before any other pci devices can be initialized, we need
>>>>>>> +        * explicitly trigger the pci bus configuration.
>>>>>>> +        */
>>>>>>> +       struct udevice *dev;
>>>>>>> +       int ret;
>>>>>>> +
>>>>>>> +       ret = uclass_first_device(UCLASS_PCI, &dev);
>>>>>>> +       if (ret)
>>>>>>> +               return ret;
>>>>>>
>>>>>> Won't this happen anyway when you first access a PCI device?
>>>>>>
>>>>>
>>>>> Unfortunately no. The pci bus configuration will not be triggered when
>>>>> calling pci config read/write.
>>>>>
>>>>> [snip]
>>>>
>>>> We should be able to use the dm_pci_config..() functions and by just
>>>> getting hold of the bus device it should probe the bus before doing
>>>> any config. Then it would be auto-triggered.
>>>
>>> So far I don't see any config r/w routines can trigger the enumeration.
>>>
>>>>
>>>> In general we should try to make use of automatic probing - it was
>>>> supposed to be a key feature of driver model.
>>>>
>>>
>>> Yep I know this is supposed to be done this way. I am not sure how it
>>> looks like on other domain, but at least it is now broken for dm pci.
>>> In order to get the enumeration process automatically triggered, we
>>> need make sure all public pci apis will end up triggering the
>>> configuration.
>>
>> Provided that we always call uclass_get_device() or any of those
>> *_get_* functions then the bus will be probed and thus enumerated.
>>
>
> Yes.
>
>> The problem is that we have these sideways functions to accessing PCI
>> on x86. Once we get rid of those then we should be OK. Everything
>> should use a struct udevice.
>>
>
> Do you plan to fix this or is there already a patch that I missed?

Not really. I am thinking that we should try to use the dm_pci
functions but until we get into it I'm not sure how easy it is.

Regards,
Simon


More information about the U-Boot mailing list