* [PATCH] PCI: dwc: Initialize pp->lock before MSI domain registration
@ 2026-04-14 6:52 Yadu M G
2026-04-21 1:22 ` Shawn Lin
0 siblings, 1 reply; 3+ messages in thread
From: Yadu M G @ 2026-04-14 6:52 UTC (permalink / raw)
To: jingoohan1, mani
Cc: lpieralisi, kwilczynski, bhelgaas, robh, linux-pci, linux-kernel
A lockdep warning is observed during boot on a Qcom firmware managed
platform:
INFO: trying to register non-static key.
The code is fine but needs lockdep annotation, or maybe
you didn't initialize this object before use?
turning off the locking correctness validator.
...
Call trace:
register_lock_class+0x128/0x4d8
__lock_acquire+0x110/0x1db0
lock_acquire+0x278/0x3d8
_raw_spin_lock_irq+0x6c/0xc0
dw_pcie_irq_domain_alloc+0x48/0x190
irq_domain_alloc_irqs_parent+0x2c/0x48
msi_domain_alloc+0x90/0x160
...
dw_pcie_irq_domain_alloc() takes pp->lock while allocating MSI
interrupts. pp->lock was initialized in dw_pcie_host_init(). However,
some DWC glue drivers like those on Qcom firmware managed platforms
allocate MSI domains from their .msi_init callback by calling
dw_pcie_allocate_domains() directly, bypassing dw_pcie_host_init(). This
leaves pp->lock without a lockdep key and triggers the warning when MSI
vectors are later allocated.
Initialize pp->lock in dw_pcie_allocate_domains() immediately before
registering the MSI IRQ domain so the lock is always initialized for
every caller path.
Signed-off-by: Yadu M G <yadu.mg@oss.qualcomm.com>
---
drivers/pci/controller/dwc/pcie-designware-host.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index c9517a348836..8acd671bbc8c 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -215,6 +215,14 @@ int dw_pcie_allocate_domains(struct dw_pcie_rp *pp)
.host_data = pp,
};
+ /*
+ * Initialize the lock here rather than in dw_pcie_host_init() so that
+ * drivers using a custom msi_init() callback that call
+ * dw_pcie_allocate_domains() directly also have the lock properly
+ * initialized before dw_pcie_irq_domain_alloc() can be invoked.
+ */
+ raw_spin_lock_init(&pp->lock);
+
pp->irq_domain = msi_create_parent_irq_domain(&info, &dw_pcie_msi_parent_ops);
if (!pp->irq_domain) {
dev_err(pci->dev, "Failed to create IRQ domain\n");
@@ -573,8 +581,6 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
struct pci_host_bridge *bridge;
int ret;
- raw_spin_lock_init(&pp->lock);
-
bridge = devm_pci_alloc_host_bridge(dev, 0);
if (!bridge)
return -ENOMEM;
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: dwc: Initialize pp->lock before MSI domain registration
2026-04-14 6:52 [PATCH] PCI: dwc: Initialize pp->lock before MSI domain registration Yadu M G
@ 2026-04-21 1:22 ` Shawn Lin
2026-04-23 13:45 ` Yadu M G
0 siblings, 1 reply; 3+ messages in thread
From: Shawn Lin @ 2026-04-21 1:22 UTC (permalink / raw)
To: Yadu M G, jingoohan1, mani
Cc: shawn.lin, lpieralisi, kwilczynski, bhelgaas, robh, linux-pci,
linux-kernel
在 2026/04/14 星期二 14:52, Yadu M G 写道:
> A lockdep warning is observed during boot on a Qcom firmware managed
> platform:
>
> INFO: trying to register non-static key.
> The code is fine but needs lockdep annotation, or maybe
> you didn't initialize this object before use?
> turning off the locking correctness validator.
> ...
> Call trace:
> register_lock_class+0x128/0x4d8
> __lock_acquire+0x110/0x1db0
> lock_acquire+0x278/0x3d8
> _raw_spin_lock_irq+0x6c/0xc0
> dw_pcie_irq_domain_alloc+0x48/0x190
> irq_domain_alloc_irqs_parent+0x2c/0x48
> msi_domain_alloc+0x90/0x160
> ...
>
> dw_pcie_irq_domain_alloc() takes pp->lock while allocating MSI
> interrupts. pp->lock was initialized in dw_pcie_host_init(). However,
> some DWC glue drivers like those on Qcom firmware managed platforms
> allocate MSI domains from their .msi_init callback by calling
> dw_pcie_allocate_domains() directly, bypassing dw_pcie_host_init(). This
> leaves pp->lock without a lockdep key and triggers the warning when MSI
> vectors are later allocated.
>
> Initialize pp->lock in dw_pcie_allocate_domains() immediately before
> registering the MSI IRQ domain so the lock is always initialized for
> every caller path.
>
If pci_msi_enabled()returns false in dw_pcie_host_init()(e.g., via the
pci=nomsi), the call to dw_pcie_allocate_domains() is skipped entirely,
leaving pp‑>lock uninitialized. Since the same lock is also used to
protect legacy INTx interrupts in some glue drivers (pcie‑sophgo.c or
pcie‑uniphier.c), could those drivers attempt to acquire an
uninitialized lock when unmasking or handling INTx interrupts? If so, we
would need to ensure the lock is initialized regardless of the MSI
enable state.
Moreover, sophgo_pcie_host_init() calls sophgo_pcie_msi_enable() which
need to acquires pp->lock with a uninitialized lock with your patch now.
That could possible break all other variant drivers which need this lock
in the .init() callback.
> Signed-off-by: Yadu M G <yadu.mg@oss.qualcomm.com>
> ---
> drivers/pci/controller/dwc/pcie-designware-host.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index c9517a348836..8acd671bbc8c 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -215,6 +215,14 @@ int dw_pcie_allocate_domains(struct dw_pcie_rp *pp)
> .host_data = pp,
> };
>
> + /*
> + * Initialize the lock here rather than in dw_pcie_host_init() so that
> + * drivers using a custom msi_init() callback that call
> + * dw_pcie_allocate_domains() directly also have the lock properly
> + * initialized before dw_pcie_irq_domain_alloc() can be invoked.
> + */
> + raw_spin_lock_init(&pp->lock);
> +
> pp->irq_domain = msi_create_parent_irq_domain(&info, &dw_pcie_msi_parent_ops);
> if (!pp->irq_domain) {
> dev_err(pci->dev, "Failed to create IRQ domain\n");
> @@ -573,8 +581,6 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
> struct pci_host_bridge *bridge;
> int ret;
>
> - raw_spin_lock_init(&pp->lock);
> -
> bridge = devm_pci_alloc_host_bridge(dev, 0);
> if (!bridge)
> return -ENOMEM;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: dwc: Initialize pp->lock before MSI domain registration
2026-04-21 1:22 ` Shawn Lin
@ 2026-04-23 13:45 ` Yadu M G
0 siblings, 0 replies; 3+ messages in thread
From: Yadu M G @ 2026-04-23 13:45 UTC (permalink / raw)
To: Shawn Lin, jingoohan1, mani
Cc: lpieralisi, kwilczynski, bhelgaas, robh, linux-pci, linux-kernel
On 4/21/2026 6:52 AM, Shawn Lin wrote:
> Moreover, sophgo_pcie_host_init() calls sophgo_pcie_msi_enable() which
> need to acquires pp->lock with a uninitialized lock with your patch now.
> That could possible break all other variant drivers which need this lock
> in the .init() callback.
>
Agreed — pp->lock must be initialized even when MSI is disabled.
I'll keep the init in dw_pcie_host_init() and add a one-time init in
dw_pcie_allocate_domains() for direct callers, then resend.
Thanks,
Yadu
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-23 13:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-14 6:52 [PATCH] PCI: dwc: Initialize pp->lock before MSI domain registration Yadu M G
2026-04-21 1:22 ` Shawn Lin
2026-04-23 13:45 ` Yadu M G
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®