public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] backlight: led_bl: take led_access lock when required
@ 2023-06-19 16:02 Mans Rullgard
  2023-06-26 14:27 ` Daniel Thompson
  2023-06-26 15:30 ` Lee Jones
  0 siblings, 2 replies; 3+ messages in thread
From: Mans Rullgard @ 2023-06-19 16:02 UTC (permalink / raw)
  To: Lee Jones, Daniel Thompson, Jingoo Han
  Cc: Tomi Valkeinen, dri-devel, linux-kernel

The led_access lock must be held when calling led_sysfs_enable() and
led_sysfs_disable().  This fixes warnings such as this:

[    2.432495] ------------[ cut here ]------------
[    2.437316] WARNING: CPU: 0 PID: 22 at drivers/leds/led-core.c:349 led_sysfs_disable+0x54/0x58
[    2.446105] Modules linked in:
[    2.449218] CPU: 0 PID: 22 Comm: kworker/u2:1 Not tainted 6.3.8+ #1
[    2.456268] Hardware name: Generic AM3517 (Flattened Device Tree)
[    2.462402] Workqueue: events_unbound deferred_probe_work_func
[    2.468353]  unwind_backtrace from show_stack+0x10/0x14
[    2.473632]  show_stack from dump_stack_lvl+0x24/0x2c
[    2.478759]  dump_stack_lvl from __warn+0x9c/0xc4
[    2.483551]  __warn from warn_slowpath_fmt+0x64/0xc0
[    2.488586]  warn_slowpath_fmt from led_sysfs_disable+0x54/0x58
[    2.494567]  led_sysfs_disable from led_bl_probe+0x20c/0x3b0
[    2.500305]  led_bl_probe from platform_probe+0x5c/0xb8
[    2.505615]  platform_probe from really_probe+0xc8/0x2a0
[    2.510986]  really_probe from __driver_probe_device+0x88/0x19c
[    2.516967]  __driver_probe_device from driver_probe_device+0x30/0xcc
[    2.523498]  driver_probe_device from __device_attach_driver+0x94/0xc4
[    2.530090]  __device_attach_driver from bus_for_each_drv+0x80/0xcc
[    2.536437]  bus_for_each_drv from __device_attach+0xf8/0x19c
[    2.542236]  __device_attach from bus_probe_device+0x8c/0x90
[    2.547973]  bus_probe_device from deferred_probe_work_func+0x80/0xb0
[    2.554504]  deferred_probe_work_func from process_one_work+0x228/0x4c0
[    2.561187]  process_one_work from worker_thread+0x1fc/0x4d0
[    2.566925]  worker_thread from kthread+0xb4/0xd0
[    2.571685]  kthread from ret_from_fork+0x14/0x2c
[    2.576446] Exception stack(0xd0079fb0 to 0xd0079ff8)
[    2.581573] 9fa0:                                     00000000 00000000 00000000 00000000
[    2.589813] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[    2.598052] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    2.604888] ---[ end trace 0000000000000000 ]---


Signed-off-by: Mans Rullgard <mans@mansr.com>
---
 drivers/video/backlight/led_bl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c
index f54d256e2d54..7d02deb3444a 100644
--- a/drivers/video/backlight/led_bl.c
+++ b/drivers/video/backlight/led_bl.c
@@ -209,8 +209,11 @@ static int led_bl_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->bl_dev);
 	}
 
-	for (i = 0; i < priv->nb_leds; i++)
+	for (i = 0; i < priv->nb_leds; i++) {
+		mutex_lock(&priv->leds[i]->led_access);
 		led_sysfs_disable(priv->leds[i]);
+		mutex_unlock(&priv->leds[i]->led_access);
+	}
 
 	backlight_update_status(priv->bl_dev);
 
-- 
2.41.0


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

* Re: [PATCH] backlight: led_bl: take led_access lock when required
  2023-06-19 16:02 [PATCH] backlight: led_bl: take led_access lock when required Mans Rullgard
@ 2023-06-26 14:27 ` Daniel Thompson
  2023-06-26 15:30 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Thompson @ 2023-06-26 14:27 UTC (permalink / raw)
  To: Mans Rullgard
  Cc: Lee Jones, Jingoo Han, Tomi Valkeinen, dri-devel, linux-kernel

On Mon, Jun 19, 2023 at 05:02:49PM +0100, Mans Rullgard wrote:
> The led_access lock must be held when calling led_sysfs_enable() and
> led_sysfs_disable().  This fixes warnings such as this:
>
> [    2.432495] ------------[ cut here ]------------
> [    2.437316] WARNING: CPU: 0 PID: 22 at drivers/leds/led-core.c:349 led_sysfs_disable+0x54/0x58
> [    2.446105] Modules linked in:
> [    2.449218] CPU: 0 PID: 22 Comm: kworker/u2:1 Not tainted 6.3.8+ #1
> [    2.456268] Hardware name: Generic AM3517 (Flattened Device Tree)
> [    2.462402] Workqueue: events_unbound deferred_probe_work_func
> [    2.468353]  unwind_backtrace from show_stack+0x10/0x14
> [    2.473632]  show_stack from dump_stack_lvl+0x24/0x2c
> [    2.478759]  dump_stack_lvl from __warn+0x9c/0xc4
> [    2.483551]  __warn from warn_slowpath_fmt+0x64/0xc0
> [    2.488586]  warn_slowpath_fmt from led_sysfs_disable+0x54/0x58
> [    2.494567]  led_sysfs_disable from led_bl_probe+0x20c/0x3b0
> [    2.500305]  led_bl_probe from platform_probe+0x5c/0xb8
> [    2.505615]  platform_probe from really_probe+0xc8/0x2a0
> [    2.510986]  really_probe from __driver_probe_device+0x88/0x19c
> [    2.516967]  __driver_probe_device from driver_probe_device+0x30/0xcc
> [    2.523498]  driver_probe_device from __device_attach_driver+0x94/0xc4
> [    2.530090]  __device_attach_driver from bus_for_each_drv+0x80/0xcc
> [    2.536437]  bus_for_each_drv from __device_attach+0xf8/0x19c
> [    2.542236]  __device_attach from bus_probe_device+0x8c/0x90
> [    2.547973]  bus_probe_device from deferred_probe_work_func+0x80/0xb0
> [    2.554504]  deferred_probe_work_func from process_one_work+0x228/0x4c0
> [    2.561187]  process_one_work from worker_thread+0x1fc/0x4d0
> [    2.566925]  worker_thread from kthread+0xb4/0xd0
> [    2.571685]  kthread from ret_from_fork+0x14/0x2c
> [    2.576446] Exception stack(0xd0079fb0 to 0xd0079ff8)
> [    2.581573] 9fa0:                                     00000000 00000000 00000000 00000000
> [    2.589813] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [    2.598052] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
> [    2.604888] ---[ end trace 0000000000000000 ]---
>
>
> Signed-off-by: Mans Rullgard <mans@mansr.com>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


Daniel.

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

* Re: [PATCH] backlight: led_bl: take led_access lock when required
  2023-06-19 16:02 [PATCH] backlight: led_bl: take led_access lock when required Mans Rullgard
  2023-06-26 14:27 ` Daniel Thompson
@ 2023-06-26 15:30 ` Lee Jones
  1 sibling, 0 replies; 3+ messages in thread
From: Lee Jones @ 2023-06-26 15:30 UTC (permalink / raw)
  To: Mans Rullgard
  Cc: Daniel Thompson, Jingoo Han, Tomi Valkeinen, dri-devel,
	linux-kernel

On Mon, 19 Jun 2023, Mans Rullgard wrote:

> The led_access lock must be held when calling led_sysfs_enable() and
> led_sysfs_disable().  This fixes warnings such as this:
> 
> [    2.432495] ------------[ cut here ]------------
> [    2.437316] WARNING: CPU: 0 PID: 22 at drivers/leds/led-core.c:349 led_sysfs_disable+0x54/0x58
> [    2.446105] Modules linked in:
> [    2.449218] CPU: 0 PID: 22 Comm: kworker/u2:1 Not tainted 6.3.8+ #1
> [    2.456268] Hardware name: Generic AM3517 (Flattened Device Tree)
> [    2.462402] Workqueue: events_unbound deferred_probe_work_func
> [    2.468353]  unwind_backtrace from show_stack+0x10/0x14
> [    2.473632]  show_stack from dump_stack_lvl+0x24/0x2c
> [    2.478759]  dump_stack_lvl from __warn+0x9c/0xc4
> [    2.483551]  __warn from warn_slowpath_fmt+0x64/0xc0
> [    2.488586]  warn_slowpath_fmt from led_sysfs_disable+0x54/0x58
> [    2.494567]  led_sysfs_disable from led_bl_probe+0x20c/0x3b0
> [    2.500305]  led_bl_probe from platform_probe+0x5c/0xb8
> [    2.505615]  platform_probe from really_probe+0xc8/0x2a0
> [    2.510986]  really_probe from __driver_probe_device+0x88/0x19c
> [    2.516967]  __driver_probe_device from driver_probe_device+0x30/0xcc
> [    2.523498]  driver_probe_device from __device_attach_driver+0x94/0xc4
> [    2.530090]  __device_attach_driver from bus_for_each_drv+0x80/0xcc
> [    2.536437]  bus_for_each_drv from __device_attach+0xf8/0x19c
> [    2.542236]  __device_attach from bus_probe_device+0x8c/0x90
> [    2.547973]  bus_probe_device from deferred_probe_work_func+0x80/0xb0
> [    2.554504]  deferred_probe_work_func from process_one_work+0x228/0x4c0
> [    2.561187]  process_one_work from worker_thread+0x1fc/0x4d0
> [    2.566925]  worker_thread from kthread+0xb4/0xd0
> [    2.571685]  kthread from ret_from_fork+0x14/0x2c
> [    2.576446] Exception stack(0xd0079fb0 to 0xd0079ff8)
> [    2.581573] 9fa0:                                     00000000 00000000 00000000 00000000
> [    2.589813] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
> [    2.598052] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
> [    2.604888] ---[ end trace 0000000000000000 ]---
> 
> 
> Signed-off-by: Mans Rullgard <mans@mansr.com>
> ---
>  drivers/video/backlight/led_bl.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Applied, thanks

-- 
Lee Jones [李琼斯]

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

end of thread, other threads:[~2023-06-26 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-19 16:02 [PATCH] backlight: led_bl: take led_access lock when required Mans Rullgard
2023-06-26 14:27 ` Daniel Thompson
2023-06-26 15:30 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox