Re: I3C Mastership RFC

Boris Brezillon
2019-11-25T14:50:38Z

On Mon, 25 Nov 2019 14:27:18 +0000
Vitor Soares <Vitor.Soares@synopsys.com> wrote:

> From: Boris Brezillon <boris.brezillon@collabora.com>
> Date: Mon, Nov 25, 2019 at 13:09:36
>
> > On Mon, 25 Nov 2019 13:00:17 +0000
> > Vitor Soares <Vitor.Soares@synopsys.com> wrote:
> >
> > > > > > > > I'm pretty sure we solved that already (that's what
> > > > > > > > i3c_master_acquire_bus_ownership() calls are supposed to take care of).
> > > > > > > > Can you be a bit more specific? What makes you think the master might
> > > > > > > > not be in control of the bus when i3c_dev_do_priv_xfers_locked() is
> > > > > > > > called?
> > > > > > >
> > > > > > > You are assuming that after i3c_master_acquire_bus_ownership() return,
> > > > > > > secondary master already owns the bus. Main master can ack the MR request
> > > > > > > and not send the CETACCMST immediately.
> > > > > > >
> > > > > >
> > > > > > In Cadence HC driver, I'm waiting for GETACCMST longer, polling the
> > > > > > status and after I exit from ->request_mastership(), I'm the bus owner.
> > > > > > If not, error exit code is returned and we can't make the transfers.
> > > > > > Are you able to implement the same behavior?
> > > > >
> > > > > You can assume everyone will do in that way. What happen if you receive a
> > > > > request or an information from current master?
> > > >
> > > > We have this ->request_mastership() method so controllers that have
> > > > this logic (MR+wait(GETACCMST) automated can still interface with the
> > > > subsystem.
> > >
> > > I can also poll the GETACCMST but we are assuming nothing will happen
> > > between MR and GETACCMST.
> >
> > Nothing coming from the master that tries to acquire the bus, yes.
> > Nothing coming from the current master, no, and that shouldn't be a
> > problem as long as those operations don't involve acquiring bus->lock.
> > And if some of those operation involve acquiring the lock (I'd still
> > need to understand which operation that would be) they'll just be
> > delayed/rejected.
>
> You are assuming this is straight forward which is not the case. Between
> MR and GETACCMST may happen everything as in a Master-Slave topology.

Like what? Be more specific, I want real examples that don't work
because of the way mastership handover is done in Przemek's proposal.

> For me, poll the controller to check when GETACCMST arrive and lock
> everything is not a solution.

We don't lock everything: other devs can still communicate until we've
acquired the bus, and the slave end of your master should also work
(since the master is still not acting as a master yet).
We do prevent new MR request once we've acquired the bus to avoid
situations where another master requests bus ownership before we could
send the messages we were asked to send (device driver request). But
that's a completely orthogonal thing, and has nothing to do with the
polling solution you seem to complain about.
BTW, you don't have to poll the reg value, using interrupt-based
waiting is fine too. My point is, if we want to keep the code simple,
we have to make this operation synchronous from the caller PoV.