Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2086506rwe; Fri, 2 Sep 2022 08:17:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR693NioW6KeSWmRwapKVj0AMWRrt1qfDAzzDD43TT6r1Uao2h5LCmyIwIJ+2Ndu89oZYCsw X-Received: by 2002:a05:6402:4498:b0:448:dd50:c22d with SMTP id er24-20020a056402449800b00448dd50c22dmr14193566edb.196.1662131854825; Fri, 02 Sep 2022 08:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662131854; cv=none; d=google.com; s=arc-20160816; b=c4IDQSaEej84KXReUKrhlW2Xsx+fcxThxdUyJvrWTgOW21EL11vWf3knFbWN9Z25Wq J6bKw9hdTNwq2QVwWeH9Xg+9rbi6R3Q2lyRysZpJmf1CgycMsYImewebtQ8EOB7xG/D+ 1jIixmy6bFFnEN9X5POy176gOo3dIECrLO3fwdZp/Gi6jXulHPZOEwl7i+u9XUZ3aVAL tzp1d6MkVcW1yD5ht5VrRRXF4NXi+PmwALr156avbdbNAY6ldU0qedTZU56tJui0PuqF xjF/z5wiXYsbJFadDpaJ5OUbGcQjRBwbuKOHd6BGNak80XkYP8mAhsBFTGqAX2/z565w xQVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=gX9Umfgqu2roD3Wa2ljF65jc2fstpTgGO3fvliUmrUI=; b=kyWXn7nPD/ZKBaFqItrqJFJSzDPtR4FtS331invcxog6OLTWc+qos3tFRrsCu/HCNm Srm4SEJdTBPuXiQtChNEU1QMswuFBi+eKMID9EgUZzguY51e/izbpx8mOLHFTPCoeLqj bpwNB4mWG7pMmfV8eyRocWxTdRMjUV4xBmXLuUQHra27nw0tSLz+9BtO0zapD0aSPI/o 9fSn1JL/8ycCMg/L5U8E2w+J/TZqjDSFBpbrgUUBC3MLlBiTr+nrhiv7mLL35d16STbw Yp5VGKlg+FcyWdrnFnMQuwOLGB5qA9zfR2ynV8g9d+vx3LE99Fs+9NzHdgvkBR4oKf21 n4IA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id es9-20020a056402380900b0044d4a87aed7si410009edb.461.2022.09.02.08.17.09; Fri, 02 Sep 2022 08:17:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236064AbiIBOvO (ORCPT + 99 others); Fri, 2 Sep 2022 10:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbiIBOu7 (ORCPT ); Fri, 2 Sep 2022 10:50:59 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 2CAB95E32F for ; Fri, 2 Sep 2022 07:12:58 -0700 (PDT) Received: (qmail 272628 invoked by uid 1000); 2 Sep 2022 10:12:58 -0400 Date: Fri, 2 Sep 2022 10:12:58 -0400 From: Alan Stern To: Yinbo Zhu Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Patchwork Bot Subject: Re: [PATCH v4] usb: ohci-platform: fix usb disconnect issue after s4 Message-ID: References: <20220902063639.17875-1-zhuyinbo@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220902063639.17875-1-zhuyinbo@loongson.cn> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 02, 2022 at 02:36:39PM +0800, Yinbo Zhu wrote: > The ohci retaining bogus hardware states cause usb disconnect devices > connected before hibernation(s4), this issue occur when ohci-platform > driver build as a module and the built-in ohci-platform driver will > re probe and re enumerate the devices, so there will be no such problem. > > 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 '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 > resume-from-hibernation and it should be true when usb resume from disk. > > 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 > --- > Change in v4: > Add explain what this disconnect issue is. Acked-by: Alan Stern I'm a little surprised that the driver doesn't support runtime PM. > 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..822a0f927e62 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_resume_common(struct device *dev, bool hibernated) > { > 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_resume_common(dev, false); > +} > + > +static int ohci_platform_restore(struct device *dev) > +{ > + return ohci_platform_resume_common(dev, true); > +} > #endif /* CONFIG_PM_SLEEP */ > > static const struct of_device_id ohci_platform_ids[] = { > @@ -325,8 +335,16 @@ static const struct platform_device_id ohci_platform_table[] = { > }; > MODULE_DEVICE_TABLE(platform, ohci_platform_table); > > -static SIMPLE_DEV_PM_OPS(ohci_platform_pm_ops, ohci_platform_suspend, > - ohci_platform_resume); > +#ifdef CONFIG_PM_SLEEP > +static const struct dev_pm_ops ohci_platform_pm_ops = { > + .suspend = ohci_platform_suspend, > + .resume = ohci_platform_resume, > + .freeze = ohci_platform_suspend, > + .thaw = ohci_platform_resume, > + .poweroff = ohci_platform_suspend, > + .restore = ohci_platform_restore, > +}; > +#endif > > static struct platform_driver ohci_platform_driver = { > .id_table = ohci_platform_table, > @@ -335,7 +353,9 @@ static struct platform_driver ohci_platform_driver = { > .shutdown = usb_hcd_platform_shutdown, > .driver = { > .name = "ohci-platform", > +#ifdef CONFIG_PM_SLEEP > .pm = &ohci_platform_pm_ops, > +#endif > .of_match_table = ohci_platform_ids, > .probe_type = PROBE_PREFER_ASYNCHRONOUS, > } > -- > 2.31.1 >