diff mbox series

[v2,7/8] PCI: epf-mhi: Add wakeup host op

Message ID 1688122331-25478-8-git-send-email-quic_krichai@quicinc.com
State Superseded
Headers show
Series PCCI: EPC: Add support to wake up host from D3 states | expand

Commit Message

Krishna chaitanya chundru June 30, 2023, 10:52 a.m. UTC
Add wakeup host op for MHI EPF.
If the D-state is in D3cold toggle wake signal, otherwise send PME.

Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
---
 drivers/pci/endpoint/functions/pci-epf-mhi.c | 19 +++++++++++++++++++
 include/linux/mhi_ep.h                       |  1 +
 2 files changed, 20 insertions(+)

Comments

Manivannan Sadhasivam July 7, 2023, 6:14 a.m. UTC | #1
On Fri, Jun 30, 2023 at 04:22:10PM +0530, Krishna chaitanya chundru wrote:
> Add wakeup host op for MHI EPF.
> If the D-state is in D3cold toggle wake signal, otherwise send PME.
> 
> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
> ---
>  drivers/pci/endpoint/functions/pci-epf-mhi.c | 19 +++++++++++++++++++
>  include/linux/mhi_ep.h                       |  1 +
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> index 64ff37d..deb742c 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> @@ -237,6 +237,24 @@ static int pci_epf_mhi_write_to_host(struct mhi_ep_cntrl *mhi_cntrl,
>  	return 0;
>  }
>  
> +static int pci_epf_mhi_wakeup_host(struct mhi_ep_cntrl *mhi_cntrl)
> +{
> +	struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
> +	struct pci_epf *epf = epf_mhi->epf;
> +	struct pci_epc *epc = epf->epc;
> +	int ret;
> +
> +	if (mhi_cntrl->dstate == PCI_D3cold)
> +		ret = pci_epc_wakeup_host(epc, epf->func_no,
> +					epf->vfunc_no, PCI_WAKEUP_TOGGLE_WAKE);
> +	else
> +		ret = pci_epc_wakeup_host(epc, epf->func_no,
> +					epf->vfunc_no, PCI_WAKEUP_SEND_PME);
> +

If the wakeup argument is of type bool (ie. bool use_pme), then

	wakeup = (mhi_cntrl->dstate == PCI_D3cold) ? false : true;

	return pci_epc_wakeup_host(epc, epf->func_no, epf->vfunc_no, state);

- Mani

> +	return ret;
> +
> +}
> +
>  static int pci_epf_mhi_core_init(struct pci_epf *epf)
>  {
>  	struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
> @@ -293,6 +311,7 @@ static int pci_epf_mhi_link_up(struct pci_epf *epf)
>  	mhi_cntrl->unmap_free = pci_epf_mhi_unmap_free;
>  	mhi_cntrl->read_from_host = pci_epf_mhi_read_from_host;
>  	mhi_cntrl->write_to_host = pci_epf_mhi_write_to_host;
> +	mhi_cntrl->wakeup_host = pci_epf_mhi_wakeup_host;
>  
>  	/* Register the MHI EP controller */
>  	ret = mhi_ep_register_controller(mhi_cntrl, info->config);
> diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
> index c3a0685..e353c429 100644
> --- a/include/linux/mhi_ep.h
> +++ b/include/linux/mhi_ep.h
> @@ -137,6 +137,7 @@ struct mhi_ep_cntrl {
>  			   void __iomem *virt, size_t size);
>  	int (*read_from_host)(struct mhi_ep_cntrl *mhi_cntrl, u64 from, void *to, size_t size);
>  	int (*write_to_host)(struct mhi_ep_cntrl *mhi_cntrl, void *from, u64 to, size_t size);
> +	int (*wakeup_host)(struct mhi_ep_cntrl *mhi_cntrl);
>  
>  	enum mhi_state mhi_state;
>  
> -- 
> 2.7.4
>
Krishna chaitanya chundru July 7, 2023, 11 a.m. UTC | #2
On 7/7/2023 11:44 AM, Manivannan Sadhasivam wrote:
> On Fri, Jun 30, 2023 at 04:22:10PM +0530, Krishna chaitanya chundru wrote:
>> Add wakeup host op for MHI EPF.
>> If the D-state is in D3cold toggle wake signal, otherwise send PME.
>>
>> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
>> ---
>>   drivers/pci/endpoint/functions/pci-epf-mhi.c | 19 +++++++++++++++++++
>>   include/linux/mhi_ep.h                       |  1 +
>>   2 files changed, 20 insertions(+)
>>
>> diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> index 64ff37d..deb742c 100644
>> --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> @@ -237,6 +237,24 @@ static int pci_epf_mhi_write_to_host(struct mhi_ep_cntrl *mhi_cntrl,
>>   	return 0;
>>   }
>>   
>> +static int pci_epf_mhi_wakeup_host(struct mhi_ep_cntrl *mhi_cntrl)
>> +{
>> +	struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
>> +	struct pci_epf *epf = epf_mhi->epf;
>> +	struct pci_epc *epc = epf->epc;
>> +	int ret;
>> +
>> +	if (mhi_cntrl->dstate == PCI_D3cold)
>> +		ret = pci_epc_wakeup_host(epc, epf->func_no,
>> +					epf->vfunc_no, PCI_WAKEUP_TOGGLE_WAKE);
>> +	else
>> +		ret = pci_epc_wakeup_host(epc, epf->func_no,
>> +					epf->vfunc_no, PCI_WAKEUP_SEND_PME);
>> +
> If the wakeup argument is of type bool (ie. bool use_pme), then
>
> 	wakeup = (mhi_cntrl->dstate == PCI_D3cold) ? false : true;
>
> 	return pci_epc_wakeup_host(epc, epf->func_no, epf->vfunc_no, state);
>
> - Mani

better to use type as it as it has more readability

but I have taken your inputs here and will change the code as suggetsed.

- KC

>> +	return ret;
>> +
>> +}
>> +
>>   static int pci_epf_mhi_core_init(struct pci_epf *epf)
>>   {
>>   	struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
>> @@ -293,6 +311,7 @@ static int pci_epf_mhi_link_up(struct pci_epf *epf)
>>   	mhi_cntrl->unmap_free = pci_epf_mhi_unmap_free;
>>   	mhi_cntrl->read_from_host = pci_epf_mhi_read_from_host;
>>   	mhi_cntrl->write_to_host = pci_epf_mhi_write_to_host;
>> +	mhi_cntrl->wakeup_host = pci_epf_mhi_wakeup_host;
>>   
>>   	/* Register the MHI EP controller */
>>   	ret = mhi_ep_register_controller(mhi_cntrl, info->config);
>> diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
>> index c3a0685..e353c429 100644
>> --- a/include/linux/mhi_ep.h
>> +++ b/include/linux/mhi_ep.h
>> @@ -137,6 +137,7 @@ struct mhi_ep_cntrl {
>>   			   void __iomem *virt, size_t size);
>>   	int (*read_from_host)(struct mhi_ep_cntrl *mhi_cntrl, u64 from, void *to, size_t size);
>>   	int (*write_to_host)(struct mhi_ep_cntrl *mhi_cntrl, void *from, u64 to, size_t size);
>> +	int (*wakeup_host)(struct mhi_ep_cntrl *mhi_cntrl);
>>   
>>   	enum mhi_state mhi_state;
>>   
>> -- 
>> 2.7.4
>>
diff mbox series

Patch

diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
index 64ff37d..deb742c 100644
--- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
+++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
@@ -237,6 +237,24 @@  static int pci_epf_mhi_write_to_host(struct mhi_ep_cntrl *mhi_cntrl,
 	return 0;
 }
 
+static int pci_epf_mhi_wakeup_host(struct mhi_ep_cntrl *mhi_cntrl)
+{
+	struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
+	struct pci_epf *epf = epf_mhi->epf;
+	struct pci_epc *epc = epf->epc;
+	int ret;
+
+	if (mhi_cntrl->dstate == PCI_D3cold)
+		ret = pci_epc_wakeup_host(epc, epf->func_no,
+					epf->vfunc_no, PCI_WAKEUP_TOGGLE_WAKE);
+	else
+		ret = pci_epc_wakeup_host(epc, epf->func_no,
+					epf->vfunc_no, PCI_WAKEUP_SEND_PME);
+
+	return ret;
+
+}
+
 static int pci_epf_mhi_core_init(struct pci_epf *epf)
 {
 	struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
@@ -293,6 +311,7 @@  static int pci_epf_mhi_link_up(struct pci_epf *epf)
 	mhi_cntrl->unmap_free = pci_epf_mhi_unmap_free;
 	mhi_cntrl->read_from_host = pci_epf_mhi_read_from_host;
 	mhi_cntrl->write_to_host = pci_epf_mhi_write_to_host;
+	mhi_cntrl->wakeup_host = pci_epf_mhi_wakeup_host;
 
 	/* Register the MHI EP controller */
 	ret = mhi_ep_register_controller(mhi_cntrl, info->config);
diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
index c3a0685..e353c429 100644
--- a/include/linux/mhi_ep.h
+++ b/include/linux/mhi_ep.h
@@ -137,6 +137,7 @@  struct mhi_ep_cntrl {
 			   void __iomem *virt, size_t size);
 	int (*read_from_host)(struct mhi_ep_cntrl *mhi_cntrl, u64 from, void *to, size_t size);
 	int (*write_to_host)(struct mhi_ep_cntrl *mhi_cntrl, void *from, u64 to, size_t size);
+	int (*wakeup_host)(struct mhi_ep_cntrl *mhi_cntrl);
 
 	enum mhi_state mhi_state;