From patchwork Wed Aug 9 09:58:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinbo Zhu X-Patchwork-Id: 133154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2700518vqr; Wed, 9 Aug 2023 03:32:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7HXaIefo0g2RfPlf+nKWcWNlPDmY9OrndsT+fMceVfoXfwBsYYObHDw0fwHk8RoRFf6Cx X-Received: by 2002:a17:907:270d:b0:99d:101b:8403 with SMTP id w13-20020a170907270d00b0099d101b8403mr1116095ejk.36.1691577168845; Wed, 09 Aug 2023 03:32:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691577168; cv=none; d=google.com; s=arc-20160816; b=RjT2j0JnPTAYGl8kaUvj4BnPW3UBf6tDUWA9GjGDcPJEAsou9As+jbiHUnONQ72JYc 5rpeCBf3m86vvHvZPOwSjmoqZucsYKu5TChQ/HXh3Aa+pInOOpuQGNuHNe7MUbA6BTfB Im77YeluIoMpLI6YI7LE8n3Ke4Tcn1zJRdv9xw1Mt0DQQanPsArxe1sB8bSB4Z7WU/NG Uh6mGf354qPzaeQS6O0+7IB8isBTLH68Eb2OaFwWR8p8rTA1CQiT0LGkMrMjAUtg+t+C EyEjzEvPBjFkgqMKNsJp8FdeBqOsyxU4U7iPSLgALboxw72gHB5vTmG/eKELE0Re0s6j 8Idg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jwoN7O3OVdy2NRUScKzrbaYL16Z9YoH0P7/S8Fwakqc=; fh=qhNNi9GloKyUkLs9yM2mphH8hh3Wv9KgOtOjQeyghzE=; b=VNGBLanQLSb/HakfZ8I78z4xVN3EMlGL9o1/mQ1q39HYooKangNOXpvg2pBYvjAV6L f1Gks97Nu8XN+6NALD767JWplqokCxMaf5pMfr4F6Zh7prxlPNHcJ9jrqQb1mgBWYNpf XjF59tLxD8vX3RyUdy44mcBsH2VYlNOZy6TBhXpanG1xZfcO3au3KepLMmMDMLWZ4oi+ yEEOO/CobeZa25e3ym7IO/u86NxRZLv9ft3Bb7Itn+HmpTIMbtEUbKt86ydWhpS6FCoP vvBFlYktCOiZX+vnpQbHAKQBsblkd3rXkWkVDSm3jvT6Ljk0/Ww5uUZZl2xjmS7cQ+cc LCYg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a170906560800b00992e14a3655si9006803ejq.354.2023.08.09.03.32.17; Wed, 09 Aug 2023 03:32:48 -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 S231769AbjHIJ6o (ORCPT + 99 others); Wed, 9 Aug 2023 05:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229620AbjHIJ6n (ORCPT ); Wed, 9 Aug 2023 05:58:43 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB2461BFA; Wed, 9 Aug 2023 02:58:41 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.201]) by gateway (Coremail) with SMTP id _____8DxVuhQY9NkLrgTAA--.7322S3; Wed, 09 Aug 2023 17:58:40 +0800 (CST) Received: from localhost.localdomain (unknown [10.20.42.201]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxB81DY9Nk3RZRAA--.65284S2; Wed, 09 Aug 2023 17:58:39 +0800 (CST) From: Yinbo Zhu To: Mathias Nyman , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jianmin Lv , wanghongliang@loongson.cn, loongson-kernel@lists.loongnix.cn, Yinbo Zhu Subject: [PATCH v2] usb: xhci-plat: fix usb disconnect issue after s4 Date: Wed, 9 Aug 2023 17:58:26 +0800 Message-Id: <20230809095826.18183-1-zhuyinbo@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxB81DY9Nk3RZRAA--.65284S2 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773110159549112799 X-GMAIL-MSGID: 1773747221083122446 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 --- 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)