All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Mickler <florian@mickler.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "John W. Linville" <linville@tuxdriver.com>,
	Marcel Holtmann <marcel@holtmann.org>,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Johannes Berg <johannes@sipsolutions.net>,
	linux-wireless@vger.kernel.org,
	Randy Dunlap <rdunlap@xenotime.net>,
	Alan Jenkins <alan-jenkins@tuffmail.co.uk>,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	Valdis.Kletnieks@vt.edu
Subject: Re: [PATCH 2/2] enhance sysfs rfkill interface
Date: Sat, 13 Mar 2010 10:41:28 +0100	[thread overview]
Message-ID: <20100313104128.79aa2846@schatten.dmk.lab> (raw)
In-Reply-To: <20100312224828.GA18618@core.coreip.homeip.net>

On Fri, 12 Mar 2010 14:48:28 -0800
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:

> On Fri, Mar 12, 2010 at 11:39:25PM +0100, Florian Mickler wrote:
> > On Fri, 12 Mar 2010 13:20:26 -0800
> > Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> > 
> > > On Fri, Mar 12, 2010 at 09:57:43PM +0100, Florian Mickler wrote:
> > > > On Fri, 12 Mar 2010 10:22:09 -0800
> > > > Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> > > > 
> > > > > On Fri, Mar 12, 2010 at 07:03:08PM +0100, florian@mickler.org wrote:
> > > > > >  
> > > > > > +static ssize_t rfkill_hard_show(struct device *dev,
> > > > > > +				 struct device_attribute *attr,
> > > > > > +				 char *buf)
> > > > > > +{
> > > > > > +	struct rfkill *rfkill = to_rfkill(dev);
> > > > > > +	unsigned long flags;
> > > > > > +	u32 state;
> > > > > > +
> > > > > > +	spin_lock_irqsave(&rfkill->lock, flags);
> > > > > > +	state = rfkill->state;
> > > > > > +	spin_unlock_irqrestore(&rfkill->lock, flags);
> > > > > 
> > > > > Why exactly is this lock needed?
> > > > 
> > > > The rfkill state is updated from multiple contexts... Am I overlooking
> > > > smth obvious here?
> > > > 
> > > 
> > > You are not updating but reading... Are you concerned about seeing
> > > a partial write to u32? It does not happen.
> > > 
> > Hm.. You shure? On every arch that supports wireless drivers? 
> > 
> > I've just copied that code from the old sysfs state-file handler.
> > So I assumed that reading partial updated state can happen... Also I
> > just searched a little but did not find anything, cause i didn't know
> > where to look. Who garantees this? Is it a gcc thing? 
> > 
> 
> None of the arches would do byte-by-byte writes to a u32, they'd write
> dword at once. Also, even if they could, you are interested in a single
> flag (bit). You do realize that once you leave spinlock whatever you
> fetched is stale data and may not be trusted?

On Fri, 12 Mar 2010 18:48:19 -0500
Valdis.Kletnieks@vt.edu wrote:
> If a u32 load or store from memory isn't atomic, the Linux kernel is screwed
> anyhow.  Hint - imagine if every 32-bit reference had to be treated the way
> we currently treat 64-bit references on a 32-bit system.


i presume, there is no way any digital device could write _one bit_
partial :) 
so this _may_ actually be safe *g* 
 
how about the write in the _store() function? there we
read,update and write back the whole 32 bit which then potentially
overwrites some other flag concurrently set by an driver interrupt on
another cpu? i think the lock there is needed.

cheers,
Flo

  reply	other threads:[~2010-03-13  9:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-12 18:03 [PATCH 0/2] rfkill sysfs ABI florian
2010-03-12 18:03 ` [PATCH 1/2] Document the " florian
2010-03-12 18:03   ` [PATCH 2/2] enhance sysfs rfkill interface florian
2010-03-12 18:22     ` Dmitry Torokhov
2010-03-12 20:57       ` Florian Mickler
2010-03-12 21:20         ` Dmitry Torokhov
2010-03-12 22:39           ` Florian Mickler
2010-03-12 22:48             ` Dmitry Torokhov
2010-03-13  9:41               ` Florian Mickler [this message]
2010-03-13  9:44                 ` [PATCH] rename new rfkill sysfs knobs florian
2010-03-13  9:56                   ` Dmitry Torokhov
2010-03-13 12:31                     ` [PATCH v2] " florian
2010-03-18 10:59                       ` Florian Mickler
2010-03-18 13:42                         ` John W. Linville
2010-03-13  9:55                 ` [PATCH 2/2] enhance sysfs rfkill interface Dmitry Torokhov
2010-03-13 12:33                   ` Florian Mickler
2010-03-12 23:48             ` Valdis.Kletnieks
2010-03-12 18:18 ` [PATCH 0/2] rfkill sysfs ABI Florian Mickler
2010-03-12 19:52   ` John W. Linville

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=20100313104128.79aa2846@schatten.dmk.lab \
    --to=florian@mickler.org \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=dmitry.torokhov@gmail.com \
    --cc=hmh@hmh.eng.br \
    --cc=johannes@sipsolutions.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=marcel@holtmann.org \
    --cc=rdunlap@xenotime.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 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.