mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Pavel Machek <pavel@ucw.cz>
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org,
	craig.mcqueen@innerrange.com.au,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Matthieu CASTET" <matthieu.castet@parrot.com>,
	"Dan Murphy" <dmurphy@ti.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Ben Whitten" <ben.whitten@gmail.com>,
	"Bjorn Andersson" <bjorn.andersson@linaro.org>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Alan Mizrahi" <alan@mizrahi.com.ve>,
	"Vadim Pasternak" <vadimp@mellanox.com>,
	"David Lin" <dtwlin@google.com>, "Joel Stanley" <joel@jms.id.au>,
	"Cédric Le Goater" <clg@kaod.org>, "Willy Tarreau" <w@1wt.eu>,
	"Andrew Jeffery" <andrew@aj.id.au>,
	"Javier Martinez Canillas" <javier@dowhile0.org>,
	"Colin King" <colin.king@canonical.com>
Subject: Re: [PATCH] led: core: Fix race on software blink cancellation
Date: Fri, 9 Feb 2018 22:35:00 +0100	[thread overview]
Message-ID: <d078e26a-6250-72c5-b9ba-28d8787fcd51@gmail.com> (raw)
In-Reply-To: <20180208215041.GA31216@amd>

On 02/08/2018 10:50 PM, Pavel Machek wrote:
> Hi!
> 
>> Any comments? I'd like to have some acks before applying
>> this patch.
> 
> I can't say I like it.

Please point out the bits you don't like and spot any risks.

>>> Commit d23a22a74fde ("leds: delay led_set_brightness if stopping soft-blink")
>>> made a modifications to the LED core allowing for led_set_brightness() to be
>>> called from hard-irq context when soft blink is being handled in soft-irq.
>>>
>>> Since that time LED core has undergone modifications related to addition of
>>> generic support for delegating brightness setting to a workqueue as well as
>>> subsequent fixes for blink setting use cases.
>>>
>>> After that the LED core code became hard to maintain and analyze, especially
>>> due to the imposed hard-irq context compatibility. It also turned out that
>>> in some cases a LED remained off after executing following sequence of commands:
>>>
>>> 1. echo timer > trigger
>>> 2. echo 0 > brightness
>>> 3. echo 100 > brightness
>>>
>>> The reason was LED_BLINK_DISABLE operation delegated to a set_brightness_work,
>>> triggered in 2., which was handled after 3. took effect.
> 
> Could we wait for delayed work to be done before setting the
> brightness to fix this one?

Without mutually exclusive section you can always be preempted
after wait test succeeds and before requesting new brightness.
Then the other process can jump in, request other brightness
(and change it in struct led_classdev via led_set_brightness_nosleep()),
which causes we end up with non deterministic LED class device
state after that.

Every solution without mutually exclusive section is prone to races
here.

-- 
Best regards,
Jacek Anaszewski

      reply	other threads:[~2018-02-09 21:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 21:12 Jacek Anaszewski
2018-02-08 20:55 ` Jacek Anaszewski
2018-02-08 21:50   ` Pavel Machek
2018-02-09 21:35     ` Jacek Anaszewski [this message]

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=d078e26a-6250-72c5-b9ba-28d8787fcd51@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=alan@mizrahi.com.ve \
    --cc=andrew@aj.id.au \
    --cc=andrew@lunn.ch \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=ben.whitten@gmail.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=clg@kaod.org \
    --cc=colin.king@canonical.com \
    --cc=craig.mcqueen@innerrange.com.au \
    --cc=dmurphy@ti.com \
    --cc=dtwlin@google.com \
    --cc=hdegoede@redhat.com \
    --cc=javier@dowhile0.org \
    --cc=joel@jms.id.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=matthieu.castet@parrot.com \
    --cc=pavel@ucw.cz \
    --cc=sakari.ailus@linux.intel.com \
    --cc=vadimp@mellanox.com \
    --cc=w@1wt.eu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome