From b5f1f90cb86efb73d33fd9ecb758498e0fe07e31 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Thu, 29 Aug 2019 17:50:31 +0100 Subject: [PATCH] Upstream fix for WP detection on SD card --- ...i-tegra-drop---get_ro-implementation.patch | 158 ++++++++++++++++++ arm64-tegra-jetson-tx1-fixes.patch | 29 ---- kernel.spec | 2 + 3 files changed, 160 insertions(+), 29 deletions(-) create mode 100644 arm64-Revert-mmc-sdhci-tegra-drop---get_ro-implementation.patch diff --git a/arm64-Revert-mmc-sdhci-tegra-drop---get_ro-implementation.patch b/arm64-Revert-mmc-sdhci-tegra-drop---get_ro-implementation.patch new file mode 100644 index 000000000..831ec8a18 --- /dev/null +++ b/arm64-Revert-mmc-sdhci-tegra-drop---get_ro-implementation.patch @@ -0,0 +1,158 @@ +From patchwork Thu Aug 8 22:24:30 2019 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +X-Patchwork-Submitter: Dmitry Osipenko +X-Patchwork-Id: 11084925 +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 E38C414DB + for ; + Thu, 8 Aug 2019 22:25:47 +0000 (UTC) +Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) + by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D121728911 + for ; + Thu, 8 Aug 2019 22:25:47 +0000 (UTC) +Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) + id C3F6B289AD; Thu, 8 Aug 2019 22:25:47 +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,FREEMAIL_FROM,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 656C628911 + for ; + Thu, 8 Aug 2019 22:25:47 +0000 (UTC) +Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand + id S2404695AbfHHWZr (ORCPT + ); + Thu, 8 Aug 2019 18:25:47 -0400 +Received: from mail-lj1-f196.google.com ([209.85.208.196]:39456 "EHLO + mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org + with ESMTP id S1732708AbfHHWZq (ORCPT + ); Thu, 8 Aug 2019 18:25:46 -0400 +Received: by mail-lj1-f196.google.com with SMTP id v18so90278587ljh.6; + Thu, 08 Aug 2019 15:25:45 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=gmail.com; s=20161025; + h=from:to:cc:subject:date:message-id:mime-version + :content-transfer-encoding; + bh=Q9p8dp4Vwd7zb49ZfmkHjOde2lTf1kQmZ0LZmoXXg+Y=; + b=X/HCeJp6SdIpegsENNIX5jnBFbtDSt0UzsTUaN0a3V8l4KnCb/S47gsOo5w4dI/NuL + V5etWewZyguGVw5FG6KZWbW1LS15klZZSFCTiM7xpoSJFKT0PQDSyqOStwc5XptUNDIb + qgY409tTcnSLMME5LL0QF9qUqJEJ5eul/A29A05dpYuiAE/VlwyFHs9wqNchY3n6E3tm + PvQ0AGqmCEPC4oalZvcTWwYpZWM+7HKgb3eXOP5yluvevmLCNFylOeAYk+oId8vPdONf + JOWaRweXeFZl1b7jrY0HUlayIuG7iqV2+q/o6hzKZx9BLRodDP11LPPM9cHiWEb3wN3X + 4CBA== +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:mime-version + :content-transfer-encoding; + bh=Q9p8dp4Vwd7zb49ZfmkHjOde2lTf1kQmZ0LZmoXXg+Y=; + b=JGAzGWjuAZo8BCyJ+jFiDtGtbpEogcNiooDB8Q1/3nLH0goLK+zBDHd1O9vjLhGwy2 + AMGb5hZq8/csTSRCwTLpO0XWbLb+GETMzbiW7kBz5wrUIXdMfnxkVrAemaUbPFFPp8jh + 17jh5PvWtDEfBiixw6hba23owcAHs9TZ6s+6adekP+0J4Rw+hLjVuJQ1J/eIcS8Ea5T5 + 9pj9rHF7cZ+CvccJTgTk45Q6YVjZIVbOTZmvvRTVwNULu29Op2EPzwI9oTVQj75V+RpE + QFGIAEgayyd0hCaz93b9eC/4UjtpyX3SLjqWLNoa7OgLy2F+D3tQzZ+dzq1ljGT2bwWt + UnPA== +X-Gm-Message-State: APjAAAUx1JJ0CXUgSqw4EMqq5ZYk57Si1XVKMzl5tKnOckrzsVCbL18C + y0L1c2r4HgvumbNZx1lPlCY= +X-Google-Smtp-Source: + APXvYqyRb0wvQlmXB+gXw3/gwm+pd7UaBZTu3orpe9dFWQXE6Yy8xkJqi7BlFLmgkM9E0td9w8j+IQ== +X-Received: by 2002:a2e:9b48:: with SMTP id o8mr9572286ljj.122.1565303144838; + Thu, 08 Aug 2019 15:25:44 -0700 (PDT) +Received: from localhost.localdomain ([94.29.34.218]) + by smtp.gmail.com with ESMTPSA id + g5sm19318415ljj.69.2019.08.08.15.25.43 + (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Thu, 08 Aug 2019 15:25:43 -0700 (PDT) +From: Dmitry Osipenko +To: Thierry Reding , + Jonathan Hunter , + Adrian Hunter , + Ulf Hansson +Cc: linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org, + linux-kernel@vger.kernel.org +Subject: [PATCH v1] Revert "mmc: sdhci-tegra: drop ->get_ro() implementation" +Date: Fri, 9 Aug 2019 01:24:30 +0300 +Message-Id: <20190808222430.28477-1-digetx@gmail.com> +X-Mailer: git-send-email 2.22.0 +MIME-Version: 1.0 +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 + +The WRITE_PROTECT bit is always in a "protected mode" on Tegra and +WP-GPIO state need to be used instead. In a case of the GPIO absence, +write-enable should be assumed. External SD is writable once again as +a result of this patch because the offending commit changed behaviour for +the case of a missing WP-GPIO to fall back to WRITE_PROTECT bit-checking, +which is incorrect for Tegra. + +Cc: stable@vger.kernel.org # v5.1+ +Fixes: e8391453e27f ("mmc: sdhci-tegra: drop ->get_ro() implementation") +Signed-off-by: Dmitry Osipenko +Acked-by: Thierry Reding +Acked-by: Adrian Hunter +--- + drivers/mmc/host/sdhci-tegra.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c +index f4d4761cf20a..02d8f524bb9e 100644 +--- a/drivers/mmc/host/sdhci-tegra.c ++++ b/drivers/mmc/host/sdhci-tegra.c +@@ -258,6 +258,16 @@ static void tegra210_sdhci_writew(struct sdhci_host *host, u16 val, int reg) + } + } + ++static unsigned int tegra_sdhci_get_ro(struct sdhci_host *host) ++{ ++ /* ++ * Write-enable shall be assumed if GPIO is missing in a board's ++ * device-tree because SDHCI's WRITE_PROTECT bit doesn't work on ++ * Tegra. ++ */ ++ return mmc_gpio_get_ro(host->mmc); ++} ++ + static bool tegra_sdhci_is_pad_and_regulator_valid(struct sdhci_host *host) + { + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); +@@ -1224,6 +1234,7 @@ static const struct cqhci_host_ops sdhci_tegra_cqhci_ops = { + }; + + static const struct sdhci_ops tegra_sdhci_ops = { ++ .get_ro = tegra_sdhci_get_ro, + .read_w = tegra_sdhci_readw, + .write_l = tegra_sdhci_writel, + .set_clock = tegra_sdhci_set_clock, +@@ -1279,6 +1290,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra30 = { + }; + + static const struct sdhci_ops tegra114_sdhci_ops = { ++ .get_ro = tegra_sdhci_get_ro, + .read_w = tegra_sdhci_readw, + .write_w = tegra_sdhci_writew, + .write_l = tegra_sdhci_writel, +@@ -1332,6 +1344,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra124 = { + }; + + static const struct sdhci_ops tegra210_sdhci_ops = { ++ .get_ro = tegra_sdhci_get_ro, + .read_w = tegra_sdhci_readw, + .write_w = tegra210_sdhci_writew, + .write_l = tegra_sdhci_writel, +@@ -1366,6 +1379,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra210 = { + }; + + static const struct sdhci_ops tegra186_sdhci_ops = { ++ .get_ro = tegra_sdhci_get_ro, + .read_w = tegra_sdhci_readw, + .write_l = tegra_sdhci_writel, + .set_clock = tegra_sdhci_set_clock, diff --git a/arm64-tegra-jetson-tx1-fixes.patch b/arm64-tegra-jetson-tx1-fixes.patch index 4ac5ea22a..0f476970f 100644 --- a/arm64-tegra-jetson-tx1-fixes.patch +++ b/arm64-tegra-jetson-tx1-fixes.patch @@ -1,32 +1,3 @@ -From 005e0b987019fff6013dff99f44d9f6ce68f08ad Mon Sep 17 00:00:00 2001 -From: Peter Robinson -Date: Sat, 23 Mar 2019 17:42:18 +0000 -Subject: [PATCH 1/3] arm64: tegra210: Jetson TX1: disable WP to make SD card - work - -There's some issue with Write Protect detection on the Jetson TX1 -so just apply a quirk to disable the check for the time being. - -Signed-off-by: Peter Robinson ---- - arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi b/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi -index a96e6ee70c21..072788646cbf 100644 ---- a/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi -+++ b/arch/arm64/boot/dts/nvidia/tegra210-p2597.dtsi -@@ -1456,6 +1456,7 @@ - sdhci@700b0000 { - status = "okay"; - bus-width = <4>; -+ disable-wp; - - cd-gpios = <&gpio TEGRA_GPIO(Z, 1) GPIO_ACTIVE_LOW>; - --- -2.20.1 - From aea4a7a551fd7342299d34f04a8b75f58644ac07 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: Sat, 23 Mar 2019 17:45:10 +0000 diff --git a/kernel.spec b/kernel.spec index ae835146e..5add2fcd0 100644 --- a/kernel.spec +++ b/kernel.spec @@ -558,6 +558,8 @@ Patch306: arm-sdhci-esdhc-imx-fixes.patch Patch320: arm64-tegra-jetson-tx1-fixes.patch # https://www.spinics.net/lists/linux-tegra/msg43110.html Patch321: arm64-tegra-Jetson-TX2-Allow-bootloader-to-configure.patch +# https://patchwork.kernel.org/patch/11084925/ +Patch322: arm64-Revert-mmc-sdhci-tegra-drop---get_ro-implementation.patch # 400 - IBM (ppc/s390x) patches