Commit 79175b6
platform/x86: ISST: Fix possible circular locking dependency detected
[ Upstream commit 17da2d5 ]
As reported:
[ 256.104522] ======================================================
[ 256.113783] WARNING: possible circular locking dependency detected
[ 256.120093] 5.16.0-rc6-yocto-standard+ torvalds#99 Not tainted
[ 256.125362] ------------------------------------------------------
[ 256.131673] intel-speed-sel/844 is trying to acquire lock:
[ 256.137290] ffffffffc036f0d0 (punit_misc_dev_lock){+.+.}-{3:3}, at: isst_if_open+0x18/0x90 [isst_if_common]
[ 256.147171]
[ 256.147171] but task is already holding lock:
[ 256.153135] ffffffff8ee7cb50 (misc_mtx){+.+.}-{3:3}, at: misc_open+0x2a/0x170
[ 256.160407]
[ 256.160407] which lock already depends on the new lock.
[ 256.160407]
[ 256.168712]
[ 256.168712] the existing dependency chain (in reverse order) is:
[ 256.176327]
[ 256.176327] -> #1 (misc_mtx){+.+.}-{3:3}:
[ 256.181946] lock_acquire+0x1e6/0x330
[ 256.186265] __mutex_lock+0x9b/0x9b0
[ 256.190497] mutex_lock_nested+0x1b/0x20
[ 256.195075] misc_register+0x32/0x1a0
[ 256.199390] isst_if_cdev_register+0x65/0x180 [isst_if_common]
[ 256.205878] isst_if_probe+0x144/0x16e [isst_if_mmio]
...
[ 256.241976]
[ 256.241976] -> #0 (punit_misc_dev_lock){+.+.}-{3:3}:
[ 256.248552] validate_chain+0xbc6/0x1750
[ 256.253131] __lock_acquire+0x88c/0xc10
[ 256.257618] lock_acquire+0x1e6/0x330
[ 256.261933] __mutex_lock+0x9b/0x9b0
[ 256.266165] mutex_lock_nested+0x1b/0x20
[ 256.270739] isst_if_open+0x18/0x90 [isst_if_common]
[ 256.276356] misc_open+0x100/0x170
[ 256.280409] chrdev_open+0xa5/0x1e0
...
The call sequence suggested that misc_device /dev file can be opened
before misc device is yet to be registered, which is done only once.
Here punit_misc_dev_lock was used as common lock, to protect the
registration by multiple ISST HW drivers, one time setup, prevent
duplicate registry of misc device and prevent load/unload when device
is open.
We can split into locks:
- One which just prevent duplicate call to misc_register() and one
time setup. Also never call again if the misc_register() failed or
required one time setup is failed. This lock is not shared with
any misc device callbacks.
- The other lock protects registry, load and unload of HW drivers.
Sequence in isst_if_cdev_register()
- Register callbacks under punit_misc_dev_open_lock
- Call isst_misc_reg() which registers misc_device on the first
registry which is under punit_misc_dev_reg_lock, which is not
shared with callbacks.
Sequence in isst_if_cdev_unregister
Just opposite of isst_if_cdev_register
Reported-and-tested-by: Liwei Song <[email protected]>
Signed-off-by: Srinivas Pandruvada <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Hans de Goede <[email protected]>
Signed-off-by: Hans de Goede <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>1 parent 066c905 commit 79175b6
File tree
1 file changed
+63
-34
lines changed- drivers/platform/x86/intel_speed_select_if
1 file changed
+63
-34
lines changedLines changed: 63 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
535 | | - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
536 | 539 | | |
537 | 540 | | |
538 | 541 | | |
| |||
542 | 545 | | |
543 | 546 | | |
544 | 547 | | |
545 | | - | |
| 548 | + | |
546 | 549 | | |
547 | 550 | | |
548 | 551 | | |
| |||
564 | 567 | | |
565 | 568 | | |
566 | 569 | | |
567 | | - | |
| 570 | + | |
568 | 571 | | |
569 | 572 | | |
570 | 573 | | |
| |||
573 | 576 | | |
574 | 577 | | |
575 | 578 | | |
576 | | - | |
| 579 | + | |
577 | 580 | | |
578 | 581 | | |
579 | 582 | | |
580 | 583 | | |
581 | 584 | | |
582 | 585 | | |
583 | 586 | | |
584 | | - | |
| 587 | + | |
585 | 588 | | |
586 | 589 | | |
587 | 590 | | |
| |||
598 | 601 | | |
599 | 602 | | |
600 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
601 | 641 | | |
602 | 642 | | |
603 | 643 | | |
| |||
615 | 655 | | |
616 | 656 | | |
617 | 657 | | |
618 | | - | |
619 | | - | |
| 658 | + | |
620 | 659 | | |
621 | 660 | | |
622 | 661 | | |
623 | 662 | | |
624 | | - | |
| 663 | + | |
| 664 | + | |
625 | 665 | | |
626 | | - | |
| 666 | + | |
627 | 667 | | |
628 | 668 | | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | 669 | | |
644 | 670 | | |
645 | | - | |
646 | | - | |
647 | | - | |
| 671 | + | |
648 | 672 | | |
649 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
650 | 683 | | |
651 | 684 | | |
652 | 685 | | |
| |||
661 | 694 | | |
662 | 695 | | |
663 | 696 | | |
664 | | - | |
665 | | - | |
| 697 | + | |
| 698 | + | |
666 | 699 | | |
667 | 700 | | |
668 | 701 | | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | | - | |
673 | | - | |
| 702 | + | |
674 | 703 | | |
675 | 704 | | |
676 | 705 | | |
| |||
0 commit comments