> On 10 Mar 2026, at 1:51 PM, Nilay Shroff <[email protected]> wrote:
> 
> Commit a75b2be249d6 ("iommu: Add iommu_driver_get_domain_for_dev()
> helper") introduced iommu_driver_get_domain_for_dev() for driver
> code paths that hold iommu_group->mutex while attaching a device
> to an IOMMU domain.
> 
> The same commit also added a lockdep assertion in
> iommu_get_domain_for_dev() to ensure that callers do not hold
> iommu_group->mutex when invoking it.
> 
> On powerpc platforms, when PCI device ownership is switched from
> BLOCKED to the PLATFORM domain, the attach callback
> spapr_tce_platform_iommu_attach_dev() still calls
> iommu_get_domain_for_dev(). This happens while iommu_group->mutex
> is held during domain switching, which triggers the lockdep warning
> below during PCI enumeration:
> 
> WARNING: drivers/iommu/iommu.c:2252 at iommu_get_domain_for_dev+0x38/0x80, 
> CPU#2: swapper/0/1
> Modules linked in:
> CPU: 2 UID: 0 PID: 1 Comm: swapper/0 Not tainted 7.0.0-rc2+ #35 PREEMPT
> Hardware name: IBM,9105-22A Power11 (architected) 0x820200 0xf000007 
> of:IBM,FW1120.00 (RB1120_115) hv:phyp pSeries
> NIP:  c000000000c244c4 LR: c00000000005b5a4 CTR: c00000000005b578
> REGS: c00000000a7bf280 TRAP: 0700   Not tainted  (7.0.0-rc2+)
> MSR:  8000000002029033 <SF,VEC,EE,ME,IR,DR,RI,LE>  CR: 22004422  XER: 0000000a
> CFAR: c000000000c24508 IRQMASK: 0
> GPR00: c00000000005b5a4 c00000000a7bf520 c000000001dc8100 0000000000000001
> GPR04: c00000000f972f10 0000000000000000 0000000000000000 0000000000000001
> GPR08: 0000001ffbc60000 0000000000000001 0000000000000000 0000000000000000
> GPR12: c00000000005b578 c000001fffffe480 c000000000011618 0000000000000000
> GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
> GPR20: ffffffffffffefff 0000000000000000 c000000002d30eb0 0000000000000001
> GPR24: c0000000017881f8 0000000000000000 0000000000000001 c00000000f972e00
> GPR28: c00000000bbba0d0 0000000000000000 c00000000bbba0d0 c00000000f972e00
> NIP [c000000000c244c4] iommu_get_domain_for_dev+0x38/0x80
> LR [c00000000005b5a4] spapr_tce_platform_iommu_attach_dev+0x2c/0x98
> Call Trace:
> iommu_get_domain_for_dev+0x68/0x80 (unreliable)
> spapr_tce_platform_iommu_attach_dev+0x2c/0x98
> __iommu_attach_device+0x44/0x220
> __iommu_device_set_domain+0xf4/0x194
> __iommu_group_set_domain_internal+0xec/0x228
> iommu_setup_default_domain+0x5f4/0x6a4
> __iommu_probe_device+0x674/0x724
> iommu_probe_device+0x50/0xb4
> iommu_add_device+0x48/0x198
> pci_dma_dev_setup_pSeriesLP+0x198/0x4f0
> pcibios_bus_add_device+0x80/0x464
> pci_bus_add_device+0x40/0x100
> pci_bus_add_devices+0x54/0xb0
> pcibios_init+0xd8/0x140
> do_one_initcall+0x8c/0x598
> kernel_init_freeable+0x3ec/0x850
> kernel_init+0x34/0x270
> ret_from_kernel_user_thread+0x14/0x1c
> 
> Fix this by using iommu_driver_get_domain_for_dev() instead of
> iommu_get_domain_for_dev() in spapr_tce_platform_iommu_attach_dev(),
> which is the appropriate helper for callers holding the group mutex.
> 
> Cc: [email protected]
> Fixes: a75b2be249d6 ("iommu: Add iommu_driver_get_domain_for_dev() helper")
> Signed-off-by: Nilay Shroff <[email protected]>
> ---


Tested-by: Venkat Rao Bagalkote <[email protected]>

This patch fixes the reported issue. No warning is seen, during PICe init.

Logs:

[    0.107228] EDAC MC: Ver: 3.0.0
[    0.108270] NetLabel: Initializing
[    0.108274] NetLabel:  domain hash size = 128
[    0.108278] NetLabel:  protocols = UNLABELED CIPSOv4 CALIPSO
[    0.108307] NetLabel:  unlabeled traffic allowed by default
[    0.108362] PCI: Probing PCI hardware
[    0.108539] PCI host bridge to bus 0019:01
[    0.108545] pci_bus 0019:01: root bus resource [mem 
0x40080000000-0x400feffffff] (bus address [0x80000000-0xfeffffff])
[    0.108552] pci_bus 0019:01: root bus resource [mem 
0x44000000000-0x47fffffffff 64bit] (bus address 
[0x6204000000000-0x6207fffffffff])
[    0.108559] pci_bus 0019:01: root bus resource [bus 01-ff]
[    0.109223] pci 0019:01:00.0: No hypervisor support for SR-IOV on this 
device, IOV BARs disabled.
[    0.123390] IOMMU table initialized, virtual merging enabled
[    0.123522] pci_bus 0019:01: resource 4 [mem 0x40080000000-0x400feffffff]
[    0.123528] pci_bus 0019:01: resource 5 [mem 0x44000000000-0x47fffffffff 
64bit]
[    0.123589] pci 0019:01:00.0: ibm,query-pe-dma-windows(53) 10000 8000000 
20000019 returned 0, lb=1000000 ps=103 wn=1
[    0.123628] pci 0019:01:00.0: Adding to iommu group 0
[    0.136163] EEH: Capable adapter found: recovery enabled.
[    0.136393] vgaarb: loaded
[    0.136708] clocksource: Switched to clocksource timebase
[    0.139813] VFS: Disk quotas dquot_6.6.0
[    0.139895] VFS: Dquot-cache hash table entries: 8192 (order 0, 65536 bytes)
[    0.147370] NET: Registered PF_INET protocol family
[    0.147545] IP idents hash table entries: 262144 (order: 5, 2097152 bytes, 
linear)

Regards,
Venkat.
> arch/powerpc/kernel/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index 0ce71310b7d9..d122e8447831 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -1159,7 +1159,7 @@ spapr_tce_platform_iommu_attach_dev(struct iommu_domain 
> *platform_domain,
>    struct device *dev,
>    struct iommu_domain *old)
> {
> - struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
> + struct iommu_domain *domain = iommu_driver_get_domain_for_dev(dev);
> struct iommu_table_group *table_group;
> struct iommu_group *grp;
> 
> -- 
> 2.53.0
> 
> 


Reply via email to