mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Yinbo Zhu <zhuyinbo@loongson.cn>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Patchwork Bot <patchwork-bot@kernel.org>
Subject: Re: [PATCH v1] usb: ohci-platform: fix usb disconnect issue after s4
Date: Tue, 30 Aug 2022 14:59:03 +0200	[thread overview]
Message-ID: <Yw4JlyrjwHE5nYyd@kroah.com> (raw)
In-Reply-To: <20220830111449.2300-1-zhuyinbo@loongson.cn>

On Tue, Aug 30, 2022 at 07:14:49PM +0800, Yinbo Zhu wrote:
> Avoid retaining bogus hardware states during resume-from-hibernation.
> Previously we had reset the hardware as part of preparing to reinstate
> the snapshot image. But we can do better now with the new PM framework,
> since we know exactly which resume operations are from hibernation
> 
> According to the commit "cd1965db0" and "6ec4beb5c" that the flag
> "hibernated" is for resume-from-hibernation and it should be true when
> usb resume from disk.

When writing commit ids in changelogs, please use the recommended
format.  For this, that paragraph would read:

According to commit cd1965db054e ("USB: ohci: move
ohci_pci_{suspend,resume} to ohci-hcd.c") and commit 6ec4beb5c701 ("USB:
new flag for resume-from-hibernation"), the flag "hibernated" is for...

> When this flag "hibernated" is set, the drivers will reset the hardware
> to get rid of any existing state and make sure resume from hibernation
> re-enumerates everything for ohci.
> 
> Signed-off-by: Yinbo Zhu <zhuyinbo@loongson.cn>

What commit id does this fix?


> ---
>  drivers/usb/host/ohci-platform.c | 28 ++++++++++++++++++++++++----
>  1 file changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
> index 0adae6265127..e733da2cd3b7 100644
> --- a/drivers/usb/host/ohci-platform.c
> +++ b/drivers/usb/host/ohci-platform.c
> @@ -289,7 +289,7 @@ static int ohci_platform_suspend(struct device *dev)
>  	return ret;
>  }
>  
> -static int ohci_platform_resume(struct device *dev)
> +static int ohci_platform_renew(struct device *dev, bool hibernated)

I hate functions like this as it's now impossible to read the caller and
understand what is going on.

>  {
>  	struct usb_hcd *hcd = dev_get_drvdata(dev);
>  	struct usb_ohci_pdata *pdata = dev_get_platdata(dev);
> @@ -301,7 +301,7 @@ static int ohci_platform_resume(struct device *dev)
>  			return err;
>  	}
>  
> -	ohci_resume(hcd, false);
> +	ohci_resume(hcd, hibernated);
>  
>  	pm_runtime_disable(dev);
>  	pm_runtime_set_active(dev);
> @@ -309,6 +309,16 @@ static int ohci_platform_resume(struct device *dev)
>  
>  	return 0;
>  }
> +
> +static int ohci_platform_resume(struct device *dev)
> +{
> +	return ohci_platform_renew(dev, false);

See, what does "false" here mean?

You can wrap the ohci_platform_renew() function with two helpers that
are ohci_platform_renew_hibernated() and ohci_platform_renew() or
something like that, which would explain what the difference is here.

thanks,

greg k-h

  reply	other threads:[~2022-08-30 12:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30 11:14 Yinbo Zhu
2022-08-30 12:59 ` Greg Kroah-Hartman [this message]
2022-08-30 14:30 ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yw4JlyrjwHE5nYyd@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=patchwork-bot@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=zhuyinbo@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®