diff mbox series

[v3,3/4] soc: qcom: geni-se: Do not keep GPIOs to sleep state for shared SE usecase

Message ID 20240927063108.2773304-4-quic_msavaliy@quicinc.com
State New
Headers show
Series Enable shared SE support over I2C | expand

Commit Message

Mukesh Kumar Savaliya Sept. 27, 2024, 6:31 a.m. UTC
Currently the driver provides a function called geni_serial_resources_off()
to turn off resources like clocks and  pinctrl.

For shared SE between two SS, we don't need to keep pinctrl to sleep state
as other SS may be actively transferring data over SE. Hence,bypass keeping
pinctrl to sleep state conditionally using shared_geni_se flag.

Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
---
 drivers/soc/qcom/qcom-geni-se.c  | 14 ++++++++++----
 include/linux/soc/qcom/geni-se.h |  3 +++
 2 files changed, 13 insertions(+), 4 deletions(-)

Comments

Bjorn Andersson Sept. 30, 2024, 3:27 a.m. UTC | #1
On Fri, Sep 27, 2024 at 12:01:07PM GMT, Mukesh Kumar Savaliya wrote:
> Currently the driver provides a function called geni_serial_resources_off()
> to turn off resources like clocks and  pinctrl.
> 
> For shared SE between two SS, we don't need to keep pinctrl to sleep state
> as other SS may be actively transferring data over SE.

"don't need to" sounds like an optimization. Is this really the case?
The comment in the code below seems to indicate no.

As with the other commit message, expand your abbreviations.

> Hence,bypass keeping
> pinctrl to sleep state conditionally using shared_geni_se flag.
> 
> Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
> ---
>  drivers/soc/qcom/qcom-geni-se.c  | 14 ++++++++++----
>  include/linux/soc/qcom/geni-se.h |  3 +++
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
> index 2e8f24d5da80..89cf18699336 100644
> --- a/drivers/soc/qcom/qcom-geni-se.c
> +++ b/drivers/soc/qcom/qcom-geni-se.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
> +// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>  
>  /* Disable MMIO tracing to prevent excessive logging of unwanted MMIO traces */
>  #define __DISABLE_TRACE_MMIO__
> @@ -503,10 +504,15 @@ int geni_se_resources_off(struct geni_se *se)
>  
>  	if (has_acpi_companion(se->dev))
>  		return 0;
> -
> -	ret = pinctrl_pm_select_sleep_state(se->dev);
> -	if (ret)
> -		return ret;
> +	/* Keep pinctrl to sleep state only for regular usecase.
> +	 * Do not sleep pinctrl for shared SE because other SS(subsystems)
> +	 * may continueto perform transfer.
> +	 */
> +	if (se->shared_geni_se == false) {
> +		ret = pinctrl_pm_select_sleep_state(se->dev);

I'm a bit rusty on the pinctrl API, but wouldn't you achieve the same
result by just not specifying a "sleep" pinctrl state?

> +		if (ret)
> +			return ret;
> +	}
>  
>  	geni_se_clks_off(se);
>  	return 0;
> diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
> index c3bca9c0bf2c..359041c64ad8 100644
> --- a/include/linux/soc/qcom/geni-se.h
> +++ b/include/linux/soc/qcom/geni-se.h
> @@ -1,6 +1,7 @@
>  /* SPDX-License-Identifier: GPL-2.0 */
>  /*
>   * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>   */
>  
>  #ifndef _LINUX_QCOM_GENI_SE
> @@ -61,6 +62,7 @@ struct geni_icc_path {
>   * @num_clk_levels:	Number of valid clock levels in clk_perf_tbl
>   * @clk_perf_tbl:	Table of clock frequency input to serial engine clock
>   * @icc_paths:		Array of ICC paths for SE
> + * @shared_geni_se:	Tells if SE is used by two SS in shared environment.

Please avoid the abbreviations. Be succinct, e.g. does it matter that
it's two SS - what if it's 3?
"Tell" is not the correct verb here, struct members don't speak.

Regards,
Bjorn

>   */
>  struct geni_se {
>  	void __iomem *base;
> @@ -70,6 +72,7 @@ struct geni_se {
>  	unsigned int num_clk_levels;
>  	unsigned long *clk_perf_tbl;
>  	struct geni_icc_path icc_paths[3];
> +	bool shared_geni_se;
>  };
>  
>  /* Common SE registers */
> -- 
> 2.25.1
>
Konrad Dybcio Oct. 25, 2024, 6:53 p.m. UTC | #2
On 27.09.2024 8:31 AM, Mukesh Kumar Savaliya wrote:
> Currently the driver provides a function called geni_serial_resources_off()
> to turn off resources like clocks and  pinctrl.
> 
> For shared SE between two SS, we don't need to keep pinctrl to sleep state
> as other SS may be actively transferring data over SE. Hence,bypass keeping
> pinctrl to sleep state conditionally using shared_geni_se flag.
> 
> Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
> ---
>  drivers/soc/qcom/qcom-geni-se.c  | 14 ++++++++++----
>  include/linux/soc/qcom/geni-se.h |  3 +++
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
> index 2e8f24d5da80..89cf18699336 100644
> --- a/drivers/soc/qcom/qcom-geni-se.c
> +++ b/drivers/soc/qcom/qcom-geni-se.c
> @@ -1,5 +1,6 @@
>  // SPDX-License-Identifier: GPL-2.0
>  // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
> +// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>  
>  /* Disable MMIO tracing to prevent excessive logging of unwanted MMIO traces */
>  #define __DISABLE_TRACE_MMIO__
> @@ -503,10 +504,15 @@ int geni_se_resources_off(struct geni_se *se)
>  
>  	if (has_acpi_companion(se->dev))
>  		return 0;
> -
> -	ret = pinctrl_pm_select_sleep_state(se->dev);
> -	if (ret)
> -		return ret;
> +	/* Keep pinctrl to sleep state only for regular usecase.
> +	 * Do not sleep pinctrl for shared SE because other SS(subsystems)
> +	 * may continueto perform transfer.
> +	 */

/*
 * Don't alter pin states on shared SEs to avoid potentially
 * interrupting transfers started by other subsystems
 */


> +	if (se->shared_geni_se == false) {

if (!se->shared_geni_se)

> +		ret = pinctrl_pm_select_sleep_state(se->dev);
> +		if (ret)
> +			return ret;
> +	}
>  
>  	geni_se_clks_off(se);

Should the clocks be turned off?

Konrad
Mukesh Kumar Savaliya Nov. 13, 2024, 4:07 p.m. UTC | #3
Thanks Konrad for the review.

On 10/26/2024 12:23 AM, Konrad Dybcio wrote:
> On 27.09.2024 8:31 AM, Mukesh Kumar Savaliya wrote:
>> Currently the driver provides a function called geni_serial_resources_off()
>> to turn off resources like clocks and  pinctrl.
>>
>> For shared SE between two SS, we don't need to keep pinctrl to sleep state
>> as other SS may be actively transferring data over SE. Hence,bypass keeping
>> pinctrl to sleep state conditionally using shared_geni_se flag.
>>
>> Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
>> ---
>>   drivers/soc/qcom/qcom-geni-se.c  | 14 ++++++++++----
>>   include/linux/soc/qcom/geni-se.h |  3 +++
>>   2 files changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
>> index 2e8f24d5da80..89cf18699336 100644
>> --- a/drivers/soc/qcom/qcom-geni-se.c
>> +++ b/drivers/soc/qcom/qcom-geni-se.c
>> @@ -1,5 +1,6 @@
>>   // SPDX-License-Identifier: GPL-2.0
>>   // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
>> +// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>>   
>>   /* Disable MMIO tracing to prevent excessive logging of unwanted MMIO traces */
>>   #define __DISABLE_TRACE_MMIO__
>> @@ -503,10 +504,15 @@ int geni_se_resources_off(struct geni_se *se)
>>   
>>   	if (has_acpi_companion(se->dev))
>>   		return 0;
>> -
>> -	ret = pinctrl_pm_select_sleep_state(se->dev);
>> -	if (ret)
>> -		return ret;
>> +	/* Keep pinctrl to sleep state only for regular usecase.
>> +	 * Do not sleep pinctrl for shared SE because other SS(subsystems)
>> +	 * may continueto perform transfer.
>> +	 */
> 
> /*
>   * Don't alter pin states on shared SEs to avoid potentially
>   * interrupting transfers started by other subsystems
>   */
> 
Done
> 
>> +	if (se->shared_geni_se == false) {
> 
> if (!se->shared_geni_se)
Done
> 
>> +		ret = pinctrl_pm_select_sleep_state(se->dev);
>> +		if (ret)
>> +			return ret;
>> +	}
>>   
>>   	geni_se_clks_off(se);
> 
> Should the clocks be turned off?
> 
Yes, it's required to be turned off.
> Konrad
Mukesh Kumar Savaliya Nov. 13, 2024, 4:09 p.m. UTC | #4
Hi Bjorn,

On 9/30/2024 8:57 AM, Bjorn Andersson wrote:
> On Fri, Sep 27, 2024 at 12:01:07PM GMT, Mukesh Kumar Savaliya wrote:
>> Currently the driver provides a function called geni_serial_resources_off()
>> to turn off resources like clocks and  pinctrl.
>>
>> For shared SE between two SS, we don't need to keep pinctrl to sleep state
>> as other SS may be actively transferring data over SE.
> 
> "don't need to" sounds like an optimization. Is this really the case?
> The comment in the code below seems to indicate no.
It's not an optimization but real need for shared SE.
> 
> As with the other commit message, expand your abbreviations.
> 
Sure.
>> Hence,bypass keeping
>> pinctrl to sleep state conditionally using shared_geni_se flag.
>>
>> Signed-off-by: Mukesh Kumar Savaliya <quic_msavaliy@quicinc.com>
>> ---
>>   drivers/soc/qcom/qcom-geni-se.c  | 14 ++++++++++----
>>   include/linux/soc/qcom/geni-se.h |  3 +++
>>   2 files changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
>> index 2e8f24d5da80..89cf18699336 100644
>> --- a/drivers/soc/qcom/qcom-geni-se.c
>> +++ b/drivers/soc/qcom/qcom-geni-se.c
>> @@ -1,5 +1,6 @@
>>   // SPDX-License-Identifier: GPL-2.0
>>   // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
>> +// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>>   
>>   /* Disable MMIO tracing to prevent excessive logging of unwanted MMIO traces */
>>   #define __DISABLE_TRACE_MMIO__
>> @@ -503,10 +504,15 @@ int geni_se_resources_off(struct geni_se *se)
>>   
>>   	if (has_acpi_companion(se->dev))
>>   		return 0;
>> -
>> -	ret = pinctrl_pm_select_sleep_state(se->dev);
>> -	if (ret)
>> -		return ret;
>> +	/* Keep pinctrl to sleep state only for regular usecase.
>> +	 * Do not sleep pinctrl for shared SE because other SS(subsystems)
>> +	 * may continueto perform transfer.
>> +	 */
>> +	if (se->shared_geni_se == false) {
>> +		ret = pinctrl_pm_select_sleep_state(se->dev);
> 
> I'm a bit rusty on the pinctrl API, but wouldn't you achieve the same
> result by just not specifying a "sleep" pinctrl state?
I find it more generic if code takes required action based on the flag. 
As such this flag is required to perform other actions too. Rather 
guiding with documentations, it would be good to have feature flag and 
manage.
> 
>> +		if (ret)
>> +			return ret;
>> +	}
>>   
>>   	geni_se_clks_off(se);
>>   	return 0;
>> diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
>> index c3bca9c0bf2c..359041c64ad8 100644
>> --- a/include/linux/soc/qcom/geni-se.h
>> +++ b/include/linux/soc/qcom/geni-se.h
>> @@ -1,6 +1,7 @@
>>   /* SPDX-License-Identifier: GPL-2.0 */
>>   /*
>>    * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
>> + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
>>    */
>>   
>>   #ifndef _LINUX_QCOM_GENI_SE
>> @@ -61,6 +62,7 @@ struct geni_icc_path {
>>    * @num_clk_levels:	Number of valid clock levels in clk_perf_tbl
>>    * @clk_perf_tbl:	Table of clock frequency input to serial engine clock
>>    * @icc_paths:		Array of ICC paths for SE
>> + * @shared_geni_se:	Tells if SE is used by two SS in shared environment.
> 
> Please avoid the abbreviations. Be succinct, e.g. does it matter that
> it's two SS - what if it's 3?
Sure Bjorn, I shall enhance like multiprocessors running different OS.
> "Tell" is not the correct verb here, struct members don't speak.
Agree, corrected.
> 
> Regards,
> Bjorn
> 
>>    */
>>   struct geni_se {
>>   	void __iomem *base;
>> @@ -70,6 +72,7 @@ struct geni_se {
>>   	unsigned int num_clk_levels;
>>   	unsigned long *clk_perf_tbl;
>>   	struct geni_icc_path icc_paths[3];
>> +	bool shared_geni_se;
>>   };
>>   
>>   /* Common SE registers */
>> -- 
>> 2.25.1
>>
diff mbox series

Patch

diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
index 2e8f24d5da80..89cf18699336 100644
--- a/drivers/soc/qcom/qcom-geni-se.c
+++ b/drivers/soc/qcom/qcom-geni-se.c
@@ -1,5 +1,6 @@ 
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
 
 /* Disable MMIO tracing to prevent excessive logging of unwanted MMIO traces */
 #define __DISABLE_TRACE_MMIO__
@@ -503,10 +504,15 @@  int geni_se_resources_off(struct geni_se *se)
 
 	if (has_acpi_companion(se->dev))
 		return 0;
-
-	ret = pinctrl_pm_select_sleep_state(se->dev);
-	if (ret)
-		return ret;
+	/* Keep pinctrl to sleep state only for regular usecase.
+	 * Do not sleep pinctrl for shared SE because other SS(subsystems)
+	 * may continueto perform transfer.
+	 */
+	if (se->shared_geni_se == false) {
+		ret = pinctrl_pm_select_sleep_state(se->dev);
+		if (ret)
+			return ret;
+	}
 
 	geni_se_clks_off(se);
 	return 0;
diff --git a/include/linux/soc/qcom/geni-se.h b/include/linux/soc/qcom/geni-se.h
index c3bca9c0bf2c..359041c64ad8 100644
--- a/include/linux/soc/qcom/geni-se.h
+++ b/include/linux/soc/qcom/geni-se.h
@@ -1,6 +1,7 @@ 
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _LINUX_QCOM_GENI_SE
@@ -61,6 +62,7 @@  struct geni_icc_path {
  * @num_clk_levels:	Number of valid clock levels in clk_perf_tbl
  * @clk_perf_tbl:	Table of clock frequency input to serial engine clock
  * @icc_paths:		Array of ICC paths for SE
+ * @shared_geni_se:	Tells if SE is used by two SS in shared environment.
  */
 struct geni_se {
 	void __iomem *base;
@@ -70,6 +72,7 @@  struct geni_se {
 	unsigned int num_clk_levels;
 	unsigned long *clk_perf_tbl;
 	struct geni_icc_path icc_paths[3];
+	bool shared_geni_se;
 };
 
 /* Common SE registers */