diff mbox series

[v2,1/6] bus: mhi: core: Allow receiving a STOP channel command response

Message ID 1605122473-12179-2-git-send-email-bbhatt@codeaurora.org (mailing list archive)
State Superseded
Headers show
Series Updates to MHI channel handling | expand

Commit Message

Bhaumik Bhatt Nov. 11, 2020, 7:21 p.m. UTC
Add support to receive the response to a STOP channel command to the
MHI bus. If a client would like to STOP a channel instead of issuing
a RESET to it, this would provide support for it.

Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
---
 drivers/bus/mhi/core/init.c | 5 +++--
 drivers/bus/mhi/core/main.c | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)

Comments

Manivannan Sadhasivam Nov. 16, 2020, 7:13 a.m. UTC | #1
On Wed, Nov 11, 2020 at 11:21:08AM -0800, Bhaumik Bhatt wrote:
> Add support to receive the response to a STOP channel command to the
> MHI bus. If a client would like to STOP a channel instead of issuing
> a RESET to it, this would provide support for it.
> 
> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> ---
>  drivers/bus/mhi/core/init.c | 5 +++--
>  drivers/bus/mhi/core/main.c | 5 +++++
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> index 8cefa35..4d34d62 100644
> --- a/drivers/bus/mhi/core/init.c
> +++ b/drivers/bus/mhi/core/init.c
> @@ -1267,8 +1267,9 @@ static int mhi_driver_remove(struct device *dev)
>  
>  		mutex_lock(&mhi_chan->mutex);
>  
> -		if (ch_state[dir] == MHI_CH_STATE_ENABLED &&
> -		    !mhi_chan->offload_ch)
> +		if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
> +		     ch_state[dir] == MHI_CH_STATE_STOP) &&

This enum is not defined in this patch so it'll break. Please add a separate
patch which introduces the new state enums alone and then have patches 1/2
as a followup.

Also this change is not belonging to this commit I believe.

Thanks,
Mani

> +		     !mhi_chan->offload_ch)
>  			mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan);
>  
>  		mhi_chan->ch_state = MHI_CH_STATE_DISABLED;
> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
> index f953e2a..ad881a1 100644
> --- a/drivers/bus/mhi/core/main.c
> +++ b/drivers/bus/mhi/core/main.c
> @@ -1194,6 +1194,11 @@ int mhi_send_cmd(struct mhi_controller *mhi_cntrl,
>  		cmd_tre->dword[0] = MHI_TRE_CMD_RESET_DWORD0;
>  		cmd_tre->dword[1] = MHI_TRE_CMD_RESET_DWORD1(chan);
>  		break;
> +	case MHI_CMD_STOP_CHAN:
> +		cmd_tre->ptr = MHI_TRE_CMD_STOP_PTR;
> +		cmd_tre->dword[0] = MHI_TRE_CMD_STOP_DWORD0;
> +		cmd_tre->dword[1] = MHI_TRE_CMD_STOP_DWORD1(chan);
> +		break;
>  	case MHI_CMD_START_CHAN:
>  		cmd_tre->ptr = MHI_TRE_CMD_START_PTR;
>  		cmd_tre->dword[0] = MHI_TRE_CMD_START_DWORD0;
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
Bhaumik Bhatt Nov. 16, 2020, 5:36 p.m. UTC | #2
Hi Mani,

On 2020-11-15 23:13, Manivannan Sadhasivam wrote:
> On Wed, Nov 11, 2020 at 11:21:08AM -0800, Bhaumik Bhatt wrote:
>> Add support to receive the response to a STOP channel command to the
>> MHI bus. If a client would like to STOP a channel instead of issuing
>> a RESET to it, this would provide support for it.
>> 
>> Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
>> ---
>>  drivers/bus/mhi/core/init.c | 5 +++--
>>  drivers/bus/mhi/core/main.c | 5 +++++
>>  2 files changed, 8 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
>> index 8cefa35..4d34d62 100644
>> --- a/drivers/bus/mhi/core/init.c
>> +++ b/drivers/bus/mhi/core/init.c
>> @@ -1267,8 +1267,9 @@ static int mhi_driver_remove(struct device *dev)
>> 
>>  		mutex_lock(&mhi_chan->mutex);
>> 
>> -		if (ch_state[dir] == MHI_CH_STATE_ENABLED &&
>> -		    !mhi_chan->offload_ch)
>> +		if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
>> +		     ch_state[dir] == MHI_CH_STATE_STOP) &&
> 
> This enum is not defined in this patch so it'll break. Please add a 
> separate
> patch which introduces the new state enums alone and then have patches 
> 1/2
> as a followup.
> 
It is actually already defined and present in internal.h as enum 
mhi_ch_state.

The old set of enums has MHI_CH_STATE_STOP from enum mhi_ch_state and 
the new
enum I introduced is MHI_CH_STATE_TYPE_STOP from enum enum 
mhi_ch_state_type.

If it seems confusing, suggestions to renaming them are welcome.

> Also this change is not belonging to this commit I believe.
> 
I included this change here because, a channel can be in "stopped" state 
and
a user module could be unloaded or a crash could force a driver remove 
leading
us to come this check.

If you think I should move it as a separate patch, let me know.
> Thanks,
> Mani
> 
>> +		     !mhi_chan->offload_ch)
>>  			mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan);
>> 
>>  		mhi_chan->ch_state = MHI_CH_STATE_DISABLED;
>> diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
>> index f953e2a..ad881a1 100644
>> --- a/drivers/bus/mhi/core/main.c
>> +++ b/drivers/bus/mhi/core/main.c
>> @@ -1194,6 +1194,11 @@ int mhi_send_cmd(struct mhi_controller 
>> *mhi_cntrl,
>>  		cmd_tre->dword[0] = MHI_TRE_CMD_RESET_DWORD0;
>>  		cmd_tre->dword[1] = MHI_TRE_CMD_RESET_DWORD1(chan);
>>  		break;
>> +	case MHI_CMD_STOP_CHAN:
>> +		cmd_tre->ptr = MHI_TRE_CMD_STOP_PTR;
>> +		cmd_tre->dword[0] = MHI_TRE_CMD_STOP_DWORD0;
>> +		cmd_tre->dword[1] = MHI_TRE_CMD_STOP_DWORD1(chan);
>> +		break;
>>  	case MHI_CMD_START_CHAN:
>>  		cmd_tre->ptr = MHI_TRE_CMD_START_PTR;
>>  		cmd_tre->dword[0] = MHI_TRE_CMD_START_DWORD0;
>> --
>> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
>> Forum,
>> a Linux Foundation Collaborative Project
>> 

Thanks,
Bhaumik
Manivannan Sadhasivam Nov. 21, 2020, 5:16 p.m. UTC | #3
On Mon, Nov 16, 2020 at 09:36:09AM -0800, Bhaumik Bhatt wrote:
> Hi Mani,
> 
> On 2020-11-15 23:13, Manivannan Sadhasivam wrote:
> > On Wed, Nov 11, 2020 at 11:21:08AM -0800, Bhaumik Bhatt wrote:
> > > Add support to receive the response to a STOP channel command to the
> > > MHI bus. If a client would like to STOP a channel instead of issuing
> > > a RESET to it, this would provide support for it.
> > > 
> > > Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
> > > ---
> > >  drivers/bus/mhi/core/init.c | 5 +++--
> > >  drivers/bus/mhi/core/main.c | 5 +++++
> > >  2 files changed, 8 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
> > > index 8cefa35..4d34d62 100644
> > > --- a/drivers/bus/mhi/core/init.c
> > > +++ b/drivers/bus/mhi/core/init.c
> > > @@ -1267,8 +1267,9 @@ static int mhi_driver_remove(struct device *dev)
> > > 
> > >  		mutex_lock(&mhi_chan->mutex);
> > > 
> > > -		if (ch_state[dir] == MHI_CH_STATE_ENABLED &&
> > > -		    !mhi_chan->offload_ch)
> > > +		if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
> > > +		     ch_state[dir] == MHI_CH_STATE_STOP) &&
> > 
> > This enum is not defined in this patch so it'll break. Please add a
> > separate
> > patch which introduces the new state enums alone and then have patches
> > 1/2
> > as a followup.
> > 
> It is actually already defined and present in internal.h as enum
> mhi_ch_state.
> 
> The old set of enums has MHI_CH_STATE_STOP from enum mhi_ch_state and the
> new
> enum I introduced is MHI_CH_STATE_TYPE_STOP from enum enum
> mhi_ch_state_type.
> 
> If it seems confusing, suggestions to renaming them are welcome.
> 

Ah, sorry. I got confused with MHI_CH_STATE_TYPE_STOP and MHI_CH_STATE_STOP.
Ignore my previous comment.

Thanks,
Mani

> > Also this change is not belonging to this commit I believe.
> > 
> I included this change here because, a channel can be in "stopped" state and
> a user module could be unloaded or a crash could force a driver remove
> leading
> us to come this check.
> 
> If you think I should move it as a separate patch, let me know.
> > Thanks,
> > Mani
> > 
> > > +		     !mhi_chan->offload_ch)
> > >  			mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan);
> > > 
> > >  		mhi_chan->ch_state = MHI_CH_STATE_DISABLED;
> > > diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
> > > index f953e2a..ad881a1 100644
> > > --- a/drivers/bus/mhi/core/main.c
> > > +++ b/drivers/bus/mhi/core/main.c
> > > @@ -1194,6 +1194,11 @@ int mhi_send_cmd(struct mhi_controller
> > > *mhi_cntrl,
> > >  		cmd_tre->dword[0] = MHI_TRE_CMD_RESET_DWORD0;
> > >  		cmd_tre->dword[1] = MHI_TRE_CMD_RESET_DWORD1(chan);
> > >  		break;
> > > +	case MHI_CMD_STOP_CHAN:
> > > +		cmd_tre->ptr = MHI_TRE_CMD_STOP_PTR;
> > > +		cmd_tre->dword[0] = MHI_TRE_CMD_STOP_DWORD0;
> > > +		cmd_tre->dword[1] = MHI_TRE_CMD_STOP_DWORD1(chan);
> > > +		break;
> > >  	case MHI_CMD_START_CHAN:
> > >  		cmd_tre->ptr = MHI_TRE_CMD_START_PTR;
> > >  		cmd_tre->dword[0] = MHI_TRE_CMD_START_DWORD0;
> > > --
> > > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
> > > Forum,
> > > a Linux Foundation Collaborative Project
> > > 
> 
> Thanks,
> Bhaumik
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
Bhaumik Bhatt Nov. 24, 2020, 12:23 a.m. UTC | #4
On 2020-11-21 09:16 AM, Manivannan Sadhasivam wrote:
> On Mon, Nov 16, 2020 at 09:36:09AM -0800, Bhaumik Bhatt wrote:
>> Hi Mani,
>> 
>> On 2020-11-15 23:13, Manivannan Sadhasivam wrote:
>> > On Wed, Nov 11, 2020 at 11:21:08AM -0800, Bhaumik Bhatt wrote:
>> > > Add support to receive the response to a STOP channel command to the
>> > > MHI bus. If a client would like to STOP a channel instead of issuing
>> > > a RESET to it, this would provide support for it.
>> > >
>> > > Signed-off-by: Bhaumik Bhatt <bbhatt@codeaurora.org>
>> > > ---
>> > >  drivers/bus/mhi/core/init.c | 5 +++--
>> > >  drivers/bus/mhi/core/main.c | 5 +++++
>> > >  2 files changed, 8 insertions(+), 2 deletions(-)
>> > >
>> > > diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
>> > > index 8cefa35..4d34d62 100644
>> > > --- a/drivers/bus/mhi/core/init.c
>> > > +++ b/drivers/bus/mhi/core/init.c
>> > > @@ -1267,8 +1267,9 @@ static int mhi_driver_remove(struct device *dev)
>> > >
>> > >  		mutex_lock(&mhi_chan->mutex);
>> > >
>> > > -		if (ch_state[dir] == MHI_CH_STATE_ENABLED &&
>> > > -		    !mhi_chan->offload_ch)
>> > > +		if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
>> > > +		     ch_state[dir] == MHI_CH_STATE_STOP) &&
>> >
>> > This enum is not defined in this patch so it'll break. Please add a
>> > separate
>> > patch which introduces the new state enums alone and then have patches
>> > 1/2
>> > as a followup.
>> >
>> It is actually already defined and present in internal.h as enum
>> mhi_ch_state.
>> 
>> The old set of enums has MHI_CH_STATE_STOP from enum mhi_ch_state and 
>> the
>> new
>> enum I introduced is MHI_CH_STATE_TYPE_STOP from enum enum
>> mhi_ch_state_type.
>> 
>> If it seems confusing, suggestions to renaming them are welcome.
>> 
> 
> Ah, sorry. I got confused with MHI_CH_STATE_TYPE_STOP and 
> MHI_CH_STATE_STOP.
> Ignore my previous comment.
> 
> Thanks,
> Mani
> 
No problem.
>> > Also this change is not belonging to this commit I believe.
>> >
>> I included this change here because, a channel can be in "stopped" 
>> state and
>> a user module could be unloaded or a crash could force a driver remove
>> leading
>> us to come this check.
>> 
>> If you think I should move it as a separate patch, let me know.
>> > Thanks,
>> > Mani
>> >
>> > > +		     !mhi_chan->offload_ch)
>> > >  			mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan);
>> > >
>> > >  		mhi_chan->ch_state = MHI_CH_STATE_DISABLED;
>> > > diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
>> > > index f953e2a..ad881a1 100644
>> > > --- a/drivers/bus/mhi/core/main.c
>> > > +++ b/drivers/bus/mhi/core/main.c
>> > > @@ -1194,6 +1194,11 @@ int mhi_send_cmd(struct mhi_controller
>> > > *mhi_cntrl,
>> > >  		cmd_tre->dword[0] = MHI_TRE_CMD_RESET_DWORD0;
>> > >  		cmd_tre->dword[1] = MHI_TRE_CMD_RESET_DWORD1(chan);
>> > >  		break;
>> > > +	case MHI_CMD_STOP_CHAN:
>> > > +		cmd_tre->ptr = MHI_TRE_CMD_STOP_PTR;
>> > > +		cmd_tre->dword[0] = MHI_TRE_CMD_STOP_DWORD0;
>> > > +		cmd_tre->dword[1] = MHI_TRE_CMD_STOP_DWORD1(chan);
>> > > +		break;
>> > >  	case MHI_CMD_START_CHAN:
>> > >  		cmd_tre->ptr = MHI_TRE_CMD_START_PTR;
>> > >  		cmd_tre->dword[0] = MHI_TRE_CMD_START_DWORD0;
>> > > --
>> > > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora
>> > > Forum,
>> > > a Linux Foundation Collaborative Project
>> > >
>> 
>> Thanks,
>> Bhaumik
>> --
>> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
>> Forum,
>> a Linux Foundation Collaborative Project

Thanks,
Bhaumik
---
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum,
a Linux Foundation Collaborative Project
diff mbox series

Patch

diff --git a/drivers/bus/mhi/core/init.c b/drivers/bus/mhi/core/init.c
index 8cefa35..4d34d62 100644
--- a/drivers/bus/mhi/core/init.c
+++ b/drivers/bus/mhi/core/init.c
@@ -1267,8 +1267,9 @@  static int mhi_driver_remove(struct device *dev)
 
 		mutex_lock(&mhi_chan->mutex);
 
-		if (ch_state[dir] == MHI_CH_STATE_ENABLED &&
-		    !mhi_chan->offload_ch)
+		if ((ch_state[dir] == MHI_CH_STATE_ENABLED ||
+		     ch_state[dir] == MHI_CH_STATE_STOP) &&
+		     !mhi_chan->offload_ch)
 			mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan);
 
 		mhi_chan->ch_state = MHI_CH_STATE_DISABLED;
diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index f953e2a..ad881a1 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -1194,6 +1194,11 @@  int mhi_send_cmd(struct mhi_controller *mhi_cntrl,
 		cmd_tre->dword[0] = MHI_TRE_CMD_RESET_DWORD0;
 		cmd_tre->dword[1] = MHI_TRE_CMD_RESET_DWORD1(chan);
 		break;
+	case MHI_CMD_STOP_CHAN:
+		cmd_tre->ptr = MHI_TRE_CMD_STOP_PTR;
+		cmd_tre->dword[0] = MHI_TRE_CMD_STOP_DWORD0;
+		cmd_tre->dword[1] = MHI_TRE_CMD_STOP_DWORD1(chan);
+		break;
 	case MHI_CMD_START_CHAN:
 		cmd_tre->ptr = MHI_TRE_CMD_START_PTR;
 		cmd_tre->dword[0] = MHI_TRE_CMD_START_DWORD0;