linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: qcom: Add shutdown callback for dwc3
@ 2020-11-12  6:30 Sandeep Maheswaram
  2021-01-13  5:44 ` sanm
  2021-01-13  8:40 ` Felipe Balbi
  0 siblings, 2 replies; 4+ messages in thread
From: Sandeep Maheswaram @ 2020-11-12  6:30 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Felipe Balbi, Stephen Boyd, Doug Anderson,
	Matthias Kaehlcke
  Cc: linux-arm-msm, linux-usb, devicetree, linux-kernel, Manu Gautam,
	Sandeep Maheswaram

This patch adds a shutdown callback to USB DWC QCOM driver to ensure that
it is properly shutdown in reboot/shutdown path. This is required
where SMMU address translation is enabled like on SC7180
SoC and few others. If the hardware is still accessing memory after
SMMU translation is disabled as part of SMMU shutdown callback in
system reboot or shutdown path, then IOVAs(I/O virtual address)
which it was using will go on the bus as the physical addresses which
might result in unknown crashes (NoC/interconnect errors).

Signed-off-by: Sandeep Maheswaram <sanm@codeaurora.org>
---
 drivers/usb/dwc3/dwc3-qcom.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index c703d55..a930e06 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -790,13 +790,11 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int dwc3_qcom_remove(struct platform_device *pdev)
+static void __dwc3_qcom_teardown(struct dwc3_qcom *qcom)
 {
-	struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
-	struct device *dev = &pdev->dev;
 	int i;
 
-	of_platform_depopulate(dev);
+	of_platform_depopulate(qcom->dev);
 
 	for (i = qcom->num_clocks - 1; i >= 0; i--) {
 		clk_disable_unprepare(qcom->clks[i]);
@@ -807,12 +805,27 @@ static int dwc3_qcom_remove(struct platform_device *pdev)
 	dwc3_qcom_interconnect_exit(qcom);
 	reset_control_assert(qcom->resets);
 
-	pm_runtime_allow(dev);
-	pm_runtime_disable(dev);
+	pm_runtime_allow(qcom->dev);
+	pm_runtime_disable(qcom->dev);
+}
+
+static int dwc3_qcom_remove(struct platform_device *pdev)
+{
+	struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
+
+	__dwc3_qcom_teardown(qcom);
 
 	return 0;
 }
 
+static void dwc3_qcom_shutdown(struct platform_device *pdev)
+{
+	struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
+
+	__dwc3_qcom_teardown(qcom);
+
+}
+
 static int __maybe_unused dwc3_qcom_pm_suspend(struct device *dev)
 {
 	struct dwc3_qcom *qcom = dev_get_drvdata(dev);
@@ -887,6 +900,7 @@ MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
 static struct platform_driver dwc3_qcom_driver = {
 	.probe		= dwc3_qcom_probe,
 	.remove		= dwc3_qcom_remove,
+	.shutdown	= dwc3_qcom_shutdown,
 	.driver		= {
 		.name	= "dwc3-qcom",
 		.pm	= &dwc3_qcom_dev_pm_ops,
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc3: qcom: Add shutdown callback for dwc3
  2020-11-12  6:30 [PATCH] usb: dwc3: qcom: Add shutdown callback for dwc3 Sandeep Maheswaram
@ 2021-01-13  5:44 ` sanm
  2021-01-13  8:40 ` Felipe Balbi
  1 sibling, 0 replies; 4+ messages in thread
From: sanm @ 2021-01-13  5:44 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Felipe Balbi, Stephen Boyd, Doug Anderson,
	Matthias Kaehlcke
  Cc: linux-arm-msm, linux-usb, devicetree, linux-kernel, Manu Gautam

On 2020-11-12 12:00, Sandeep Maheswaram wrote:
> This patch adds a shutdown callback to USB DWC QCOM driver to ensure 
> that
> it is properly shutdown in reboot/shutdown path. This is required
> where SMMU address translation is enabled like on SC7180
> SoC and few others. If the hardware is still accessing memory after
> SMMU translation is disabled as part of SMMU shutdown callback in
> system reboot or shutdown path, then IOVAs(I/O virtual address)
> which it was using will go on the bus as the physical addresses which
> might result in unknown crashes (NoC/interconnect errors).
> 
> Signed-off-by: Sandeep Maheswaram <sanm@codeaurora.org>
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 26 ++++++++++++++++++++------
>  1 file changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c 
> b/drivers/usb/dwc3/dwc3-qcom.c
> index c703d55..a930e06 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -790,13 +790,11 @@ static int dwc3_qcom_probe(struct platform_device 
> *pdev)
>  	return ret;
>  }
> 
> -static int dwc3_qcom_remove(struct platform_device *pdev)
> +static void __dwc3_qcom_teardown(struct dwc3_qcom *qcom)
>  {
> -	struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
> -	struct device *dev = &pdev->dev;
>  	int i;
> 
> -	of_platform_depopulate(dev);
> +	of_platform_depopulate(qcom->dev);
> 
>  	for (i = qcom->num_clocks - 1; i >= 0; i--) {
>  		clk_disable_unprepare(qcom->clks[i]);
> @@ -807,12 +805,27 @@ static int dwc3_qcom_remove(struct 
> platform_device *pdev)
>  	dwc3_qcom_interconnect_exit(qcom);
>  	reset_control_assert(qcom->resets);
> 
> -	pm_runtime_allow(dev);
> -	pm_runtime_disable(dev);
> +	pm_runtime_allow(qcom->dev);
> +	pm_runtime_disable(qcom->dev);
> +}
> +
> +static int dwc3_qcom_remove(struct platform_device *pdev)
> +{
> +	struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
> +
> +	__dwc3_qcom_teardown(qcom);
> 
>  	return 0;
>  }
> 
> +static void dwc3_qcom_shutdown(struct platform_device *pdev)
> +{
> +	struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
> +
> +	__dwc3_qcom_teardown(qcom);
> +
> +}
> +
>  static int __maybe_unused dwc3_qcom_pm_suspend(struct device *dev)
>  {
>  	struct dwc3_qcom *qcom = dev_get_drvdata(dev);
> @@ -887,6 +900,7 @@ MODULE_DEVICE_TABLE(acpi, dwc3_qcom_acpi_match);
>  static struct platform_driver dwc3_qcom_driver = {
>  	.probe		= dwc3_qcom_probe,
>  	.remove		= dwc3_qcom_remove,
> +	.shutdown	= dwc3_qcom_shutdown,
>  	.driver		= {
>  		.name	= "dwc3-qcom",
>  		.pm	= &dwc3_qcom_dev_pm_ops,

Hi Felipe,

Can you please review this patch.

Regards
Sandeep

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc3: qcom: Add shutdown callback for dwc3
  2020-11-12  6:30 [PATCH] usb: dwc3: qcom: Add shutdown callback for dwc3 Sandeep Maheswaram
  2021-01-13  5:44 ` sanm
@ 2021-01-13  8:40 ` Felipe Balbi
  2021-01-18  6:32   ` sanm
  1 sibling, 1 reply; 4+ messages in thread
From: Felipe Balbi @ 2021-01-13  8:40 UTC (permalink / raw)
  To: Sandeep Maheswaram, Andy Gross, Bjorn Andersson,
	Greg Kroah-Hartman, Rob Herring, Mark Rutland, Stephen Boyd,
	Doug Anderson, Matthias Kaehlcke
  Cc: linux-arm-msm, linux-usb, devicetree, linux-kernel, Manu Gautam,
	Sandeep Maheswaram

[-- Attachment #1: Type: text/plain, Size: 1935 bytes --]


Hi,

Sandeep Maheswaram <sanm@codeaurora.org> writes:
> This patch adds a shutdown callback to USB DWC QCOM driver to ensure that
> it is properly shutdown in reboot/shutdown path. This is required
> where SMMU address translation is enabled like on SC7180
> SoC and few others. If the hardware is still accessing memory after
> SMMU translation is disabled as part of SMMU shutdown callback in
> system reboot or shutdown path, then IOVAs(I/O virtual address)
> which it was using will go on the bus as the physical addresses which
> might result in unknown crashes (NoC/interconnect errors).
>
> Signed-off-by: Sandeep Maheswaram <sanm@codeaurora.org>

sounds like this is fixing a bug. Do you have a Fixes tag for it? Should
this go to stable?

> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index c703d55..a930e06 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -790,13 +790,11 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
>  	return ret;
>  }
>  
> -static int dwc3_qcom_remove(struct platform_device *pdev)
> +static void __dwc3_qcom_teardown(struct dwc3_qcom *qcom)
>  {
> -	struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
> -	struct device *dev = &pdev->dev;
>  	int i;
>  
> -	of_platform_depopulate(dev);
> +	of_platform_depopulate(qcom->dev);
>  
>  	for (i = qcom->num_clocks - 1; i >= 0; i--) {
>  		clk_disable_unprepare(qcom->clks[i]);
> @@ -807,12 +805,27 @@ static int dwc3_qcom_remove(struct platform_device *pdev)
>  	dwc3_qcom_interconnect_exit(qcom);
>  	reset_control_assert(qcom->resets);
>  
> -	pm_runtime_allow(dev);
> -	pm_runtime_disable(dev);
> +	pm_runtime_allow(qcom->dev);
> +	pm_runtime_disable(qcom->dev);
> +}

you can make the changes smaller by adding:

	struct device *dev = qcom->dev;

The nothing else needs to change in this function ;-)

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 857 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: dwc3: qcom: Add shutdown callback for dwc3
  2021-01-13  8:40 ` Felipe Balbi
@ 2021-01-18  6:32   ` sanm
  0 siblings, 0 replies; 4+ messages in thread
From: sanm @ 2021-01-18  6:32 UTC (permalink / raw)
  To: Felipe Balbi
  Cc: Andy Gross, Bjorn Andersson, Greg Kroah-Hartman, Rob Herring,
	Mark Rutland, Stephen Boyd, Doug Anderson, Matthias Kaehlcke,
	linux-arm-msm, linux-usb, devicetree, linux-kernel, Manu Gautam

On 2021-01-13 14:10, Felipe Balbi wrote:
> Hi,
> 
> Sandeep Maheswaram <sanm@codeaurora.org> writes:
>> This patch adds a shutdown callback to USB DWC QCOM driver to ensure 
>> that
>> it is properly shutdown in reboot/shutdown path. This is required
>> where SMMU address translation is enabled like on SC7180
>> SoC and few others. If the hardware is still accessing memory after
>> SMMU translation is disabled as part of SMMU shutdown callback in
>> system reboot or shutdown path, then IOVAs(I/O virtual address)
>> which it was using will go on the bus as the physical addresses which
>> might result in unknown crashes (NoC/interconnect errors).
>> 
>> Signed-off-by: Sandeep Maheswaram <sanm@codeaurora.org>
> 
> sounds like this is fixing a bug. Do you have a Fixes tag for it? 
> Should
> this go to stable?
> 
Didn't encounter any bug till now but made this change to prevent issue.

>> diff --git a/drivers/usb/dwc3/dwc3-qcom.c 
>> b/drivers/usb/dwc3/dwc3-qcom.c
>> index c703d55..a930e06 100644
>> --- a/drivers/usb/dwc3/dwc3-qcom.c
>> +++ b/drivers/usb/dwc3/dwc3-qcom.c
>> @@ -790,13 +790,11 @@ static int dwc3_qcom_probe(struct 
>> platform_device *pdev)
>>  	return ret;
>>  }
>> 
>> -static int dwc3_qcom_remove(struct platform_device *pdev)
>> +static void __dwc3_qcom_teardown(struct dwc3_qcom *qcom)
>>  {
>> -	struct dwc3_qcom *qcom = platform_get_drvdata(pdev);
>> -	struct device *dev = &pdev->dev;
>>  	int i;
>> 
>> -	of_platform_depopulate(dev);
>> +	of_platform_depopulate(qcom->dev);
>> 
>>  	for (i = qcom->num_clocks - 1; i >= 0; i--) {
>>  		clk_disable_unprepare(qcom->clks[i]);
>> @@ -807,12 +805,27 @@ static int dwc3_qcom_remove(struct 
>> platform_device *pdev)
>>  	dwc3_qcom_interconnect_exit(qcom);
>>  	reset_control_assert(qcom->resets);
>> 
>> -	pm_runtime_allow(dev);
>> -	pm_runtime_disable(dev);
>> +	pm_runtime_allow(qcom->dev);
>> +	pm_runtime_disable(qcom->dev);
>> +}
> 
> you can make the changes smaller by adding:
> 
> 	struct device *dev = qcom->dev;
> 
> The nothing else needs to change in this function ;-)

I will do this in next version

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-18  6:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-12  6:30 [PATCH] usb: dwc3: qcom: Add shutdown callback for dwc3 Sandeep Maheswaram
2021-01-13  5:44 ` sanm
2021-01-13  8:40 ` Felipe Balbi
2021-01-18  6:32   ` sanm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).