Re: [PATCH v9 3/4] drivers/perf: add DesignWare PCIe PMU driver

From: Shuai Xue
Date: Mon Oct 30 2023 - 06:29:54 EST




On 2023/10/30 14:28, Krishna Chaitanya Chundru wrote:
>
...
>> +
>> +static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)
>> +{
>> +    struct pci_dev *pdev = NULL;
>> +    struct dwc_pcie_pmu *pcie_pmu;
>> +    bool notify = false;
>> +    char *name;
>> +    u32 bdf;
>> +    int ret;
>> +
>> +    /* Match the rootport with VSEC_RAS_DES_ID, and register a PMU for it */
>> +    for_each_pci_dev(pdev) {
>> +        u16 vsec;
>> +        u32 val;
>> +
>> +        if (!(pci_is_pcie(pdev) &&
>> +              pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT))
>> +            continue;
>> +
>> +        vsec = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_ALIBABA,
>> +                        DWC_PCIE_VSEC_RAS_DES_ID);
>
> We are searching for ALIBABA vendor only  for this capability.
>
> Can we have a list of vendor ID's and we can check for all those vendors for this capability so that it will be easy to add new vendors in the list
>
> something like this
>
> struct vendor_ids {
>
> int vendor_id;
>
> };
>
> struct vendor_ids dwc_ids[] = {
>
>     {.vendor_id =PCI_VENDOR_ID_ALIBABA },
>
>      {.vendor_id = XXX},
>
> };
>
>     for_each_pci_dev(pdev) {
>         u16 vsec;
>         u32 val;
>
>         if (!(pci_is_pcie(pdev) &&
>               pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT))
>             continue;
>         for (int i = 0; i < num of elements of dwc_ids < i++) {
>             ---
>
>         }
>        
>         ---
>     }
>
> Thanks & Regards,
> Krishna Chaitanya.
>


Good idea, with vendor_ids, I think it will be easy to extend for other vendors in the future.

Thank you.

Best Regards,
Shuai