Re: [PATCH] eeprom: at24: wait for write cycle before releasing runtime PM
From: Bartosz Golaszewski
Date: Thu Nov 26 2026 - 09:59:43 EST
On Thu, Nov 26, 2026 at 01:15:35AM +0100, Daniel Svendsen wrote:
> at24_regmap_write() returns as soon as the chip has ACKed the
> transfer, but the EEPROM only programs the data afterwards, during its
> internal write cycle (typically up to 5 ms). For all but the last
> chunk, the following write is NACKed and retried until that cycle has
> finished. After the last chunk nothing waits, and at24_write() drops
> its runtime PM reference right away. When vcc is controlled through
> runtime PM and has no other users, at24_suspend() disables the
> regulator in the middle of the write cycle and the last chunk is lost,
> while the write is reported as successful.
>
> This was seen on a board where the EEPROM supply is a switchable
> regulator used only by at24: 32-byte writes with a 16-byte page size
> programmed just the first 16 bytes.
>
> Wait for the write cycle to finish before releasing runtime PM by
> doing a one-byte read of the last written address. at24_regmap_read()
> retries while the chip NACKs, up to write_timeout.
>
> Fixes: cd5676db0574 ("misc: eeprom: at24: support pm_runtime control")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Daniel Svendsen <das@xxxxxxxxxx>
> ---
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>