From patchwork Tue Mar 10 15:33:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 229432 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7233C18E5B for ; Tue, 10 Mar 2020 15:33:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E0B120578 for ; Tue, 10 Mar 2020 15:33:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="d3gT/cV7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726315AbgCJPdu (ORCPT ); Tue, 10 Mar 2020 11:33:50 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42145 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726380AbgCJPdu (ORCPT ); Tue, 10 Mar 2020 11:33:50 -0400 Received: by mail-lj1-f195.google.com with SMTP id q19so14618918ljp.9 for ; Tue, 10 Mar 2020 08:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0AS4iD/EqLgDWiA/Em9kdqcmCXIvsjkX4pJSBWor6Nk=; b=d3gT/cV7yOBnJzdr1xBBXMnSAnWAFLDvl7xcHlspC0LOGFpsE72iS1YE9y9y1hng/8 sVSc2dRPuFLTwq5AA5GAA4NjVCYrvI4spfy6YFz9qV6Bkufx+syjQ/YfV09B0Hw8grLz scrjQBrAxtPZsDpMoTyYsktdNQ9Dw5JtGWltX2b05iZX01gTZ84NVjkd0NQd5efjTm5D 0jg3uvhnLV4DfctHeY6npC1Klk3gdFU5zG+79f9ngEBV4TGe8vvilXAi7NKk1XBCnUDA ASRWW/gH6EKTbIsc9nX+RY5S3+YDYQPBYp9pk307/CS9FDalkm0EFzDtt65dofgKd3TV eQqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0AS4iD/EqLgDWiA/Em9kdqcmCXIvsjkX4pJSBWor6Nk=; b=AIPXUbL9PjzeYOaS57pEpId5P5gm8LocJAElXXwIXiy3/0KwEV+CNLHYy+s4MKa0IG LOvy0amj6UYl9SJcG8Y6O2O1Jelqf/CMoaQ6SkgBtWTwq8lT8ABG8bPmX85DAaO+EQIy 4vhpQcSEtoB80vbWIjxDr7IwQgZlQYyjEqxTzMhjhcxp9fFzgxGKMSlun1VnRCt3exSB cVHlYJLw/jViDNTV0gYn30mS4ubPsdwqDjEVofC7nxYYs06XjBd8WZM6fui2zBPSXgp7 Vd4FPpe/bDMJ93zB315c9yf8DcSr51fuxarMAN2v+JWBD/vJkUWllei0m/Hnfm17NfN3 M6PQ== X-Gm-Message-State: ANhLgQ23dswwRxjf+nHnwMU9iVDV+UjFBDxa4q4qr31Scp/ljcj9orxw BzXR+2rtxFiZeTY5LUc1DUL6uw== X-Google-Smtp-Source: ADFU+vvDpOfAMYNpRyOb2/6Q/jBOsY7V3AOt4HZMfeH3/3M38eXJsrZFEEpUT+38SSIr+2kEgT0qCg== X-Received: by 2002:a05:651c:414:: with SMTP id 20mr12234008lja.165.1583854427939; Tue, 10 Mar 2020 08:33:47 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id c22sm17283776lfi.41.2020.03.10.08.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 08:33:46 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Wolfram Sang , Ludovic Barre , Baolin Wang , Linus Walleij , Chaotian Jing , Shawn Lin , mirq-linux@rere.qmqm.pl, Bitan Biswas , Peter Geis , Sowjanya Komatineni , Faiz Abbas , Anders Roxell , Naresh Kamboju , Jon Hunter , stable@vger.kernel.org Subject: [PATCH 1/4] mmc: core: Allow host controllers to require R1B for CMD6 Date: Tue, 10 Mar 2020 16:33:37 +0100 Message-Id: <20200310153340.5593-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310153340.5593-1-ulf.hansson@linaro.org> References: <20200310153340.5593-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org It has turned out that some host controllers can't use R1B for CMD6 and other commands that have R1B associated with them. Therefore invent a new host cap, MMC_CAP_NEED_RSP_BUSY to let them specify this. In __mmc_switch(), let's check the flag and use it to prevent R1B responses from being converted into R1. Note that, this also means that the host are on its own, when it comes to manage the busy timeout. Suggested-by: Sowjanya Komatineni Cc: Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc_ops.c | 6 ++++-- include/linux/mmc/host.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index da425ee2d9bf..e025604e17d4 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -542,9 +542,11 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, * If the max_busy_timeout of the host is specified, make sure it's * enough to fit the used timeout_ms. In case it's not, let's instruct * the host to avoid HW busy detection, by converting to a R1 response - * instead of a R1B. + * instead of a R1B. Note, some hosts requires R1B, which also means + * they are on their own when it comes to deal with the busy timeout. */ - if (host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) + if (!(host->caps & MMC_CAP_NEED_RSP_BUSY) && host->max_busy_timeout && + (timeout_ms > host->max_busy_timeout)) use_r1b_resp = false; cmd.opcode = MMC_SWITCH; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index ba703384bea0..4c5eb3aa8e72 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -333,6 +333,7 @@ struct mmc_host { MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | \ MMC_CAP_UHS_DDR50) #define MMC_CAP_SYNC_RUNTIME_PM (1 << 21) /* Synced runtime PM suspends. */ +#define MMC_CAP_NEED_RSP_BUSY (1 << 22) /* Commands with R1B can't use R1. */ #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */ #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */ #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */ From patchwork Tue Mar 10 15:33:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 229431 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E03CAC10F27 for ; Tue, 10 Mar 2020 15:33:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8541215A4 for ; Tue, 10 Mar 2020 15:33:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cGdazkWP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbgCJPdy (ORCPT ); Tue, 10 Mar 2020 11:33:54 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38249 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726382AbgCJPdy (ORCPT ); Tue, 10 Mar 2020 11:33:54 -0400 Received: by mail-lj1-f196.google.com with SMTP id w1so14648435ljh.5 for ; Tue, 10 Mar 2020 08:33:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tQ91NJmSAV4APRs3KHb2zhKlTLEt52ygW4o1xrxv0Yc=; b=cGdazkWPAfKhtnRnEI2GJzFwuVajaBOS4BQ8hqRTuAgc81uzqNxFrUtq6heoNaKsSU OZWF59ABGCQQRm43Ezooj5qClm98b4lC2ETvbslgeg1zcRIOc1kNWoBa9yfyTCd2hDTH g7XZ7EGusHb2yPm3G2Etafv9bDdPlhF9oBgHUNy3s4ZUJINM88zPILHB7p8b/0UVKxmc IFspfNsRKQ8Agq6u/MYR+v+NA5Mak11gbH6sJsz2yh6pgaq8E7bcQ3eCzFnIaBXBvZjy hlzn9nd296Q6BaA2E20i1LCYf4xImX9mORB10ES0NGu3Fa5+zE4k/uCtDB7PsEWR4gPc SdIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tQ91NJmSAV4APRs3KHb2zhKlTLEt52ygW4o1xrxv0Yc=; b=jf0hG3+iZaqaOGoOHGC/T0KqcJ7YrKtJ2kFB4IJ+LNmNuwKu9kRpiIVUPHMDYU3CJg 4y7NmIvEQibNaN5Lv3BAlFeV8zk0uiWDXfGKLRUm9g8reZHzCMoMKKx4ul8WV5PdLijf S2NaIB5OZROkJtIInJiNUngRiur6Myuy1cZpqxX86extXerrorGjGHuqxy8lgpByRVMN LCKlrIEQYE4Zbb5JCL9nqbctsl4zCYHIhqKPS0SZ+3i2m7hJOYLWERLB7axQgKmS683l o+WFxeAkA4pDU2fRSfrIdaK/afnvJjqnt2VxKX3dEtOa3JGQp9sc6BvKGavt7ytXdWOe kb0Q== X-Gm-Message-State: ANhLgQ3Lxgsj9COUrK8ek6fH9R8bRNhRmN1NeOhU0T4RJDe/HsGsFPoZ Gw2tzBNmwhxR4V6669ajqHOe4A== X-Google-Smtp-Source: ADFU+vsIvho5Opw/cggl/Q7zZCuGRhCYRY6r8tou4/ZEGVeYx3TZIfDapQeyl9aT5hVka/YBRvw9Jw== X-Received: by 2002:a2e:a419:: with SMTP id p25mr3027492ljn.206.1583854432037; Tue, 10 Mar 2020 08:33:52 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id c22sm17283776lfi.41.2020.03.10.08.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 08:33:51 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Wolfram Sang , Ludovic Barre , Baolin Wang , Linus Walleij , Chaotian Jing , Shawn Lin , mirq-linux@rere.qmqm.pl, Bitan Biswas , Peter Geis , Sowjanya Komatineni , Faiz Abbas , Anders Roxell , Naresh Kamboju , Jon Hunter , stable@vger.kernel.org Subject: [PATCH 3/4] mmc: sdhci-omap: Fix busy detection by enabling MMC_CAP_NEED_RSP_BUSY Date: Tue, 10 Mar 2020 16:33:39 +0100 Message-Id: <20200310153340.5593-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200310153340.5593-1-ulf.hansson@linaro.org> References: <20200310153340.5593-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org It has turned out that the sdhci-omap controller requires the R1B response, for commands that has this response associated with them. So, converting from an R1B to an R1 response for a CMD6 for example, leads to problems with the HW busy detection support. Fix this by informing the mmc core about the requirement, via setting the host cap, MMC_CAP_NEED_RSP_BUSY. Reported-by: Naresh Kamboju Reported-by: Anders Roxell Reported-by: Faiz Abbas Cc: Signed-off-by: Ulf Hansson --- drivers/mmc/host/sdhci-omap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c index 882053151a47..c4978177ef88 100644 --- a/drivers/mmc/host/sdhci-omap.c +++ b/drivers/mmc/host/sdhci-omap.c @@ -1192,6 +1192,9 @@ static int sdhci_omap_probe(struct platform_device *pdev) if (of_find_property(dev->of_node, "dmas", NULL)) sdhci_switch_external_dma(host, true); + /* R1B responses is required to properly manage HW busy detection. */ + mmc->caps |= MMC_CAP_NEED_RSP_BUSY; + ret = sdhci_setup_host(host); if (ret) goto err_put_sync;