On Wed, Nov 11, 2020 at 11:21:09AM -0800, Bhaumik Bhatt wrote: > Add support to enable sending the stop channel command and > improve the channel handling state machine such that all commands > go through a common function. This can help ensure that the state > machine is not violated in any way and adheres to the MHI > specification. > > Signed-off-by: Bhaumik Bhatt <bbhatt@xxxxxxxxxxxxxx> > --- > drivers/bus/mhi/core/init.c | 6 ++ > drivers/bus/mhi/core/internal.h | 12 +++ > drivers/bus/mhi/core/main.c | 163 ++++++++++++++++++++++++---------------- > 3 files changed, 116 insertions(+), 65 deletions(-) > > diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c > index 4d34d62..c9b1de8 100644 > --- a/drivers/bus/mhi/core/init.c > +++ b/drivers/bus/mhi/core/init.c > @@ -51,6 +51,12 @@ const char * const mhi_state_str[MHI_STATE_MAX] = { > [MHI_STATE_SYS_ERR] = "SYS_ERR", > }; > > +const char * const mhi_ch_state_type_str[MHI_CH_STATE_TYPE_MAX] = { > + [MHI_CH_STATE_TYPE_RESET] = "RESET", > + [MHI_CH_STATE_TYPE_STOP] = "STOP", > + [MHI_CH_STATE_TYPE_START] = "START", > +}; > + > static const char * const mhi_pm_state_str[] = { > [MHI_PM_STATE_DISABLE] = "DISABLE", > [MHI_PM_STATE_POR] = "POR", > diff --git a/drivers/bus/mhi/core/internal.h b/drivers/bus/mhi/core/internal.h > index 2df8de5..f4efb15 100644 > --- a/drivers/bus/mhi/core/internal.h > +++ b/drivers/bus/mhi/core/internal.h > @@ -369,6 +369,18 @@ enum mhi_ch_state { > MHI_CH_STATE_ERROR = 0x5, > }; > > +enum mhi_ch_state_type { > + MHI_CH_STATE_TYPE_RESET, > + MHI_CH_STATE_TYPE_STOP, > + MHI_CH_STATE_TYPE_START, > + MHI_CH_STATE_TYPE_MAX, > +}; > + As said in previous patch, this needs to be moved to a separate one. > +extern const char * const mhi_ch_state_type_str[MHI_CH_STATE_TYPE_MAX]; > +#define TO_CH_STATE_TYPE_STR(state) (((state) >= MHI_CH_STATE_TYPE_MAX) ? \ > + "INVALID_STATE" : \ > + mhi_ch_state_type_str[state]) > + > #define MHI_INVALID_BRSTMODE(mode) (mode != MHI_DB_BRST_DISABLE && \ > mode != MHI_DB_BRST_ENABLE) > > diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c > index ad881a1..1226933 100644 > --- a/drivers/bus/mhi/core/main.c > +++ b/drivers/bus/mhi/core/main.c > @@ -1220,56 +1220,120 @@ int mhi_send_cmd(struct mhi_controller *mhi_cntrl, > return 0; > } > [...] > +static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, > + struct mhi_chan *mhi_chan) > +{ > + int ret; > + struct device *dev = &mhi_cntrl->mhi_dev->dev; > + > + dev_dbg(dev, "Entered: unprepare channel:%d\n", mhi_chan->chan); Please get rid of these debug prints. We have some of them right now but they should be removed at some point. For debugging, use ftrace. Thanks, Mani