From patchwork Thu Dec 28 07:11:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yinbo Zhu X-Patchwork-Id: 183659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1868543dyb; Thu, 28 Dec 2023 00:21:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6jmWDXHnL/6Lfbs/XuZU9qAmwsNMkK08dd31m1U+2ojMEgSh6MzzpWmrKTIeBeqDXS4Bd X-Received: by 2002:a50:c317:0:b0:555:363c:d918 with SMTP id a23-20020a50c317000000b00555363cd918mr1640630edb.25.1703751718335; Thu, 28 Dec 2023 00:21:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703751718; cv=none; d=google.com; s=arc-20160816; b=VoTXWPg42K9D1CGLP3yHwezgtkyIPkBO89skr2u1QLJeBjTDcRUCSaE+IcjGOICbfL B1E2YAdXRoifHsfiQSER6O0DG36bZknFSzHhYGVnwkjLuqWJ9ahB1YljCOGMG2k9Zm5c F8xxvx1DD66a4hmqe7DakU3XlCBKtT8X8YAvFrjQ7adymFGdeRL5NL7kr7cze4q/X93A 5ya6CPrGBlWmaBQYkzmT+Lfx+qeC+DcOpMCGZ7AWHi1FskNAJV0fxUpIeVyf+isLU8nd ZmKgXHUiQsxVYofN/PMxl4MoyQyAhwYKDr7yNbJfQ8he2O7B0TPJnPkq5colgbN3rJGw 3XXg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12509-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id y16-20020a056402359000b005549157eb2asi4646284edc.585.2023.12.28.00.21.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 00:21:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12509-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12509-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12509-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id EB5541F2269A for ; Thu, 28 Dec 2023 08:21:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3931563D6; Thu, 28 Dec 2023 08:21:42 +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 X-CM-TRANSID: AQAAf8AxPL6UH41lP9MNAA--.19293S2 X-CM-SenderInfo: 52kx5xhqerqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786513161491327721 X-GMAIL-MSGID: 1786513161491327721 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,