2014-11-03 16:43 GMT+03:00 Linus Walleij [off-list ref]:
On Fri, Oct 31, 2014 at 10:39 AM, Dmitry Eremin-Solenikov
[off-list ref] wrote:
quoted
2014-10-31 10:48 GMT+03:00 Linus Walleij [off-list ref]:
quoted
On Tue, Oct 28, 2014 at 1:01 AM, Dmitry Eremin-Solenikov
[off-list ref] wrote:
quoted
Add gpiolib driver for gpio pins placed on the LoCoMo GA.
Signed-off-by: Dmitry Eremin-Solenikov <redacted>
[skipped]
quoted
(etc, everywhere this pattern occurs).
quoted
+static void locomo_gpio_set(struct gpio_chip *chip,
+ unsigned offset, int value)
+{
+ struct locomo_gpio *lg = container_of(chip, struct locomo_gpio, gpio);
+ unsigned long flags;
+
+ spin_lock_irqsave(&lg->lock, flags);
+
+ __locomo_gpio_set(chip, offset, value);
+
+ spin_unlock_irqrestore(&lg->lock, flags);
If you actually always have to be getting and releasing a spin lock around
the register writes, contemplate using regmap-mmio because that
is part of what it does.
But is this locking really necessary?
I have a custom of doing such locking and never having to think about
somebody breaking into RMW cycles.
Also isn't regmap an overkill here? Wouldn't regmap also do a lock/unlock
around each register read/write/RMW?
Yes that's the point: if you use regmap mmio you get the RMW-locking
for free, with the regmap implementation.
Just to be more concrete. Currently locomo_gpio_ack_irq() function uses
one lock and one unlock for doing 3 consecutive RMW I I convert locomo
to regmap, will that be 3 lock/unlock calls or still one? (Or maybe I'm
trying to be over-protective here and adding more lock/unlock cycles
won't matter that much?)
Next question: if I have to export regmap to several subdrivers, is it better
to have one big regmap or to have one-map-per-driver approach?
--
With best wishes
Dmitry
On Thu, Nov 06, 2014 at 01:33:24AM +0400, Dmitry Eremin-Solenikov wrote:
2014-11-03 16:43 GMT+03:00 Linus Walleij [off-list ref]:
quoted
Yes that's the point: if you use regmap mmio you get the RMW-locking
for free, with the regmap implementation.
Just to be more concrete. Currently locomo_gpio_ack_irq() function uses
one lock and one unlock for doing 3 consecutive RMW I I convert locomo
to regmap, will that be 3 lock/unlock calls or still one? (Or maybe I'm
trying to be over-protective here and adding more lock/unlock cycles
won't matter that much?)
You'll get three lock/unlocks, we could add an interface for bulk
updates under one lock if it's important though.
Next question: if I have to export regmap to several subdrivers, is it better
to have one big regmap or to have one-map-per-driver approach?
One regmap for the physical register map which is shared between all the
users.
2014-11-06 9:03 GMT+03:00 Mark Brown [off-list ref]:
On Thu, Nov 06, 2014 at 01:33:24AM +0400, Dmitry Eremin-Solenikov wrote:
quoted
2014-11-03 16:43 GMT+03:00 Linus Walleij [off-list ref]:
quoted
quoted
Yes that's the point: if you use regmap mmio you get the RMW-locking
for free, with the regmap implementation.
quoted
Just to be more concrete. Currently locomo_gpio_ack_irq() function uses
one lock and one unlock for doing 3 consecutive RMW I I convert locomo
to regmap, will that be 3 lock/unlock calls or still one? (Or maybe I'm
trying to be over-protective here and adding more lock/unlock cycles
won't matter that much?)
You'll get three lock/unlocks, we could add an interface for bulk
updates under one lock if it's important though.
quoted
Next question: if I have to export regmap to several subdrivers, is it better
to have one big regmap or to have one-map-per-driver approach?
One regmap for the physical register map which is shared between all the
users.
Mark, Linus,
Just to better understand your suggestions: do you want me to convert
to regmap only gpio driver or do you suggest to convert all LoCoMo drivers?
That is doable, of course, but the amount of changes is overwhelming.
Also I'm concerned about the performance impact from going through
regmap layers.
--
With best wishes
Dmitry