From patchwork Mon Oct 24 17:54:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9971 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp614840wru; Mon, 24 Oct 2022 12:24:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6LIUfbpj006EqDxId7WzLh2GB7j4tCgMoTok0ayiOKsJtO1DlgdcrXzh3dN/qlJ24+xsjV X-Received: by 2002:a17:90b:380b:b0:20b:8dd:4f5f with SMTP id mq11-20020a17090b380b00b0020b08dd4f5fmr76887952pjb.158.1666639497677; Mon, 24 Oct 2022 12:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639497; cv=none; d=google.com; s=arc-20160816; b=I96ia7k7sez30M2tvJ/b1dlfqc7dYs3VyYPGEnS2gH0qNq6Rgx3fmDGS+8lcpt4j3D OpVD4V4LQlMIE6rPXILMmDqsJ2/zRPC0P64vBbHNkMu7tP+OrS+B8zjy1gI9eqOlVjoz 9cB5sdCZYlVjAPtqwyiPjUHoWT6eVPD5TJ1aZhKL87fwff7k9M92HUjsHOuCN8zeJVI0 z6MV+RfvmU4fXMNyRBrQWwrFjqO2FUdcMueu4azyuFYPX/raPHH6Tcm+uF1QbCKmd+T/ 7aeynH2dBJIEXqFBzFEaq5xotPZlQIhKF42O0uRiYKuLpoQNzXB/xchwZIzcaSo1L20h zpjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aHRjtpJRM3U1ghY1hCFtCgckU5MadMj28s/UZ9ZqXJY=; b=R7Cd3zg7gKvOW2hKXTynUx0yDJ6rGgC3/7BrmeIaeOtOPtE8SqJKgTmwnG4cDQLS4s xQvIZVDTEXiz1CCHpSuuY6/Rtd6peEJj2aLUTRq7PjKGWpcMvwW630b5WNJjPSjCZN4U GhapADbbwy+E7Py30xBVP7bTX9Mm56TIcPPEbEFy3xSs2ze+AJw8mfFxK8tgTWYmUspt ZKFvsugoFXalvYvvRkfM4e/+EbeSnksH16s3cDrnALpqwlEuPFsQeWENTWQIhpTCJfCI NL3j27DPqFSKli1sp+U6b4Sb9kLJ/faVtX1nSlyOureMA3/anEc6z1F30q8CrKAZbxw5 lSqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=huM5ypBT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a637150000000b0046b208e7298si219793pgn.782.2022.10.24.12.24.41; Mon, 24 Oct 2022 12:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=huM5ypBT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbiJXTWC (ORCPT + 99 others); Mon, 24 Oct 2022 15:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231247AbiJXTVN (ORCPT ); Mon, 24 Oct 2022 15:21:13 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6071E501A6 for ; Mon, 24 Oct 2022 10:56:53 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id jo13so5494953plb.13 for ; Mon, 24 Oct 2022 10:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aHRjtpJRM3U1ghY1hCFtCgckU5MadMj28s/UZ9ZqXJY=; b=huM5ypBTUsffC1by9Jd9TL5QHxmbKm3XfeGX4DjCG2CA1f88rtNfIcdskO8MVHkZ96 Vesb6S2I1QxVDYiE1YZC336xhLf5LG+Ffg3a3xgl52ahBWt7nRsFgYugqfogVOhTYztP bJvp7aFAa5/SlYxVzpmhRUN73Lh+HFi81d6cw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aHRjtpJRM3U1ghY1hCFtCgckU5MadMj28s/UZ9ZqXJY=; b=0/vZmvujSsO7I1wrg8DFIoK3P7Rm5t4L0ps6Ih+dj/Br/0yk9xy/LrLWTk7iB8eASI G99LVBNcpGHyUYFbrdCEwPbCMfInBNmWKEMwCmN0gTD4l7C9tTkMD3DHEPr8TSBV5PTR NUuk2g+g/20mLvTqO7jy4GW/zseE450qn4K4XgUFCycbM5cX7sicO84B20l9PJDhfAbI Ht2RHv1FDF64+g1X3cdg0Wwo2cTvkaSIx48Tde2QWuU3Wq+rxxIpFYCBSxDyEPR5Eu9d tkm7/QJq3tIFz6Za5IBSqcEfV5mY7ezOoYXKjqHOB+kTkMCVc+sXy2pm8WGdV/kc7Y4F DPkA== X-Gm-Message-State: ACrzQf0nLa0rum6f7BLIezR7exLZ71Y0Obi27rUtugQxdOPrlfWEczvN phZrr6nd8d1owrtC4b7Wvy73Gg== X-Received: by 2002:a17:90a:1690:b0:212:f865:4f0e with SMTP id o16-20020a17090a169000b00212f8654f0emr11266624pja.197.1666634172695; Mon, 24 Oct 2022 10:56:12 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:808b:e2f6:edcf:ccb0]) by smtp.gmail.com with UTF8SMTPSA id d28-20020aa797bc000000b0056c0d129edfsm90824pfq.121.2022.10.24.10.56.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 10:56:12 -0700 (PDT) From: Brian Norris To: Ulf Hansson Cc: Shawn Lin , linux-mmc@vger.kernel.org, Al Cooper , Bjorn Andersson , Sowjanya Komatineni , Broadcom internal kernel review list , Sascha Hauer , Konrad Dybcio , Florian Fainelli , NXP Linux Team , Thierry Reding , Fabio Estevam , Michal Simek , linux-kernel@vger.kernel.org, Shawn Guo , Adrian Hunter , Pengutronix Kernel Team , linux-arm-msm@vger.kernel.org, Haibo Chen , Andy Gross , linux-arm-kernel@lists.infradead.org, Faiz Abbas , Jonathan Hunter , Brian Norris , stable@vger.kernel.org Subject: [PATCH v3 1/7] mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI Date: Mon, 24 Oct 2022 10:54:55 -0700 Message-Id: <20221024105229.v3.1.Ie85faa09432bfe1b0890d8c24ff95e17f3097317@changeid> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221024175501.2265400-1-briannorris@chromium.org> References: <20221024175501.2265400-1-briannorris@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747598177545854287?= X-GMAIL-MSGID: =?utf-8?q?1747598177545854287?= Several SDHCI drivers need to deactivate command queueing in their reset hook (see sdhci_cqhci_reset() / sdhci-pci-core.c, for example), and several more are coming. Those reset implementations have some small subtleties (e.g., ordering of initialization of SDHCI vs. CQHCI might leave us resetting with a NULL ->cqe_private), and are often identical across different host drivers. We also don't want to force a dependency between SDHCI and CQHCI, or vice versa; non-SDHCI drivers use CQHCI, and SDHCI drivers might support command queueing through some other means. So, implement a small helper, to avoid repeating the same mistakes in different drivers. Simply stick it in a header, because it's so small it doesn't deserve its own module right now, and inlining to each driver is pretty reasonable. This is marked for -stable, as it is an important prerequisite patch for several SDHCI controller bugfixes that follow. Cc: Signed-off-by: Brian Norris Reviewed-by: Florian Fainelli Acked-by: Adrian Hunter --- Changes in v3: - New in v3 (replacing a simple 'cqe_private == NULL' patch in v2) drivers/mmc/host/sdhci-cqhci.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 drivers/mmc/host/sdhci-cqhci.h diff --git a/drivers/mmc/host/sdhci-cqhci.h b/drivers/mmc/host/sdhci-cqhci.h new file mode 100644 index 000000000000..270ab1f1de3c --- /dev/null +++ b/drivers/mmc/host/sdhci-cqhci.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright 2022 The Chromium OS Authors + * + * Support that applies to the combination of SDHCI and CQHCI, while not + * expressing a dependency between the two modules. + */ + +#ifndef __MMC_HOST_SDHCI_CQHCI_H__ +#define __MMC_HOST_SDHCI_CQHCI_H__ + +#include "cqhci.h" +#include "sdhci.h" + +static inline void sdhci_and_cqhci_reset(struct sdhci_host *host, u8 mask) +{ + if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) && + host->mmc->cqe_private) + cqhci_deactivate(host->mmc); + + sdhci_reset(host, mask); +} + + +#endif /* __MMC_HOST_SDHCI_CQHCI_H__ */ From patchwork Mon Oct 24 17:54:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp615239wru; Mon, 24 Oct 2022 12:25:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5cj4xwPSrqzpvd5pTPcmAsbe9iH3gEM8pWJHjKMpDqwwrI4NyUHEPvten2bSNqAS3AWuoa X-Received: by 2002:a17:907:7805:b0:780:24fd:c4e8 with SMTP id la5-20020a170907780500b0078024fdc4e8mr29368409ejc.78.1666639554308; Mon, 24 Oct 2022 12:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639554; cv=none; d=google.com; s=arc-20160816; b=yL7i2M12OBUZVuuRY6qXnq4NAsEKFIlTEpaSzGcdsZ1maDPtE3WTHEKpHUeVBE654/ C1Amme7OLonDWu6fJIddzSABpMeUT6SAdBNKr6xtLtjW2gm+wdIbszsvu3+M/4X6oPFw Gb4I4Rx6DsLWl46KVCUYeJSRELQYnrfUeTbp2CYpY9j5G+T0GxHzAolAl9zpqMsQ0n4C Bo3N/36xvBCSVK4t8Gvpn6SrvKlIA973stLnOLLEXL0kNiSR9/uytqCNWTg+ggLnB/cs zlmteIj3Mm0wVLX2fT18GwyOhx42JYAuyBkd4w4eGWyYSI3oPB76evmcGSrZoJANKPpG 1c6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kj33p7JdC03bi8muflplwrkkTeKEhU1qK5ms8K2qnYw=; b=cAg/dHHQnxksobA6Chpuvtn10X6fSJms6WJUH6HDBZOfy0lcXoFPc3q5uoF3txKi+1 ZbuusIx/l8P7U2Vq4e9t8gZ2dSxkXB6UpGorpilQuozdfGqsCr4+3A0ckLOal+apMPSq UMeR46ppXehayiJzCMpfpZ9YaB+iF38jsUtC0qZQx6ww61+ynJ9kE6ghmEKHghMwnu7p bmYhhD3vU9alsEz959ceO9Thr67fzX6mi4CDT0L2bxE81Yjid7NjXc701Y9X8WiaOQUe einoyDoa6SfabE/dfN0QjW2AkYy9QOYmNyQ1AZEuae94dYG89S4dhAdRauCblq1Ylu82 3h2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nzykeBNF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn7-20020a1709070d0700b007833cbbb747si660173ejc.578.2022.10.24.12.25.27; Mon, 24 Oct 2022 12:25:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nzykeBNF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232386AbiJXTXY (ORCPT + 99 others); Mon, 24 Oct 2022 15:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232171AbiJXTVv (ORCPT ); Mon, 24 Oct 2022 15:21:51 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1650C2D75B for ; Mon, 24 Oct 2022 10:57:14 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d10so9605406pfh.6 for ; Mon, 24 Oct 2022 10:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kj33p7JdC03bi8muflplwrkkTeKEhU1qK5ms8K2qnYw=; b=nzykeBNFH40raHYAmGXOty01g/6nzbiDvq+zDWKIdNwOAPn5f8q4jxQnDVsAG1oDcC AhM8H5Av+nJ9E6ng/FNVrDq75WbJDwmUEvLj2Kg814cjo2iUn/ASUE04gAbuSFX1lRDy BCKNYIqneKZWIYFdZOXNRu+y0xg7hgX7j7WGY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kj33p7JdC03bi8muflplwrkkTeKEhU1qK5ms8K2qnYw=; b=bDCl2Lx2tGwDWSGt4BjSX9Bggi90kHK5YWQGVj6Xdp3/CFQUGsutaeJ6pzmRT5j7oj N+Xuq/ZiXdSQBXGjZRvYtXCglocpAp0rfnh3Dr/6E3xqZ6kHoaW4U80Q1Yr1JcCIACK+ ze9d/Mxqo+wSPJWbrKyYxYu9UsL/KGEYqth9+HEt4TOlhV9KaLaE5JLJAazwfrE/CNr7 POU3ZL6LT9MDdymtMO+eJuMUCezD+GqdwRjztZ96TBHH7Ip4L55xyLIUyF1gwlFN2NsB IW7oJnQRITHNrFisDXOVzePTtrc0MwMQwnmWgJUfhWPPMKcv9SXhp+xC4ldSxsqJn6vI lHKw== X-Gm-Message-State: ACrzQf3wcYCWipNVZb8XJ1tt4NkFa80ipeVDxou/Gwcz5mzJDImpZIUe y5cXEZHP1ilTnO/9wxTkMlLd+A== X-Received: by 2002:a05:6a00:e1b:b0:537:7c74:c405 with SMTP id bq27-20020a056a000e1b00b005377c74c405mr34703121pfb.43.1666634176496; Mon, 24 Oct 2022 10:56:16 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:808b:e2f6:edcf:ccb0]) by smtp.gmail.com with UTF8SMTPSA id a1-20020a170902ecc100b0016cf3f124e1sm30195plh.234.2022.10.24.10.56.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 10:56:15 -0700 (PDT) From: Brian Norris To: Ulf Hansson Cc: Shawn Lin , linux-mmc@vger.kernel.org, Al Cooper , Bjorn Andersson , Sowjanya Komatineni , Broadcom internal kernel review list , Sascha Hauer , Konrad Dybcio , Florian Fainelli , NXP Linux Team , Thierry Reding , Fabio Estevam , Michal Simek , linux-kernel@vger.kernel.org, Shawn Guo , Adrian Hunter , Pengutronix Kernel Team , linux-arm-msm@vger.kernel.org, Haibo Chen , Andy Gross , linux-arm-kernel@lists.infradead.org, Faiz Abbas , Jonathan Hunter , Brian Norris , stable@vger.kernel.org, Guenter Roeck Subject: [PATCH v3 2/7] mmc: sdhci-of-arasan: Fix SDHCI_RESET_ALL for CQHCI Date: Mon, 24 Oct 2022 10:54:56 -0700 Message-Id: <20221024105229.v3.2.I29f6a2189e84e35ad89c1833793dca9e36c64297@changeid> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221024175501.2265400-1-briannorris@chromium.org> References: <20221024175501.2265400-1-briannorris@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747598237554582292?= X-GMAIL-MSGID: =?utf-8?q?1747598237554582292?= SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't tracking that properly in software. When out of sync, we may trigger various timeouts. It's not typical to perform resets while CQE is enabled, but one particular case I hit commonly enough: mmc_suspend() -> mmc_power_off(). Typically we will eventually deactivate CQE (cqhci_suspend() -> cqhci_deactivate()), but that's not guaranteed -- in particular, if we perform a partial (e.g., interrupted) system suspend. The same bug was already found and fixed for two other drivers, in v5.7 and v5.9: 5cf583f1fb9c mmc: sdhci-msm: Deactivate CQE during SDHC reset df57d73276b8 mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers The latter is especially prescient, saying "other drivers using CQHCI might benefit from a similar change, if they also have CQHCI reset by SDHCI_RESET_ALL." So like these other patches, deactivate CQHCI when resetting the controller. Do this via the new sdhci_and_cqhci_reset() helper. Fixes: 84362d79f436 ("mmc: sdhci-of-arasan: Add CQHCI support for arasan,sdhci-5.1") Cc: Signed-off-by: Brian Norris Reviewed-by: Guenter Roeck Acked-by: Adrian Hunter --- Changes in v3: - Refactor to a "SDHCI and CQHCI" helper -- sdhci_and_cqhci_reset() Changes in v2: - Rely on cqhci_deactivate() to safely handle (ignore) not-yet-initialized CQE support drivers/mmc/host/sdhci-of-arasan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c index 3997cad1f793..cfb891430174 100644 --- a/drivers/mmc/host/sdhci-of-arasan.c +++ b/drivers/mmc/host/sdhci-of-arasan.c @@ -25,6 +25,7 @@ #include #include "cqhci.h" +#include "sdhci-cqhci.h" #include "sdhci-pltfm.h" #define SDHCI_ARASAN_VENDOR_REGISTER 0x78 @@ -366,7 +367,7 @@ static void sdhci_arasan_reset(struct sdhci_host *host, u8 mask) struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host); - sdhci_reset(host, mask); + sdhci_and_cqhci_reset(host, mask); if (sdhci_arasan->quirks & SDHCI_ARASAN_QUIRK_FORCE_CDTEST) { ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); From patchwork Mon Oct 24 17:54:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9989 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp615446wru; Mon, 24 Oct 2022 12:26:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6dQhJ0tsb/pPZDftuNlaOwHFGqPvDNOhdUNUNt0yEwtGXnwsAyrSr+WslvtAjtePp0u1xz X-Received: by 2002:a17:907:2be9:b0:7a1:11a9:1334 with SMTP id gv41-20020a1709072be900b007a111a91334mr957056ejc.131.1666639583501; Mon, 24 Oct 2022 12:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639583; cv=none; d=google.com; s=arc-20160816; b=O7AXvCYcW22yTHeTZSn5Ro2tRHgIMsDqXnaVr5YnBfjFB5x7tnFoZ5q5rG17nxfF1h TSpr2ex2AfcNrUIt1zJQkJISNNWT0vZ9o0bfqutHKWC3S3yk7lur4ZDq/udHn1/rdKuW b5zk6xC2Fs/56ldf3Uo1F9vQGZ5MrJfqAlUHo5puV+eHlzvlzw14PwgqDE0eqZvta4iE xmwkQ2gPFwUZRns3cWMv6mVwQDAcEmPWbgWpU7R/y8vsCM6Czd8rHE8xYHluODXTivkU c5+4dky1J9R618hZrJzlIUgu9WF5JTeJNfNA2wulGV+ZI0eAKw4UqWMjR9WG9AAaT+dQ LyPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PlyFLurvfH7029w8iwxQ1Sku/pg4fNXCW6GH7YT3X1o=; b=lYwVGjDzcM+qhKh5IiD4DcdYq4D/Cc7rwy3GaEil38KbzxVLw5Tx4xn9VgSpjOqu+6 SCRY+H2DtZaJy+ydr7X4tTkmISBJujN1z+v1ZPeuZQts0QzNtzgIZ/KTnUBKpAvb3mjM iFLl7isr3fCK4JC6dfGdUvG22CwNHO8GC99ufDhiwRXdK+az+ZAqsLhzMfnPI1XAfx2R F5UrsSdjM0rxRtup50DeYjKvWHJ43O+su+/ATj6lEIo2ju80hnQJh93uLqLRJBp33WFq WApxvPM8eaHR+woI7FtymDVvt6gG3q6tedL9/Zcph9yOpafNHNCWanSKFvM2Cq+rCSRE UR9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oFFypgAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c13-20020a0564021f8d00b004597fa7ee6csi578412edc.108.2022.10.24.12.25.56; Mon, 24 Oct 2022 12:26:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oFFypgAm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233033AbiJXTX5 (ORCPT + 99 others); Mon, 24 Oct 2022 15:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232246AbiJXTWC (ORCPT ); Mon, 24 Oct 2022 15:22:02 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D0D83AE66 for ; Mon, 24 Oct 2022 10:57:22 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id s196so9308434pgs.3 for ; Mon, 24 Oct 2022 10:57:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PlyFLurvfH7029w8iwxQ1Sku/pg4fNXCW6GH7YT3X1o=; b=oFFypgAmtRSfdYpG2g2vzrpENnpBptPReooSwNKcKMviZOjIzHdqvDt9dal43yElrs pjMh+aBByGRMnMNHeptY6IphflqbfVd2BqYoYNmd7AMSahsxsSPrM47jqwMcKMV4XVBi tKrPXznD/J4GqIn/JRB0IhdbNpRPvrVOg2Pqc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PlyFLurvfH7029w8iwxQ1Sku/pg4fNXCW6GH7YT3X1o=; b=1mjsmbcB5bIEVz0M5zy3aAZZrsn/sjCm70MyJbNBFwcZNJegYmh9wac8uD0ncp1wlF 2lDe5tZ+nTkGKO0p9t9NZDnX83hwJzqVk5gO6hW9PU6hH8BAtYGPQ4hGLTiqLb1UwRlB v5HJWpN686gqWVRadFBG2FQmzKRjtgu9KElpek1I8fLWff4LbjMcAiMgXIMb+96LpGOk rAul+8JW4d7ioyyBUtPCglf8xNu7wesmdtYJlpiKpIRh8jbuVeD9kkP1Bh9L0ufg0Fpf Y8L3Dl0SlusvkXEe5vaKZyoGAwly3M2rYnc7rwfy7fGY6iReqgOdLEfMzBwSh7GlCnlT WN4w== X-Gm-Message-State: ACrzQf0MHvWm8JhXRIXuAlOo5KILskyQnpFqFkVqhPxES0lqT95w6grN FzNtvROVhBEgYjN3UWB50SfGOQ== X-Received: by 2002:a63:f755:0:b0:44b:e438:ef2f with SMTP id f21-20020a63f755000000b0044be438ef2fmr30101590pgk.314.1666634180688; Mon, 24 Oct 2022 10:56:20 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:808b:e2f6:edcf:ccb0]) by smtp.gmail.com with UTF8SMTPSA id w20-20020a170902ca1400b001714e7608fdsm26385pld.256.2022.10.24.10.56.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 10:56:20 -0700 (PDT) From: Brian Norris To: Ulf Hansson Cc: Shawn Lin , linux-mmc@vger.kernel.org, Al Cooper , Bjorn Andersson , Sowjanya Komatineni , Broadcom internal kernel review list , Sascha Hauer , Konrad Dybcio , Florian Fainelli , NXP Linux Team , Thierry Reding , Fabio Estevam , Michal Simek , linux-kernel@vger.kernel.org, Shawn Guo , Adrian Hunter , Pengutronix Kernel Team , linux-arm-msm@vger.kernel.org, Haibo Chen , Andy Gross , linux-arm-kernel@lists.infradead.org, Faiz Abbas , Jonathan Hunter , Brian Norris Subject: [PATCH v3 3/7] mmc: sdhci-brcmstb: Fix SDHCI_RESET_ALL for CQHCI Date: Mon, 24 Oct 2022 10:54:57 -0700 Message-Id: <20221024105229.v3.3.I6a715feab6d01f760455865e968ecf0d85036018@changeid> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221024175501.2265400-1-briannorris@chromium.org> References: <20221024175501.2265400-1-briannorris@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747598267697447593?= X-GMAIL-MSGID: =?utf-8?q?1747598267697447593?= [[ NOTE: this is completely untested by the author, but included solely because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other drivers using CQHCI might benefit from a similar change, if they also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same bug on at least MSM, Arasan, and Intel hardware. ]] SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't tracking that properly in software. When out of sync, we may trigger various timeouts. It's not typical to perform resets while CQE is enabled, but this may occur in some suspend or error recovery scenarios. Include this fix by way of the new sdhci_and_cqhci_reset() helper. Fixes: d46ba2d17f90 ("mmc: sdhci-brcmstb: Add support for Command Queuing (CQE)") Signed-off-by: Brian Norris Reviewed-by: Florian Fainelli Acked-by: Adrian Hunter --- Changes in v3: - Use new SDHCI+CQHCI helper Changes in v2: - Rely on cqhci_deactivate() to handle NULL cqe_private, instead of moving around CQE capability flags drivers/mmc/host/sdhci-brcmstb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index aff36a933ebe..55d8bd232695 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -12,6 +12,7 @@ #include #include +#include "sdhci-cqhci.h" #include "sdhci-pltfm.h" #include "cqhci.h" @@ -55,7 +56,7 @@ static void brcmstb_reset(struct sdhci_host *host, u8 mask) struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); - sdhci_reset(host, mask); + sdhci_and_cqhci_reset(host, mask); /* Reset will clear this, so re-enable it */ if (priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK) From patchwork Mon Oct 24 17:54:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9973 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp614913wru; Mon, 24 Oct 2022 12:25:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5IvSHWzJeWu+7z/O0MA3TFZxs3u6q+/tUtPZ9P6qHM8s6sLZYyHuTe5elIEh4Cj/2+Bj9E X-Received: by 2002:a17:907:86a2:b0:791:910e:cce4 with SMTP id qa34-20020a17090786a200b00791910ecce4mr29520095ejc.36.1666639509220; Mon, 24 Oct 2022 12:25:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639509; cv=none; d=google.com; s=arc-20160816; b=BNDixRnlCjyILL5E59QWYu/4F5d2T7sBYLGMW47XJ6kGwqOwoSgbPwhWlX7GUIwjj+ NUkL/mRN/CU9c41B9/z0CjiZxnu9u6+ChONH1U2ccjCiwhkbZfuz0vBoEROOcZKf5dZF fr4bvTxiwOoI99NvA9u7IOLvR9yxA8QooKaHL/1B/BdozsAsCqJgw6YnrbZKt2I8bbx5 5bdWJdaXGPhj7jLL2zQ8apZsUks0gY6kBLSybzVgKz2RsSrI3B7BaKFCAARHLLIHkUId KMuk83FXFUQRdDH5OMs/z0WKd6ug3dqQDzco/V3ecDjabV2mLnsok7ff8OYZKzTVoMUv NuPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hDRHGSwf7KM6nOlEftMlpWT5HOavgsCjZBMurS4KgKQ=; b=gHzvGrFfTiv6LAdhtpHrFRoFoIH87VgsCluYXhqbk5008BQFciUlDReHEOXk4smvLT yDiCQscktikYEyHLwZxYfQ1riQezxoA7EerQus4mLyJgUyUipwgxMW0JUIUsIKfNVGhA R7oUtH5Wu9uKG/crI+0diPhyOs9ExB9pbxiDeQOLjHoJCuP0eYcORxiTLtZ+WdqJyZvv WfxFa0IbJyBzvIsY67u+2i4YzsV1mh2NM7ZgN9iJlbKD4lynI9gb6lKTDMue/6Ky6bvE MBo7E8cpQ6XB/mzRjNxSiSNHEEc5lR2JbfZzBLjBxb/Rh5ThM7Wxs0MDvxKQHrG9L/fx U/lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="N7qZz/zJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eh19-20020a0564020f9300b004615bea1d62si430564edb.472.2022.10.24.12.24.41; Mon, 24 Oct 2022 12:25:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="N7qZz/zJ"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231241AbiJXTWs (ORCPT + 99 others); Mon, 24 Oct 2022 15:22:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232484AbiJXTVp (ORCPT ); Mon, 24 Oct 2022 15:21:45 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1145357FC for ; Mon, 24 Oct 2022 10:57:09 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id u8-20020a17090a5e4800b002106dcdd4a0so13700706pji.1 for ; Mon, 24 Oct 2022 10:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hDRHGSwf7KM6nOlEftMlpWT5HOavgsCjZBMurS4KgKQ=; b=N7qZz/zJfn8lrPYDgaQNbAKG2AbnWZeyNQLBZ7DHtw0LYdnjsr6ZX1FDH55nDDkMIo UcqYTJ9Nprz+nvahXLqZBr+tO2XbMHIwASvchpoIo1YliHu11CIR9y4k65EolzPxGa4N gtKpf+WRwwqv/Gv/eyY9jWWqok8HVyLx+4LSE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hDRHGSwf7KM6nOlEftMlpWT5HOavgsCjZBMurS4KgKQ=; b=u65xhfkdFZj4YY0k4+vg1tUdABgu88IdQCJbrak7AJJuQZ1zTK9AyP+hWEkXeq9bIP drZJuo8dD6Qg7scliTsdkNKXjKq0BP2wPcWvTxjOv/nkpj8n+Mv3QTyc8TAEs3WYuh8F myLdLC/H7KR7JKtAB24cgpgJDpT41hgMRd8nP+2fHYnwc5apQoFNhLtzc/oN9vW6SyKk HomGl9J7F7/CedQtJ+Fq9svYnkZL77bZGW03ZQKNrfC6X0RBR7ftYFLbNPcpBo3UjJj+ YzPGuuvIyobNRPz4ZMZhhF7XO5aAOjuxis08yvqk07+J/YA986Koz57LQWkPht4jSgbc xuig== X-Gm-Message-State: ACrzQf2ncjZz/nAqz62C+nHlSnGUYFUe6jf3M0vCi5z7l/0rlxmzFZk0 kiYRId+8McSum8Fp7p4hBms/KQ== X-Received: by 2002:a17:90a:c306:b0:211:8e5e:9a66 with SMTP id g6-20020a17090ac30600b002118e5e9a66mr29200392pjt.152.1666634183551; Mon, 24 Oct 2022 10:56:23 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:808b:e2f6:edcf:ccb0]) by smtp.gmail.com with UTF8SMTPSA id mr2-20020a17090b238200b0021301a63e86sm2386229pjb.18.2022.10.24.10.56.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 10:56:23 -0700 (PDT) From: Brian Norris To: Ulf Hansson Cc: Shawn Lin , linux-mmc@vger.kernel.org, Al Cooper , Bjorn Andersson , Sowjanya Komatineni , Broadcom internal kernel review list , Sascha Hauer , Konrad Dybcio , Florian Fainelli , NXP Linux Team , Thierry Reding , Fabio Estevam , Michal Simek , linux-kernel@vger.kernel.org, Shawn Guo , Adrian Hunter , Pengutronix Kernel Team , linux-arm-msm@vger.kernel.org, Haibo Chen , Andy Gross , linux-arm-kernel@lists.infradead.org, Faiz Abbas , Jonathan Hunter , Brian Norris Subject: [PATCH v3 4/7] mms: sdhci-esdhc-imx: Fix SDHCI_RESET_ALL for CQHCI Date: Mon, 24 Oct 2022 10:54:58 -0700 Message-Id: <20221024105229.v3.4.I7d01f9ad11bacdc9213dee61b7918982aea39115@changeid> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221024175501.2265400-1-briannorris@chromium.org> References: <20221024175501.2265400-1-briannorris@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747598190142791387?= X-GMAIL-MSGID: =?utf-8?q?1747598190142791387?= [[ NOTE: this is completely untested by the author, but included solely because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other drivers using CQHCI might benefit from a similar change, if they also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same bug on at least MSM, Arasan, and Intel hardware. ]] SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't tracking that properly in software. When out of sync, we may trigger various timeouts. It's not typical to perform resets while CQE is enabled, but this may occur in some suspend or error recovery scenarios. Include this fix by way of the new sdhci_and_cqhci_reset() helper. Fixes: bb6e358169bf ("mmc: sdhci-esdhc-imx: add CMDQ support") Signed-off-by: Brian Norris Reviewed-by: Haibo Chen Acked-by: Adrian Hunter --- Changes in v3: - Use new SDHCI+CQHCI helper - Add Reviewed-by Changes in v2: - Drop unnecessary ESDHC_FLAG_CQHCI check drivers/mmc/host/sdhci-esdhc-imx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 55981b0f0b10..b297c3c360eb 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -25,6 +25,7 @@ #include #include #include +#include "sdhci-cqhci.h" #include "sdhci-pltfm.h" #include "sdhci-esdhc.h" #include "cqhci.h" @@ -1288,7 +1289,7 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing) static void esdhc_reset(struct sdhci_host *host, u8 mask) { - sdhci_reset(host, mask); + sdhci_and_cqhci_reset(host, mask); sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); From patchwork Mon Oct 24 17:54:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10059 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp623418wru; Mon, 24 Oct 2022 12:47:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM79GJfWoWzGIMZlwEtMAO2deRPrwJxNgOLTuWywS7Da4/IBPxZ3KJM92BzPSlvcHihlBiTc X-Received: by 2002:a63:8641:0:b0:46e:c693:2e57 with SMTP id x62-20020a638641000000b0046ec6932e57mr14203277pgd.341.1666640875280; Mon, 24 Oct 2022 12:47:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666640875; cv=none; d=google.com; s=arc-20160816; b=L6I1o56hTSrmSuHySqycJghHiX2DdSFSTeWEl7auBysigIcMGFVKX3yirQt2S2lHHR MoUBxVPreYcYxw/4NoUgwqosg57WIirlGIvOOK0RU6ZsAux5LMJEnuREsMj1qxel92gN /yhPiFhc1B+7Rs62pf2SWj6WNT0S2vD9LHycS1LJEHr+MseMKhToRJX9J0vqkNuNaAVR R3rbCvOyJp54dNwdyJDECAzzpzxHzQOVBYosdIk6Bo/M+9ZyQ6BAJGXtli1cNXYYwJUa yi0uLivn1EEXlhk3u1IRpRhfZt9jgkTxR+fzMin9MQ+KaS0Cw4JwrfyM3/KOuHuHxGfX hXeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FWp3gLeR18gDUBWllj7p7A295JT2g0xhsqKP4jhnM/M=; b=RGMN0ggS7CHueJVwTCE0aFeqQt2+DG8IC6tBa1kh9nFgyYN4sSuKsjphwU31OzmTVR +XxCaHjgs4xEn3teilsCSAJeKXwYDdoE/wXQlLZBgJGPhR2A0oYlv2It1FhM3L304UJ8 VyVmKUi2DeBRCHBevDWyTV9VzWkPob/2lJvQ9ViK2t2DANBFtVcvcprvXLia06CjlfRd RyzhyDl3WKjyR4p03ddukKj9aOhwIAlXTRelxCQm+BkT+nVdAOV8wv8m2RJOatLh4IgW t6DP5jrFVKMw+WeqoMacPuDk92U5XuqmMC37ZDJ9LHWi5rw6H0qGkm21ilF4qJ9MHqdJ ABGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="A/JR5Rj+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020a170902e5c200b00182631bdf78si494449plf.222.2022.10.24.12.47.42; Mon, 24 Oct 2022 12:47:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="A/JR5Rj+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232983AbiJXTp3 (ORCPT + 99 others); Mon, 24 Oct 2022 15:45:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233235AbiJXTma (ORCPT ); Mon, 24 Oct 2022 15:42:30 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35BF91162F0 for ; Mon, 24 Oct 2022 11:11:39 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id y72so11690797oia.3 for ; Mon, 24 Oct 2022 11:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FWp3gLeR18gDUBWllj7p7A295JT2g0xhsqKP4jhnM/M=; b=A/JR5Rj+tGKKJmsT6QxHlUP2Ul2+BXbXtagTpnwvYnwmKxL5N2i2722xv3L4gmoVxL enNvMIwKR66QuY/eIput2Ma8qJZNhgvTyyEjn1HJFLvoIFpN3488+3tfqob8hEH8ryhu aV+VtyqiHt+tNyB8m0QKqS8JkPsGe2ZQsAOq4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FWp3gLeR18gDUBWllj7p7A295JT2g0xhsqKP4jhnM/M=; b=xLadiTgyAvpMX3wMFol0KYxyQqWNkvrVxj6tNJG5Db04xQvorcC9oiUq+wcnCCZR5a agny63Ci9c2qQsFYOTz0T/4YSNkzZyWZTUUDycSEwM2zAYDsbZQknkAuMe8TrOXzpxN4 U/x5OgdhsPe2Sv59kK696QygRLLaGxr5eSz4bbUPADbYh+pcMX0LfK1sTkakuCUx+L+r PWIbQAVJvawQj/4fHeZAC/N+7pw7dmDirUO/VOORzU70CH6nAgJJnKMP+AF2Y8DeZlP6 iCAm1yNXnLFHD9E4OvV31A99cjA4LMYX0wQTj4F7MyeKSuethItUXsts28bL6YSuVyU/ oZFQ== X-Gm-Message-State: ACrzQf10o7Nyeef5fJjqQB/a0qZPjLaBybPfOPYxXmucaT/3JdWQIXGA mJ6fIJApfElxNDX6NV0mU+2tz7Xd2vH/Ow== X-Received: by 2002:a17:90b:954:b0:213:c01:b8ce with SMTP id dw20-20020a17090b095400b002130c01b8cemr7841306pjb.168.1666634186333; Mon, 24 Oct 2022 10:56:26 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:808b:e2f6:edcf:ccb0]) by smtp.gmail.com with UTF8SMTPSA id g29-20020aa79ddd000000b0056bdb5197f4sm103804pfq.35.2022.10.24.10.56.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 10:56:25 -0700 (PDT) From: Brian Norris To: Ulf Hansson Cc: Shawn Lin , linux-mmc@vger.kernel.org, Al Cooper , Bjorn Andersson , Sowjanya Komatineni , Broadcom internal kernel review list , Sascha Hauer , Konrad Dybcio , Florian Fainelli , NXP Linux Team , Thierry Reding , Fabio Estevam , Michal Simek , linux-kernel@vger.kernel.org, Shawn Guo , Adrian Hunter , Pengutronix Kernel Team , linux-arm-msm@vger.kernel.org, Haibo Chen , Andy Gross , linux-arm-kernel@lists.infradead.org, Faiz Abbas , Jonathan Hunter , Brian Norris Subject: [PATCH v3 5/7] mmc: sdhci-tegra: Fix SDHCI_RESET_ALL for CQHCI Date: Mon, 24 Oct 2022 10:54:59 -0700 Message-Id: <20221024105229.v3.5.I418c9eaaf754880fcd2698113e8c3ef821a944d7@changeid> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221024175501.2265400-1-briannorris@chromium.org> References: <20221024175501.2265400-1-briannorris@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747599622320044795?= X-GMAIL-MSGID: =?utf-8?q?1747599622320044795?= [[ NOTE: this is completely untested by the author, but included solely because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other drivers using CQHCI might benefit from a similar change, if they also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same bug on at least MSM, Arasan, and Intel hardware. ]] SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't tracking that properly in software. When out of sync, we may trigger various timeouts. It's not typical to perform resets while CQE is enabled, but this may occur in some suspend or error recovery scenarios. Include this fix by way of the new sdhci_and_cqhci_reset() helper. Fixes: 3c4019f97978 ("mmc: tegra: HW Command Queue Support for Tegra SDMMC") Signed-off-by: Brian Norris Acked-by: Adrian Hunter --- Changes in v3: - Use new SDHCI+CQHCI helper Changes in v2: - Drop unnecessary 'enable_hwcq' check drivers/mmc/host/sdhci-tegra.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index 413925bce0ca..c71000a07656 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -28,6 +28,7 @@ #include +#include "sdhci-cqhci.h" #include "sdhci-pltfm.h" #include "cqhci.h" @@ -367,7 +368,7 @@ static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask) const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data; u32 misc_ctrl, clk_ctrl, pad_ctrl; - sdhci_reset(host, mask); + sdhci_and_cqhci_reset(host, mask); if (!(mask & SDHCI_RESET_ALL)) return; From patchwork Mon Oct 24 17:55:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp615272wru; Mon, 24 Oct 2022 12:25:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4tg3HddYkA+slEga0s9SvPgP0uj6Cgd9DWs2mpC0B12GiLxjxnFC6au7TaesZG3YMTTCRs X-Received: by 2002:a17:907:701:b0:780:2c44:e4dd with SMTP id xb1-20020a170907070100b007802c44e4ddmr29806738ejb.589.1666639559200; Mon, 24 Oct 2022 12:25:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639559; cv=none; d=google.com; s=arc-20160816; b=Npc0mvkgUoAyGxCVUVG/ZR73erQEnYklY2oMUkqNrVwDm1Pn2LO8Z/lEuNKY4trF+o 4qXSw4xpaMEkOceNMjtA42iCBDlHUQbW+RtciFL+Lj/3wo6uK3b0uwAslU4MGvcZkNBt aVW6zURSB/gKx+7B2XBtgTQNtSB4+28JOlNj4LY3IyhppI7xl0Wpgoyt+dvWy5Euzzwy qfcxXpfqCaW0JtGSG6RQwL0ht+/SYq8endFbGtCNtm8NYBjFze5VBKtrW9aj/+Dr7LTT CvQXzfsRq7z9tFHDhIUHT+KmMC2NBJsEsyCYudNRYis8awsiS3z7jB+4HOSY0JhWRqbR JPDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N4yDlVPTic37KZH9AxC8wwe58VczX65vPPEZffD7EQE=; b=rRMjd2XxoSnvwTxIjCI5WxHK9cGKz+ac0VXxwrfs64MoikMKcO+Ryzo+kWPraqblXN 5M1Hp6NaYkkQHS5ZsiXcTCG8bkJjWK77vrMxtjCF52kM2CfxYa8wA4OlQry69e4FzSvd NcXvunX2TQ6ow0k7xYZRJdF/1c2ERURerjaurf53M+kDE/oIRbj7M1tRKFAjUnBHWFSg U+xiDw80Rg59/4bA1GXlc5rrAqTTk5Pi45fN0q9Qax87n4DyYlaMARlOVoht3O5TPp4L hUgGy3Mw8z2cy+I5VOZGCa02I8SqlB7p84Lgz4OEL3nQWtpoNICwB3flZj0Ptk22SMqn GDbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=M3glaN3K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l21-20020a056402345500b0045ca3839229si517157edc.274.2022.10.24.12.25.33; Mon, 24 Oct 2022 12:25:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=M3glaN3K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231288AbiJXTX2 (ORCPT + 99 others); Mon, 24 Oct 2022 15:23:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232509AbiJXTVz (ORCPT ); Mon, 24 Oct 2022 15:21:55 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEA4C74E1B for ; Mon, 24 Oct 2022 10:57:23 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id m14-20020a17090a3f8e00b00212dab39bcdso7194132pjc.0 for ; Mon, 24 Oct 2022 10:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=N4yDlVPTic37KZH9AxC8wwe58VczX65vPPEZffD7EQE=; b=M3glaN3KH7v0Fj2TVX/4rEpKIqio36DUJjjhUWq3EPd2n2k/0Wvh02RurfIdEzV+9M eqcD/iUxn2JpiQDZOvX04A+jwTMsRrIANx1MRiQUV29n9kQ7J2AobjK/cvv/YRt4F8TJ Q0m4E4bXsFTCCwhixA4Dgy+lEpaZb3laJvH4w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N4yDlVPTic37KZH9AxC8wwe58VczX65vPPEZffD7EQE=; b=MIJj3fAJ03KEQjvUh7Us6kB9iNxyNIt9O24OnzWXGSCDUvBfKUDW7kGZlW9zaZDIqd ARNR7JDsQQhFNGpHEVnd/VRz4rLO+xOuE4TIwsrHQYJUQH23AJxR4Tokx8Xv7Nf/jIi+ TWgnLlQosrpHCzsNMn+EYZKCQ+5SzR+GmwHiSccCHLjFX7UbPK7yH49LkWmm3Yc0uD8Z O/DuunoDN+L4YOsgPSk3jYlMuPBcuosSNj67CvAQFZaLfyqiZkXBT3ONXmwb7MLnSOVo U0HrOxIvmL8hHH456Ge0aVVUgFPRiQ1HPQ9WGLZV1PPawFReZG5uFj2MSZeDBJjVGJjT ygzg== X-Gm-Message-State: ACrzQf2ue06nqp73iG64lRQPMtAIINVkijzIVtYA5sq92QIUW7AOwsrF Un/bQGHrHSS71STD+/LILZP/4w== X-Received: by 2002:a17:90b:3d8e:b0:213:c01:b8bb with SMTP id pq14-20020a17090b3d8e00b002130c01b8bbmr7616310pjb.68.1666634189383; Mon, 24 Oct 2022 10:56:29 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:808b:e2f6:edcf:ccb0]) by smtp.gmail.com with UTF8SMTPSA id r24-20020aa79638000000b0056bab544100sm80142pfg.197.2022.10.24.10.56.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 10:56:28 -0700 (PDT) From: Brian Norris To: Ulf Hansson Cc: Shawn Lin , linux-mmc@vger.kernel.org, Al Cooper , Bjorn Andersson , Sowjanya Komatineni , Broadcom internal kernel review list , Sascha Hauer , Konrad Dybcio , Florian Fainelli , NXP Linux Team , Thierry Reding , Fabio Estevam , Michal Simek , linux-kernel@vger.kernel.org, Shawn Guo , Adrian Hunter , Pengutronix Kernel Team , linux-arm-msm@vger.kernel.org, Haibo Chen , Andy Gross , linux-arm-kernel@lists.infradead.org, Faiz Abbas , Jonathan Hunter , Brian Norris Subject: [PATCH v3 6/7] mmc: sdhci_am654: Fix SDHCI_RESET_ALL for CQHCI Date: Mon, 24 Oct 2022 10:55:00 -0700 Message-Id: <20221024105229.v3.6.I35ca9d6220ba48304438b992a76647ca8e5b126f@changeid> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221024175501.2265400-1-briannorris@chromium.org> References: <20221024175501.2265400-1-briannorris@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747598242591524251?= X-GMAIL-MSGID: =?utf-8?q?1747598242591524251?= [[ NOTE: this is completely untested by the author, but included solely because, as noted in commit df57d73276b8 ("mmc: sdhci-pci: Fix SDHCI_RESET_ALL for CQHCI for Intel GLK-based controllers"), "other drivers using CQHCI might benefit from a similar change, if they also have CQHCI reset by SDHCI_RESET_ALL." We've now seen the same bug on at least MSM, Arasan, and Intel hardware. ]] SDHCI_RESET_ALL resets will reset the hardware CQE state, but we aren't tracking that properly in software. When out of sync, we may trigger various timeouts. It's not typical to perform resets while CQE is enabled, but this may occur in some suspend or error recovery scenarios. Include this fix by way of the new sdhci_and_cqhci_reset() helper. Fixes: f545702b74f9 ("mmc: sdhci_am654: Add Support for Command Queuing Engine to J721E") Signed-off-by: Brian Norris --- Changes in v3: - Use new SDHCI+CQHCI helper drivers/mmc/host/sdhci_am654.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci_am654.c b/drivers/mmc/host/sdhci_am654.c index 8f1023480e12..6a282c7a221e 100644 --- a/drivers/mmc/host/sdhci_am654.c +++ b/drivers/mmc/host/sdhci_am654.c @@ -15,6 +15,7 @@ #include #include "cqhci.h" +#include "sdhci-cqhci.h" #include "sdhci-pltfm.h" /* CTL_CFG Registers */ @@ -378,7 +379,7 @@ static void sdhci_am654_reset(struct sdhci_host *host, u8 mask) struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host); - sdhci_reset(host, mask); + sdhci_and_cqhci_reset(host, mask); if (sdhci_am654->quirks & SDHCI_AM654_QUIRK_FORCE_CDTEST) { ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); From patchwork Mon Oct 24 17:55:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp615288wru; Mon, 24 Oct 2022 12:26:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5HMfaYlBuohG2gromttFl0NiuGbG3RLZLiqlbkWQM3A8aKWuIE3xfABveBqhhkf4wg5ODk X-Received: by 2002:a17:907:25c9:b0:77b:a343:bd62 with SMTP id ae9-20020a17090725c900b0077ba343bd62mr29408079ejc.660.1666639561904; Mon, 24 Oct 2022 12:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666639561; cv=none; d=google.com; s=arc-20160816; b=FTAyzKiL58CDtDBldXrLTCVpADkWxCjnYXGkQ22GigMQ7ZXnHClNnMODO/p06SObci YiB6X4WM9W9OpOQhd00xSwaeWv5rHBxR9VC5/+W1uPn1RDrXp/oovgr+9r8GQHVrUrsn xFOD86k9rdUce9JtnJMxsRibNvrcRijLH4c03P21HrTku32gVz91+yGr6896kXvNpmQI d4ITdZA7dzfL5+Jyz5x/99qSDMmzeO2/I2ozGr9iMa7YCKV39ke+TvG8TCF5sCNApw9Z rLPeYtdCdUQeDmDeEPFQjh37TcNPS8Xa1Z6v6wfE4zW0u01oByehVtYAiH+gRmQ/EfkZ i4MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kBU82kTAb6ejCzCPdRzJommk6OJkr5XyNm4aFLMb1Lo=; b=nM51WPW53qAykY+w8CxduCui8g9HsjhrtTtTaMsOaVTQ+62bhHsbid7qTYHX07l3si BOmTtnYQdYhNGlBI5TTh48eUS4RkRUZTKywqv8okNvpzhrSGtsAZKunkRY+ghOOy/6pH GpZ4zRIV5GajKktRXTHskUtqn3ZVmTKBcQUQc2dNNyLuiEmEqZ+HszCnC/BaSaEy+CgX ianlZDOOeyA7Efftz39OQKsVEhR24aOe8E3SrWAfCjKyLmfMy9S995eLEBRwAOeeFRGg jI3WDad7LP+lOGXqo+Sq7jS7Wb8Ch8MSgfGIiCMIlZ9015D1P4xbiuRSjXfCKBzd4FLR d9vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="RnX9z/Ey"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e5-20020a17090658c500b0078e18bd3073si500782ejs.820.2022.10.24.12.25.35; Mon, 24 Oct 2022 12:26:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="RnX9z/Ey"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230413AbiJXTXc (ORCPT + 99 others); Mon, 24 Oct 2022 15:23:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232226AbiJXTVy (ORCPT ); Mon, 24 Oct 2022 15:21:54 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99591E718 for ; Mon, 24 Oct 2022 10:57:24 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id y1so9613490pfr.3 for ; Mon, 24 Oct 2022 10:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kBU82kTAb6ejCzCPdRzJommk6OJkr5XyNm4aFLMb1Lo=; b=RnX9z/EyXFWaUQ4+NHwDXdpAWxW+FR9R8nm39w0AaYU9kdznNu4IHmM6GSKF4cRcV4 aRfuhZxa9CM2GIlk54VdFm5ss32J0pIw9JiN4zYfVZ12g2Llv4W2LoC94v4PMZ40bAzx 3kA73t9lBnjmWm9QMfq36+K1fqNixXiAfEkTE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kBU82kTAb6ejCzCPdRzJommk6OJkr5XyNm4aFLMb1Lo=; b=7kWrDHkwhHmSBPGfoefn4wAhTWtRaolAg+CY4uHrkdIUAuXL2VU+aUULLktzmL9jqS rmn2oT9U3WgeTrH4XaUJizoAHDlL4HxNCKMFJuq4PPMOmjyaQwVXckfTo2OCQxP5W3ZQ cAnwXZ/29h84K/99JXNaZmafK+VTIgLO3dIAPL2U1BiqsQl1P4DuEQ0WFkTt5mIBLPYW zIiCO62y3E1iZAdMgQmvUbdj1CrVic9u1KAPLBdB2XBuGH7rLY84b9uLVanWDWkfhnFB lgpEUDj5wUl6YaUgLJmpmgd8gM5dFcDKkbeszNDQcuJUfw37miSmLYaaWuuhDYWnYDAO KWDA== X-Gm-Message-State: ACrzQf3yLn7EcyYOq5hPtRJ623Vs1vPKfIwydNjkQnoNFvmPJbcygmqn fP7ixJ4dTWobX8D3VSTdeSM65g== X-Received: by 2002:a62:1a97:0:b0:562:5587:12d6 with SMTP id a145-20020a621a97000000b00562558712d6mr34124134pfa.37.1666634192416; Mon, 24 Oct 2022 10:56:32 -0700 (PDT) Received: from localhost ([2620:15c:9d:2:808b:e2f6:edcf:ccb0]) by smtp.gmail.com with UTF8SMTPSA id b1-20020a1709027e0100b00176a6ba5969sm39531plm.98.2022.10.24.10.56.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Oct 2022 10:56:32 -0700 (PDT) From: Brian Norris To: Ulf Hansson Cc: Shawn Lin , linux-mmc@vger.kernel.org, Al Cooper , Bjorn Andersson , Sowjanya Komatineni , Broadcom internal kernel review list , Sascha Hauer , Konrad Dybcio , Florian Fainelli , NXP Linux Team , Thierry Reding , Fabio Estevam , Michal Simek , linux-kernel@vger.kernel.org, Shawn Guo , Adrian Hunter , Pengutronix Kernel Team , linux-arm-msm@vger.kernel.org, Haibo Chen , Andy Gross , linux-arm-kernel@lists.infradead.org, Faiz Abbas , Jonathan Hunter , Brian Norris Subject: [PATCH v3 7/7] mmc: sdhci-*: Convert drivers to new sdhci_and_cqhci_reset() Date: Mon, 24 Oct 2022 10:55:01 -0700 Message-Id: <20221024105229.v3.7.Ia91f031f5f770af7bd2ff3e28b398f277606d970@changeid> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221024175501.2265400-1-briannorris@chromium.org> References: <20221024175501.2265400-1-briannorris@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747598245443155023?= X-GMAIL-MSGID: =?utf-8?q?1747598245443155023?= An earlier patch ("mmc: cqhci: Provide helper for resetting both SDHCI and CQHCI") does these operations for us. I keep these as a separate patch, since the earlier patch is a prerequisite to some important bugfixes that need to be backported via linux-stable. Signed-off-by: Brian Norris Acked-by: Adrian Hunter --- Changes in v3: - Rewrite to new helper, patch sdhci-msm too Changes in v2: - Factor out ->cqe_private helpers drivers/mmc/host/sdhci-msm.c | 10 ++-------- drivers/mmc/host/sdhci-pci-core.c | 11 ++--------- drivers/mmc/host/sdhci-pci-gli.c | 11 ++--------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 3a091a387ecb..03f76384ab3f 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -19,6 +19,7 @@ #include #include +#include "sdhci-cqhci.h" #include "sdhci-pltfm.h" #include "cqhci.h" @@ -2304,13 +2305,6 @@ static void sdhci_msm_set_regulator_caps(struct sdhci_msm_host *msm_host) pr_debug("%s: supported caps: 0x%08x\n", mmc_hostname(mmc), caps); } -static void sdhci_msm_reset(struct sdhci_host *host, u8 mask) -{ - if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL)) - cqhci_deactivate(host->mmc); - sdhci_reset(host, mask); -} - static int sdhci_msm_register_vreg(struct sdhci_msm_host *msm_host) { int ret; @@ -2450,7 +2444,7 @@ static const struct of_device_id sdhci_msm_dt_match[] = { MODULE_DEVICE_TABLE(of, sdhci_msm_dt_match); static const struct sdhci_ops sdhci_msm_ops = { - .reset = sdhci_msm_reset, + .reset = sdhci_and_cqhci_reset, .set_clock = sdhci_msm_set_clock, .get_min_clock = sdhci_msm_get_min_clock, .get_max_clock = sdhci_msm_get_max_clock, diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 169b84761041..cc039155b5c7 100644 --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c @@ -38,6 +38,7 @@ #include "cqhci.h" #include "sdhci.h" +#include "sdhci-cqhci.h" #include "sdhci-pci.h" static void sdhci_pci_hw_reset(struct sdhci_host *host); @@ -234,14 +235,6 @@ static void sdhci_pci_dumpregs(struct mmc_host *mmc) sdhci_dumpregs(mmc_priv(mmc)); } -static void sdhci_cqhci_reset(struct sdhci_host *host, u8 mask) -{ - if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) && - host->mmc->cqe_private) - cqhci_deactivate(host->mmc); - sdhci_reset(host, mask); -} - /*****************************************************************************\ * * * Hardware specific quirk handling * @@ -703,7 +696,7 @@ static const struct sdhci_ops sdhci_intel_glk_ops = { .set_power = sdhci_intel_set_power, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width, - .reset = sdhci_cqhci_reset, + .reset = sdhci_and_cqhci_reset, .set_uhs_signaling = sdhci_intel_set_uhs_signaling, .hw_reset = sdhci_pci_hw_reset, .irq = sdhci_cqhci_irq, diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c index 4d509f656188..633a8ee8f8c5 100644 --- a/drivers/mmc/host/sdhci-pci-gli.c +++ b/drivers/mmc/host/sdhci-pci-gli.c @@ -15,6 +15,7 @@ #include #include #include "sdhci.h" +#include "sdhci-cqhci.h" #include "sdhci-pci.h" #include "cqhci.h" @@ -922,14 +923,6 @@ static int gl9763e_add_host(struct sdhci_pci_slot *slot) return ret; } -static void sdhci_gl9763e_reset(struct sdhci_host *host, u8 mask) -{ - if ((host->mmc->caps2 & MMC_CAP2_CQE) && (mask & SDHCI_RESET_ALL) && - host->mmc->cqe_private) - cqhci_deactivate(host->mmc); - sdhci_reset(host, mask); -} - static void gli_set_gl9763e(struct sdhci_pci_slot *slot) { struct pci_dev *pdev = slot->chip->pdev; @@ -1136,7 +1129,7 @@ static const struct sdhci_ops sdhci_gl9763e_ops = { .set_clock = sdhci_set_clock, .enable_dma = sdhci_pci_enable_dma, .set_bus_width = sdhci_set_bus_width, - .reset = sdhci_gl9763e_reset, + .reset = sdhci_and_cqhci_reset, .set_uhs_signaling = sdhci_set_gl9763e_signaling, .voltage_switch = sdhci_gli_voltage_switch, .irq = sdhci_gl9763e_cqhci_irq,