From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Ricardo Cerqueira <v4l@cerqueira.org>,
Carvalho Chehab <mchehab@infradead.org>
Cc: Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Incorrect atomic usage in cx88-alsa driver
Date: Tue, 08 May 2007 13:25:06 +1000 [thread overview]
Message-ID: <1178594706.14928.66.camel@localhost.localdomain> (raw)
Hi !
So I see this construct:
if (test_and_set_bit(0, &chip->opened))
return -EBUSY;
.../...
return 0;
_error:
dprintk(1,"Error opening PCM!\n");
clear_bit(0, &chip->opened);
smp_mb__after_clear_bit();
return err;
So that's basically an attempt at doing a spinlock. The problem is your
barrier is wrong at the end. Better would be:
done:
smp_mb__before_clear_bit();
clear_bit(0, &chip->opened);
Though it's still less optimal that doing:
if (!spin_trylock(...))
goto bail;
.../...
done:
spin_unlock(...)
If you really want to stick to bitops, then you may want to look at
Nick's upcoming patches adding some bitops with appropriate lock
semantics.
Cheers,
Ben.
reply other threads:[~2007-05-08 3:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1178594706.14928.66.camel@localhost.localdomain \
--to=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@infradead.org \
--cc=v4l@cerqueira.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
all inboxes | Powered by JetHome®