Commit a349ffc
iommu/vt-d: Fix recursive lock issue in iommu_flush_dev_iotlb()
The per domain spinlock is acquired in iommu_flush_dev_iotlb(), which
is possbile to be called in the interrupt context. For example, the
drm-intel's CI system got completely blocked with below error:
WARNING: inconsistent lock state
6.0.0-rc1-CI_DRM_11990-g6590d43d39b9+ #1 Not tainted
--------------------------------
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
swapper/6/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
ffff88810440d678 (&domain->lock){+.?.}-{2:2}, at: iommu_flush_dev_iotlb.part.61+0x23/0x80
{SOFTIRQ-ON-W} state was registered at:
lock_acquire+0xd3/0x310
_raw_spin_lock+0x2a/0x40
domain_update_iommu_cap+0x20b/0x2c0
intel_iommu_attach_device+0x5bd/0x860
__iommu_attach_device+0x18/0xe0
bus_iommu_probe+0x1f3/0x2d0
bus_set_iommu+0x82/0xd0
intel_iommu_init+0xe45/0x102a
pci_iommu_init+0x9/0x31
do_one_initcall+0x53/0x2f0
kernel_init_freeable+0x18f/0x1e1
kernel_init+0x11/0x120
ret_from_fork+0x1f/0x30
irq event stamp: 162354
hardirqs last enabled at (162354): [<ffffffff81b59274>] _raw_spin_unlock_irqrestore+0x54/0x70
hardirqs last disabled at (162353): [<ffffffff81b5901b>] _raw_spin_lock_irqsave+0x4b/0x50
softirqs last enabled at (162338): [<ffffffff81e00323>] __do_softirq+0x323/0x48e
softirqs last disabled at (162349): [<ffffffff810c1588>] irq_exit_rcu+0xb8/0xe0
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&domain->lock);
<Interrupt>
lock(&domain->lock);
*** DEADLOCK ***
1 lock held by swapper/6/0:
This coverts the spin_lock/unlock() into the irq save/restore varieties
to fix the recursive locking issues.
Fixes: ffd5869 ("iommu/vt-d: Replace spin_lock_irqsave() with spin_lock()")
Signed-off-by: Lu Baolu <[email protected]>
Acked-by: Lucas De Marchi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>1 parent 53fc7ad commit a349ffc
1 file changed
+23
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
| 518 | + | |
518 | 519 | | |
519 | | - | |
| 520 | + | |
520 | 521 | | |
521 | 522 | | |
522 | 523 | | |
| |||
528 | 529 | | |
529 | 530 | | |
530 | 531 | | |
531 | | - | |
| 532 | + | |
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
| |||
1362 | 1363 | | |
1363 | 1364 | | |
1364 | 1365 | | |
| 1366 | + | |
1365 | 1367 | | |
1366 | 1368 | | |
1367 | 1369 | | |
1368 | 1370 | | |
1369 | | - | |
| 1371 | + | |
1370 | 1372 | | |
1371 | 1373 | | |
1372 | 1374 | | |
1373 | | - | |
| 1375 | + | |
1374 | 1376 | | |
1375 | 1377 | | |
1376 | 1378 | | |
1377 | | - | |
| 1379 | + | |
1378 | 1380 | | |
1379 | 1381 | | |
1380 | 1382 | | |
| |||
1383 | 1385 | | |
1384 | 1386 | | |
1385 | 1387 | | |
| 1388 | + | |
1386 | 1389 | | |
1387 | | - | |
| 1390 | + | |
1388 | 1391 | | |
1389 | 1392 | | |
1390 | 1393 | | |
1391 | 1394 | | |
1392 | 1395 | | |
1393 | 1396 | | |
1394 | 1397 | | |
1395 | | - | |
| 1398 | + | |
1396 | 1399 | | |
1397 | 1400 | | |
1398 | 1401 | | |
| |||
1484 | 1487 | | |
1485 | 1488 | | |
1486 | 1489 | | |
| 1490 | + | |
1487 | 1491 | | |
1488 | 1492 | | |
1489 | 1493 | | |
1490 | 1494 | | |
1491 | | - | |
| 1495 | + | |
1492 | 1496 | | |
1493 | 1497 | | |
1494 | | - | |
| 1498 | + | |
1495 | 1499 | | |
1496 | 1500 | | |
1497 | 1501 | | |
| |||
2453 | 2457 | | |
2454 | 2458 | | |
2455 | 2459 | | |
| 2460 | + | |
2456 | 2461 | | |
2457 | 2462 | | |
2458 | 2463 | | |
| |||
2464 | 2469 | | |
2465 | 2470 | | |
2466 | 2471 | | |
2467 | | - | |
| 2472 | + | |
2468 | 2473 | | |
2469 | | - | |
| 2474 | + | |
2470 | 2475 | | |
2471 | 2476 | | |
2472 | 2477 | | |
| |||
4090 | 4095 | | |
4091 | 4096 | | |
4092 | 4097 | | |
| 4098 | + | |
4093 | 4099 | | |
4094 | 4100 | | |
4095 | 4101 | | |
| |||
4101 | 4107 | | |
4102 | 4108 | | |
4103 | 4109 | | |
4104 | | - | |
| 4110 | + | |
4105 | 4111 | | |
4106 | | - | |
| 4112 | + | |
4107 | 4113 | | |
4108 | 4114 | | |
4109 | 4115 | | |
| |||
4422 | 4428 | | |
4423 | 4429 | | |
4424 | 4430 | | |
| 4431 | + | |
4425 | 4432 | | |
4426 | 4433 | | |
4427 | 4434 | | |
4428 | 4435 | | |
4429 | | - | |
| 4436 | + | |
4430 | 4437 | | |
4431 | | - | |
| 4438 | + | |
4432 | 4439 | | |
4433 | 4440 | | |
4434 | 4441 | | |
4435 | 4442 | | |
4436 | 4443 | | |
4437 | | - | |
| 4444 | + | |
4438 | 4445 | | |
4439 | 4446 | | |
4440 | 4447 | | |
| |||
0 commit comments