public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Christie <michaelc@cs.wisc.edu>
To: SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: possible scsi driver bugs with atomic_set/atomic_read and missing barrier
Date: Tue, 10 Mar 2009 22:25:44 -0500	[thread overview]
Message-ID: <49B72F38.8090703@cs.wisc.edu> (raw)

Hi,

A couple scsi drivers will use a atomic_t for some host/device state.

They will do:

atomic_set(&hba->state, SOME_STATE_VALUE);

in a interrupt or thread or tasklet then in another thread they will do


if (atomic_read(&hba->state) == SOME_STATE_VALUE))



In the Documentation/atomic_ops.txt it says:

	atomic_read does not guarantee that the runtime
	initialization by any other thread is visible yet, so the user of the
	interface must take care of that with a proper implicit or 	explicit memory
	barrier.


Does this mean that the drivers should be doing a


atomic_set(&hba->state, SOME_STATE_VALUE);
smp_mb();

             reply	other threads:[~2009-03-11  3:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11  3:25 Mike Christie [this message]
2009-03-11  3:39 ` possible scsi driver bugs with atomic_set/atomic_read and missing barrier Matthew Wilcox
2009-03-11  9:36   ` Stefan Richter
2009-03-11  8:45 ` Stefan Richter

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=49B72F38.8090703@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=linux-scsi@vger.kernel.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