From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Andrew Morton <akpm@osdl.org>
Cc: linuxppc-dev@ozlabs.org, aris@valeta.org,
johannes@sipsolutions.net, linux-kernel@killerfox.forkbomb.ch
Subject: Re: powermac: More powermac backlight fixes
Date: Tue, 25 Jul 2006 16:49:01 -0500 [thread overview]
Message-ID: <1153864141.18353.2.camel@localhost.localdomain> (raw)
In-Reply-To: <20060724200315.d3c80ed0.akpm@osdl.org>
On Mon, 2006-07-24 at 20:03 -0700, Andrew Morton wrote:
> On Sat, 15 Jul 2006 15:09:00 +0200
> Michael Hanselmann <linux-kernel@hansmi.ch> wrote:
>
> > This patch fixes several problems:
> > - The legacy backlight value might be set at interrupt time. Introduced
> > a worker to prevent it from directly calling the backlight code.
> > - via-pmu allows the backlight to be grabbed, in which case we need to
> > prevent other kernel code from changing the brightness.
> > - Don't send PMU requests in via-pmu-backlight when the machine is about
> > to sleep or waking up.
> > - More Kconfig fixes.
> >
> > ...
> >
> > static void pmac_backlight_key_worker(void *data);
> > +static void pmac_backlight_set_legacy_worker(void *data);
> > +
> > static DECLARE_WORK(pmac_backlight_key_work, pmac_backlight_key_worker, NULL);
> > +static DECLARE_WORK(pmac_backlight_set_legacy_work, pmac_backlight_set_legacy_worker, NULL);
>
> I see schedule_work()s in there, but no flush_scheduled_work()s or anything
> like that. Generally, this means there are races against rmmod, close(),
> etc.
Can this be rmmod'ed ? No code at hand right now, but the old version
certainly couldn't and the PMU driver who calls that can't neither. It's
not a file descriptor neither.
> >
> > +void pmac_backlight_disable()
> > +{
> > + atomic_inc(&kernel_backlight_disabled);
> > +}
> > +
> > +void pmac_backlight_enable()
> > +{
> > + atomic_dec(&kernel_backlight_disabled);
> > +}
> > +
>
> So if userspace calls ioctl(PMU_IOC_GRAB_BACKLIGHT) eleven times, eleven
> enables are needed? (Actually, eleven open()/close() sequences, I think).
It makes sense to do it his way... You do that to stop kernel from
handling the backlight keys as long as at least one userspace client has
set the "grab" and thus basically says it handles them there. When they
all are gone and/or their fd closed, the backlight control returns to
the kernel default version
> Methinks you wanted just
>
> kernel_backlight_disabled = 1;
Nope, I think he's right there. There are cases where both gnome and
pbbuttons for example say to the kernel they handle the backlight keys.
A bit dodgy but it actually works and you want the kernel to properly
refcount before re-enabling it's own implementation.
Ben.
prev parent reply other threads:[~2006-07-25 21:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-15 13:09 powermac: More powermac backlight fixes Michael Hanselmann
2006-07-25 3:03 ` Andrew Morton
2006-07-25 18:44 ` Michael Hanselmann
2006-07-25 20:06 ` Michael Hanselmann
2006-07-25 21:49 ` Benjamin Herrenschmidt [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=1153864141.18353.2.camel@localhost.localdomain \
--to=benh@kernel.crashing.org \
--cc=akpm@osdl.org \
--cc=aris@valeta.org \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@killerfox.forkbomb.ch \
--cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).