From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
x86@kernel.org,
Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [v2 3/4] platform: (TS-5500) add LED support
Date: Tue, 30 Aug 2011 17:56:44 -0400 [thread overview]
Message-ID: <20110830175644.2ff5d086@v0nbox> (raw)
In-Reply-To: <4E5D535B.3050304@zytor.com>
On Tue, 30 Aug 2011 14:17:15 -0700,
"H. Peter Anvin" <hpa@zytor.com> wrote:
> On 08/30/2011 02:15 PM, Mark Brown wrote:
> > On Tue, Aug 30, 2011 at 05:14:24PM -0400, Vivien Didelot wrote:
> >> "H. Peter Anvin" <hpa@zytor.com> wrote:
> >>> On 08/29/2011 03:16 PM, Mark Brown wrote:
> >
> >>>> Can you not do outb() from atomic context? The reason lots of
> >>>> LED drivers update the hardware in a workqueue is that they
> >>>> communicate with the hardware over buses that can't be used in
> >>>> atomic context like I2C or SPI but if that's not an issue then
> >>>> the workqueue is not required and the code can be simplified.
> >
> >>> outb() can definitely be executed from atomic context.
> >
> >> Good to know, thanks. I removed the work_struct and instead lock a
> >> mutex before setting led->new_brightness and calling outb().
> >
> > You can't take a mutex in atomic context...
>
> OK, so what is the potential race that this mutex is called for? If
> it just means that the brightness can be redundantly set to the same
> value more than once, no atomicity is needed.
>
> -hpa
>
I wrote the led_set function like:
static void ts5500_led_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
struct ts5500_led *led = container_of(led_cdev,
struct ts5500_led,
cdev);
mutex_lock(&led->lock);
led->new_brightness = (value == LED_OFF) ? LED_OFF : LED_FULL;
outb(value, led->ioaddr);
mutex_unlock(&led->lock);
}
I guess the wrong value could be read if we get preempted just before
the outb() call, am I wrong?
Vivien
next prev parent reply other threads:[~2011-08-30 21:56 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-26 23:40 [v2 0/4] Support for the TS-5500 platform Vivien Didelot
2011-08-26 23:40 ` [v2 1/4] platform: (TS-5500) add base support Vivien Didelot
2011-08-26 23:40 ` [v2 2/4] platform: (TS-5500) add GPIO support Vivien Didelot
2011-08-29 22:11 ` Mark Brown
2011-08-30 5:36 ` H. Peter Anvin
2011-08-30 11:00 ` Mark Brown
2011-08-30 14:49 ` Vivien Didelot
2011-08-30 15:12 ` Mark Brown
2011-10-12 16:41 ` Linus Walleij
2011-10-13 3:31 ` Grant Likely
2011-08-30 18:39 ` Vivien Didelot
2011-08-30 18:41 ` Mark Brown
2011-08-30 18:43 ` H. Peter Anvin
2011-08-30 21:12 ` Vivien Didelot
2011-10-12 15:35 ` Ingo Molnar
2011-10-14 6:14 ` Ingo Molnar
2011-10-15 14:29 ` Vivien Didelot
2011-08-26 23:40 ` [v2 3/4] platform: (TS-5500) add LED support Vivien Didelot
2011-08-29 22:16 ` Mark Brown
2011-08-30 5:37 ` H. Peter Anvin
2011-08-30 21:14 ` Vivien Didelot
2011-08-30 21:15 ` Mark Brown
2011-08-30 21:17 ` H. Peter Anvin
2011-08-30 21:56 ` Vivien Didelot [this message]
2011-08-30 22:04 ` H. Peter Anvin
2011-08-31 20:01 ` Vivien Didelot
2011-10-12 15:34 ` Ingo Molnar
2011-10-15 14:42 ` Vivien Didelot
2011-10-15 14:56 ` Ingo Molnar
2011-11-16 5:41 ` Ingo Molnar
2011-11-16 12:50 ` Mark Brown
2011-10-26 15:41 ` Ingo Molnar
2011-11-17 15:27 ` Vivien Didelot
2011-08-26 23:40 ` [v2 4/4] platform: (TS-5500) add ADC support Vivien Didelot
2011-08-29 22:13 ` Mark Brown
2011-09-12 7:28 ` [v2 0/4] Support for the TS-5500 platform 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=20110830175644.2ff5d086@v0nbox \
--to=vivien.didelot@savoirfairelinux.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=hpa@zytor.com \
--cc=jonas.fonseca@savoirfairelinux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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