Re: [PATCH] iio: magnetometer: ak8975: ensure device is awake for buffered capture

From: Joshua Crofts

Date: Thu May 14 2026 - 07:01:54 EST


On Wed, 13 May 2026 at 16:35, Joshua Crofts via B4 Relay
<devnull+joshua.crofts1.gmail.com@xxxxxxxxxx> wrote:
>
> From: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
>
> Currently, the ak8975_start_read_axis() can be called while the device
> is autosuspended, causing two issues:
>
> 1. I2C transfers in the aforementioned function will fail or timeout
> because ak8975_runtime_suspend() disables the device regulators.
> 2. Since ak8975_fill_buffer() does not hold runtime references,
> ak8975_runtime_suspend() can run concurrently, and since PM callbacks
> do not use a locking mechanism, it may cause a race accessing the
> control register via the I2C bus.
>
> Fix this issue by adding struct iio_buffer_setup_ops that contains
> preenable and postdisable functions to ensure correct that device is
> powered on when running a buffered capture.
>
> Fixes: bc11ca4a0b84 ("iio:magnetometer:ak8975: triggered buffer support")
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Closes: https://sashiko.dev/#/patchset/20260511-magnetometer-fixes-post-pickup-v7-0-9d910faa28b6%40gmail.com
> Signed-off-by: Joshua Crofts <joshua.crofts1@xxxxxxxxx>
> ---

FYI, Sashiko reported an additional issue concerning the leaking
of uninitialized kernel stack memory.

https://sashiko.dev/#/patchset/20260513-ak8975-fix-v1-1-104ea605dd54%40gmail.com