mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>
To: "Richard Purdie" <rpurdie@rpsys.net>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"Michael Hanselmann" <linux-kernel@hansmi.ch>,
	"Antonino A. Daplas" <adaplas@pol.net>
Subject: Re: [patch 5/6] Convert to use mutexes instead of semaphores
Date: Fri, 11 Aug 2006 09:34:44 -0400	[thread overview]
Message-ID: <d120d5000608110634n501d33b0yb7702a24cbf064e3@mail.gmail.com> (raw)
In-Reply-To: <1155302169.19959.16.camel@localhost.localdomain>

On 8/11/06, Richard Purdie <rpurdie@rpsys.net> wrote:
> On Fri, 2006-08-11 at 08:58 -0400, Dmitry Torokhov wrote:
> > On 8/11/06, Dmitry Torokhov <dtor@insightbb.com> wrote:
> > > Backlight: convert to use mutexes instead of semaphores
> > >
> >
> > Apparently I missed that several drivers also use bd->sem so they need
> > to be converted too... But what is it with the drivers:
> >
> > static void aty128_bl_set_power(struct fb_info *info, int power)
> > {
> >         mutex_lock(&info->bl_mutex);
> >         up(&info->bl_dev->sem);
> >         info->bl_dev->props->power = power;
> >         __aty128_bl_update_status(info->bl_dev);
> >         down(&info->bl_dev->sem);
> >         mutex_unlock(&info->bl_mutex);
> > }
> >
> > Why we are doing up() before down()??? And it is in almost every
> > driver that uses backlight... Do I need more coffee? [CC-ing bunch of
> > people trying to get an answer...]
>
> It looks totally wrong.
>

Ok, so that is not only me seeing things ;)

> In the archives, there are a number of comments from me questioning
> whether that driver needs to touch bl_dev->sem anyway (esp. given the
> mutex as well). I never did find out what it was trying to protect
> against...

I think it is prudent to protect assess to these data structures. For
example, it could possibly race with setting power through sysfs
attribute. Now for this particular driver the race window is
non-existent for all practical purposes, but it looks like atyfb_base
might be needig it (of course currentimplementation not only have
up/down mixed but also has AB-BA deadlock).

How about we add backlight_set_power(&bd, power) to the backlight core
to take care of proper locking for drivers?

-- 
Dmitry

  reply	other threads:[~2006-08-11 13:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-11  5:03 [patch 0/6] Backlight & lcd fixes/cleanups Dmitry Torokhov
2006-08-11  5:03 ` [patch 1/6] Convert to use default class device attributes Dmitry Torokhov
2006-08-11  5:03 ` [patch 2/6] Fix error handling when registering new device Dmitry Torokhov
2006-08-11  5:03 ` [patch 3/6] Get rid of excessive amount of likely()s Dmitry Torokhov
2006-08-11  5:03 ` [patch 4/6] Remove "owner" from backlight_properties structure Dmitry Torokhov
2006-08-11  5:03 ` [patch 5/6] Convert to use mutexes instead of semaphores Dmitry Torokhov
2006-08-11 12:58   ` Dmitry Torokhov
2006-08-11 13:16     ` Richard Purdie
2006-08-11 13:34       ` Dmitry Torokhov [this message]
2006-08-11 13:42         ` Michael Hanselmann
2006-08-11 14:07           ` Dmitry Torokhov
2006-08-11 16:45             ` Richard Purdie
2006-08-11 17:20               ` Dmitry Torokhov
2006-08-29 20:54               ` Michael Hanselmann
2006-08-11  5:03 ` [patch 6/6] Move per-device data out of backlight_properties Dmitry Torokhov
2006-08-11  8:02   ` Richard Purdie
2006-08-11 12:27     ` Dmitry Torokhov
2006-08-11 12:55       ` Richard Purdie
2006-08-11 13:10         ` Dmitry Torokhov

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=d120d5000608110634n501d33b0yb7702a24cbf064e3@mail.gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=adaplas@pol.net \
    --cc=linux-kernel@hansmi.ch \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rpurdie@rpsys.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®