Skip to content

Commit e669388

Browse files
Krishna chaitanya chundruwilldeacon
authored andcommitted
perf/dwc_pcie: Fix registration issue in multi PCIe controller instances
When there are multiple of instances of PCIe controllers, registration to perf driver fails with this error. sysfs: cannot create duplicate filename '/devices/platform/dwc_pcie_pmu.0' CPU: 0 PID: 166 Comm: modprobe Not tainted 6.10.0-rc2-next-20240607-dirty Hardware name: Qualcomm SA8775P Ride (DT) Call trace: dump_backtrace.part.8+0x98/0xf0 show_stack+0x14/0x1c dump_stack_lvl+0x74/0x88 dump_stack+0x14/0x1c sysfs_warn_dup+0x60/0x78 sysfs_create_dir_ns+0xe8/0x100 kobject_add_internal+0x94/0x224 kobject_add+0xa8/0x118 device_add+0x298/0x7b4 platform_device_add+0x1a0/0x228 platform_device_register_full+0x11c/0x148 dwc_pcie_register_dev+0x74/0xf0 [dwc_pcie_pmu] dwc_pcie_pmu_init+0x7c/0x1000 [dwc_pcie_pmu] do_one_initcall+0x58/0x1c0 do_init_module+0x58/0x208 load_module+0x1804/0x188c __do_sys_init_module+0x18c/0x1f0 __arm64_sys_init_module+0x14/0x1c invoke_syscall+0x40/0xf8 el0_svc_common.constprop.1+0x70/0xf4 do_el0_svc+0x18/0x20 el0_svc+0x28/0xb0 el0t_64_sync_handler+0x9c/0xc0 el0t_64_sync+0x160/0x164 kobject: kobject_add_internal failed for dwc_pcie_pmu.0 with -EEXIST, don't try to register things with the same name in the same directory. This is because of having same bdf value for devices under two different controllers. Update the logic to use sbdf which is a unique number in case of multi instance also. Fixes: af9597a ("drivers/perf: add DesignWare PCIe PMU driver") Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com> Reviewed-by: Yicong Yang <yangyicong@hisilicon.com> Link: https://lore.kernel.org/r/20240816-dwc_pmu_fix-v2-1-198b8ab1077c@quicinc.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent a3dd920 commit e669388

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

drivers/perf/dwc_pcie_pmu.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,10 @@ static int dwc_pcie_register_dev(struct pci_dev *pdev)
556556
{
557557
struct platform_device *plat_dev;
558558
struct dwc_pcie_dev_info *dev_info;
559-
u32 bdf;
559+
u32 sbdf;
560560

561-
bdf = PCI_DEVID(pdev->bus->number, pdev->devfn);
562-
plat_dev = platform_device_register_data(NULL, "dwc_pcie_pmu", bdf,
561+
sbdf = (pci_domain_nr(pdev->bus) << 16) | PCI_DEVID(pdev->bus->number, pdev->devfn);
562+
plat_dev = platform_device_register_data(NULL, "dwc_pcie_pmu", sbdf,
563563
pdev, sizeof(*pdev));
564564

565565
if (IS_ERR(plat_dev))
@@ -611,15 +611,15 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)
611611
struct pci_dev *pdev = plat_dev->dev.platform_data;
612612
struct dwc_pcie_pmu *pcie_pmu;
613613
char *name;
614-
u32 bdf, val;
614+
u32 sbdf, val;
615615
u16 vsec;
616616
int ret;
617617

618618
vsec = pci_find_vsec_capability(pdev, pdev->vendor,
619619
DWC_PCIE_VSEC_RAS_DES_ID);
620620
pci_read_config_dword(pdev, vsec + PCI_VNDR_HEADER, &val);
621-
bdf = PCI_DEVID(pdev->bus->number, pdev->devfn);
622-
name = devm_kasprintf(&plat_dev->dev, GFP_KERNEL, "dwc_rootport_%x", bdf);
621+
sbdf = plat_dev->id;
622+
name = devm_kasprintf(&plat_dev->dev, GFP_KERNEL, "dwc_rootport_%x", sbdf);
623623
if (!name)
624624
return -ENOMEM;
625625

@@ -650,7 +650,7 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)
650650
ret = cpuhp_state_add_instance(dwc_pcie_pmu_hp_state,
651651
&pcie_pmu->cpuhp_node);
652652
if (ret) {
653-
pci_err(pdev, "Error %d registering hotplug @%x\n", ret, bdf);
653+
pci_err(pdev, "Error %d registering hotplug @%x\n", ret, sbdf);
654654
return ret;
655655
}
656656

@@ -663,7 +663,7 @@ static int dwc_pcie_pmu_probe(struct platform_device *plat_dev)
663663

664664
ret = perf_pmu_register(&pcie_pmu->pmu, name, -1);
665665
if (ret) {
666-
pci_err(pdev, "Error %d registering PMU @%x\n", ret, bdf);
666+
pci_err(pdev, "Error %d registering PMU @%x\n", ret, sbdf);
667667
return ret;
668668
}
669669
ret = devm_add_action_or_reset(&plat_dev->dev, dwc_pcie_unregister_pmu,

0 commit comments

Comments
 (0)