Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp266779pxf; Thu, 8 Apr 2021 02:37:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWffXGFuFJ9OijQCKaoF6KK1vpBCEO7lfRf6LBQ4TIWhIrL7Tvh4vEl+8M6DXCeIit2TNy X-Received: by 2002:a05:6402:51c6:: with SMTP id r6mr9918845edd.278.1617874671484; Thu, 08 Apr 2021 02:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617874671; cv=none; d=google.com; s=arc-20160816; b=PVrL1QY48xCGxKRE24SV140ZXWthjb0w12Wu4rZdRj+QGjSrO/7uRi3m8MC0g2+Slp UGlMLYIb9bbiXYM/7SkZVZn8MoBuHC1g61v7DiB34zMSBi6xmaS4iCN2rH4PdoUrI2Y9 oCHYVM6aYdXXzzZlFsos21Gg8n/HREzbOm0AkvlqugaoDWv8KaiA4+Sz2hMfQ2yob3IZ ZyG6PfCFqRAdFZAO8Oq22v5qsh1sMC+l1a4ya+JBohizt8Yu3nVI2dpoyJ3OQdVZjMIg EI4HnetsLvxi8MiFYF970pozd14uh9Z+bPTt7d52bzCYy4AYNWgnUMYk3rmpwXneqTAt w1/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=yPI4gsDxmhQ0WlanEWivewvFMloosKT68dBpXJ4LECQ=; b=YEsSV9HLsTWe+u9QeH65ld3GUXr+cH0k28Lpbju0eHhVWMWi9ncKaDOQ0nF6P9zUp5 kgKhIieWshxcr3DkwM13I2s9AmJJd2K3T8/7eu8YbS2XDdY3zMG2BcPiK83cdeUcdBpq bqoM7tJUA5mG1jLhUkCbM7qPrAnx61sPYQ6W6+tn0aWK2s+I9jRlT+m6EjOJi8DUcWHz FWOj42uiDVpZpFiKsNIziYhUVM3rHOMDx2HjmxTQeLDIw1pNJxNHM9S64DMB0bF+1QTd Vmr/GdMPI76roXg8OCtuo+C+3+HH7biSeBpkXzOoV3Mm4mEznXMH/QsdrQ32Dj4tZqpI iIog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si22116068edr.347.2021.04.08.02.37.27; Thu, 08 Apr 2021 02:37:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbhDHJft (ORCPT + 99 others); Thu, 8 Apr 2021 05:35:49 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:50611 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231272AbhDHJfh (ORCPT ); Thu, 8 Apr 2021 05:35:37 -0400 X-UUID: 236ae62e2a614e9692898ed1c828fb3b-20210408 X-UUID: 236ae62e2a614e9692898ed1c828fb3b-20210408 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1780418086; Thu, 08 Apr 2021 17:35:21 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 17:35:19 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 8 Apr 2021 17:35:18 +0800 From: Chunfeng Yun To: Rob Herring , Mathias Nyman CC: Chunfeng Yun , Greg Kroah-Hartman , Matthias Brugger , "Rafael J. Wysocki" , Len Brown , Pavel Machek , , , , , , , Tony Lindgren , Tianping Fang , Eddie Hung , Ikjoon Jang , Nicolas Boichat Subject: [PATCH 2/6] usb: xhci-mtk: check return value in suspend/resume hooks Date: Thu, 8 Apr 2021 17:35:10 +0800 Message-ID: <1617874514-12282-2-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1617874514-12282-1-git-send-email-chunfeng.yun@mediatek.com> References: <1617874514-12282-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return error number if encounter errors during suspend and resume. Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mtk.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index c1bc40289833..a74764ab914a 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -630,18 +630,12 @@ static int xhci_mtk_remove(struct platform_device *dev) return 0; } -/* - * if ip sleep fails, and all clocks are disabled, access register will hang - * AHB bus, so stop polling roothubs to avoid regs access on bus suspend. - * and no need to check whether ip sleep failed or not; this will cause SPM - * to wake up system immediately after system suspend complete if ip sleep - * fails, it is what we wanted. - */ static int __maybe_unused xhci_mtk_suspend(struct device *dev) { struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); struct usb_hcd *hcd = mtk->hcd; struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; xhci_dbg(xhci, "%s: stop port polling\n", __func__); clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); @@ -649,10 +643,21 @@ static int __maybe_unused xhci_mtk_suspend(struct device *dev) clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); del_timer_sync(&xhci->shared_hcd->rh_timer); - xhci_mtk_host_disable(mtk); + ret = xhci_mtk_host_disable(mtk); + if (ret) + goto restart_poll_rh; + xhci_mtk_clks_disable(mtk); usb_wakeup_set(mtk, true); return 0; + +restart_poll_rh: + xhci_dbg(xhci, "%s: restart port polling\n", __func__); + set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); + usb_hcd_poll_rh_status(xhci->shared_hcd); + set_bit(HCD_FLAG_POLL_RH, &hcd->flags); + usb_hcd_poll_rh_status(hcd); + return ret; } static int __maybe_unused xhci_mtk_resume(struct device *dev) @@ -660,10 +665,16 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); struct usb_hcd *hcd = mtk->hcd; struct xhci_hcd *xhci = hcd_to_xhci(hcd); + int ret; usb_wakeup_set(mtk, false); - xhci_mtk_clks_enable(mtk); - xhci_mtk_host_enable(mtk); + ret = xhci_mtk_clks_enable(mtk); + if (ret) + goto enable_wakeup; + + ret = xhci_mtk_host_enable(mtk); + if (ret) + goto disable_clks; xhci_dbg(xhci, "%s: restart port polling\n", __func__); set_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); @@ -671,6 +682,12 @@ static int __maybe_unused xhci_mtk_resume(struct device *dev) set_bit(HCD_FLAG_POLL_RH, &hcd->flags); usb_hcd_poll_rh_status(hcd); return 0; + +disable_clks: + xhci_mtk_clks_disable(mtk); +enable_wakeup: + usb_wakeup_set(mtk, true); + return ret; } static const struct dev_pm_ops xhci_mtk_pm_ops = { -- 2.18.0