Re: [PATCH v4 3/3] iio: accel: bmc150: use guard(mutex) for mutex handling
Jonathan Cameron <[email protected]>
| Newsgroups | org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260822231130.6011f3ce@jic23-huawei> |
On Tue, 18 Aug 2026 18:47:56 +0300 Andy Shevchenko <[email protected]> wrote: > On Tue, Aug 18, 2026 at 04:41:35PM +0100, Gabriel Rondon wrote: > > On Mon, Aug 17, 2026 at 06:39:18PM +0300, Andy Shevchenko wrote: > > > Not directly related to this change, but even in the original code what is > > > protected here by the mutex? data->scan.channels? > > > > Agreed it is out of scope for this cleanup, so I left the scope unchanged. > > > > Honest answer: not much that is obvious. data->scan.channels does not need > > it, since the triggered handler is the only writer and the core serializes > > it. The accel one-shot read is already gated with -EBUSY while buffering, so > > bmc150_accel_get_axis cannot race the handler. What is left sharing > > data->mutex and still reachable during capture is the temperature read, the > > bandwidth get/set and scale set, and the event config. But since the handler > > is a single regmap_bulk_read and regmap already serializes the bus, it is not > > clear the driver mutex guards a real invariant here, and it may well be > > vestigial. > > > Dropping it is a behavioral change worth its own patch and testing rather > > than something to fold into a lock-syntax cleanup. > > Of course! Just made an observation. > > > Happy to look into that separately. > > If you have HW to test, I would like to see such a change. > See my reply to Yash's thread. The lock scope may well expand as a trade off against bloat of the iio_priv() structure. If following what I suggest it will be protecting the set of cachelines containing the various buffers used for bulk reads during both DMA and whatever else is done with them. Jonathan