From: Ivo van Doorn <ivdoorn@gmail.com>
To: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: John Linville <linville@tuxdriver.com>, linux-wireless@vger.kernel.org
Subject: Re: [PATCH 4/4] rfkill: mutex fixes
Date: Sat, 19 Jul 2008 16:50:30 +0200 [thread overview]
Message-ID: <200807191650.30337.IvDoorn@gmail.com> (raw)
In-Reply-To: <20080719141954.GC11269@khazad-dum.debian.net>
On Saturday 19 July 2008, Henrique de Moraes Holschuh wrote:
> On Sat, 19 Jul 2008, Ivo van Doorn wrote:
> > > @@ -150,7 +150,7 @@ static void update_rfkill_state(struct rfkill *rfkill)
> > > * even if the radio is in RFKILL_STATE_HARD_BLOCKED state, so as to
> > > * give the driver a hint that it should double-BLOCK the transmitter.
> > > *
> > > - * Caller must have aquired rfkill_mutex.
> > > + * Caller must have acquired rfkill->mutex.
> >
> > Should rfkill_toggle_radio() not grab the rfkill->mutex itself?
> > At the moment every caller to rfkill_toggle_radio() does:
> >
> > mutex_lock(&rfkill->mutex);
> > rfkill_toggle_radio(rfkill, state, 0);
> > mutex_unlock(&rfkill->mutex);
> >
> > without anything in between, so perhaps the safest way would be moving
> > the locking requirement into the function.
>
> sysfs attributes need to use mutex_lock_interruptible or
> mutex_lock_killable, and I also need it with external locking in some later
> patches that I haven't sent yet because I am reviewing them.
Ok, in that case it can be kept externally.
I believe there is a patch for sparse soon which adds __requires annotation
which we can use to make sparse check for the correct locking. ;)
> > > @@ -521,8 +527,11 @@ static void rfkill_remove_switch(struct rfkill *rfkill)
> > > {
> > > mutex_lock(&rfkill_mutex);
> > > list_del_init(&rfkill->node);
> > > - rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
> > > mutex_unlock(&rfkill_mutex);
> > > +
> > > + mutex_lock(&rfkill->mutex);
> > > + rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
> > > + mutex_unlock(&rfkill->mutex);
> >
> > Not sure about this one, something tells me it should be something like:
> >
> > mutex_lock(&rfkill_mutex);
> > list_del_init(&rfkill->node);
> >
> > mutex_lock(&rfkill->mutex);
> > rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1);
> > mutex_unlock(&rfkill->mutex);
> >
> > mutex_unlock(&rfkill_mutex);
>
> We really shouldn't need the nesting, as once we have deleted something from
> the list (which is always iterated and manipulated with rfkill_mutex
> locked), nothing that would need the rfkill_mutex will access that rfkill
> struct anymore.
>
> Nesting wouldn't hurt anything, though. If you really feel better with
> that nesting in place, I can nest them.
Ok, I now have looked long at this piece of code, and I think your version is
correct. No need to nest it.
Ivo
next prev parent reply other threads:[~2008-07-19 14:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-15 19:32 [GIT PATCH] rfkill fixes, set 2 Henrique de Moraes Holschuh
2008-07-15 19:32 ` [PATCH 1/4] rfkill: document rfkill_force_state as required Henrique de Moraes Holschuh
2008-07-19 12:34 ` Ivo van Doorn
2008-07-19 13:42 ` Henrique de Moraes Holschuh
2008-07-15 19:32 ` [PATCH 2/4] rfkill: fix led-trigger unregister order in error unwind Henrique de Moraes Holschuh
2008-07-19 12:35 ` Ivo van Doorn
2008-07-15 19:32 ` [PATCH 3/4] rfkill: document the rfkill struct locking Henrique de Moraes Holschuh
2008-07-19 12:39 ` Ivo van Doorn
2008-07-19 13:43 ` Henrique de Moraes Holschuh
2008-07-15 19:32 ` [PATCH 4/4] rfkill: mutex fixes Henrique de Moraes Holschuh
2008-07-17 4:56 ` Michael Buesch
2008-07-17 11:33 ` drago01
2008-07-17 12:10 ` Henrique de Moraes Holschuh
2008-07-19 12:47 ` Ivo van Doorn
2008-07-19 14:19 ` Henrique de Moraes Holschuh
2008-07-19 14:50 ` Ivo van Doorn [this message]
2008-07-19 14:51 ` Ivo van Doorn
2008-07-16 16:29 ` [GIT PATCH] rfkill fixes, set 2 Dan Williams
2008-07-17 11:54 ` Henrique de Moraes Holschuh
2008-07-17 21:56 ` [PATCH 5/4] rfkill: query EV_SW states when rfkill-input connects to a input device Henrique de Moraes Holschuh
2008-07-19 4:01 ` 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=200807191650.30337.IvDoorn@gmail.com \
--to=ivdoorn@gmail.com \
--cc=hmh@hmh.eng.br \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.