From: philippe.retornaz@gmail.com (Philippe Rétornaz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RESEND] mfd: mc13xxx: Remove unneeded mc13xxx_lock/unlock
Date: Mon, 02 Dec 2013 10:51:00 +0100 [thread overview]
Message-ID: <529C5804.2020501@gmail.com> (raw)
In-Reply-To: <1385787681-7736-1-git-send-email-shc_work@mail.ru>
Le 30/11/2013 06:01, Alexander Shiyan a ?crit :
> Locking is performed by regmap API so no additional locking is
> needed. Nevertheless, keep locking in the ADC conversion routine.
> This need for keep proper read ADC sequence when calling from adc &
> touchscreen drivers.
You can't do that so easily !
Regmap only protect against concurrent access to the SPI/I2C bus, but do
not protect the driver's internal data.
And it does not protect against a race between concurrent access at a
higher level :
reg = regmap_read();
(modify reg)
regmap_write(reg);
And we do have such behavior:
* The mc13xxx->irqhandler/irqdata array is
protected by this mutex.
* And we also have non-atomic RMW in mc13xxx_irq_unmask():
ret = mc13xxx_reg_read(mc13xxx, offmask, &mask);
if (ret)
return ret;
if (!(mask & irqbit))
return 0;
return mc13xxx_reg_write(mc13xxx, offmask, mask & ~irqbit);
It's OK to do this if you are protected by a mutex, but as soon as you
remove it you will have concurrency between two irq_unmask/irq_mask.
So you can remove the lock from trivial function like:
mc13xxx_lock(led->master);
mc13xxx_reg_rmw(led->master, reg, mask << shift, value << shift);
mc13xxx_unlock(led->master);
Which protect only a single access to regmap.
But we need to keep it for more complex behavior.
Regards,
Philippe
WARNING: multiple messages have this Message-ID (diff)
From: "Philippe Rétornaz" <philippe.retornaz@gmail.com>
To: Alexander Shiyan <shc_work@mail.ru>
Cc: linux-kernel@vger.kernel.org,
Samuel Ortiz <sameo@linux.intel.com>,
Sascha Hauer <kernel@pengutronix.de>,
Shawn Guo <shawn.guo@linaro.org>,
Lee Jones <lee.jones@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH RESEND] mfd: mc13xxx: Remove unneeded mc13xxx_lock/unlock
Date: Mon, 02 Dec 2013 10:51:00 +0100 [thread overview]
Message-ID: <529C5804.2020501@gmail.com> (raw)
In-Reply-To: <1385787681-7736-1-git-send-email-shc_work@mail.ru>
Le 30/11/2013 06:01, Alexander Shiyan a écrit :
> Locking is performed by regmap API so no additional locking is
> needed. Nevertheless, keep locking in the ADC conversion routine.
> This need for keep proper read ADC sequence when calling from adc &
> touchscreen drivers.
You can't do that so easily !
Regmap only protect against concurrent access to the SPI/I2C bus, but do
not protect the driver's internal data.
And it does not protect against a race between concurrent access at a
higher level :
reg = regmap_read();
(modify reg)
regmap_write(reg);
And we do have such behavior:
* The mc13xxx->irqhandler/irqdata array is
protected by this mutex.
* And we also have non-atomic RMW in mc13xxx_irq_unmask():
ret = mc13xxx_reg_read(mc13xxx, offmask, &mask);
if (ret)
return ret;
if (!(mask & irqbit))
return 0;
return mc13xxx_reg_write(mc13xxx, offmask, mask & ~irqbit);
It's OK to do this if you are protected by a mutex, but as soon as you
remove it you will have concurrency between two irq_unmask/irq_mask.
So you can remove the lock from trivial function like:
mc13xxx_lock(led->master);
mc13xxx_reg_rmw(led->master, reg, mask << shift, value << shift);
mc13xxx_unlock(led->master);
Which protect only a single access to regmap.
But we need to keep it for more complex behavior.
Regards,
Philippe
next prev parent reply other threads:[~2013-12-02 9:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-30 5:01 [PATCH RESEND] mfd: mc13xxx: Remove unneeded mc13xxx_lock/unlock Alexander Shiyan
2013-11-30 5:01 ` Alexander Shiyan
2013-12-02 9:51 ` Philippe Rétornaz [this message]
2013-12-02 9:51 ` Philippe Rétornaz
2013-12-02 10:33 ` Alexander Shiyan
2013-12-02 10:33 ` Alexander Shiyan
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=529C5804.2020501@gmail.com \
--to=philippe.retornaz@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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 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.