Re: [PATCH v3] i2c: at91: support atomic write xfer

From: Wolfram Sang
Date: Tue May 05 2020 - 11:52:32 EST


Hi,

> I don't expect this to be used for much more than a simple write to PMIC
> to kill the power. So this patch is tailor made for exactly this purpose.

Frankly, I don't like it much. The atomic callbacks are supposed to be
drop-in replacements of the non-atomic contexts. There may be a need to
read a PMIC register before writing something. I considered checking in
the core if we can fall back to non-atomic calls if the the atomic ones
return -EOPNOTSUPP, though, but I still don't like the idea. I expect
that people send me minimal versions then which are extended over time
by very personal use cases. Having a proper implementation
once-and-for-all (despite bugfixes) sounds much more maintainable to me.

> Though, if you would go for full support of atomic transfers, then
> I would suggest to hack the non-atomic path to be usable in atomic mode
> instead (some I2C drivers do just that, eg. i2c-tegra).

Yes, that is what I am aiming for.

> BTW, I found this comment in i2c-core.h:
>
> * We only allow atomic transfers for very late communication, e.g. to send
> * the powerdown command to a PMIC. Atomic transfers are a corner case and not
> * for generic use!
>
> I think this covers the idea.

Well, since I implemented the atomic_xfer mechanism, I think I am the
primary authority of what "covers the idea", so I will fix the comment
above :) Note, there is also this comment in the way more user-visible
include/linux/i2c.h:

509 * @master_xfer_atomic: same as @master_xfer. Yet, only using atomic context
510 * so e.g. PMICs can be accessed very late before shutdown. Optional.

All the best,

Wolfram

Attachment: signature.asc
Description: PGP signature