diff mbox series

[v2] usb: xhci-plat: fix usb disconnect issue after s4

Message ID 20230809095826.18183-1-zhuyinbo@loongson.cn (mailing list archive)
State New, archived
Headers show
Series [v2] usb: xhci-plat: fix usb disconnect issue after s4 | expand

Commit Message

Yinbo Zhu Aug. 9, 2023, 9:58 a.m. UTC
The xhci retaining bogus hardware states cause usb disconnect devices
connected before hibernation(s4) and refer to the commit 'f3d478858be
("usb: ohci-platform: fix usb disconnect issue after s4")' which set
flag "hibernated" as true when resume-from-hibernation and that the
drivers will reset the hardware to get rid of any existing state and
make sure resume from hibernation re-enumerates everything for xhci.

Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
---
Change in v2:
		1. Add CONFIG_PM_SLEEP in xhci_plat_pm_ops that for fix
		   compile issue when CONFIG_PM not enable.

 drivers/usb/host/xhci-plat.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

Comments

Yinbo Zhu Aug. 29, 2023, 12:43 p.m. UTC | #1
Friendly ping ?


在 2023/8/9 下午5:58, Yinbo Zhu 写道:
> The xhci retaining bogus hardware states cause usb disconnect devices
> connected before hibernation(s4) and refer to the commit 'f3d478858be
> ("usb: ohci-platform: fix usb disconnect issue after s4")' which set
> flag "hibernated" as true when resume-from-hibernation and that the
> drivers will reset the hardware to get rid of any existing state and
> make sure resume from hibernation re-enumerates everything for xhci.
> 
> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
> ---
> Change in v2:
> 		1. Add CONFIG_PM_SLEEP in xhci_plat_pm_ops that for fix
> 		   compile issue when CONFIG_PM not enable.
> 
>   drivers/usb/host/xhci-plat.c | 24 ++++++++++++++++++++----
>   1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 28218c8f1837..112468fdcca2 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -451,7 +451,7 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
>   	return 0;
>   }
>   
> -static int __maybe_unused xhci_plat_resume(struct device *dev)
> +static int __maybe_unused xhci_plat_resume_common(struct device *dev, struct pm_message pmsg)
>   {
>   	struct usb_hcd	*hcd = dev_get_drvdata(dev);
>   	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
> @@ -466,7 +466,7 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
>   	if (ret)
>   		return ret;
>   
> -	ret = xhci_resume(xhci, PMSG_RESUME);
> +	ret = xhci_resume(xhci, pmsg);
>   	if (ret)
>   		return ret;
>   
> @@ -477,6 +477,16 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
>   	return 0;
>   }
>   
> +static int __maybe_unused xhci_plat_resume(struct device *dev)
> +{
> +	return xhci_plat_resume_common(dev, PMSG_RESUME);
> +}
> +
> +static int __maybe_unused xhci_plat_restore(struct device *dev)
> +{
> +	return xhci_plat_resume_common(dev, PMSG_RESTORE);
> +}
> +
>   static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev)
>   {
>   	struct usb_hcd  *hcd = dev_get_drvdata(dev);
> @@ -499,8 +509,14 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev)
>   }
>   
>   const struct dev_pm_ops xhci_plat_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(xhci_plat_suspend, xhci_plat_resume)
> -
> +#ifdef CONFIG_PM_SLEEP
> +	.suspend = xhci_plat_suspend,
> +	.resume = xhci_plat_resume,
> +	.freeze = xhci_plat_suspend,
> +	.thaw = xhci_plat_resume,
> +	.poweroff = xhci_plat_suspend,
> +	.restore = xhci_plat_restore,
> +#endif
>   	SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend,
>   			   xhci_plat_runtime_resume,
>   			   NULL)
>
Greg KH Aug. 29, 2023, 1:49 p.m. UTC | #2
On Tue, Aug 29, 2023 at 08:43:18PM +0800, Yinbo Zhu wrote:
> 
> 
> Friendly ping ?

It's the middle of the merge window, I can't take anything new until
after -rc1 is out.

thanks,

greg k-h
Yinbo Zhu Sept. 21, 2023, 1:58 a.m. UTC | #3
Friendly ping ?


在 2023/8/9 下午5:58, Yinbo Zhu 写道:
> The xhci retaining bogus hardware states cause usb disconnect devices
> connected before hibernation(s4) and refer to the commit 'f3d478858be
> ("usb: ohci-platform: fix usb disconnect issue after s4")' which set
> flag "hibernated" as true when resume-from-hibernation and that the
> drivers will reset the hardware to get rid of any existing state and
> make sure resume from hibernation re-enumerates everything for xhci.
> 
> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
> ---
> Change in v2:
> 		1. Add CONFIG_PM_SLEEP in xhci_plat_pm_ops that for fix
> 		   compile issue when CONFIG_PM not enable.
> 
>   drivers/usb/host/xhci-plat.c | 24 ++++++++++++++++++++----
>   1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 28218c8f1837..112468fdcca2 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -451,7 +451,7 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
>   	return 0;
>   }
>   
> -static int __maybe_unused xhci_plat_resume(struct device *dev)
> +static int __maybe_unused xhci_plat_resume_common(struct device *dev, struct pm_message pmsg)
>   {
>   	struct usb_hcd	*hcd = dev_get_drvdata(dev);
>   	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
> @@ -466,7 +466,7 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
>   	if (ret)
>   		return ret;
>   
> -	ret = xhci_resume(xhci, PMSG_RESUME);
> +	ret = xhci_resume(xhci, pmsg);
>   	if (ret)
>   		return ret;
>   
> @@ -477,6 +477,16 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
>   	return 0;
>   }
>   
> +static int __maybe_unused xhci_plat_resume(struct device *dev)
> +{
> +	return xhci_plat_resume_common(dev, PMSG_RESUME);
> +}
> +
> +static int __maybe_unused xhci_plat_restore(struct device *dev)
> +{
> +	return xhci_plat_resume_common(dev, PMSG_RESTORE);
> +}
> +
>   static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev)
>   {
>   	struct usb_hcd  *hcd = dev_get_drvdata(dev);
> @@ -499,8 +509,14 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev)
>   }
>   
>   const struct dev_pm_ops xhci_plat_pm_ops = {
> -	SET_SYSTEM_SLEEP_PM_OPS(xhci_plat_suspend, xhci_plat_resume)
> -
> +#ifdef CONFIG_PM_SLEEP
> +	.suspend = xhci_plat_suspend,
> +	.resume = xhci_plat_resume,
> +	.freeze = xhci_plat_suspend,
> +	.thaw = xhci_plat_resume,
> +	.poweroff = xhci_plat_suspend,
> +	.restore = xhci_plat_restore,
> +#endif
>   	SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend,
>   			   xhci_plat_runtime_resume,
>   			   NULL)
>
Mathias Nyman Sept. 21, 2023, 12:38 p.m. UTC | #4
On 21.9.2023 4.58, Yinbo Zhu wrote:
> 
> 
> Friendly ping ?
> 
> 
> 在 2023/8/9 下午5:58, Yinbo Zhu 写道:
>> The xhci retaining bogus hardware states cause usb disconnect devices
>> connected before hibernation(s4) and refer to the commit 'f3d478858be
>> ("usb: ohci-platform: fix usb disconnect issue after s4")' which set
>> flag "hibernated" as true when resume-from-hibernation and that the
>> drivers will reset the hardware to get rid of any existing state and
>> make sure resume from hibernation re-enumerates everything for xhci.
>>
>> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>
>> ---
>> Change in v2:
>>         1. Add CONFIG_PM_SLEEP in xhci_plat_pm_ops that for fix
>>            compile issue when CONFIG_PM not enable.
>>
>>   drivers/usb/host/xhci-plat.c | 24 ++++++++++++++++++++----
>>   1 file changed, 20 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>> index 28218c8f1837..112468fdcca2 100644
>> --- a/drivers/usb/host/xhci-plat.c
>> +++ b/drivers/usb/host/xhci-plat.c
>> @@ -451,7 +451,7 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev)
>>       return 0;
>>   }
>> -static int __maybe_unused xhci_plat_resume(struct device *dev)
>> +static int __maybe_unused xhci_plat_resume_common(struct device *dev, struct pm_message pmsg)
>>   {
>>       struct usb_hcd    *hcd = dev_get_drvdata(dev);
>>       struct xhci_hcd    *xhci = hcd_to_xhci(hcd);
>> @@ -466,7 +466,7 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
>>       if (ret)
>>           return ret;
>> -    ret = xhci_resume(xhci, PMSG_RESUME);
>> +    ret = xhci_resume(xhci, pmsg);
>>       if (ret)
>>           return ret;
>> @@ -477,6 +477,16 @@ static int __maybe_unused xhci_plat_resume(struct device *dev)
>>       return 0;
>>   }
>> +static int __maybe_unused xhci_plat_resume(struct device *dev)
>> +{
>> +    return xhci_plat_resume_common(dev, PMSG_RESUME);
>> +}
>> +
>> +static int __maybe_unused xhci_plat_restore(struct device *dev)
>> +{
>> +    return xhci_plat_resume_common(dev, PMSG_RESTORE);
>> +}
>> +
>>   static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev)
>>   {
>>       struct usb_hcd  *hcd = dev_get_drvdata(dev);
>> @@ -499,8 +509,14 @@ static int __maybe_unused xhci_plat_runtime_resume(struct device *dev)
>>   }
>>   const struct dev_pm_ops xhci_plat_pm_ops = {
>> -    SET_SYSTEM_SLEEP_PM_OPS(xhci_plat_suspend, xhci_plat_resume)
>> -
>> +#ifdef CONFIG_PM_SLEEP
>> +    .suspend = xhci_plat_suspend,
>> +    .resume = xhci_plat_resume,
>> +    .freeze = xhci_plat_suspend,
>> +    .thaw = xhci_plat_resume,
>> +    .poweroff = xhci_plat_suspend,
>> +    .restore = xhci_plat_restore,
>> +#endif

How about using pm_ptr() and pm_sleep_ptr() macros instead of the #ifdef CONFIG_PM_SLEEP?
should be able to get rif of the __maybe_unused flags as well.

Thanks
-Mathias
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 28218c8f1837..112468fdcca2 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -451,7 +451,7 @@  static int __maybe_unused xhci_plat_suspend(struct device *dev)
 	return 0;
 }
 
-static int __maybe_unused xhci_plat_resume(struct device *dev)
+static int __maybe_unused xhci_plat_resume_common(struct device *dev, struct pm_message pmsg)
 {
 	struct usb_hcd	*hcd = dev_get_drvdata(dev);
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
@@ -466,7 +466,7 @@  static int __maybe_unused xhci_plat_resume(struct device *dev)
 	if (ret)
 		return ret;
 
-	ret = xhci_resume(xhci, PMSG_RESUME);
+	ret = xhci_resume(xhci, pmsg);
 	if (ret)
 		return ret;
 
@@ -477,6 +477,16 @@  static int __maybe_unused xhci_plat_resume(struct device *dev)
 	return 0;
 }
 
+static int __maybe_unused xhci_plat_resume(struct device *dev)
+{
+	return xhci_plat_resume_common(dev, PMSG_RESUME);
+}
+
+static int __maybe_unused xhci_plat_restore(struct device *dev)
+{
+	return xhci_plat_resume_common(dev, PMSG_RESTORE);
+}
+
 static int __maybe_unused xhci_plat_runtime_suspend(struct device *dev)
 {
 	struct usb_hcd  *hcd = dev_get_drvdata(dev);
@@ -499,8 +509,14 @@  static int __maybe_unused xhci_plat_runtime_resume(struct device *dev)
 }
 
 const struct dev_pm_ops xhci_plat_pm_ops = {
-	SET_SYSTEM_SLEEP_PM_OPS(xhci_plat_suspend, xhci_plat_resume)
-
+#ifdef CONFIG_PM_SLEEP
+	.suspend = xhci_plat_suspend,
+	.resume = xhci_plat_resume,
+	.freeze = xhci_plat_suspend,
+	.thaw = xhci_plat_resume,
+	.poweroff = xhci_plat_suspend,
+	.restore = xhci_plat_restore,
+#endif
 	SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend,
 			   xhci_plat_runtime_resume,
 			   NULL)