From patchwork Wed Feb 27 08:24:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 10831391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74710922 for ; Wed, 27 Feb 2019 08:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 592092CF08 for ; Wed, 27 Feb 2019 08:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BCEE2CF31; Wed, 27 Feb 2019 08:24:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5B4F2CF08 for ; Wed, 27 Feb 2019 08:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729249AbfB0IYz (ORCPT ); Wed, 27 Feb 2019 03:24:55 -0500 Received: from mail-eopbgr70075.outbound.protection.outlook.com ([40.107.7.75]:18665 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726791AbfB0IYz (ORCPT ); Wed, 27 Feb 2019 03:24:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cFrLvgX7/I5otMDfoWwUABV1cdW5hCGD3SXMB2Ri8dk=; b=qxicxdqwxT98aDkOIIHTbluC/lyz6FfVxsmJ7C5eolkEJybv5MsuCFNBq9VJ/J9ECNTaBAXWppdgGcuSapFU/URHyjbFEmNvdmsU7uPMmHDfCz+HjjdhPSWXmz18XMUlh4CdYBjUaj5YJGJZrWuCdzHz+y1g+xmyQOTyNr53RWk= Received: from VI1PR04MB5040.eurprd04.prod.outlook.com (20.177.50.97) by VI1PR04MB3166.eurprd04.prod.outlook.com (10.170.229.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.15; Wed, 27 Feb 2019 08:24:48 +0000 Received: from VI1PR04MB5040.eurprd04.prod.outlook.com ([fe80::6c6c:b113:a6c1:dcb4]) by VI1PR04MB5040.eurprd04.prod.outlook.com ([fe80::6c6c:b113:a6c1:dcb4%5]) with mapi id 15.20.1643.022; Wed, 27 Feb 2019 08:24:48 +0000 From: BOUGH CHEN To: "adrian.hunter@intel.com" , "ulf.hansson@linaro.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" CC: "festevam@gmail.com" , dl-linux-imx , "linux-mmc@vger.kernel.org" , BOUGH CHEN Subject: [PATCH V3] mmc: sdhci-esdhc-imx: clear the HALT bit when enable CQE Thread-Topic: [PATCH V3] mmc: sdhci-esdhc-imx: clear the HALT bit when enable CQE Thread-Index: AQHUznXmus71Y3mTM0ihowO0orjqnQ== Date: Wed, 27 Feb 2019 08:24:48 +0000 Message-ID: <20190227083226.32679-1-haibo.chen@nxp.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.17.1 x-clientproxiedby: HK2PR04CA0068.apcprd04.prod.outlook.com (2603:1096:202:15::12) To VI1PR04MB5040.eurprd04.prod.outlook.com (2603:10a6:803:59::33) authentication-results: spf=none (sender IP is ) smtp.mailfrom=haibo.chen@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 85d278d7-83b4-479e-41b2-08d69c8d0952 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB3166; x-ms-traffictypediagnostic: VI1PR04MB3166: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BVI1PR04MB3166=3B23=3AOH?= =?iso-8859-1?q?dXHg0u1FW8/UPir66we7Zi9p+QVLdJE1pNeYNccdR9ZNYLBQVYEtcxkqOKiH?= =?iso-8859-1?q?Q61k8xcW/et2PLWCJDoG+POA/MX4Nj4jMB9k2ZIWBKOpkNu9kRWhm1vrqK4f?= =?iso-8859-1?q?KmCWcOjGc0Wk5u6j5kZg+bH4FVRrPWCOX9QsA7Q86G+suFufyliowhpR4y5q?= =?iso-8859-1?q?GkZzTFla/pvo6EAATMR0+WQr/Um+2i4+Y7UJxKoyDTuRdcsMChSHNCj1ViAH?= =?iso-8859-1?q?+nlMym/s6yqcIqEE1691ARXdbrDsEKwZBgv6zcnBod3UB0c18ey4tvjEWYWM?= =?iso-8859-1?q?gqYxu7gGQToU7iu/8H/YO45Rbq9AP1kvcd4wv3DoqLXxnzOxoL459vMWco2m?= =?iso-8859-1?q?4PGH3Vi6V06NzoCfcLwaYdw1ky2oE90O52P7t/vwZwQOPPC8MbHsRYIyEYBF?= =?iso-8859-1?q?ySEwAg9FyUJOngaf3KpMSIuhFdDYYF2MWk713ddbnnwwzc0o5VhlSZhrv/eb?= =?iso-8859-1?q?mcHgTk4vGfUekQGdJxnVq2/NntloW2QExlZIjDd7dM5AcfE5pDE9DgaLa8yc?= =?iso-8859-1?q?+sZ+lwlFjrTbtzNUWK8woU5k/JpxlxfgNXHNFI8OZAmeMvNICzdbGfh+FUfR?= =?iso-8859-1?q?RRdHTIHql/sXoIYB7LPJ3hfiiqAbSe324rTV6bLyo7QcDNxh6j81rUB1xpX+?= =?iso-8859-1?q?B3lpTQ5xa7+bo/b9zERGwPkTae2VWSS4psUAF1CNEQW5vM7b7+uxS2eqK/Fi?= =?iso-8859-1?q?AlMzYBEVzZ5WXes/fZhr3y41kMGcaX0lLpUwYmyFHpOKeyM0Lcy0sYs6qoPV?= =?iso-8859-1?q?hHyFYqTzivpCAkHOisCJLzQB+3y5ijydC+tKFa8ttPBihMSysbR07jnl7yoA?= =?iso-8859-1?q?TM5AV2ESld+Wmmc8ObBxVOlROd1P16fBnL3pIa/IM9fpqXKH2ZshOiO0phXV?= =?iso-8859-1?q?FMEKjBfiX4eBLUD1vJUbePScmSb80/bgjPfi86cNT9LiHW1IPBJYHRJonF1b?= =?iso-8859-1?q?dwviLSOrGaUjgOePk1NL93y3PcOX/6n/E8qBtZyPPHg2egwV1HizVEpTfcR6?= =?iso-8859-1?q?lDhupLHDXWCS96AEVpn6Rit4HYK5rcxL+BUt6q2yhZ9hUeXVd6oPdYwgfehK?= =?iso-8859-1?q?SlADUXdR1BuKRzsna7Vh+kcN0FECWrDrmplqeI50ZKMDeo2JML2L6ObwAofA?= =?iso-8859-1?q?v8gwSdh1zRA0PXEhAJTHoJt8tGLvas+awLXHsJUmKBLmZv63qUnpyYsnqRQs?= =?iso-8859-1?q?D1rJoim2dnhR+fGVm4rfEmnrVkrr7ztYrtmwEz0iOYGbgieimjyx9LHUA=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(376002)(366004)(136003)(396003)(39860400002)(189003)(199004)(51234002)(53346004)(52116002)(8676002)(486006)(99286004)(81156014)(81166006)(476003)(71190400001)(2616005)(71200400001)(4326008)(36756003)(25786009)(97736004)(2906002)(316002)(102836004)(106356001)(105586002)(386003)(186003)(6506007)(26005)(478600001)(14444005)(54906003)(1076003)(256004)(66066001)(110136005)(6116002)(3846002)(5660300002)(8936002)(68736007)(86362001)(305945005)(6486002)(7736002)(14454004)(6512007)(2201001)(50226002)(53936002)(2501003)(6436002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB3166;H:VI1PR04MB5040.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 4oJw1bTpfPXkcd/Lb3KfR0rGh87gYJj30VWVVcpU30YzsE1aWabMC8bZCh+KxnnkTazuRclLgoOakOGAwAb1Ffej79QDxw+TFFGfel3ZE3fSL9vKMo5hmvShB854aLha8SR7NrSKIPJOU0lETcU+YTSdXoTiojoBXxuWiIxvAiep7JEz0Kge8a4q301JNklPfJaQNftcqy6yvRxgsUzYgzkFHdC0g8T4e0SyRGIBG2ftzTLqHdNvLO7IlS12vyRNx7ZB6qUw0mN63fYAwOTCrQ6OpQOlTgD2E28tjtMVeO6CN5y4CKelozozeiHHLNvH5DSiKhMIJ3mIooVstWf6TNzQFNhJBiiyvbB4qfhRF3pBu1OFsZZkGoAFOw3ekIEoVGaqN5rTDSEcz1bbWh9mMf8ua9pIJsWuXsdAJ2HY04w= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85d278d7-83b4-479e-41b2-08d69c8d0952 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2019 08:24:44.9259 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3166 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After system suspend, CQE is in cqhci_off state, which set the HALT bit, make CQE in HALT state. If the SoC do not power down the USDHC module, then when system resume back, this bit keep the same, still set. Though there is a sdhci reset during sdhci_resume_host(), but this reset do not impact the CQE part, so need to clear this bit when enable CQE, otherwise CQE will stuck in the first CMDQ request after system resume back. Find this issue on NXP i.MX845s-mek board [ 105.919862] mmc2: cqhci: timeout for tag 6 [ 105.923965] mmc2: cqhci: ============ CQHCI REGISTER DUMP =========== [ 105.930407] mmc2: cqhci: Caps: 0x0000310a | Version: 0x00000510 [ 105.936847] mmc2: cqhci: Config: 0x00001001 | Control: 0x00000001 [ 105.943286] mmc2: cqhci: Int stat: 0x00000000 | Int enab: 0x00000006 [ 105.949725] mmc2: cqhci: Int sig: 0x00000006 | Int Coal: 0x00000000 [ 105.956164] mmc2: cqhci: TDL base: 0x7809b000 | TDL up32: 0x00000000 [ 105.962604] mmc2: cqhci: Doorbell: 0x00000040 | TCN: 0x00000000 [ 105.969043] mmc2: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x00000000 [ 105.975483] mmc2: cqhci: Task clr: 0x00000000 | SSC1: 0x00011000 [ 105.981922] mmc2: cqhci: SSC2: 0x00000001 | DCMD rsp: 0x00000000 [ 105.988362] mmc2: cqhci: RED mask: 0xfdf9a080 | TERRI: 0x00000000 [ 105.994801] mmc2: cqhci: Resp idx: 0x00000000 | Resp arg: 0x00000000 [ 106.001240] mmc2: sdhci: ============ SDHCI REGISTER DUMP =========== [ 106.007680] mmc2: sdhci: Sys addr: 0xb2b37800 | Version: 0x00000002 [ 106.014120] mmc2: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000001 [ 106.020560] mmc2: sdhci: Argument: 0x00010000 | Trn mode: 0x00000013 [ 106.026999] mmc2: sdhci: Present: 0x01f88008 | Host ctl: 0x00000030 [ 106.033439] mmc2: sdhci: Power: 0x00000002 | Blk gap: 0x00000080 [ 106.039878] mmc2: sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f [ 106.046318] mmc2: sdhci: Timeout: 0x0000008f | Int stat: 0x00000000 [ 106.052757] mmc2: sdhci: Int enab: 0x107f4000 | Sig enab: 0x107f4000 [ 106.059196] mmc2: sdhci: AC12 err: 0x00000000 | Slot int: 0x00000502 [ 106.065635] mmc2: sdhci: Caps: 0x07eb0000 | Caps_1: 0x8000b407 [ 106.072075] mmc2: sdhci: Cmd: 0x00000d1a | Max curr: 0x00ffffff [ 106.078514] mmc2: sdhci: Resp[0]: 0x00000900 | Resp[1]: 0x31360181 [ 106.084954] mmc2: sdhci: Resp[2]: 0x44473430 | Resp[3]: 0x00450100 [ 106.091392] mmc2: sdhci: Host ctl2: 0x00000008 [ 106.095836] mmc2: sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x7804b208 [ 106.102274] mmc2: sdhci: ============================================ [ 106.108785] mmc2: running CQE recovery Signed-off-by: Haibo Chen Acked-by: Adrian Hunter --- Changes for V3 - remove 'clearing all tasks' in comments, to avoid misleading - add the ack from Adrian Hunter Changes for V2 - move the clear HALT behavior from common code __cqhci_enable to platform specific function esdhc_cqe_enable --- drivers/mmc/host/sdhci-esdhc-imx.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index c7215f5321d7..c60542f6693c 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -1245,6 +1245,7 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host) static void esdhc_cqe_enable(struct mmc_host *mmc) { struct sdhci_host *host = mmc_priv(mmc); + struct cqhci_host *cq_host = mmc->cqe_private; u32 reg; u16 mode; int count = 10; @@ -1277,6 +1278,18 @@ static void esdhc_cqe_enable(struct mmc_host *mmc) mode |= SDHCI_TRNS_BLK_CNT_EN; sdhci_writew(host, mode, SDHCI_TRANSFER_MODE); + /* + * Though Runtime resume reset the entire host controller, + * but do not impact the CQHCI side, need to clear the + * HALT bit, avoid CQHCI stuck in the first request when + * system resume back. + */ + cqhci_writel(cq_host, 0, CQHCI_CTL); + if (cqhci_readl(cq_host, CQHCI_CTL) && CQHCI_HALT) + dev_err(mmc_dev(host->mmc), + "failed to exit halt state when enable CQE\n"); + + sdhci_cqe_enable(mmc); }