All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@list.ru>
To: Jacek Anaszewski <j.anaszewski@samsung.com>,
	Stas Sergeev <stsp@users.sourceforge.net>
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bryan Wu <cooloney@gmail.com>, Richard Purdie <rpurdie@rpsys.net>,
	Pavel Machek <pavel@ucw.cz>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Andreas Werner <andreas.werner@men.de>,
	Andrew Lunn <andrew@lunn.ch>,
	Antonio Ospite <ospite@studenti.unina.it>,
	Atsushi Nemoto <anemo@mba.ocn.ne.jp>,
	Ben Dooks <ben@simtec.co.uk>, Chris Boot <bootc@bootc.net>,
	Dan Murphy <dmurphy@ti.com>, Daniel Jeong <daniel.jeong@ti.com>,
	Daniel Mack <daniel@zonque.org>,
	"David S. Miller" <davem@davemloft.net>,
	Fabio Baltieri <fabio.baltieri@gmail.com>,
	Felipe Balbi <balbi@ti.com>,
	Florian Fainelli <florian@openwrt.org>,
	"G.Shark Jeong" <gshark.jeong@gmail.com>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Ingi Kim <ingi2.kim@samsung.com>,
	Jan-Simon Moeller <dl9pf@gmx.de>, Johan Hovold <johan@kernel.org>,
	John Lenz <lenz@cs.wisc.>
Subject: Re: [PATCH/RFC RESEND] leds: Use set_brightness_work for brightness_set ops that can sleep
Date: Tue, 30 Jun 2015 14:41:08 +0300	[thread overview]
Message-ID: <55928054.8070705@list.ru> (raw)
In-Reply-To: <559252EC.2050906@samsung.com>

30.06.2015 11:27, Jacek Anaszewski пишет:
> On 06/29/2015 05:17 PM, Stas Sergeev wrote:> 29.06.2015 17:05, Jacek Anaszewski пишет:
>>> +         * If need to disable soft blinking delegate this to the
>>> +         * work queue task to avoid problems in case we are
>>> +         * called from hard irq context.
>>> +         */
>>> +        led_cdev->flags |= LED_BLINK_DISABLE;
>> Wouldn't it be better to just enforce the callers
>> to explicitly disable software blink, so that it to
>> never happen from irq context? Something like in this
>> patch:
>> https://lkml.org/lkml/2015/5/13/491
>>
> 
> Blinking can be disabled not only by removing trigger explicitly,
> but also by setting brightness to 0 and led_set_brightness
> can be called from hard irq context. set_brightness_work
> was originally introduced exactly for this use case.
Could you please describe where does this happen?
I can see LED_OFF happening only in led_heartbeat_function(), but
it doesn't use soft-blink, so it will not activate the delayed
timer cancel.

I would suggest the patch below to make it explicit that
led_heartbeat_function() doesn't want to cancel soft blink.
Note that led_heartbeat_function() already uses led_set_brightness_async()
in a normal case.


diff --git a/drivers/leds/trigger/ledtrig-heartbeat.c b/drivers/leds/trigger/ledtrig-heartbeat.c
index fea6871..0f89d12 100644
--- a/drivers/leds/trigger/ledtrig-heartbeat.c
+++ b/drivers/leds/trigger/ledtrig-heartbeat.c
@@ -37,7 +37,7 @@ static void led_heartbeat_function(unsigned long data)
 	unsigned long delay = 0;

 	if (unlikely(panic_heartbeats)) {
-		led_set_brightness(led_cdev, LED_OFF);
+		led_set_brightness_async(led_cdev, LED_OFF);
 		return;
 	}

WARNING: multiple messages have this Message-ID (diff)
From: Stas Sergeev <stsp@list.ru>
To: Jacek Anaszewski <j.anaszewski@samsung.com>,
	Stas Sergeev <stsp@users.sourceforge.net>
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Bryan Wu" <cooloney@gmail.com>,
	"Richard Purdie" <rpurdie@rpsys.net>,
	"Pavel Machek" <pavel@ucw.cz>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Andreas Werner" <andreas.werner@men.de>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Antonio Ospite" <ospite@studenti.unina.it>,
	"Atsushi Nemoto" <anemo@mba.ocn.ne.jp>,
	"Ben Dooks" <ben@simtec.co.uk>, "Chris Boot" <bootc@bootc.net>,
	"Dan Murphy" <dmurphy@ti.com>,
	"Daniel Jeong" <daniel.jeong@ti.com>,
	"Daniel Mack" <daniel@zonque.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Fabio Baltieri" <fabio.baltieri@gmail.com>,
	"Felipe Balbi" <balbi@ti.com>,
	"Florian Fainelli" <florian@openwrt.org>,
	"G.Shark Jeong" <gshark.jeong@gmail.com>,
	"Guennadi Liakhovetski" <g.liakhovetski@gmx.de>,
	"Ingi Kim" <ingi2.kim@samsung.com>,
	"Jan-Simon Moeller" <dl9pf@gmx.de>,
	"Johan Hovold" <johan@kernel.org>, "John Lenz" <lenz@cs.wisc.edu>,
	"Jonas Gorski" <jogo@openwrt.org>,
	"Kim Kyuwon" <q1.kim@samsung.com>,
	"Kristian Kielhofner" <kris@krisk.org>,
	"Kristoffer Ericson" <kristoffer.ericson@gmail.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Mark Brown" <broonie@kernel.org>,
	"Michael Hennerich" <michael.hennerich@analog.com>,
	"Milo Kim" <milo.kim@ti.com>, "Márton Németh" <nm127@freemail.hu>,
	"Nate Case" <ncase@xes-inc.com>, NeilBrown <neilb@suse.de>,
	"Nick Forbes" <nick.forbes@incepta.com>,
	"Paul Parsons" <lost.distance@yahoo.com>,
	"Peter Meerwald" <p.meerwald@bct-electronic.com>,
	"Phil Sutter" <n0-1@freewrt.org>,
	"Philippe Retornaz" <philippe.retornaz@epfl.ch>,
	"Raphael Assenat" <raph@8d.com>,
	"Richard Purdie" <rpurdie@openedhand.com>,
	"Rod Whitby" <rod@whitby.id.au>, "Dave Hansen" <dave@sr71.net>,
	"Rodolfo Giometti" <giometti@linux.it>,
	"Sebastian A. Siewior" <bigeasy@linutronix.de>,
	"Shuah Khan" <shuahkhan@gmail.com>,
	"Simon Guinot" <sguinot@lacie.com>,
	"Álvaro Fernández Rojas" <noltari@gmail.com>
Subject: Re: [PATCH/RFC RESEND] leds: Use set_brightness_work for brightness_set ops that can sleep
Date: Tue, 30 Jun 2015 14:41:08 +0300	[thread overview]
Message-ID: <55928054.8070705@list.ru> (raw)
In-Reply-To: <559252EC.2050906@samsung.com>

30.06.2015 11:27, Jacek Anaszewski пишет:
> On 06/29/2015 05:17 PM, Stas Sergeev wrote:> 29.06.2015 17:05, Jacek Anaszewski пишет:
>>> +         * If need to disable soft blinking delegate this to the
>>> +         * work queue task to avoid problems in case we are
>>> +         * called from hard irq context.
>>> +         */
>>> +        led_cdev->flags |= LED_BLINK_DISABLE;
>> Wouldn't it be better to just enforce the callers
>> to explicitly disable software blink, so that it to
>> never happen from irq context? Something like in this
>> patch:
>> https://lkml.org/lkml/2015/5/13/491
>>
> 
> Blinking can be disabled not only by removing trigger explicitly,
> but also by setting brightness to 0 and led_set_brightness
> can be called from hard irq context. set_brightness_work
> was originally introduced exactly for this use case.
Could you please describe where does this happen?
I can see LED_OFF happening only in led_heartbeat_function(), but
it doesn't use soft-blink, so it will not activate the delayed
timer cancel.

I would suggest the patch below to make it explicit that
led_heartbeat_function() doesn't want to cancel soft blink.
Note that led_heartbeat_function() already uses led_set_brightness_async()
in a normal case.


diff --git a/drivers/leds/trigger/ledtrig-heartbeat.c b/drivers/leds/trigger/ledtrig-heartbeat.c
index fea6871..0f89d12 100644
--- a/drivers/leds/trigger/ledtrig-heartbeat.c
+++ b/drivers/leds/trigger/ledtrig-heartbeat.c
@@ -37,7 +37,7 @@ static void led_heartbeat_function(unsigned long data)
 	unsigned long delay = 0;

 	if (unlikely(panic_heartbeats)) {
-		led_set_brightness(led_cdev, LED_OFF);
+		led_set_brightness_async(led_cdev, LED_OFF);
 		return;
 	}


  reply	other threads:[~2015-06-30 11:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30  8:01 [PATCH/RFC RESEND] leds: Use set_brightness_work for brightness_set ops that can sleep Jacek Anaszewski
2015-06-30  8:01 ` Jacek Anaszewski
2015-06-30  8:27 ` Jacek Anaszewski
2015-06-30  8:27   ` Jacek Anaszewski
2015-06-30 11:41   ` Stas Sergeev [this message]
2015-06-30 11:41     ` Stas Sergeev
2015-06-30 12:41     ` Jacek Anaszewski
2015-06-30 12:41       ` Jacek Anaszewski
2015-06-30 12:55       ` Stas Sergeev
2015-06-30 12:55         ` Stas Sergeev
2015-06-30 11:58 ` Pavel Machek
2015-06-30 11:58   ` Pavel Machek
2015-06-30 13:06   ` Jacek Anaszewski
2015-06-30 13:06     ` Jacek Anaszewski
2015-06-30 17:46     ` Pavel Machek
2015-06-30 17:46       ` Pavel Machek
2015-07-01  7:28       ` Jacek Anaszewski
2015-07-01  7:28         ` Jacek Anaszewski
2015-07-01  7:43         ` Pavel Machek
2015-07-01  7:43           ` Pavel Machek
2015-07-01 10:47           ` Jacek Anaszewski
2015-07-01 10:47             ` Jacek Anaszewski
2015-07-01 13:37             ` Pavel Machek
2015-07-01 13:37               ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55928054.8070705@list.ru \
    --to=stsp@list.ru \
    --cc=andreas.werner@men.de \
    --cc=andrew@lunn.ch \
    --cc=anemo@mba.ocn.ne.jp \
    --cc=balbi@ti.com \
    --cc=ben@simtec.co.uk \
    --cc=bootc@bootc.net \
    --cc=cooloney@gmail.com \
    --cc=daniel.jeong@ti.com \
    --cc=daniel@zonque.org \
    --cc=davem@davemloft.net \
    --cc=dl9pf@gmx.de \
    --cc=dmurphy@ti.com \
    --cc=fabio.baltieri@gmail.com \
    --cc=florian@openwrt.org \
    --cc=g.liakhovetski@gmx.de \
    --cc=gshark.jeong@gmail.com \
    --cc=ingi2.kim@samsung.com \
    --cc=j.anaszewski@samsung.com \
    --cc=johan@kernel.org \
    --cc=lenz@cs.wisc. \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=ospite@studenti.unina.it \
    --cc=pavel@ucw.cz \
    --cc=rpurdie@rpsys.net \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stsp@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.