All of lore.kernel.org
 help / color / mirror / Atom feed
* i.MX53 restart via watchdog does not work
@ 2016-04-15 16:17 Stanislav Meduna
  2016-04-19 15:39 ` Fabio Estevam
  0 siblings, 1 reply; 7+ messages in thread
From: Stanislav Meduna @ 2016-04-15 16:17 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

I am using an TQMa53 board, which expects to be resetted
by watchdog circuit. In older kernels ths was done in
by mxc_restart defined in arch/arm/mach-imx/system.c
and initialized and wired in mach-imx53.c.

Current kernels however do not use this and the mach-imx53.c
does not set .restart. I am getting
  imx2-wdt 53f98000.wdog: Device shutdown: Expect reboot!
  reboot: Restarting system
and the system just hangs there.

What is the correct way to accomplish this? I can of course
try to merge the old code back, but I expect there is
a reason why it was removed. Is writing the restart function
where I get and enable the clock, get an I/O mapping and
write the watchdog registers the correct approach?
Or should this be controlled by the device tree? Are there
maybe some patches flying (I was not able to google
anything relevant)?

Thanks
-- 
                                Stano

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

* i.MX53 restart via watchdog does not work
  2016-04-15 16:17 i.MX53 restart via watchdog does not work Stanislav Meduna
@ 2016-04-19 15:39 ` Fabio Estevam
  2016-04-19 15:54   ` Stanislav Meduna
  0 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2016-04-19 15:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Apr 15, 2016 at 1:17 PM, Stanislav Meduna
<stanislav.meduna@nxtcontrol.com> wrote:
> Hi,
>
> I am using an TQMa53 board, which expects to be resetted
> by watchdog circuit. In older kernels ths was done in
> by mxc_restart defined in arch/arm/mach-imx/system.c
> and initialized and wired in mach-imx53.c.
>
> Current kernels however do not use this and the mach-imx53.c
> does not set .restart. I am getting
>   imx2-wdt 53f98000.wdog: Device shutdown: Expect reboot!
>   reboot: Restarting system
> and the system just hangs there.

I am able to reproduce this issue on a imx6ul-evk board.

It works fine on a imx6q sabresd board though.

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

* i.MX53 restart via watchdog does not work
  2016-04-19 15:39 ` Fabio Estevam
@ 2016-04-19 15:54   ` Stanislav Meduna
  2016-04-19 18:18     ` Fabio Estevam
  0 siblings, 1 reply; 7+ messages in thread
From: Stanislav Meduna @ 2016-04-19 15:54 UTC (permalink / raw)
  To: linux-arm-kernel

On 4/19/2016 5:39 PM, Fabio Estevam wrote:

>> I am using an TQMa53 board, which expects to be resetted
>> by watchdog circuit. In older kernels ths was done in
>> by mxc_restart defined in arch/arm/mach-imx/system.c
>> and initialized and wired in mach-imx53.c.
>>
>> Current kernels however do not use this and the mach-imx53.c
>> does not set .restart. I am getting
>>   imx2-wdt 53f98000.wdog: Device shutdown: Expect reboot!
>>   reboot: Restarting system
>> and the system just hangs there.
> 
> I am able to reproduce this issue on a imx6ul-evk board.
> 
> It works fine on a imx6q sabresd board though.

After much head-scratching I was able to isolate the problem.
In fact it has nothing to do with the watchdog or at least
not directly. The reset is now located in the watchdog
code itself and gets called normally (which I have
overlooked when writing the original message).

The probable culprit is the eMMC card being left in some
state that the bootloader cannot handle. For now I worked
around it using the patch below (4.4-based), using a device
tree property to prevent the card from sleeping
in _mmc_suspend.

I'm not really sure what the 3.9 kernel does differently
here though...

Could you try to jump around the mmc_sleep(host)
call in _mmc_suspend to see whether it fixes the problem
also for you?

Regards
                                   Stano


commit a130df68e1c7770fa8ffc807fe40931615d2383a
Author: Stanislav Meduna <stanislav.meduna@nxtcontrol.com>
Date:   Mon Apr 18 19:19:28 2016 +0200

    mmc: disable card sleep via device-tree

    On a TQMa53 module the mmc_sleep leaves the eMMC card in a state
    that (probably) the U-Boot is unable to probe, resulting in
    reboot hanging. Add a device tree property to disable sleeping
    on suspend.

diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.txt b/Documentation/devicetree/bindings/mmc/mmc-card.txt
index a70fcd6..776a17333 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:

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 3d5087b..6506617 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -357,7 +357,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"))
+	{
 		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);

 	/*
@@ -1824,7 +1828,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 eb0151b..e1d275d 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -313,6 +313,7 @@ struct mmc_card {
 	struct dentry		*debugfs_root;
 	struct mmc_part	part[MMC_NUM_PHY_PARTITION]; /* physical partitions */
 	unsigned int    nr_parts;
+	bool	no_sleep_on_suspend;
 };

 /*

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

* i.MX53 restart via watchdog does not work
  2016-04-19 15:54   ` Stanislav Meduna
@ 2016-04-19 18:18     ` Fabio Estevam
  2016-04-19 18:28       ` Stanislav Meduna
  0 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2016-04-19 18:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 19, 2016 at 12:54 PM, Stanislav Meduna
<stanislav.meduna@nxtcontrol.com> wrote:

> After much head-scratching I was able to isolate the problem.
> In fact it has nothing to do with the watchdog or at least
> not directly. The reset is now located in the watchdog
> code itself and gets called normally (which I have
> overlooked when writing the original message).
>
> The probable culprit is the eMMC card being left in some
> state that the bootloader cannot handle. For now I worked
> around it using the patch below (4.4-based), using a device
> tree property to prevent the card from sleeping
> in _mmc_suspend.
>
> I'm not really sure what the 3.9 kernel does differently
> here though...
>
> Could you try to jump around the mmc_sleep(host)
> call in _mmc_suspend to see whether it fixes the problem
> also for you?

Looks like we are having different issues. Just tested on a imx53-qsb
board and it reboots fine with 4.6-rc4.

I am booting via NFS, so not eMMC related.

I will investigate the mx6ul-evk issue.

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

* i.MX53 restart via watchdog does not work
  2016-04-19 18:18     ` Fabio Estevam
@ 2016-04-19 18:28       ` Stanislav Meduna
  2016-04-19 18:43         ` Fabio Estevam
  0 siblings, 1 reply; 7+ messages in thread
From: Stanislav Meduna @ 2016-04-19 18:28 UTC (permalink / raw)
  To: linux-arm-kernel

On 4/19/2016 8:18 PM, Fabio Estevam wrote:

> I am booting via NFS, so not eMMC related.

Where are you bootstrapping the bootloader from?

I am also not using the eMMC at all, I was tftp-booting
a minimal initramfs image with just rdinit=/bin/sh (the fastest
way to play with reboots).

In my case the bootloader (U-Boot) itself is loaded from
the eMMC. To me it looks the shutdown code somehow brings
the board to a state where the processor itself can't
boot the bootloader.

-- 
                                  Stano

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

* i.MX53 restart via watchdog does not work
  2016-04-19 18:28       ` Stanislav Meduna
@ 2016-04-19 18:43         ` Fabio Estevam
  2016-06-23 15:14           ` Martin Fuzzey
  0 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2016-04-19 18:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Apr 19, 2016 at 3:28 PM, Stanislav Meduna
<stanislav.meduna@nxtcontrol.com> wrote:
> On 4/19/2016 8:18 PM, Fabio Estevam wrote:
>
>> I am booting via NFS, so not eMMC related.
>
> Where are you bootstrapping the bootloader from?
>
> I am also not using the eMMC at all, I was tftp-booting
> a minimal initramfs image with just rdinit=/bin/sh (the fastest
> way to play with reboots).
>
> In my case the bootloader (U-Boot) itself is loaded from
> the eMMC. To me it looks the shutdown code somehow brings
> the board to a state where the processor itself can't
> boot the bootloader.

imx53-qsb boots from a SD card. Issuing a 'reboot' command works fine
on 4.6-rc4.

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

* i.MX53 restart via watchdog does not work
  2016-04-19 18:43         ` Fabio Estevam
@ 2016-06-23 15:14           ` Martin Fuzzey
  0 siblings, 0 replies; 7+ messages in thread
From: Martin Fuzzey @ 2016-06-23 15:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hi all,

I'm running into this same issue on a custom i.MX53 based board with a
4.4 kernel.

Bootloader (u-boot) is loaded from eMMC with the reset (kernel + root
filesystem) netbooted.

When booting from SD instead of eMMC on same board problem does not occur.

However mmc_sleep() is called on both reboot and normal suspend to RAM.
However the problem *only* occurs on reboot, not on suspend to ram.
So applying Stanislav's patch above will also increase suspend power
consumption.

The reboot sequence is:

1) suspend eMMC (CMD 5)
2) Switch off 3V3 to eMMC
3) Toggle reset line by emmc_reset
4) Reset CPU via watchdog
5) 3V3 to eMMC comes on due to board wiring
6) [BOOTROM] send CMD0
7) [BOOTROM] load u-boot

Removing step 1 makes it reboot OK
Removing step 2 makes no change
Removing step 3 makes no change

I haven't been able to probe the signals to know what's hapenning in
steps 5 or 6 and step 5 is from the flow chart in the i.MX53 reference
manual.

On my eMMC device the reset line is actually ignored by default - it
has to be enabled by a once only, non reversible write to the extcsd.
I think that's a true for all eMMC devices.
There are three ways of getting the eMMC device out of suspend:
*) CMD 0
*) CMD 5
*) Hardware reset signal

Since CMD 0 is always sent (linux only uses CMD 5 for suspend, not for
resume) that explains why disabling step 3 makes no difference

The linux suspend / resume sequence (which works) is:

1) suspend eMMC (CMD 5) (mmc_sleep())
2) Switch off 3V3 to eMMC
..
3) Switch on 3V3 to eMMC
4) Send CMD0 to get out of reset (mmc_init_card())

I'm having difficulty seeing why the reboot case doesn't work whilst
the suspend / resume case does work.
There are some differences concerning the power supply but since it
leaving it enabled doesn't fix the problem that would seem to be
eliminated.

Regards,

Martin


On Tue, Apr 19, 2016 at 8:43 PM, Fabio Estevam <festevam@gmail.com> wrote:
> On Tue, Apr 19, 2016 at 3:28 PM, Stanislav Meduna
> <stanislav.meduna@nxtcontrol.com> wrote:
>> On 4/19/2016 8:18 PM, Fabio Estevam wrote:
>>
>>> I am booting via NFS, so not eMMC related.
>>
>> Where are you bootstrapping the bootloader from?
>>
>> I am also not using the eMMC at all, I was tftp-booting
>> a minimal initramfs image with just rdinit=/bin/sh (the fastest
>> way to play with reboots).
>>
>> In my case the bootloader (U-Boot) itself is loaded from
>> the eMMC. To me it looks the shutdown code somehow brings
>> the board to a state where the processor itself can't
>> boot the bootloader.
>
> imx53-qsb boots from a SD card. Issuing a 'reboot' command works fine
> on 4.6-rc4.
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2016-06-23 15:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-15 16:17 i.MX53 restart via watchdog does not work Stanislav Meduna
2016-04-19 15:39 ` Fabio Estevam
2016-04-19 15:54   ` Stanislav Meduna
2016-04-19 18:18     ` Fabio Estevam
2016-04-19 18:28       ` Stanislav Meduna
2016-04-19 18:43         ` Fabio Estevam
2016-06-23 15:14           ` Martin Fuzzey

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.