linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* AT91: sama5d2: lockdep splat in sama5d2_pmc_of_clk_init_driver()
@ 2019-07-26 14:54 Michał Mirosław
  2019-11-27 17:19 ` Alexandre Belloni
  0 siblings, 1 reply; 4+ messages in thread
From: Michał Mirosław @ 2019-07-26 14:54 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: linux-clk, linux-kernel, Nicolas Ferre, Alexandre Belloni,
	Ludovic Desroches, Michael Turquette, Stephen Boyd,
	Matthias Wieloch

Dear Developers

Since upgrading to v5.2.2 from v5.1.x I keep getting lockdep complaints
(below) from clk initialization on SAMA5D2 board. Have you seen this?
Can you help me in finding a fix?

Best Regards,
Michał Mirosław

------- dmesg START ------

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.2.3+ (mirq@qmqm) (gcc version 8.3.0 (Debian 8.3.0-2)) #312 Fri Jul 26 15:32:06 CEST 2019
[    0.000000] CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), cr=10c53c7d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: SAMA5D2 proto3
[    0.000000] printk: bootconsole [earlycon0] enabled
[    0.000000] Memory policy: Data cache writeback
[    0.000000] On node 0 totalpages: 65536
[    0.000000]   Normal zone: 512 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 65536 pages, LIFO batch:15
[    0.000000] CPU: All CPU(s) started in SVC mode.
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0 
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 65024
[    0.000000] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p1 rootfstype=squashfs debug loglevel=9 earlyprintk
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Memory: 239752K/262144K available (8192K kernel code, 578K rwdata, 2312K rodata, 1024K init, 7103K bss, 22392K reserved, 0K cma-reserved)
[    0.000000] ftrace: allocating 25429 entries in 50 pages
[    0.000000] Running RCU self tests
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] L2C-310 ID prefetch enabled, offset 2 lines
[    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
[    0.000000] L2C-310 cache controller enabled, 8 ways, 128 kB
[    0.000000] L2C-310: CACHE_ID 0x410000c9, AUX_CTRL 0x36020000
[    0.000000] random: get_random_bytes called from start_kernel+0x2b8/0x450 with crng_init=0

[    0.000000] ======================================================
[    0.000000] WARNING: possible circular locking dependency detected
[    0.000000] 5.2.3+ #312 Not tainted
[    0.000000] ------------------------------------------------------
[    0.000000] swapper/0 is trying to acquire lock:
[    0.000000] (ptrval) (pmc_pcr_lock){....}, at: clk_sam9x5_peripheral_enable+0x28/0xac
[    0.000000] 
               but task is already holding lock:
[    0.000000] (ptrval) (enable_lock){....}, at: clk_enable_lock+0x38/0xf4
[    0.000000] 
               which lock already depends on the new lock.

[    0.000000] 
               the existing dependency chain (in reverse order) is:
[    0.000000] 
               -> #2 (enable_lock){....}:
[    0.000000]        clk_enable_lock+0x38/0xf4
[    0.000000]        clk_core_enable_lock+0x14/0x34
[    0.000000]        regmap_mmio_read+0x54/0x6c
[    0.000000]        _regmap_read+0x68/0x160
[    0.000000]        regmap_read+0x44/0x64
[    0.000000]        at91_clk_register_sam9x5_main+0xb0/0x108
[    0.000000]        sama5d2_pmc_of_clk_init_driver+0x15c/0x654
[    0.000000]        of_clk_init+0x154/0x21c
[    0.000000]        time_init+0x30/0x38
[    0.000000]        start_kernel+0x2ec/0x450
[    0.000000]        0x0
[    0.000000] 
               -> #1 (syscon:113:(&syscon_config)->lock){....}:
[    0.000000]        regmap_lock_spinlock+0x14/0x1c
[    0.000000]        regmap_write+0x34/0x64
[    0.000000]        clk_sam9x5_peripheral_recalc_rate+0x60/0xf4
[    0.000000]        __clk_register+0x28c/0x7f4
[    0.000000]        clk_hw_register+0x20/0x2c
[    0.000000]        at91_clk_register_sam9x5_peripheral+0xec/0x14c
[    0.000000]        sama5d2_pmc_of_clk_init_driver+0x42c/0x654
[    0.000000]        of_clk_init+0x154/0x21c
[    0.000000]        time_init+0x30/0x38
[    0.000000]        start_kernel+0x2ec/0x450
[    0.000000]        0x0
[    0.000000] 
               -> #0 (pmc_pcr_lock){....}:
[    0.000000]        _raw_spin_lock_irqsave+0x44/0x58
[    0.000000]        clk_sam9x5_peripheral_enable+0x28/0xac
[    0.000000]        clk_core_enable+0x88/0x258
[    0.000000]        clk_core_enable_lock+0x20/0x34
[    0.000000]        clk_prepare_enable+0x1c/0x34
[    0.000000]        tcb_clksrc_init+0x13c/0x4b8
[    0.000000]        timer_probe+0x78/0xe0
[    0.000000]        start_kernel+0x2ec/0x450
[    0.000000]        0x0
[    0.000000] 
               other info that might help us debug this:

[    0.000000] Chain exists of:
                 pmc_pcr_lock --> syscon:113:(&syscon_config)->lock --> enable_lock

[    0.000000]  Possible unsafe locking scenario:

[    0.000000]        CPU0                    CPU1
[    0.000000]        ----                    ----
[    0.000000]   lock(enable_lock);
[    0.000000]                                lock(syscon:113:(&syscon_config)->lock);
[    0.000000]                                lock(enable_lock);
[    0.000000]   lock(pmc_pcr_lock);
[    0.000000] 
                *** DEADLOCK ***

[    0.000000] 1 lock held by swapper/0:
[    0.000000]  #0: (ptrval) (enable_lock){....}, at: clk_enable_lock+0x38/0xf4
[    0.000000] 
               stack backtrace:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.2.3+ #312
[    0.000000] Hardware name: Atmel SAMA5
[    0.000000] [<c010edc0>] (unwind_backtrace) from [<c010c1a8>] (show_stack+0x18/0x1c)
[    0.000000] [<c010c1a8>] (show_stack) from [<c01515c4>] (print_circular_bug+0x220/0x25c)
[    0.000000] [<c01515c4>] (print_circular_bug) from [<c0154264>] (__lock_acquire+0x1600/0x1a80)
[    0.000000] [<c0154264>] (__lock_acquire) from [<c0154f08>] (lock_acquire+0xc4/0x168)
[    0.000000] [<c0154f08>] (lock_acquire) from [<c08330a8>] (_raw_spin_lock_irqsave+0x44/0x58)
[    0.000000] [<c08330a8>] (_raw_spin_lock_irqsave) from [<c042fabc>] (clk_sam9x5_peripheral_enable+0x28/0xac)
[    0.000000] [<c042fabc>] (clk_sam9x5_peripheral_enable) from [<c0424990>] (clk_core_enable+0x88/0x258)
[    0.000000] [<c0424990>] (clk_core_enable) from [<c0425c4c>] (clk_core_enable_lock+0x20/0x34)
[    0.000000] [<c0425c4c>] (clk_core_enable_lock) from [<c058d788>] (clk_prepare_enable+0x1c/0x34)
[    0.000000] [<c058d788>] (clk_prepare_enable) from [<c0c358bc>] (tcb_clksrc_init+0x13c/0x4b8)
[    0.000000] [<c0c358bc>] (tcb_clksrc_init) from [<c0c35718>] (timer_probe+0x78/0xe0)
[    0.000000] [<c0c35718>] (timer_probe) from [<c0c00dc4>] (start_kernel+0x2ec/0x450)
[    0.000000] [<c0c00dc4>] (start_kernel) from [<00000000>] (0x0)
[    0.000000] clocksource: timer@f800c000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 184217874325 ns
[    0.000021] sched_clock: 32 bits at 10MHz, resolution 96ns, wraps every 206986376143ns
[    0.009762] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.018365] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.022911] ... MAX_LOCK_DEPTH:          48
[    0.027546] ... MAX_LOCKDEP_KEYS:        8191
[    0.032367] ... CLASSHASH_SIZE:          4096
[    0.037190] ... MAX_LOCKDEP_ENTRIES:     32768
[    0.042109] ... MAX_LOCKDEP_CHAINS:      65536
[    0.047028] ... CHAINHASH_SIZE:          32768
[    0.051944]  memory used by lock dependency info: 4411 kB
[    0.057913]  per task-struct memory footprint: 1536 bytes
[    0.063965] Calibrating delay loop... 358.40 BogoMIPS (lpj=179200)
[    0.081133] pid_max: default: 32768 minimum: 301
[    0.086831] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.094201] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.104331] CPU: Testing write buffer coherency: ok
[    0.112611] Setting up static identity map for 0x20100000 - 0x20100060
[    0.122704] devtmpfs: initialized
[    0.151047] VFP support v0.3: implementor 41 architecture 2 part 30 variant 5 rev 1
[    0.160466] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275000 ns
[    0.171341] futex hash table entries: 256 (order: 1, 11264 bytes)
[    0.178738] pinctrl core: initialized pinctrl subsystem
[    0.186405] regulator-dummy: no parameters, enabled
[    0.194206] NET: Registered protocol family 16
[    0.207208] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.292223] AT91: PM: standby: standby, suspend: ulp0
[    0.300092] atmel_tcb: probe of f800c000.timer failed with error -16
[    0.422319] random: fast init done
[    0.496218] at_xdmac f0010000.dma-controller: 16 channels, mapped at 0x(ptrval)
[    0.511573] at_xdmac f0004000.dma-controller: 16 channels, mapped at 0x(ptrval)
[    0.521731] AT91: Detected SoC family: sama5d2
[    0.526738] AT91: Detected SoC: sama5d27, revision 2
[...]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: AT91: sama5d2: lockdep splat in sama5d2_pmc_of_clk_init_driver()
  2019-07-26 14:54 AT91: sama5d2: lockdep splat in sama5d2_pmc_of_clk_init_driver() Michał Mirosław
@ 2019-11-27 17:19 ` Alexandre Belloni
  2019-11-28 10:25   ` [PATCH] clk: at91: fix possible deadlock Alexandre Belloni
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2019-11-27 17:19 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: linux-arm-kernel, linux-clk, linux-kernel, Nicolas Ferre,
	Ludovic Desroches, Michael Turquette, Stephen Boyd,
	Matthias Wieloch

Hi,

On 26/07/2019 16:54:06+0200, Michał Mirosław wrote:
> Dear Developers
> 
> Since upgrading to v5.2.2 from v5.1.x I keep getting lockdep complaints
> (below) from clk initialization on SAMA5D2 board. Have you seen this?
> Can you help me in finding a fix?
> 

I'm going to send that patch that fixes it:

diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c
index 0de1108737db..ff7e3f727082 100644
--- a/drivers/clk/at91/sama5d2.c
+++ b/drivers/clk/at91/sama5d2.c
@@ -162,7 +162,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
                return;
        mainxtal_name = of_clk_get_parent_name(np, i);
 
-       regmap = syscon_node_to_regmap(np);
+       regmap = device_node_to_regmap(np);
        if (IS_ERR(regmap))
                return;
 


> Best Regards,
> Michał Mirosław
> 
> ------- dmesg START ------
> 
> [    0.000000] Booting Linux on physical CPU 0x0
> [    0.000000] Linux version 5.2.3+ (mirq@qmqm) (gcc version 8.3.0 (Debian 8.3.0-2)) #312 Fri Jul 26 15:32:06 CEST 2019
> [    0.000000] CPU: ARMv7 Processor [410fc051] revision 1 (ARMv7), cr=10c53c7d
> [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
> [    0.000000] OF: fdt: Machine model: SAMA5D2 proto3
> [    0.000000] printk: bootconsole [earlycon0] enabled
> [    0.000000] Memory policy: Data cache writeback
> [    0.000000] On node 0 totalpages: 65536
> [    0.000000]   Normal zone: 512 pages used for memmap
> [    0.000000]   Normal zone: 0 pages reserved
> [    0.000000]   Normal zone: 65536 pages, LIFO batch:15
> [    0.000000] CPU: All CPU(s) started in SVC mode.
> [    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
> [    0.000000] pcpu-alloc: [0] 0 
> [    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 65024
> [    0.000000] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p1 rootfstype=squashfs debug loglevel=9 earlyprintk
> [    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
> [    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
> [    0.000000] Memory: 239752K/262144K available (8192K kernel code, 578K rwdata, 2312K rodata, 1024K init, 7103K bss, 22392K reserved, 0K cma-reserved)
> [    0.000000] ftrace: allocating 25429 entries in 50 pages
> [    0.000000] Running RCU self tests
> [    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
> [    0.000000] L2C-310 ID prefetch enabled, offset 2 lines
> [    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
> [    0.000000] L2C-310 cache controller enabled, 8 ways, 128 kB
> [    0.000000] L2C-310: CACHE_ID 0x410000c9, AUX_CTRL 0x36020000
> [    0.000000] random: get_random_bytes called from start_kernel+0x2b8/0x450 with crng_init=0
> 
> [    0.000000] ======================================================
> [    0.000000] WARNING: possible circular locking dependency detected
> [    0.000000] 5.2.3+ #312 Not tainted
> [    0.000000] ------------------------------------------------------
> [    0.000000] swapper/0 is trying to acquire lock:
> [    0.000000] (ptrval) (pmc_pcr_lock){....}, at: clk_sam9x5_peripheral_enable+0x28/0xac
> [    0.000000] 
>                but task is already holding lock:
> [    0.000000] (ptrval) (enable_lock){....}, at: clk_enable_lock+0x38/0xf4
> [    0.000000] 
>                which lock already depends on the new lock.
> 
> [    0.000000] 
>                the existing dependency chain (in reverse order) is:
> [    0.000000] 
>                -> #2 (enable_lock){....}:
> [    0.000000]        clk_enable_lock+0x38/0xf4
> [    0.000000]        clk_core_enable_lock+0x14/0x34
> [    0.000000]        regmap_mmio_read+0x54/0x6c
> [    0.000000]        _regmap_read+0x68/0x160
> [    0.000000]        regmap_read+0x44/0x64
> [    0.000000]        at91_clk_register_sam9x5_main+0xb0/0x108
> [    0.000000]        sama5d2_pmc_of_clk_init_driver+0x15c/0x654
> [    0.000000]        of_clk_init+0x154/0x21c
> [    0.000000]        time_init+0x30/0x38
> [    0.000000]        start_kernel+0x2ec/0x450
> [    0.000000]        0x0
> [    0.000000] 
>                -> #1 (syscon:113:(&syscon_config)->lock){....}:
> [    0.000000]        regmap_lock_spinlock+0x14/0x1c
> [    0.000000]        regmap_write+0x34/0x64
> [    0.000000]        clk_sam9x5_peripheral_recalc_rate+0x60/0xf4
> [    0.000000]        __clk_register+0x28c/0x7f4
> [    0.000000]        clk_hw_register+0x20/0x2c
> [    0.000000]        at91_clk_register_sam9x5_peripheral+0xec/0x14c
> [    0.000000]        sama5d2_pmc_of_clk_init_driver+0x42c/0x654
> [    0.000000]        of_clk_init+0x154/0x21c
> [    0.000000]        time_init+0x30/0x38
> [    0.000000]        start_kernel+0x2ec/0x450
> [    0.000000]        0x0
> [    0.000000] 
>                -> #0 (pmc_pcr_lock){....}:
> [    0.000000]        _raw_spin_lock_irqsave+0x44/0x58
> [    0.000000]        clk_sam9x5_peripheral_enable+0x28/0xac
> [    0.000000]        clk_core_enable+0x88/0x258
> [    0.000000]        clk_core_enable_lock+0x20/0x34
> [    0.000000]        clk_prepare_enable+0x1c/0x34
> [    0.000000]        tcb_clksrc_init+0x13c/0x4b8
> [    0.000000]        timer_probe+0x78/0xe0
> [    0.000000]        start_kernel+0x2ec/0x450
> [    0.000000]        0x0
> [    0.000000] 
>                other info that might help us debug this:
> 
> [    0.000000] Chain exists of:
>                  pmc_pcr_lock --> syscon:113:(&syscon_config)->lock --> enable_lock
> 
> [    0.000000]  Possible unsafe locking scenario:
> 
> [    0.000000]        CPU0                    CPU1
> [    0.000000]        ----                    ----
> [    0.000000]   lock(enable_lock);
> [    0.000000]                                lock(syscon:113:(&syscon_config)->lock);
> [    0.000000]                                lock(enable_lock);
> [    0.000000]   lock(pmc_pcr_lock);
> [    0.000000] 
>                 *** DEADLOCK ***
> 
> [    0.000000] 1 lock held by swapper/0:
> [    0.000000]  #0: (ptrval) (enable_lock){....}, at: clk_enable_lock+0x38/0xf4
> [    0.000000] 
>                stack backtrace:
> [    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.2.3+ #312
> [    0.000000] Hardware name: Atmel SAMA5
> [    0.000000] [<c010edc0>] (unwind_backtrace) from [<c010c1a8>] (show_stack+0x18/0x1c)
> [    0.000000] [<c010c1a8>] (show_stack) from [<c01515c4>] (print_circular_bug+0x220/0x25c)
> [    0.000000] [<c01515c4>] (print_circular_bug) from [<c0154264>] (__lock_acquire+0x1600/0x1a80)
> [    0.000000] [<c0154264>] (__lock_acquire) from [<c0154f08>] (lock_acquire+0xc4/0x168)
> [    0.000000] [<c0154f08>] (lock_acquire) from [<c08330a8>] (_raw_spin_lock_irqsave+0x44/0x58)
> [    0.000000] [<c08330a8>] (_raw_spin_lock_irqsave) from [<c042fabc>] (clk_sam9x5_peripheral_enable+0x28/0xac)
> [    0.000000] [<c042fabc>] (clk_sam9x5_peripheral_enable) from [<c0424990>] (clk_core_enable+0x88/0x258)
> [    0.000000] [<c0424990>] (clk_core_enable) from [<c0425c4c>] (clk_core_enable_lock+0x20/0x34)
> [    0.000000] [<c0425c4c>] (clk_core_enable_lock) from [<c058d788>] (clk_prepare_enable+0x1c/0x34)
> [    0.000000] [<c058d788>] (clk_prepare_enable) from [<c0c358bc>] (tcb_clksrc_init+0x13c/0x4b8)
> [    0.000000] [<c0c358bc>] (tcb_clksrc_init) from [<c0c35718>] (timer_probe+0x78/0xe0)
> [    0.000000] [<c0c35718>] (timer_probe) from [<c0c00dc4>] (start_kernel+0x2ec/0x450)
> [    0.000000] [<c0c00dc4>] (start_kernel) from [<00000000>] (0x0)
> [    0.000000] clocksource: timer@f800c000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 184217874325 ns
> [    0.000021] sched_clock: 32 bits at 10MHz, resolution 96ns, wraps every 206986376143ns
> [    0.009762] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
> [    0.018365] ... MAX_LOCKDEP_SUBCLASSES:  8
> [    0.022911] ... MAX_LOCK_DEPTH:          48
> [    0.027546] ... MAX_LOCKDEP_KEYS:        8191
> [    0.032367] ... CLASSHASH_SIZE:          4096
> [    0.037190] ... MAX_LOCKDEP_ENTRIES:     32768
> [    0.042109] ... MAX_LOCKDEP_CHAINS:      65536
> [    0.047028] ... CHAINHASH_SIZE:          32768
> [    0.051944]  memory used by lock dependency info: 4411 kB
> [    0.057913]  per task-struct memory footprint: 1536 bytes
> [    0.063965] Calibrating delay loop... 358.40 BogoMIPS (lpj=179200)
> [    0.081133] pid_max: default: 32768 minimum: 301
> [    0.086831] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
> [    0.094201] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
> [    0.104331] CPU: Testing write buffer coherency: ok
> [    0.112611] Setting up static identity map for 0x20100000 - 0x20100060
> [    0.122704] devtmpfs: initialized
> [    0.151047] VFP support v0.3: implementor 41 architecture 2 part 30 variant 5 rev 1
> [    0.160466] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275000 ns
> [    0.171341] futex hash table entries: 256 (order: 1, 11264 bytes)
> [    0.178738] pinctrl core: initialized pinctrl subsystem
> [    0.186405] regulator-dummy: no parameters, enabled
> [    0.194206] NET: Registered protocol family 16
> [    0.207208] DMA: preallocated 256 KiB pool for atomic coherent allocations
> [    0.292223] AT91: PM: standby: standby, suspend: ulp0
> [    0.300092] atmel_tcb: probe of f800c000.timer failed with error -16
> [    0.422319] random: fast init done
> [    0.496218] at_xdmac f0010000.dma-controller: 16 channels, mapped at 0x(ptrval)
> [    0.511573] at_xdmac f0004000.dma-controller: 16 channels, mapped at 0x(ptrval)
> [    0.521731] AT91: Detected SoC family: sama5d2
> [    0.526738] AT91: Detected SoC: sama5d27, revision 2
> [...]

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] clk: at91: fix possible deadlock
@ 2019-11-28 10:25   ` Alexandre Belloni
  2019-11-28 13:58     ` Michał Mirosław
  0 siblings, 1 reply; 4+ messages in thread
From: Alexandre Belloni @ 2019-11-28 10:25 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Nicolas Ferre, Michael Turquette, linux-clk, linux-arm-kernel,
	linux-kernel, Alexandre Belloni, Michał Mirosław

Lockdep warns about a possible circular locking dependency because using
syscon_node_to_regmap() will make the created regmap get and enable the
first clock it can parse from the device tree. This clock is not needed to
access the registers and should not be enabled at that time.

Use the recently introduced device_node_to_regmap to solve that as it looks
up the regmap in the same list but doesn't care about the clocks.

Reported-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
---
 drivers/clk/at91/at91sam9260.c | 2 +-
 drivers/clk/at91/at91sam9rl.c  | 2 +-
 drivers/clk/at91/at91sam9x5.c  | 2 +-
 drivers/clk/at91/pmc.c         | 2 +-
 drivers/clk/at91/sama5d2.c     | 2 +-
 drivers/clk/at91/sama5d4.c     | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/clk/at91/at91sam9260.c b/drivers/clk/at91/at91sam9260.c
index 0aabe49aed09..a9d4234758d7 100644
--- a/drivers/clk/at91/at91sam9260.c
+++ b/drivers/clk/at91/at91sam9260.c
@@ -348,7 +348,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
diff --git a/drivers/clk/at91/at91sam9rl.c b/drivers/clk/at91/at91sam9rl.c
index 0ac34cdaa106..77fe83a73bf4 100644
--- a/drivers/clk/at91/at91sam9rl.c
+++ b/drivers/clk/at91/at91sam9rl.c
@@ -83,7 +83,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
diff --git a/drivers/clk/at91/at91sam9x5.c b/drivers/clk/at91/at91sam9x5.c
index 0855f3a80cc7..086cf0b4955c 100644
--- a/drivers/clk/at91/at91sam9x5.c
+++ b/drivers/clk/at91/at91sam9x5.c
@@ -146,7 +146,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 0b03cfae3a9d..b71515acdec1 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -275,7 +275,7 @@ static int __init pmc_register_ops(void)
 
 	np = of_find_matching_node(NULL, sama5d2_pmc_dt_ids);
 
-	pmcreg = syscon_node_to_regmap(np);
+	pmcreg = device_node_to_regmap(np);
 	if (IS_ERR(pmcreg))
 		return PTR_ERR(pmcreg);
 
diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c
index 0de1108737db..ff7e3f727082 100644
--- a/drivers/clk/at91/sama5d2.c
+++ b/drivers/clk/at91/sama5d2.c
@@ -162,7 +162,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
diff --git a/drivers/clk/at91/sama5d4.c b/drivers/clk/at91/sama5d4.c
index 25b156d4e645..a6dee4a3b6e4 100644
--- a/drivers/clk/at91/sama5d4.c
+++ b/drivers/clk/at91/sama5d4.c
@@ -136,7 +136,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
 		return;
 	mainxtal_name = of_clk_get_parent_name(np, i);
 
-	regmap = syscon_node_to_regmap(np);
+	regmap = device_node_to_regmap(np);
 	if (IS_ERR(regmap))
 		return;
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] clk: at91: fix possible deadlock
  2019-11-28 10:25   ` [PATCH] clk: at91: fix possible deadlock Alexandre Belloni
@ 2019-11-28 13:58     ` Michał Mirosław
  0 siblings, 0 replies; 4+ messages in thread
From: Michał Mirosław @ 2019-11-28 13:58 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Stephen Boyd, Nicolas Ferre, Michael Turquette, linux-clk,
	linux-arm-kernel, linux-kernel

On Thu, Nov 28, 2019 at 11:25:31AM +0100, Alexandre Belloni wrote:
> Lockdep warns about a possible circular locking dependency because using
> syscon_node_to_regmap() will make the created regmap get and enable the
> first clock it can parse from the device tree. This clock is not needed to
> access the registers and should not be enabled at that time.
> 
> Use the recently introduced device_node_to_regmap to solve that as it looks
> up the regmap in the same list but doesn't care about the clocks.
> 
> Reported-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
[...]

Tested-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Thanks! Can you push this to stable?

Best Regards,
Michał Mirosław

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-11-28 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-26 14:54 AT91: sama5d2: lockdep splat in sama5d2_pmc_of_clk_init_driver() Michał Mirosław
2019-11-27 17:19 ` Alexandre Belloni
2019-11-28 10:25   ` [PATCH] clk: at91: fix possible deadlock Alexandre Belloni
2019-11-28 13:58     ` Michał Mirosław

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).