Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp164537pxb; Wed, 11 Nov 2020 23:55:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHDBlZuY9wb/Roq0Lcr8cYHcw00SHicfafyxe+HJrEREli9Jt8cE/L5cNHO4kbTZfxCSMa X-Received: by 2002:a05:6402:48d:: with SMTP id k13mr3889294edv.92.1605167712512; Wed, 11 Nov 2020 23:55:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605167712; cv=none; d=google.com; s=arc-20160816; b=h16G1WjXj/d2jWWsxDPwZxAJyPrnNg0EKT8+X+OuFze7/zJ9dMSJ/eqig7TtMnr6h9 kPxgsvlTYXWP504JGBRvu+BdWyF58oa2Pm9gHYXOL6RZiViU5odC0Kqm+bAePYtSCwX+ nSF+eeg5bdCz6B/e+ne3/qelFTaJAeaJQJxWMBUoB1QC/bceEQNGb+rRFcrgRHV9/o2Z GyIxA6sudswvfQhJKcgtSDD1et0HK5Nu7Y4vHe54E1lms6nLYl6JFZ6IsqRgsG9pOuDD Po9H37uemNKa8mQCq56IRqFdWtr+erKT4EQCGgduizrMfjiT/49yM09SeOcHJF0cbo5l ROZg== 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=fcmIf+Zw+QofcKYurF66ZuMDL6to85ANIK6Um0bhsjA=; b=WmXDVleoQ3bGv62mGz6v+wcHvGus0CUJCGLw5fj+940bkrtIJcoZrLeWce3SZOjTvL hzheWLCY0hQ6jZYHAGyDSM4l8YalSPTVLtAQ9CBFjzfyWYiuf4aXuWE25rVk30wo/Vrr PAG5Z3SLkH/qhBkYtfrmbA3CBzFiSEyzFrRy1YfrSnMDlwdVsqLWuzTeOXr6hNrW6b5I 2556oaQ/whrMbARX3138bECfJwacX7nxRE0kXztjz82angiq9JIIM4dRDNaiwFfHls2q beaZPmHO6ZREmmynBTRL6JmQ+KTbKSu4Ws1PxS72btzvpnbiFJMgbX58N6sISjtOtGPP vmjw== 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 br9si3182878ejb.115.2020.11.11.23.54.48; Wed, 11 Nov 2020 23:55:12 -0800 (PST) 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 S1726834AbgKLHw0 (ORCPT + 99 others); Thu, 12 Nov 2020 02:52:26 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:53561 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725884AbgKLHwT (ORCPT ); Thu, 12 Nov 2020 02:52:19 -0500 X-UUID: f86e32c304ef4ebaa5b93d08d8b7ec87-20201112 X-UUID: f86e32c304ef4ebaa5b93d08d8b7ec87-20201112 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] 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 1451875633; Thu, 12 Nov 2020 15:52:15 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 12 Nov 2020 15:52:13 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 12 Nov 2020 15:52:12 +0800 From: Wenbin Mei To: Ulf Hansson , Rob Herring CC: Matthias Brugger , , Wenbin Mei , Veerabhadrarao Badiganti , Yoshihiro Shimoda , Baolin Wang , Ludovic Barre , Krishna Konda , Bradley Bolen , Chaotian Jing , , , , , , Subject: [PATCH v1 3/3] mmc: core: Set cqe off during suspend flow Date: Thu, 12 Nov 2020 15:52:08 +0800 Message-ID: <20201112075208.28183-4-wenbin.mei@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201112075208.28183-1-wenbin.mei@mediatek.com> References: <20201112075208.28183-1-wenbin.mei@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 Before we got these errors on MT8192 platform: [ 59.153891] Restarting tasks ... [ 59.154540] done. [ 59.159175] PM: suspend exit [ 59.218724] mtk-msdc 11f60000.mmc: phase: [map:fffffffe] [maxlen:31] [final:16] [ 119.776083] mmc0: cqhci: timeout for tag 9 [ 119.780196] mmc0: cqhci: ============ CQHCI REGISTER DUMP =========== [ 119.786709] mmc0: cqhci: Caps: 0x100020b6 | Version: 0x00000510 [ 119.793225] mmc0: cqhci: Config: 0x00000101 | Control: 0x00000000 [ 119.799706] mmc0: cqhci: Int stat: 0x00000000 | Int enab: 0x00000000 [ 119.806177] mmc0: cqhci: Int sig: 0x00000000 | Int Coal: 0x00000000 [ 119.812670] mmc0: cqhci: TDL base: 0x00000000 | TDL up32: 0x00000000 [ 119.819149] mmc0: cqhci: Doorbell: 0x003ffc00 | TCN: 0x00000200 [ 119.825656] mmc0: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000000 [ 119.832155] mmc0: cqhci: Task clr: 0x00000000 | SSC1: 0x00001000 [ 119.838627] mmc0: cqhci: SSC2: 0x00000000 | DCMD rsp: 0x00000000 [ 119.845174] mmc0: cqhci: RED mask: 0xfdf9a080 | TERRI: 0x0000891c [ 119.851654] mmc0: cqhci: Resp idx: 0x00000000 | Resp arg: 0x00000000 [ 119.865773] mmc0: cqhci: : =========================================== [ 119.872358] mmc0: running CQE recovery From these logs, we found TDL base was back to the default value. After suspend, the mmc host is powered off by HW, and bring CQE register to the default value, so CQE need to be re-initialized after resuming back. Signed-off-by: Wenbin Mei --- drivers/mmc/core/host.c | 2 ++ drivers/mmc/core/mmc.c | 5 +++++ include/linux/mmc/pm.h | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index ce43f7573d80..c98486c8fb3b 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -284,6 +284,8 @@ int mmc_of_parse(struct mmc_host *host) if (device_property_read_bool(dev, "wakeup-source") || device_property_read_bool(dev, "enable-sdio-wakeup")) /* legacy */ host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; + if (device_property_read_bool(dev, "cqe-off-in-suspend")) + host->pm_caps |= MMC_PM_CQE_OFF_IN_SUSPEND; if (device_property_read_bool(dev, "mmc-ddr-3_3v")) host->caps |= MMC_CAP_3_3V_DDR; if (device_property_read_bool(dev, "mmc-ddr-1_8v")) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index b3fa193de846..f5ae1f13a867 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -2047,6 +2047,11 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) err = mmc_deselect_cards(host); if (!err) { + if (host->cqe_enabled && + (host->pm_caps & MMC_PM_CQE_OFF_IN_SUSPEND)) { + host->cqe_ops->cqe_disable(host); + host->cqe_enabled = false; + } mmc_power_off(host); mmc_card_set_suspended(host->card); } diff --git a/include/linux/mmc/pm.h b/include/linux/mmc/pm.h index 3549f8045784..3dd1046f2c8f 100644 --- a/include/linux/mmc/pm.h +++ b/include/linux/mmc/pm.h @@ -23,5 +23,6 @@ typedef unsigned int mmc_pm_flag_t; #define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */ #define MMC_PM_WAKE_SDIO_IRQ (1 << 1) /* wake up host system on SDIO IRQ assertion */ +#define MMC_PM_CQE_OFF_IN_SUSPEND (1 << 2) /* cqe off during suspend */ #endif /* LINUX_MMC_PM_H */ -- 2.18.0