Re: [PATCH v4 1/3] bus: mhi: host: clients: Add loopback driver with sysfs interface

From: Manivannan Sadhasivam

Date: Tue Jun 23 2026 - 07:20:18 EST


On Tue, Jun 23, 2026 at 03:58:00PM +0530, Sumit Kumar wrote:
>

[...]

> > > +static void mhi_loopback_remove(struct mhi_device *mhi_dev)
> > > +{
> > > + struct mhi_loopback *loopback = dev_get_drvdata(&mhi_dev->dev);
> > > +
> > > + complete(&loopback->comp);
> > > +
> > > + mutex_lock(&loopback->lb_mutex);
> > > + mutex_unlock(&loopback->lb_mutex);
> > What does this locking protect?
> since start_store() is holding the mutex for its entire duration,
> this lock will block until any in-progress start_store() has fully
> completed before teardown, ensuring  mhi_unprepare_from_transfer()
> does not race with an active test still accessing the channel.
>

How can you ensure that start_store doesn't race if you unlock the mutex before
mhi_unprepare_from_transfer()? Anyway, once you remove the sysfs files here as I
suggested, you do not need to worry about the race.

- Mani

--
மணிவண்ணன் சதாசிவம்