Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753027AbbF3Mlk (ORCPT ); Tue, 30 Jun 2015 08:41:40 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:49914 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752172AbbF3Mli (ORCPT ); Tue, 30 Jun 2015 08:41:38 -0400 MIME-version: 1.0 Content-type: text/plain; charset=UTF-8; format=flowed X-AuditID: cbfec7f5-f794b6d000001495-66-55928e7fd4f1 Content-transfer-encoding: 8BIT Message-id: <55928E7B.2020306@samsung.com> Date: Tue, 30 Jun 2015 14:41:31 +0200 From: Jacek Anaszewski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 To: Stas Sergeev Cc: Stas Sergeev , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, Bryan Wu , Richard Purdie , Pavel Machek , Sakari Ailus , Andreas Werner , Andrew Lunn , Antonio Ospite , Atsushi Nemoto , Ben Dooks , Chris Boot , Dan Murphy , Daniel Jeong , Daniel Mack , "David S. Miller" , Fabio Baltieri , Felipe Balbi , Florian Fainelli , "G.Shark Jeong" , Guennadi Liakhovetski , Ingi Kim , Jan-Simon Moeller , Johan Hovold , John Lenz , Jonas Gorski , Kim Kyuwon , Kristian Kielhofner , Kristoffer Ericson , Linus Walleij , Mark Brown , Michael Hennerich , Milo Kim , =?UTF-8?B?TcOhcnRvbiBOw6ltZXRo?= , Nate Case , NeilBrown , Nick Forbes , Paul Parsons , Peter Meerwald , Phil Sutter , Philippe Retornaz , Raphael Assenat , Richard Purdie , Rod Whitby , Dave Hansen , Rodolfo Giometti , "Sebastian A. Siewior" , Shuah Khan , Simon Guinot , =?UTF-8?B?w4FsdmFybyBGZXJuw6FuZGV6IFJvamFz?= Subject: Re: [PATCH/RFC RESEND] leds: Use set_brightness_work for brightness_set ops that can sleep References: <1435651268-9657-1-git-send-email-j.anaszewski@samsung.com> <559252EC.2050906@samsung.com> <55928054.8070705@list.ru> In-reply-to: <55928054.8070705@list.ru> X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUxTZxiGfc/7ntPTZo3Hiu4dZjFpsnQhfm7GPFkWw36YncxlmZsYHcRR 4ViIgKQFFF3kSxa+VisgiR1Bo1Y+ZEVplS9xWqyKpw4nwYATdKY1DtE6urJCHWwnbJn/ntz3 lTvXj4fHut/YWD49K0cyZxkz9JyGyLM3hlYWWKsT1nTUqaCy10ZgYNSDwVGzBa4+LIBGOUSg 7udqDK3ejXD0Vz8H3q4jDFy6GMBQ/Nc4gaLmHxmoHzhEoDZaz0Kl7GahJLILpoI+AsHzDQx0 3J/FUNNTwULnyB8c/OK8xUHxcBUL064yFTT0U/D2dbNQ+6qRgcHueg4uTDgRRKwXObD1uVTQ OOMk8OJFlEDg8FUV9B4vJPDn7TkME50yC60PPCxEK3sIWD1vwegtLweDt70Ezj+2MxDw3Udw 42Y/A9O9jzD0dAdYmHRPMdDm10B4Oh5K2wsxlFvrSPw6cc51EonjQx+JTWOjjBhqPkPEoZkW LLqbRxjxTOlZLJ4ui6jE8OS4Suyyj6rEl7/vEBscV7DY3lLOiTX3qlixefARIz64d4n73PCV 5sNUKSM9TzKv3pCsSbsyVYWyj8Xsu/7se1KI2oQKpOapsI4+nCll5++l9M5YG1eBNLxOcCAq /zCHlUIrLKKRmjFSgXgeC8vptbu7lRgL6+njQ048zz9BtNHxVDXPx9GRkzcZhSfCO3Rg4hsl 5oS1dPrpM0a5lwjb6Cv5MqsgMf9MnivKU2aw4FxI/YfDSGEWCxLtK6v716cE0aaj45xSqAUD tbn6GRsS7K/p2f/Xs7+mdwLhFrREyk3Jtuw0Zb63ymLMtORmmVal7MlsR/MPGO5EjusfeJDA I/0b2uTAkQQda8yz5Gd6EOWxPkZbVVydoNOmGvP3S+Y9X5tzMySLBy3jif5N7bHu4BadYDLm SLslKVsy/9cyvDq2ECVGvtxrKXq3RNs1q5484H6Znuz+Ii1R6zqwKZh0PHQt6XLHWDRE+/y5 TxLvfOKpJybTsDFssH5X4P+swb/r3KnN2ydkU3Fs6t1Nw9Ky5z+FToffr/XFx8lRT2v+p0ny 3McHcxa6lk8FJbehfLh6he8gO/v21m/VNt+CfEPK5tYmPbGkGdfGYbPF+DfVLVyGfAMAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2766 Lines: 69 On 06/30/2015 01:41 PM, Stas Sergeev wrote: > 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? This in fact doesn't take place in the mainline kernel, however there are some out of tree users apparently [1]. We could remove this possibility, just give me a reason why we should do that? If we removed it, we would force any potential driver wanting to call led_set_brightness(LED_OFF) from hard irq context to use the work queue on its own. Modifications I am proposing also need set_brightness_work, so there is almost no cost of keeping the support for calling led_set_brightness from hard irq context intact. > 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. With the new approach it should call led_set_brightness_nosleep there. > > 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; > } > > [1] http://www.spinics.net/lists/linux-leds/msg00006.html -- Best Regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/