Re: [RFC PATCH 3/4] watchdog: da9062: avoid regmap in restart handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Tony,

On Mon, Aug 20, 2018 at 07:55:22AM -0700, Tony Lindgren wrote:
> * Stefan Lengfeld <contact@xxxxxxxxxxxxxxx> [180813 21:19]:
> > Using i2c_transfer() to set the shutdown bit is more reliable than using
> > regmap.  Furthermore you have to void the default lock configuration in
> > the regmap configuration, e.g. by setting use_hwlock to true, to used in
> > atomic/IRQ disabled contexts.
> 
> Hmm so this is a bit worrying, does this mean that regmap can't deal
> with atomic i2c then?

In theory yes. Regmap can support IRQ/sleep less operation, but you have
to ensure that the whole callstack trough the regmap interface and code
never calls sleep or waits for a lock.

First you have to use a sleep-less lock/unlock implementation in the
regmap_config e.g.

    static struct regmap_config da9062_regmap_config = {
            [...]
            /* Enable hwclock to use a sleep-free lock implementation */
            .use_hwlock = 1,

Or providing an own implementations of the regmap callbacks

    struct regmap_config {
            [...]
            regmap_lock lock;
            regmap_unlock unlock;

If have tried that and tested the code with 

     CONFIG_DEBUG_ATOMIC_SLEEP

But I have still seen a sleep violation in the regmap cache
implementation. Somewhere a cache handler was acquiring a lock or made a
memory allocation. At that point I gave up and just called the I²C
interface directly.

So I would say, regmap can support atomic I²C transfers, but you need a
lot of tweaking and on device testing. 

Kind regards,
Stefan



[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux