Re: [PATCH] PCI: Speed up device init by parsing capabilities all at once
From: Vikash Bansal
Date: Sat Jan 22 2022 - 14:09:20 EST
In my earlier response, I agreed to few changes suggested by Greg.
I observed some issue while implementing 2 of those changes.
On 20/01/22, 11:01 PM, "Vikash Bansal" <bvikas@xxxxxxxxxx> wrote:
>>> + pci_bus_read_config_word(dev->bus, dev->devfn, pos, &ent);
>>> + id = ent & 0xff;
>>> + if (id == 0xff)
>>> + break;
>>> +
>>> + /* Read first instance of capability */
>>> + if (!(dev->cap_off[id]))
>>> + dev->cap_off[id] = pos;
>>
>>Shouldn't you have checked this before you read the value?
>>
>
>Yes, will move this code
>
Cannot be moved before read, because "id" used in this "if" conditions is
returned by last read.
>>> @@ -1128,6 +1129,7 @@ void pci_sort_breadthfirst(void);
>>>
>>> u8 pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
>>> u8 pci_find_capability(struct pci_dev *dev, int cap);
>>> +void pci_find_all_capabilities(struct pci_dev *dev);
>>
>>Why is this now a global function and not one just local to the pci
>>core? Who else would ever need to call it?
>
>Will make pci_find_all_capabilitie local and move it to probe.c
>
pci_find_all_capabilities function is called only once in probe.c file,
but this function is calling __pci_bus_find_cap_start which is defined in pci.c,
so need to implement this function in pci.c and make it global.
Thanks
Vikash