Re: [PATCH v2 1/2] perf/dwc_pcie: Avoid nested bus notifier locking

"Yicong Yang" <[email protected]>
Newsgroups org.kernel.vger.linux-perf-users,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 8/12/26 12:06 AM, Zhanpeng Zhang wrote:
> dwc_pcie_pmu_notifier() registers a synthetic platform device directly from
> the BUS_NOTIFY_ADD_DEVICE callback. Bus notifier callbacks run with the
> bus_notifier rwsem held, so platform_device_register_data() enters the
> platform bus notifier chain before the PCI bus notifier returns. When PCI
> host bridges are registered during late init, lockdep reports this as
> possible recursive locking.
> 
> Move platform device reconciliation to a work item that runs after the PCI
> notifier returns. Serialize it with PCI rescan and removal, and parent each
> synthetic device to its Root Port so their lifetimes remain coupled.
> 
> During removal, unregister the perf PMU and its CPU hotplug instance before
> PCI resources disappear, then defer only platform device destruction.
> Disable manual bind controls to preserve that ordering.
> 
> Fixes: af9597adc2f1 ("drivers/perf: add DesignWare PCIe PMU driver")
> Signed-off-by: Zhanpeng Zhang <[email protected]>

please attach the lockdep warning/trace in the commit for better
understanding the issue..

> ---
> Tested on a RISC-V system with CONFIG_KASAN, CONFIG_PROVE_LOCKING,
> CONFIG_DEBUG_LOCK_ALLOC and CONFIG_LOCKDEP enabled. Late-init PCI discovery
> no longer triggers the nested bus notifier warning.
> 
>  drivers/perf/dwc_pcie_pmu.c | 149 +++++++++++++++++++++++++++---------
>  1 file changed, 113 insertions(+), 36 deletions(-)
> 

[...]

>  
> @@ -815,7 +891,11 @@ static int dwc_pcie_pmu_offline_cpu(unsigned int cpu, struct hlist_node *cpuhp_n
>  
>  static struct platform_driver dwc_pcie_pmu_driver = {
>  	.probe = dwc_pcie_pmu_probe,
> -	.driver = {.name = "dwc_pcie_pmu",},
> +	.driver = {
> +		.name = "dwc_pcie_pmu",
> +		.probe_type = PROBE_FORCE_SYNCHRONOUS,

this looks irrelevant to the issue to resolve. need description here.

I suppose this issue is because both the PMU and the PCIe controller
are on the platform bus, right? If we switch the PMU to the faux device
interface [1] this could be solved?

thanks.

[1] https://lore.kernel.org/all/[email protected]/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.