All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] soundwire: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute
@ 2020-11-04 11:29 ` Srinivas Kandagatla
  0 siblings, 0 replies; 6+ messages in thread
From: Srinivas Kandagatla @ 2020-11-04 11:29 UTC (permalink / raw)
  To: vkoul, yung-chuan.liao
  Cc: pierre-louis.bossart, sanyog.r.kale, gregkh, alsa-devel,
	linux-kernel, Srinivas Kandagatla

running kernel with CONFIG_DEBUG_LOCKS_ALLOC enabled will below warning:

BUG: key ffff502e09807098 has not been registered!
DEBUG_LOCKS_WARN_ON(1)
WARNING: CPU: 5 PID: 129 at kernel/locking/lockdep.c:4623
	lockdep_init_map_waits+0xe8/0x250
Modules linked in:
CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
       W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
Workqueue: events deferred_probe_work_func
pstate: 80c00005 (Nzcv daif +PAN +UAO -TCO BTYPE=--)
pc : lockdep_init_map_waits+0xe8/0x250
lr : lockdep_init_map_waits+0xe8/0x250
 [ Trimmed ]

Call trace:
 lockdep_init_map_waits+0xe8/0x250
 __kernfs_create_file+0x78/0x180
 sysfs_add_file_mode_ns+0x94/0x1c8
 internal_create_group+0x110/0x3e0
 sysfs_create_group+0x18/0x28
 devm_device_add_group+0x4c/0xb0
 add_all_attributes+0x438/0x490
 sdw_slave_sysfs_dpn_init+0x128/0x138
 sdw_slave_sysfs_init+0x80/0xa0
 sdw_drv_probe+0x94/0x170
 really_probe+0x118/0x3e0
 driver_probe_device+0x5c/0xc0

 [ Trimmed ]

CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
     W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
Workqueue: events deferred_probe_work_func
Call trace:
 dump_backtrace+0x0/0x1c0
 show_stack+0x18/0x68
 dump_stack+0xd8/0x134
 __warn+0xa0/0x158
 report_bug+0xc8/0x178
 bug_handler+0x20/0x78
 brk_handler+0x70/0xc8

[ Trimmed ]

Fix this by initializing dynamically allocated sysfs attribute to keep lockdep happy!

Fixes: bcac59029955 ("soundwire: add Slave sysfs support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/soundwire/sysfs_slave_dpn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soundwire/sysfs_slave_dpn.c b/drivers/soundwire/sysfs_slave_dpn.c
index 05a721ea9830..c4b6543c09fd 100644
--- a/drivers/soundwire/sysfs_slave_dpn.c
+++ b/drivers/soundwire/sysfs_slave_dpn.c
@@ -37,6 +37,7 @@ static int field##_attribute_alloc(struct device *dev,			\
 		return -ENOMEM;						\
 	dpn_attr->N = N;						\
 	dpn_attr->dir = dir;						\
+	sysfs_attr_init(&dpn_attr->dev_attr.attr);			\
 	dpn_attr->format_string = format_string;			\
 	dpn_attr->dev_attr.attr.name = __stringify(field);		\
 	dpn_attr->dev_attr.attr.mode = 0444;				\
-- 
2.21.0


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

* [PATCH] soundwire: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute
@ 2020-11-04 11:29 ` Srinivas Kandagatla
  0 siblings, 0 replies; 6+ messages in thread
From: Srinivas Kandagatla @ 2020-11-04 11:29 UTC (permalink / raw)
  To: vkoul, yung-chuan.liao
  Cc: alsa-devel, gregkh, pierre-louis.bossart, linux-kernel,
	Srinivas Kandagatla, sanyog.r.kale

running kernel with CONFIG_DEBUG_LOCKS_ALLOC enabled will below warning:

BUG: key ffff502e09807098 has not been registered!
DEBUG_LOCKS_WARN_ON(1)
WARNING: CPU: 5 PID: 129 at kernel/locking/lockdep.c:4623
	lockdep_init_map_waits+0xe8/0x250
Modules linked in:
CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
       W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
Workqueue: events deferred_probe_work_func
pstate: 80c00005 (Nzcv daif +PAN +UAO -TCO BTYPE=--)
pc : lockdep_init_map_waits+0xe8/0x250
lr : lockdep_init_map_waits+0xe8/0x250
 [ Trimmed ]

Call trace:
 lockdep_init_map_waits+0xe8/0x250
 __kernfs_create_file+0x78/0x180
 sysfs_add_file_mode_ns+0x94/0x1c8
 internal_create_group+0x110/0x3e0
 sysfs_create_group+0x18/0x28
 devm_device_add_group+0x4c/0xb0
 add_all_attributes+0x438/0x490
 sdw_slave_sysfs_dpn_init+0x128/0x138
 sdw_slave_sysfs_init+0x80/0xa0
 sdw_drv_probe+0x94/0x170
 really_probe+0x118/0x3e0
 driver_probe_device+0x5c/0xc0

 [ Trimmed ]

CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
     W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
Workqueue: events deferred_probe_work_func
Call trace:
 dump_backtrace+0x0/0x1c0
 show_stack+0x18/0x68
 dump_stack+0xd8/0x134
 __warn+0xa0/0x158
 report_bug+0xc8/0x178
 bug_handler+0x20/0x78
 brk_handler+0x70/0xc8

[ Trimmed ]

Fix this by initializing dynamically allocated sysfs attribute to keep lockdep happy!

Fixes: bcac59029955 ("soundwire: add Slave sysfs support")
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/soundwire/sysfs_slave_dpn.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soundwire/sysfs_slave_dpn.c b/drivers/soundwire/sysfs_slave_dpn.c
index 05a721ea9830..c4b6543c09fd 100644
--- a/drivers/soundwire/sysfs_slave_dpn.c
+++ b/drivers/soundwire/sysfs_slave_dpn.c
@@ -37,6 +37,7 @@ static int field##_attribute_alloc(struct device *dev,			\
 		return -ENOMEM;						\
 	dpn_attr->N = N;						\
 	dpn_attr->dir = dir;						\
+	sysfs_attr_init(&dpn_attr->dev_attr.attr);			\
 	dpn_attr->format_string = format_string;			\
 	dpn_attr->dev_attr.attr.name = __stringify(field);		\
 	dpn_attr->dev_attr.attr.mode = 0444;				\
-- 
2.21.0


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

* Re: [PATCH] soundwire: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute
  2020-11-04 11:29 ` Srinivas Kandagatla
@ 2020-11-04 14:32   ` Pierre-Louis Bossart
  -1 siblings, 0 replies; 6+ messages in thread
From: Pierre-Louis Bossart @ 2020-11-04 14:32 UTC (permalink / raw)
  To: Srinivas Kandagatla, vkoul, yung-chuan.liao
  Cc: sanyog.r.kale, gregkh, alsa-devel, linux-kernel



On 11/4/20 5:29 AM, Srinivas Kandagatla wrote:
> running kernel with CONFIG_DEBUG_LOCKS_ALLOC enabled will below warning:
> 
> BUG: key ffff502e09807098 has not been registered!
> DEBUG_LOCKS_WARN_ON(1)
> WARNING: CPU: 5 PID: 129 at kernel/locking/lockdep.c:4623
> 	lockdep_init_map_waits+0xe8/0x250
> Modules linked in:
> CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
>         W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
> Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
> Workqueue: events deferred_probe_work_func
> pstate: 80c00005 (Nzcv daif +PAN +UAO -TCO BTYPE=--)
> pc : lockdep_init_map_waits+0xe8/0x250
> lr : lockdep_init_map_waits+0xe8/0x250
>   [ Trimmed ]
> 
> Call trace:
>   lockdep_init_map_waits+0xe8/0x250
>   __kernfs_create_file+0x78/0x180
>   sysfs_add_file_mode_ns+0x94/0x1c8
>   internal_create_group+0x110/0x3e0
>   sysfs_create_group+0x18/0x28
>   devm_device_add_group+0x4c/0xb0
>   add_all_attributes+0x438/0x490
>   sdw_slave_sysfs_dpn_init+0x128/0x138
>   sdw_slave_sysfs_init+0x80/0xa0
>   sdw_drv_probe+0x94/0x170
>   really_probe+0x118/0x3e0
>   driver_probe_device+0x5c/0xc0
> 
>   [ Trimmed ]
> 
> CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
>       W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
> Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
> Workqueue: events deferred_probe_work_func
> Call trace:
>   dump_backtrace+0x0/0x1c0
>   show_stack+0x18/0x68
>   dump_stack+0xd8/0x134
>   __warn+0xa0/0x158
>   report_bug+0xc8/0x178
>   bug_handler+0x20/0x78
>   brk_handler+0x70/0xc8
> 
> [ Trimmed ]
> 
> Fix this by initializing dynamically allocated sysfs attribute to keep lockdep happy!
> 
> Fixes: bcac59029955 ("soundwire: add Slave sysfs support")
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

I added the exact same fix last Friday but you beat me to it.

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

My commit message was a bit more self-explanatory though, maybe you 
could add the explanation at the end and possibly trim the logs?

"
when CONFIG_DEBUG_LOCK_ALLOC is enabled, a warning is thrown, e.g.

kernel: [ 4.078863] BUG: key ffff8a9203c92dc0 has not been registered!
kernel: [ 4.078865] ------------[ cut here ]------------
kernel: [ 4.078866] DEBUG_LOCKS_WARN_ON(1)
kernel: [ 4.078871] WARNING: CPU: 0 PID: 280 at
kernel/locking/lockdep.c:4623 lockdep_init_map_waits+0x177/0x200
kernel: [ 4.078902] Call Trace:
kernel: [ 4.078906] __kernfs_create_file+0x76/0x100
kernel: [ 4.078908] sysfs_add_file_mode_ns+0x9f/0x190
kernel: [ 4.078909] internal_create_group+0x112/0x380
kernel: [ 4.078912] devm_device_add_group+0x41/0x80
kernel: [ 4.078915] add_all_attributes+0x4bf/0x4e0 [soundwire_bus]
kernel: [ 4.078918] sdw_slave_sysfs_dpn_init+0x68/0xe0 [soundwire_bus]
kernel: [ 4.078920] sdw_slave_sysfs_init+0x6b/0x80 [soundwire_bus]

For DPn ports, the attributes are allocated dynamically and it's
required to use the macro sysfs_attr_init(), whose behavior is
precisely dependent on CONFIG_DEBUG_LOCK_ALLOC. See details in
linux/sysfs.h.
"

Thanks Srinivas!


> ---
>   drivers/soundwire/sysfs_slave_dpn.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/soundwire/sysfs_slave_dpn.c b/drivers/soundwire/sysfs_slave_dpn.c
> index 05a721ea9830..c4b6543c09fd 100644
> --- a/drivers/soundwire/sysfs_slave_dpn.c
> +++ b/drivers/soundwire/sysfs_slave_dpn.c
> @@ -37,6 +37,7 @@ static int field##_attribute_alloc(struct device *dev,			\
>   		return -ENOMEM;						\
>   	dpn_attr->N = N;						\
>   	dpn_attr->dir = dir;						\
> +	sysfs_attr_init(&dpn_attr->dev_attr.attr);			\
>   	dpn_attr->format_string = format_string;			\
>   	dpn_attr->dev_attr.attr.name = __stringify(field);		\
>   	dpn_attr->dev_attr.attr.mode = 0444;				\
> 

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

* Re: [PATCH] soundwire: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute
@ 2020-11-04 14:32   ` Pierre-Louis Bossart
  0 siblings, 0 replies; 6+ messages in thread
From: Pierre-Louis Bossart @ 2020-11-04 14:32 UTC (permalink / raw)
  To: Srinivas Kandagatla, vkoul, yung-chuan.liao
  Cc: gregkh, sanyog.r.kale, alsa-devel, linux-kernel



On 11/4/20 5:29 AM, Srinivas Kandagatla wrote:
> running kernel with CONFIG_DEBUG_LOCKS_ALLOC enabled will below warning:
> 
> BUG: key ffff502e09807098 has not been registered!
> DEBUG_LOCKS_WARN_ON(1)
> WARNING: CPU: 5 PID: 129 at kernel/locking/lockdep.c:4623
> 	lockdep_init_map_waits+0xe8/0x250
> Modules linked in:
> CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
>         W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
> Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
> Workqueue: events deferred_probe_work_func
> pstate: 80c00005 (Nzcv daif +PAN +UAO -TCO BTYPE=--)
> pc : lockdep_init_map_waits+0xe8/0x250
> lr : lockdep_init_map_waits+0xe8/0x250
>   [ Trimmed ]
> 
> Call trace:
>   lockdep_init_map_waits+0xe8/0x250
>   __kernfs_create_file+0x78/0x180
>   sysfs_add_file_mode_ns+0x94/0x1c8
>   internal_create_group+0x110/0x3e0
>   sysfs_create_group+0x18/0x28
>   devm_device_add_group+0x4c/0xb0
>   add_all_attributes+0x438/0x490
>   sdw_slave_sysfs_dpn_init+0x128/0x138
>   sdw_slave_sysfs_init+0x80/0xa0
>   sdw_drv_probe+0x94/0x170
>   really_probe+0x118/0x3e0
>   driver_probe_device+0x5c/0xc0
> 
>   [ Trimmed ]
> 
> CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
>       W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
> Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
> Workqueue: events deferred_probe_work_func
> Call trace:
>   dump_backtrace+0x0/0x1c0
>   show_stack+0x18/0x68
>   dump_stack+0xd8/0x134
>   __warn+0xa0/0x158
>   report_bug+0xc8/0x178
>   bug_handler+0x20/0x78
>   brk_handler+0x70/0xc8
> 
> [ Trimmed ]
> 
> Fix this by initializing dynamically allocated sysfs attribute to keep lockdep happy!
> 
> Fixes: bcac59029955 ("soundwire: add Slave sysfs support")
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

I added the exact same fix last Friday but you beat me to it.

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

My commit message was a bit more self-explanatory though, maybe you 
could add the explanation at the end and possibly trim the logs?

"
when CONFIG_DEBUG_LOCK_ALLOC is enabled, a warning is thrown, e.g.

kernel: [ 4.078863] BUG: key ffff8a9203c92dc0 has not been registered!
kernel: [ 4.078865] ------------[ cut here ]------------
kernel: [ 4.078866] DEBUG_LOCKS_WARN_ON(1)
kernel: [ 4.078871] WARNING: CPU: 0 PID: 280 at
kernel/locking/lockdep.c:4623 lockdep_init_map_waits+0x177/0x200
kernel: [ 4.078902] Call Trace:
kernel: [ 4.078906] __kernfs_create_file+0x76/0x100
kernel: [ 4.078908] sysfs_add_file_mode_ns+0x9f/0x190
kernel: [ 4.078909] internal_create_group+0x112/0x380
kernel: [ 4.078912] devm_device_add_group+0x41/0x80
kernel: [ 4.078915] add_all_attributes+0x4bf/0x4e0 [soundwire_bus]
kernel: [ 4.078918] sdw_slave_sysfs_dpn_init+0x68/0xe0 [soundwire_bus]
kernel: [ 4.078920] sdw_slave_sysfs_init+0x6b/0x80 [soundwire_bus]

For DPn ports, the attributes are allocated dynamically and it's
required to use the macro sysfs_attr_init(), whose behavior is
precisely dependent on CONFIG_DEBUG_LOCK_ALLOC. See details in
linux/sysfs.h.
"

Thanks Srinivas!


> ---
>   drivers/soundwire/sysfs_slave_dpn.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/soundwire/sysfs_slave_dpn.c b/drivers/soundwire/sysfs_slave_dpn.c
> index 05a721ea9830..c4b6543c09fd 100644
> --- a/drivers/soundwire/sysfs_slave_dpn.c
> +++ b/drivers/soundwire/sysfs_slave_dpn.c
> @@ -37,6 +37,7 @@ static int field##_attribute_alloc(struct device *dev,			\
>   		return -ENOMEM;						\
>   	dpn_attr->N = N;						\
>   	dpn_attr->dir = dir;						\
> +	sysfs_attr_init(&dpn_attr->dev_attr.attr);			\
>   	dpn_attr->format_string = format_string;			\
>   	dpn_attr->dev_attr.attr.name = __stringify(field);		\
>   	dpn_attr->dev_attr.attr.mode = 0444;				\
> 

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

* Re: [PATCH] soundwire: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute
  2020-11-04 11:29 ` Srinivas Kandagatla
@ 2020-11-24  8:39   ` Vinod Koul
  -1 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2020-11-24  8:39 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: yung-chuan.liao, pierre-louis.bossart, sanyog.r.kale, gregkh,
	alsa-devel, linux-kernel

On 04-11-20, 11:29, Srinivas Kandagatla wrote:
> running kernel with CONFIG_DEBUG_LOCKS_ALLOC enabled will below warning:
> 
> BUG: key ffff502e09807098 has not been registered!
> DEBUG_LOCKS_WARN_ON(1)
> WARNING: CPU: 5 PID: 129 at kernel/locking/lockdep.c:4623
> 	lockdep_init_map_waits+0xe8/0x250
> Modules linked in:
> CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
>        W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
> Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
> Workqueue: events deferred_probe_work_func
> pstate: 80c00005 (Nzcv daif +PAN +UAO -TCO BTYPE=--)
> pc : lockdep_init_map_waits+0xe8/0x250
> lr : lockdep_init_map_waits+0xe8/0x250

Applied, thanks

-- 
~Vinod

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

* Re: [PATCH] soundwire: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute
@ 2020-11-24  8:39   ` Vinod Koul
  0 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2020-11-24  8:39 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: alsa-devel, gregkh, pierre-louis.bossart, linux-kernel,
	sanyog.r.kale, yung-chuan.liao

On 04-11-20, 11:29, Srinivas Kandagatla wrote:
> running kernel with CONFIG_DEBUG_LOCKS_ALLOC enabled will below warning:
> 
> BUG: key ffff502e09807098 has not been registered!
> DEBUG_LOCKS_WARN_ON(1)
> WARNING: CPU: 5 PID: 129 at kernel/locking/lockdep.c:4623
> 	lockdep_init_map_waits+0xe8/0x250
> Modules linked in:
> CPU: 5 PID: 129 Comm: kworker/5:1 Tainted: G
>        W         5.10.0-rc1-00277-ged49f224ca3f-dirty #1210
> Hardware name: Qualcomm Technologies, Inc. Robotics RB5 (DT)
> Workqueue: events deferred_probe_work_func
> pstate: 80c00005 (Nzcv daif +PAN +UAO -TCO BTYPE=--)
> pc : lockdep_init_map_waits+0xe8/0x250
> lr : lockdep_init_map_waits+0xe8/0x250

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2020-11-24  8:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-04 11:29 [PATCH] soundwire: Fix DEBUG_LOCKS_WARN_ON for uninitialized attribute Srinivas Kandagatla
2020-11-04 11:29 ` Srinivas Kandagatla
2020-11-04 14:32 ` Pierre-Louis Bossart
2020-11-04 14:32   ` Pierre-Louis Bossart
2020-11-24  8:39 ` Vinod Koul
2020-11-24  8:39   ` Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.