* [PATCH] usb: dwc3: qcom: Add shutdown handler
@ 2025-07-25 6:21 Prashanth K
2025-07-25 8:48 ` Greg Kroah-Hartman
2025-07-29 22:19 ` Thinh Nguyen
0 siblings, 2 replies; 6+ messages in thread
From: Prashanth K @ 2025-07-25 6:21 UTC (permalink / raw)
To: Greg Kroah-Hartman, Thinh Nguyen
Cc: Bjorn Andersson, Krishna Kurapati, linux-usb, linux-kernel,
Prashanth K
Currently during system reboot, SMMU disables its translations
while devices like USB may still be actively using DMA buffers.
This can lead to NOC errors and system crashes due to invalid
memory access.
Address this by adding a shutdown callback to dwc3-qcom, which
ensures proper teardown of UDC stack and prevents DWC3 controller
from accessing memory after SMMU translation is disabled. Reuse
the existing remove callback for this purpose.
Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
---
drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index ca7e1c02773a..308360a32c93 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -764,11 +764,14 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
struct dwc3 *dwc = platform_get_drvdata(pdev);
struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
- dwc3_core_remove(&qcom->dwc);
+ if (pm_runtime_resume_and_get(qcom->dev) < 0)
+ return;
+ dwc3_core_remove(&qcom->dwc);
clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
-
dwc3_qcom_interconnect_exit(qcom);
+
+ pm_runtime_put_noidle(qcom->dev);
}
static int dwc3_qcom_pm_suspend(struct device *dev)
@@ -873,6 +876,7 @@ MODULE_DEVICE_TABLE(of, dwc3_qcom_of_match);
static struct platform_driver dwc3_qcom_driver = {
.probe = dwc3_qcom_probe,
.remove = dwc3_qcom_remove,
+ .shutdown = dwc3_qcom_remove,
.driver = {
.name = "dwc3-qcom",
.pm = pm_ptr(&dwc3_qcom_dev_pm_ops),
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: dwc3: qcom: Add shutdown handler
2025-07-25 6:21 [PATCH] usb: dwc3: qcom: Add shutdown handler Prashanth K
@ 2025-07-25 8:48 ` Greg Kroah-Hartman
2025-07-25 9:58 ` Prashanth K
2025-07-29 22:19 ` Thinh Nguyen
1 sibling, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-25 8:48 UTC (permalink / raw)
To: Prashanth K
Cc: Thinh Nguyen, Bjorn Andersson, Krishna Kurapati, linux-usb,
linux-kernel
On Fri, Jul 25, 2025 at 11:51:58AM +0530, Prashanth K wrote:
> Currently during system reboot, SMMU disables its translations
> while devices like USB may still be actively using DMA buffers.
> This can lead to NOC errors and system crashes due to invalid
> memory access.
>
> Address this by adding a shutdown callback to dwc3-qcom, which
> ensures proper teardown of UDC stack and prevents DWC3 controller
> from accessing memory after SMMU translation is disabled. Reuse
> the existing remove callback for this purpose.
>
> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
What commit id does this fix? Or is this just a new feature?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: dwc3: qcom: Add shutdown handler
2025-07-25 8:48 ` Greg Kroah-Hartman
@ 2025-07-25 9:58 ` Prashanth K
2025-07-25 11:59 ` Greg Kroah-Hartman
0 siblings, 1 reply; 6+ messages in thread
From: Prashanth K @ 2025-07-25 9:58 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Thinh Nguyen, Bjorn Andersson, Krishna Kurapati, linux-usb,
linux-kernel
On 7/25/2025 2:18 PM, Greg Kroah-Hartman wrote:
> On Fri, Jul 25, 2025 at 11:51:58AM +0530, Prashanth K wrote:
>> Currently during system reboot, SMMU disables its translations
>> while devices like USB may still be actively using DMA buffers.
>> This can lead to NOC errors and system crashes due to invalid
>> memory access.
>>
>> Address this by adding a shutdown callback to dwc3-qcom, which
>> ensures proper teardown of UDC stack and prevents DWC3 controller
>> from accessing memory after SMMU translation is disabled. Reuse
>> the existing remove callback for this purpose.
>>
>> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
>> ---
>> drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> What commit id does this fix? Or is this just a new feature?
>
> thanks,
>
> greg k-h
I didn't Fixes tag because a small dilemma. This patch is rebased on top
of the flattening series, specifically commit 1881a32fe14d ("usb: dwc3:
qcom: Transition to flattened model").
However, I don't think that this commit caused this issue.
Let me know if you want the Fixes tag.
Thanks in advance,
Prashanth K
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: dwc3: qcom: Add shutdown handler
2025-07-25 9:58 ` Prashanth K
@ 2025-07-25 11:59 ` Greg Kroah-Hartman
2025-07-28 5:21 ` Prashanth K
0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2025-07-25 11:59 UTC (permalink / raw)
To: Prashanth K
Cc: Thinh Nguyen, Bjorn Andersson, Krishna Kurapati, linux-usb,
linux-kernel
On Fri, Jul 25, 2025 at 03:28:12PM +0530, Prashanth K wrote:
>
>
> On 7/25/2025 2:18 PM, Greg Kroah-Hartman wrote:
> > On Fri, Jul 25, 2025 at 11:51:58AM +0530, Prashanth K wrote:
> >> Currently during system reboot, SMMU disables its translations
> >> while devices like USB may still be actively using DMA buffers.
> >> This can lead to NOC errors and system crashes due to invalid
> >> memory access.
> >>
> >> Address this by adding a shutdown callback to dwc3-qcom, which
> >> ensures proper teardown of UDC stack and prevents DWC3 controller
> >> from accessing memory after SMMU translation is disabled. Reuse
> >> the existing remove callback for this purpose.
> >>
> >> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
> >> ---
> >> drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++--
> >> 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > What commit id does this fix? Or is this just a new feature?
> >
> > thanks,
> >
> > greg k-h
>
> I didn't Fixes tag because a small dilemma. This patch is rebased on top
> of the flattening series, specifically commit 1881a32fe14d ("usb: dwc3:
> qcom: Transition to flattened model").
> However, I don't think that this commit caused this issue.
>
> Let me know if you want the Fixes tag.
If you don't need/want this backported to any stable tree, then leave it
as-is. Your choice.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: dwc3: qcom: Add shutdown handler
2025-07-25 11:59 ` Greg Kroah-Hartman
@ 2025-07-28 5:21 ` Prashanth K
0 siblings, 0 replies; 6+ messages in thread
From: Prashanth K @ 2025-07-28 5:21 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Thinh Nguyen, Bjorn Andersson, Krishna Kurapati, linux-usb,
linux-kernel
On 7/25/2025 5:29 PM, Greg Kroah-Hartman wrote:
> On Fri, Jul 25, 2025 at 03:28:12PM +0530, Prashanth K wrote:
>>
>>
>> On 7/25/2025 2:18 PM, Greg Kroah-Hartman wrote:
>>> On Fri, Jul 25, 2025 at 11:51:58AM +0530, Prashanth K wrote:
>>>> Currently during system reboot, SMMU disables its translations
>>>> while devices like USB may still be actively using DMA buffers.
>>>> This can lead to NOC errors and system crashes due to invalid
>>>> memory access.
>>>>
>>>> Address this by adding a shutdown callback to dwc3-qcom, which
>>>> ensures proper teardown of UDC stack and prevents DWC3 controller
>>>> from accessing memory after SMMU translation is disabled. Reuse
>>>> the existing remove callback for this purpose.
>>>>
>>>> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
>>>> ---
>>>> drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++--
>>>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>> What commit id does this fix? Or is this just a new feature?
>>>
>>> thanks,
>>>
>>> greg k-h
>>
>> I didn't Fixes tag because a small dilemma. This patch is rebased on top
>> of the flattening series, specifically commit 1881a32fe14d ("usb: dwc3:
>> qcom: Transition to flattened model").
>> However, I don't think that this commit caused this issue.
>>
>> Let me know if you want the Fixes tag.
>
> If you don't need/want this backported to any stable tree, then leave it
> as-is. Your choice.
>
Lets not take it to stable now, because it will cause conflicts.
If we encounter any issue in future, we can manually resolve the
conflict and backport to stable.
Regards,
Prashanth K
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: dwc3: qcom: Add shutdown handler
2025-07-25 6:21 [PATCH] usb: dwc3: qcom: Add shutdown handler Prashanth K
2025-07-25 8:48 ` Greg Kroah-Hartman
@ 2025-07-29 22:19 ` Thinh Nguyen
1 sibling, 0 replies; 6+ messages in thread
From: Thinh Nguyen @ 2025-07-29 22:19 UTC (permalink / raw)
To: Prashanth K
Cc: Greg Kroah-Hartman, Thinh Nguyen, Bjorn Andersson,
Krishna Kurapati, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
On Fri, Jul 25, 2025, Prashanth K wrote:
> Currently during system reboot, SMMU disables its translations
> while devices like USB may still be actively using DMA buffers.
> This can lead to NOC errors and system crashes due to invalid
> memory access.
>
> Address this by adding a shutdown callback to dwc3-qcom, which
> ensures proper teardown of UDC stack and prevents DWC3 controller
> from accessing memory after SMMU translation is disabled. Reuse
> the existing remove callback for this purpose.
>
> Signed-off-by: Prashanth K <prashanth.k@oss.qualcomm.com>
> ---
> drivers/usb/dwc3/dwc3-qcom.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index ca7e1c02773a..308360a32c93 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -764,11 +764,14 @@ static void dwc3_qcom_remove(struct platform_device *pdev)
> struct dwc3 *dwc = platform_get_drvdata(pdev);
> struct dwc3_qcom *qcom = to_dwc3_qcom(dwc);
>
> - dwc3_core_remove(&qcom->dwc);
> + if (pm_runtime_resume_and_get(qcom->dev) < 0)
> + return;
>
> + dwc3_core_remove(&qcom->dwc);
> clk_bulk_disable_unprepare(qcom->num_clocks, qcom->clks);
> -
> dwc3_qcom_interconnect_exit(qcom);
> +
> + pm_runtime_put_noidle(qcom->dev);
> }
>
> static int dwc3_qcom_pm_suspend(struct device *dev)
> @@ -873,6 +876,7 @@ MODULE_DEVICE_TABLE(of, dwc3_qcom_of_match);
> static struct platform_driver dwc3_qcom_driver = {
> .probe = dwc3_qcom_probe,
> .remove = dwc3_qcom_remove,
> + .shutdown = dwc3_qcom_remove,
> .driver = {
> .name = "dwc3-qcom",
> .pm = pm_ptr(&dwc3_qcom_dev_pm_ops),
> --
> 2.25.1
>
Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
BR,
Thinh
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-07-29 22:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 6:21 [PATCH] usb: dwc3: qcom: Add shutdown handler Prashanth K
2025-07-25 8:48 ` Greg Kroah-Hartman
2025-07-25 9:58 ` Prashanth K
2025-07-25 11:59 ` Greg Kroah-Hartman
2025-07-28 5:21 ` Prashanth K
2025-07-29 22:19 ` Thinh Nguyen
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).