From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Mon, 25 Jul 2022 14:04:59 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oFwpY-0035o2-Ec for lore@lore.pengutronix.de; Mon, 25 Jul 2022 14:04:59 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1oFwpW-0000ST-6F; Mon, 25 Jul 2022 14:04:58 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oFwpM-0000IM-Tb; Mon, 25 Jul 2022 14:04:48 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1oFwpM-0036bS-5G; Mon, 25 Jul 2022 14:04:48 +0200 Received: from afa by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1oFwpK-005R6s-Uu; Mon, 25 Jul 2022 14:04:46 +0200 From: Ahmad Fatoum To: distrokit@pengutronix.de Date: Mon, 25 Jul 2022 14:04:45 +0200 Message-Id: <20220725120445.1295669-8-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220725120445.1295669-1-a.fatoum@pengutronix.de> References: <20220725120445.1295669-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH 8/8] v7a: barebox: ignore card-detect for booted SD-Card X-BeenThere: distrokit@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: DistroKit Mailinglist List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmad Fatoum Sender: "DistroKit" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: distrokit-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false In remote labs co-located with other hardware, we've observed card detect levers of different boards to sporadically fail to detect the card, e.g. because the cable on the usbsdmux was yanked around by accident. When this happens, barebox usually boots up normally as the card detect is ignored and then Linux waits indefinitely for the card-detect to turn active. Add a new config option that can be enabled to avoid these issues altogether. We enable this for all configurations, except for barebox-am335x-mlo, which is size-constrained as it needs to fit into on-chip SRAM and those 100 extra bytes are deemed too expensive. Signed-off-by: Ahmad Fatoum --- .../platform-v7a/barebox-am335x-mlo.config | 1 + configs/platform-v7a/barebox-am335x.config | 1 + .../platform-v7a/barebox-am335x.config.diff | 2 +- configs/platform-v7a/barebox-at91.config | 1 + configs/platform-v7a/barebox-at91.config.diff | 2 +- configs/platform-v7a/barebox-mx6.config | 1 + configs/platform-v7a/barebox-mx6.config.diff | 2 +- configs/platform-v7a/barebox-rpi2.config | 1 + configs/platform-v7a/barebox-rpi2.config.diff | 2 +- configs/platform-v7a/barebox-stm32mp.config | 1 + .../platform-v7a/barebox-stm32mp.config.diff | 2 +- configs/platform-v7a/barebox-vexpress.config | 1 + .../platform-v7a/barebox-vexpress.config.diff | 2 +- configs/platform-v7a/barebox.config | 1 + ...new-MCI_BROKEN_CD-option-for-testing.patch | 122 ++++++++++++++++++ .../patches/barebox-2022.06.0/series | 1 + 16 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 configs/platform-v7a/patches/barebox-2022.06.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch create mode 100644 configs/platform-v7a/patches/barebox-2022.06.0/series diff --git a/configs/platform-v7a/barebox-am335x-mlo.config b/configs/platform-v7a/barebox-am335x-mlo.config index 8d01f854c874..14f2e1e342e6 100644 --- a/configs/platform-v7a/barebox-am335x-mlo.config +++ b/configs/platform-v7a/barebox-am335x-mlo.config @@ -299,6 +299,7 @@ CONFIG_MCI=y # CONFIG_MCI_WRITE is not set # CONFIG_MCI_MMC_BOOT_PARTITIONS is not set # CONFIG_MCI_MMC_GPP_PARTITIONS is not set +# CONFIG_MCI_BROKEN_CD is not set # # --- MCI host drivers --- diff --git a/configs/platform-v7a/barebox-am335x.config b/configs/platform-v7a/barebox-am335x.config index 964b9dd41a61..068fd5fe1679 100644 --- a/configs/platform-v7a/barebox-am335x.config +++ b/configs/platform-v7a/barebox-am335x.config @@ -655,6 +655,7 @@ CONFIG_MCI_INFO=y CONFIG_MCI_WRITE=y # CONFIG_MCI_MMC_BOOT_PARTITIONS is not set # CONFIG_MCI_MMC_GPP_PARTITIONS is not set +CONFIG_MCI_BROKEN_CD=y # # --- MCI host drivers --- diff --git a/configs/platform-v7a/barebox-am335x.config.diff b/configs/platform-v7a/barebox-am335x.config.diff index 376cddeaaa0e..17dc8972da5d 100644 --- a/configs/platform-v7a/barebox-am335x.config.diff +++ b/configs/platform-v7a/barebox-am335x.config.diff @@ -1,4 +1,4 @@ -ce1ca5fe3cea9cabd6af79b60ecde84b +c2cbf48a6de666e3854240d3b1769aee # CONFIG_AM33XX_NET_BOOT is not set CONFIG_ARCH_AM33XX=y # CONFIG_ARCH_BCM283X is not set diff --git a/configs/platform-v7a/barebox-at91.config b/configs/platform-v7a/barebox-at91.config index 4306cfd4bcae..2f00891a8cfa 100644 --- a/configs/platform-v7a/barebox-at91.config +++ b/configs/platform-v7a/barebox-at91.config @@ -610,6 +610,7 @@ CONFIG_MCI_INFO=y CONFIG_MCI_WRITE=y CONFIG_MCI_MMC_BOOT_PARTITIONS=y # CONFIG_MCI_MMC_GPP_PARTITIONS is not set +CONFIG_MCI_BROKEN_CD=y # # --- MCI host drivers --- diff --git a/configs/platform-v7a/barebox-at91.config.diff b/configs/platform-v7a/barebox-at91.config.diff index ed1ed6d7d4e2..3e80f997e9aa 100644 --- a/configs/platform-v7a/barebox-at91.config.diff +++ b/configs/platform-v7a/barebox-at91.config.diff @@ -1,4 +1,4 @@ -ce1ca5fe3cea9cabd6af79b60ecde84b +c2cbf48a6de666e3854240d3b1769aee CONFIG_ARCH_AT91=y # CONFIG_ARCH_BCM283X is not set CONFIG_ARCH_TEXT_BASE=0x23f00000 diff --git a/configs/platform-v7a/barebox-mx6.config b/configs/platform-v7a/barebox-mx6.config index 4d98b5e205e6..b6cf2e696158 100644 --- a/configs/platform-v7a/barebox-mx6.config +++ b/configs/platform-v7a/barebox-mx6.config @@ -767,6 +767,7 @@ CONFIG_MCI_INFO=y CONFIG_MCI_WRITE=y CONFIG_MCI_MMC_BOOT_PARTITIONS=y # CONFIG_MCI_MMC_GPP_PARTITIONS is not set +CONFIG_MCI_BROKEN_CD=y # # --- MCI host drivers --- diff --git a/configs/platform-v7a/barebox-mx6.config.diff b/configs/platform-v7a/barebox-mx6.config.diff index b9a05e41a1db..9f596de59486 100644 --- a/configs/platform-v7a/barebox-mx6.config.diff +++ b/configs/platform-v7a/barebox-mx6.config.diff @@ -1,4 +1,4 @@ -ce1ca5fe3cea9cabd6af79b60ecde84b +c2cbf48a6de666e3854240d3b1769aee # CONFIG_ARCH_BCM283X is not set CONFIG_ARCH_HAS_FEC_IMX=y CONFIG_ARCH_HAS_IMX_GPT=y diff --git a/configs/platform-v7a/barebox-rpi2.config b/configs/platform-v7a/barebox-rpi2.config index 77bb09edbdce..650aad7c4c22 100644 --- a/configs/platform-v7a/barebox-rpi2.config +++ b/configs/platform-v7a/barebox-rpi2.config @@ -594,6 +594,7 @@ CONFIG_MCI_INFO=y CONFIG_MCI_WRITE=y CONFIG_MCI_MMC_BOOT_PARTITIONS=y # CONFIG_MCI_MMC_GPP_PARTITIONS is not set +CONFIG_MCI_BROKEN_CD=y # # --- MCI host drivers --- diff --git a/configs/platform-v7a/barebox-rpi2.config.diff b/configs/platform-v7a/barebox-rpi2.config.diff index f7ffae897169..3ff572b319e5 100644 --- a/configs/platform-v7a/barebox-rpi2.config.diff +++ b/configs/platform-v7a/barebox-rpi2.config.diff @@ -1,4 +1,4 @@ -ce1ca5fe3cea9cabd6af79b60ecde84b +c2cbf48a6de666e3854240d3b1769aee CONFIG_ARM_ASM_UNIFIED=y CONFIG_BOOTM_INITRD=y # CONFIG_CMD_I2C is undefined diff --git a/configs/platform-v7a/barebox-stm32mp.config b/configs/platform-v7a/barebox-stm32mp.config index 15b2a8393345..6053a43fd0f1 100644 --- a/configs/platform-v7a/barebox-stm32mp.config +++ b/configs/platform-v7a/barebox-stm32mp.config @@ -560,6 +560,7 @@ CONFIG_MCI_INFO=y CONFIG_MCI_WRITE=y CONFIG_MCI_MMC_BOOT_PARTITIONS=y # CONFIG_MCI_MMC_GPP_PARTITIONS is not set +CONFIG_MCI_BROKEN_CD=y # # --- MCI host drivers --- diff --git a/configs/platform-v7a/barebox-stm32mp.config.diff b/configs/platform-v7a/barebox-stm32mp.config.diff index d14e40f60b54..dec198abd3b0 100644 --- a/configs/platform-v7a/barebox-stm32mp.config.diff +++ b/configs/platform-v7a/barebox-stm32mp.config.diff @@ -1,4 +1,4 @@ -ce1ca5fe3cea9cabd6af79b60ecde84b +c2cbf48a6de666e3854240d3b1769aee # CONFIG_ARCH_BCM283X is not set CONFIG_ARCH_HAS_RESET_CONTROLLER=y CONFIG_ARCH_NR_GPIO=416 diff --git a/configs/platform-v7a/barebox-vexpress.config b/configs/platform-v7a/barebox-vexpress.config index e6f50d1274a3..a9101f044d5c 100644 --- a/configs/platform-v7a/barebox-vexpress.config +++ b/configs/platform-v7a/barebox-vexpress.config @@ -603,6 +603,7 @@ CONFIG_MCI_INFO=y CONFIG_MCI_WRITE=y # CONFIG_MCI_MMC_BOOT_PARTITIONS is not set # CONFIG_MCI_MMC_GPP_PARTITIONS is not set +CONFIG_MCI_BROKEN_CD=y # # --- MCI host drivers --- diff --git a/configs/platform-v7a/barebox-vexpress.config.diff b/configs/platform-v7a/barebox-vexpress.config.diff index f09afd233e7f..f712d6c8ca13 100644 --- a/configs/platform-v7a/barebox-vexpress.config.diff +++ b/configs/platform-v7a/barebox-vexpress.config.diff @@ -1,4 +1,4 @@ -ce1ca5fe3cea9cabd6af79b60ecde84b +c2cbf48a6de666e3854240d3b1769aee CONFIG_AMBA_SP804=y # CONFIG_ARCH_BCM283X is not set CONFIG_ARCH_VEXPRESS=y diff --git a/configs/platform-v7a/barebox.config b/configs/platform-v7a/barebox.config index 9e15a66d08e1..655ab1c43c57 100644 --- a/configs/platform-v7a/barebox.config +++ b/configs/platform-v7a/barebox.config @@ -615,6 +615,7 @@ CONFIG_MCI_INFO=y CONFIG_MCI_WRITE=y # CONFIG_MCI_MMC_BOOT_PARTITIONS is not set # CONFIG_MCI_MMC_GPP_PARTITIONS is not set +CONFIG_MCI_BROKEN_CD=y # # --- MCI host drivers --- diff --git a/configs/platform-v7a/patches/barebox-2022.06.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch b/configs/platform-v7a/patches/barebox-2022.06.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch new file mode 100644 index 000000000000..8d10cf3d5529 --- /dev/null +++ b/configs/platform-v7a/patches/barebox-2022.06.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch @@ -0,0 +1,122 @@ +From git@z Thu Jan 1 00:00:00 1970 +Subject: [PATCH v2] mci: add new MCI_BROKEN_CD option for testing +From: Ahmad Fatoum +Date: Mon, 25 Jul 2022 13:58:56 +0200 +Message-Id: <20220725115856.1288819-1-a.fatoum@pengutronix.de> +To: barebox@lists.infradead.org +Cc: Ahmad Fatoum +List-Id: +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 7bit + +In remote labs co-located with other hardware, we've observed card +detect levers of different boards to sporadically fail to detect +the card, e.g. because the cable on the usbsdmux was yanked around +by accident. When this happens, barebox usually boots up normally as +the card detect is ignored and then Linux waits indefinitely for +the card-detect to turn active. Add a new config option that can be +enabled to avoid these issues altogether. + +Signed-off-by: Ahmad Fatoum +--- +v1 -> v2: + - use early exit instead of if-else + - don't fail mci_card_probe if of_register_fixup fails +--- + drivers/mci/Kconfig | 15 +++++++++++++++ + drivers/mci/mci-core.c | 36 ++++++++++++++++++++++++++++++++---- + 2 files changed, 47 insertions(+), 4 deletions(-) + +diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig +index 21d53c0c3f0b..651e59259790 100644 +--- a/drivers/mci/Kconfig ++++ b/drivers/mci/Kconfig +@@ -56,6 +56,21 @@ config MCI_MMC_GPP_PARTITIONS + Note: by default, 'MMC' devices have no 'general purpose partitions', + it requires a special one-time configuration step to enable them. + ++config MCI_BROKEN_CD ++ bool "ignore card-detect pin on boot and in OS" ++ help ++ Say 'y' here to have barebox unconditionally ignore the ++ card-detect pin for its own operation and manipulate the ++ kernel DT, so all detected MCI cards are polled instead ++ of expecting the card detect lever to behave correctly. ++ If you need more fine grained control use of_property ++ in an init script: ++ ++ of_property -fd mmc0 cd-gpios ++ of_property -fs mmc0 broken-cd ++ ++ If unsure, say 'n' here. ++ + comment "--- MCI host drivers ---" + + config MCI_DW +diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c +index 82e2f82f5377..4db2253c3a80 100644 +--- a/drivers/mci/mci-core.c ++++ b/drivers/mci/mci-core.c +@@ -1727,6 +1727,27 @@ static int mci_register_partition(struct mci_part *part) + return 0; + } + ++static int of_broken_cd_fixup(struct device_node *root, void *ctx) ++{ ++ struct device_d *hw_dev = ctx; ++ struct device_node *np; ++ char *name; ++ ++ name = of_get_reproducible_name(hw_dev->device_node); ++ np = of_find_node_by_reproducible_name(root, name); ++ free(name); ++ if (!np) { ++ dev_warn(hw_dev, "Cannot find nodepath %s, cannot fixup\n", ++ hw_dev->device_node->full_name); ++ return -EINVAL; ++ } ++ ++ of_property_write_bool(np, "cd-gpios", false); ++ of_property_write_bool(np, "broken-cd", true); ++ ++ return 0; ++} ++ + /** + * Probe an MCI card at the given host interface + * @param mci MCI device instance +@@ -1737,10 +1758,13 @@ static int mci_card_probe(struct mci *mci) + struct mci_host *host = mci->host; + int i, rc, disknum, ret; + +- if (host->card_present && !host->card_present(host) && +- !host->non_removable) { +- dev_err(&mci->dev, "no card inserted\n"); +- return -ENODEV; ++ if (host->card_present && !host->card_present(host) && !host->non_removable) { ++ if (!IS_ENABLED(CONFIG_MCI_BROKEN_CD)) { ++ dev_err(&mci->dev, "no card inserted\n"); ++ return -ENODEV; ++ } ++ ++ dev_info(&mci->dev, "no card inserted (ignoring)\n"); + } + + ret = regulator_enable(host->supply); +@@ -1818,6 +1842,10 @@ static int mci_card_probe(struct mci *mci) + } + } + ++ if (IS_ENABLED(CONFIG_MCI_BROKEN_CD) && !host->no_sd && ++ dev_of_node(host->hw_dev)) ++ of_register_fixup(of_broken_cd_fixup, host->hw_dev); ++ + dev_dbg(&mci->dev, "SD Card successfully added\n"); + + on_error: + +-- +2.30.2 + + diff --git a/configs/platform-v7a/patches/barebox-2022.06.0/series b/configs/platform-v7a/patches/barebox-2022.06.0/series new file mode 100644 index 000000000000..073642265726 --- /dev/null +++ b/configs/platform-v7a/patches/barebox-2022.06.0/series @@ -0,0 +1 @@ +0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch -- 2.30.2