All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: disable card sleep via device-tree
@ 2018-04-22 21:31 Lukasz Majewski
  2018-04-23  6:04   ` Vladimir Zapolskiy
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Lukasz Majewski @ 2018-04-22 21:31 UTC (permalink / raw)
  To: Ulf Hansson, Linus Walleij, linux-kernel
  Cc: Rob Herring, Mark Rutland, Adrian Hunter, Fabio Estevam,
	Wolfram Sang, Chanho Min, devicetree, linux-mmc,
	Stanislav Meduna, Lukasz Majewski

From: Stanislav Meduna <stanislav.meduna@nxtcontrol.com>

On a TQMa53 module the mmc_sleep leaves the eMMC card in a state
that the imx53 rom boot code is unable to probe, resulting in
reboot hanging. Add a device tree property to disable sleeping
on suspend.

For TQMa53 modules the exact commit to cause hang after reboot
(v3.10 -> v3.11):
commit 486fdbbc1483 ("mmc: core: Add shutdown callback for (e)MMC bus_ops")

[The exact discussion can be found here:
https://patchwork.kernel.org/patch/8881401/
"i.MX53 restart via watchdog does not work"

Signed-off-by: Stanislav Meduna <stanislav.meduna@nxtcontrol.com>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
 Documentation/devicetree/bindings/mmc/mmc-card.txt | 4 ++++
 drivers/mmc/core/mmc.c                             | 7 +++++--
 include/linux/mmc/card.h                           | 2 +-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.txt b/Documentation/devicetree/bindings/mmc/mmc-card.txt
index 8d2d71758907..c3ee151edd7c 100644
--- a/Documentation/devicetree/bindings/mmc/mmc-card.txt
+++ b/Documentation/devicetree/bindings/mmc/mmc-card.txt
@@ -12,6 +12,9 @@ Required properties:
 Optional properties:
 -broken-hpi : Use this to indicate that the mmc-card has a broken hpi
               implementation, and that hpi should not be used
+-no-sleep-on-suspend : Do not put the card to sleep when suspending.
+              There are boards with bootloaders that are unable
+              to probe such card when rebooting.
 
 Example:
 
@@ -26,5 +29,6 @@ Example:
 		reg = <0>;
 		compatible = "mmc-card";
 		broken-hpi;
+		no-sleep-on-suspend;
 	};
 };
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 208a762b87ef..a3b74b5c8893 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -381,8 +381,11 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd)
 	}
 
 	np = mmc_of_find_child_device(card->host, 0);
-	if (np && of_device_is_compatible(np, "mmc-card"))
+	if (np && of_device_is_compatible(np, "mmc-card")) {
 		broken_hpi = of_property_read_bool(np, "broken-hpi");
+		card->no_sleep_on_suspend =
+			of_property_read_bool(np, "no-sleep-on-suspend");
+	}
 	of_node_put(np);
 
 	/*
@@ -1990,7 +1993,7 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
 	if (mmc_can_poweroff_notify(host->card) &&
 		((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend))
 		err = mmc_poweroff_notify(host->card, notify_type);
-	else if (mmc_can_sleep(host->card))
+	else if (mmc_can_sleep(host->card) && !host->card->no_sleep_on_suspend)
 		err = mmc_sleep(host);
 	else if (!mmc_host_is_spi(host))
 		err = mmc_deselect_cards(host);
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 279b39008a33..c64d88e6de3b 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -304,8 +304,8 @@ struct mmc_card {
 	struct dentry		*debugfs_root;
 	struct mmc_part	part[MMC_NUM_PHY_PARTITION]; /* physical partitions */
 	unsigned int    nr_parts;
-
 	unsigned int		bouncesz;	/* Bounce buffer size */
+	bool	no_sleep_on_suspend;
 };
 
 static inline bool mmc_large_sector(struct mmc_card *card)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-04-30  9:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-22 21:31 [PATCH] mmc: disable card sleep via device-tree Lukasz Majewski
2018-04-23  6:04 ` Vladimir Zapolskiy
2018-04-23  6:04   ` Vladimir Zapolskiy
2018-04-23  8:26 ` Ulf Hansson
2018-04-23  9:36   ` Lukasz Majewski
2018-04-23 10:24     ` Ulf Hansson
2018-04-23 14:11       ` Lukasz Majewski
2018-04-23 15:01         ` Ulf Hansson
2018-04-30  9:13 ` Linus Walleij
2018-04-30  9:31   ` Lukasz Majewski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.