From: Michael Buesch <mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
To: Larry Finger <Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Martin Langer <martin-langer-Mmb7MZpHnFY@public.gmane.org>,
bcm43xx-dev-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
John Linville <linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Subject: Re: [PATCH] ucode debug status via sysfs for wireless-2.6
Date: Thu, 7 Sep 2006 22:48:39 +0200 [thread overview]
Message-ID: <200609072248.39588.mb@bu3sch.de> (raw)
In-Reply-To: <45001CCA.1000304-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>
On Thursday 07 September 2006 15:21, Larry Finger wrote:
> Michael Buesch wrote:
> > On Thursday 07 September 2006 03:34, Larry Finger wrote:
> >> + return -EPERM;
> >> +
> >
> > you want to take the spinlock lock here, too.
>
> Obviously, I copied the wrong model. Is it correct that one should take both locks if your code will
> touch the hardware, but the mutex lock only is sufficient if your code just accesses data
> structures? This seems to be the pattern in the other bcm43xx_attr_xxxx_show routines.
In general, no.
But, for some sysfs attrs it is sufficient to only take
the mutex, because:
* We don't access hardware.
* We don't modify this data in a spinlock-only critical section.
Yes, I know that having two locks does not really fit the
"lock data, not code" model. But it's well defined in bcm43xx,
so I think we can live with it. (and we must live with it,
if we want to have preemptible periodic work. And we _want_).
It's defined by the following rules:
1) Always take both, mutex and lock.
2) There are only two places where we can't take the
mutex, but only the spinlock. IRQ and TX paths.
(Yes, I know that there are still exceptions to 2.
At least in dscape. The softmac port should be OK.
These are bugs, I am aware of them and will fix it)
So these two rules lead to the following rule:
* Code where we only take the mutex can race against the
TX and IRQ paths.
Now we come back to the sysfs problem above. If the data, we
access in this sysfs code, is not touched in either TX or IRQ path
we don't need to take the spinlock. Yes, it's a little bit black
magic. So if you aren't sure, always take both locks.
--
Greetings Michael.
next prev parent reply other threads:[~2006-09-07 20:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20060904205340.GB3726@tuba>
[not found] ` <200609042256.54629.mb@bu3sch.de>
[not found] ` <20060905181232.GA4733@tuba>
2006-09-07 1:34 ` [PATCH] ucode debug status via sysfs for wireless-2.6 Larry Finger
[not found] ` <44FF772A.5000301-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>
2006-09-07 8:33 ` Michael Buesch
[not found] ` <200609071033.52258.mb-fseUSCV1ubazQB+pC5nmwQ@public.gmane.org>
2006-09-07 13:21 ` Larry Finger
[not found] ` <45001CCA.1000304-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>
2006-09-07 20:48 ` Michael Buesch [this message]
2006-09-07 21:05 ` Larry Finger
2006-09-07 15:12 ` [PATCH] Try 2: " Larry Finger
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=200609072248.39588.mb@bu3sch.de \
--to=mb-fseuscv1ubazqb+pc5nmwq@public.gmane.org \
--cc=Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org \
--cc=bcm43xx-dev-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org \
--cc=linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
--cc=martin-langer-Mmb7MZpHnFY@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).