Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3816627rdb; Thu, 28 Dec 2023 00:21:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeWLfr3vLHQ5xsGwwo6QJu6980ZIsccCM1oxtiEGWeX5fGuPSgbUvmXlcZ3AUjk0kZpJr4 X-Received: by 2002:a05:6e02:1bc3:b0:35d:58ce:2322 with SMTP id x3-20020a056e021bc300b0035d58ce2322mr16252993ilv.5.1703751715357; Thu, 28 Dec 2023 00:21:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703751715; cv=none; d=google.com; s=arc-20160816; b=yUzRGYa9H4eWuijfztgOpb9nWUq/LHT1Qj01dOZ5FiDNp7ruLzjUAOfcKNo4Zkzgxa 3qlKGOnKtmQbX90Hq7+LNgu9fMy/vG66QzQiJUVhFdzs+U67B/TK/iqpiDXeefia0Jqi vdATjFXjX8SbQ/m4mTgymkW5CDkIJbM++YHWyW2vs9F6inJwgm//yof83EARVmMbf3Q/ bfMjYu/RWvZOh4+lHYb2OoSHZa6Y6YlC6VVhWTgQ4TZTHuiBEN6CF8rHmvxYzg32B/CT PqVhTlRLmV2z2OruL+7K411hSMIVb7yzTEsh90mDLS6Ds9COjYGv9ro5UV81RVaqCCuU UFCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=3Z3GjKTYL0SsDN92cXMM1vexbb9+fwwZFMYYRcQrwhI=; fh=UcV+n1srJA3EGhO3FfeN98XYB2GdIecN/zYfSkOmjbE=; b=M2eqJjNiuBXnnygbj5r0zqdb5Dvut6C7nK2ROF4PSckfIJwjBf1dDtRpYiJEjuLLSY yH8q9AUM0NwlEX8SQgnxX0iUOLhRstwXfQerr+OiFDtV2RXdXz9B4OB9ImXd+L1H1jU6 +lIp2HGSUDTqYFGIXcWP6apTb+DpnjS/kkz/0FyOX80ZclwC2UypZych7GpaqeymroQ3 MFbl9+QDyVgHdIlyMf06G2g3fGT2trfDSLAPBtjm4c3/FMLZ2pq8qc7JxbobqPiID/oZ J+fPZKCHtUCpPupHSeU/bXV1vaTM8LFe6+Ry79GuVaiVTLJzawlKO77hsAtgqK0loLpO UJ4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12509-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12509-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id cl7-20020a056a02098700b005cdffd0ec5esi9895304pgb.477.2023.12.28.00.21.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 00:21:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12509-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12509-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12509-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 0A92CB2270F for ; Thu, 28 Dec 2023 08:21:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39BC763A8; Thu, 28 Dec 2023 08:21:41 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 534615235; Thu, 28 Dec 2023 08:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.20.42.53]) by gateway (Coremail) with SMTP id _____8DxR_AGMI1lFAAAAA--.0S3; Thu, 28 Dec 2023 16:21:26 +0800 (CST) Received: from m-pc.loongson.cn (unknown [10.20.42.53]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxPL6UH41lP9MNAA--.19293S2; Thu, 28 Dec 2023 15:11:30 +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 v3] usb: xhci-plat: fix usb disconnect issue after s4 Date: Thu, 28 Dec 2023 15:11:13 +0800 Message-Id: <20231228071113.1719-1-zhuyinbo@loongson.cn> X-Mailer: git-send-email 2.20.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:AQAAf8AxPL6UH41lP9MNAA--.19293S2 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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. Change in v3: 1. Using pm_ptr() and pm_sleep_ptr() macros instead of the #ifdef CONFIG_PM_SLEEP and get rif of the __maybe_unused flags. drivers/usb/host/xhci-plat.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index b93161374293..14a2c5f09768 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -423,7 +423,7 @@ void xhci_plat_remove(struct platform_device *dev) } EXPORT_SYMBOL_GPL(xhci_plat_remove); -static int __maybe_unused xhci_plat_suspend(struct device *dev) +static int xhci_plat_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); @@ -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 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); @@ -473,7 +473,7 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) if (ret) goto disable_clks; - ret = xhci_resume(xhci, PMSG_RESUME); + ret = xhci_resume(xhci, pmsg); if (ret) goto disable_clks; @@ -492,6 +492,16 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) return ret; } +static int xhci_plat_resume(struct device *dev) +{ + return xhci_plat_resume_common(dev, PMSG_RESUME); +} + +static int 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); @@ -514,7 +524,12 @@ 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) + .suspend = pm_sleep_ptr(xhci_plat_suspend), + .resume = pm_sleep_ptr(xhci_plat_resume), + .freeze = pm_sleep_ptr(xhci_plat_suspend), + .thaw = pm_sleep_ptr(xhci_plat_resume), + .poweroff = pm_sleep_ptr(xhci_plat_suspend), + .restore = pm_sleep_ptr(xhci_plat_restore), SET_RUNTIME_PM_OPS(xhci_plat_runtime_suspend, xhci_plat_runtime_resume, -- 2.31.1