All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Krummenacher <max.oss.09@gmail.com>
To: Max Krummenacher <max.oss.09@gmail.com>
Cc: Max Krummenacher <max.krummenacher@toradex.com>,
	Lucas Stach <l.stach@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Fabio Estevam <festevam@gmail.com>,
	Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	linux-kernel@vger.kernel.org,
	Ahmad Fatoum <a.fatoum@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Russell King <linux@armlinux.org.uk>,
	Shawn Guo <shawnguo@kernel.org>,
	NXP Linux Team <linux-imx@nxp.com>
Subject: [PATCH 0/1] ARM: imx: build suspend-imx6.S with arm instruction set
Date: Mon, 11 Jan 2021 16:17:03 +0100	[thread overview]
Message-ID: <20210111151704.26296-1-max.krummenacher@toradex.com> (raw)

When the kernel is configured to use the Thumb-2 instruction set
"suspend-to-memory" fails to resume while in ARM mode it works as
expected.
(I used imx_v6_v7_defconfig and deselected ARCH_MULTI_V6 and selected
THUMB2_KERNEL)

The system prints what is expected when suspending but an event of a
wakeup source does give no output.

root@colibri-imx6ull:~# echo mem > /sys/power/state

[   58.610809] PM: suspend entry (deep)
[   58.629354] Filesystems sync: 0.014 seconds
[   58.653411] Freezing user space processes ... (elapsed 0.001 seconds) done.
[   58.661941] OOM killer disabled.
[   58.665176] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[   58.674028] printk: Suspending console(s) (use no_console_suspend to debug)

-> trigger wakeup event, no reaction.

It looks like the CPU resumes unconditionally in ARM instruction mode
and then chokes on the presented Thumb-2 code it should execute on resume.
With the following code change resume succeeds.

--- a/arch/arm/mach-imx/suspend-imx6.S
+++ b/arch/arm/mach-imx/suspend-imx6.S
@@ -287,11 +286,20 @@ rbc_loop:
 	bne	rbc_loop

 	/* Zzz, enter stop mode */
 	wfi
+#ifdef CONFIG_THUMB2_KERNEL
+	/* i.MX CPUs seem to leave stop mode set to ARM instruction set */
+	.arm
+#endif
 	nop
 	nop
 	nop
 	nop
+#ifdef CONFIG_THUMB2_KERNEL
+	/* switch to Thumb2 mode */
+	sub     pc, pc, #3
+	.thumb
+#endif

 	/*

I propose however to compile the whole file in ARM mode and have the
linker taking care of the ARM/Thumb-2 switching. This would also keep
the code working if a i.MX CPU variant exists that resumes in the same
mode in which it went to sleep.



Max Krummenacher (1):
  ARM: imx: build suspend-imx6.S with arm instruction set

 arch/arm/mach-imx/suspend-imx6.S | 1 +
 1 file changed, 1 insertion(+)

-- 
2.26.2


WARNING: multiple messages have this Message-ID (diff)
From: Max Krummenacher <max.oss.09@gmail.com>
To: Max Krummenacher <max.oss.09@gmail.com>
Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	linux-kernel@vger.kernel.org,
	Russell King <linux@armlinux.org.uk>,
	NXP Linux Team <linux-imx@nxp.com>,
	Max Krummenacher <max.krummenacher@toradex.com>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-arm-kernel@lists.infradead.org,
	Lucas Stach <l.stach@pengutronix.de>
Subject: [PATCH 0/1] ARM: imx: build suspend-imx6.S with arm instruction set
Date: Mon, 11 Jan 2021 16:17:03 +0100	[thread overview]
Message-ID: <20210111151704.26296-1-max.krummenacher@toradex.com> (raw)

When the kernel is configured to use the Thumb-2 instruction set
"suspend-to-memory" fails to resume while in ARM mode it works as
expected.
(I used imx_v6_v7_defconfig and deselected ARCH_MULTI_V6 and selected
THUMB2_KERNEL)

The system prints what is expected when suspending but an event of a
wakeup source does give no output.

root@colibri-imx6ull:~# echo mem > /sys/power/state

[   58.610809] PM: suspend entry (deep)
[   58.629354] Filesystems sync: 0.014 seconds
[   58.653411] Freezing user space processes ... (elapsed 0.001 seconds) done.
[   58.661941] OOM killer disabled.
[   58.665176] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[   58.674028] printk: Suspending console(s) (use no_console_suspend to debug)

-> trigger wakeup event, no reaction.

It looks like the CPU resumes unconditionally in ARM instruction mode
and then chokes on the presented Thumb-2 code it should execute on resume.
With the following code change resume succeeds.

--- a/arch/arm/mach-imx/suspend-imx6.S
+++ b/arch/arm/mach-imx/suspend-imx6.S
@@ -287,11 +286,20 @@ rbc_loop:
 	bne	rbc_loop

 	/* Zzz, enter stop mode */
 	wfi
+#ifdef CONFIG_THUMB2_KERNEL
+	/* i.MX CPUs seem to leave stop mode set to ARM instruction set */
+	.arm
+#endif
 	nop
 	nop
 	nop
 	nop
+#ifdef CONFIG_THUMB2_KERNEL
+	/* switch to Thumb2 mode */
+	sub     pc, pc, #3
+	.thumb
+#endif

 	/*

I propose however to compile the whole file in ARM mode and have the
linker taking care of the ARM/Thumb-2 switching. This would also keep
the code working if a i.MX CPU variant exists that resumes in the same
mode in which it went to sleep.



Max Krummenacher (1):
  ARM: imx: build suspend-imx6.S with arm instruction set

 arch/arm/mach-imx/suspend-imx6.S | 1 +
 1 file changed, 1 insertion(+)

-- 
2.26.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2021-01-11 15:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-11 15:17 Max Krummenacher [this message]
2021-01-11 15:17 ` [PATCH 0/1] ARM: imx: build suspend-imx6.S with arm instruction set Max Krummenacher
2021-01-11 15:17 ` [PATCH 1/1] " Max Krummenacher
2021-01-11 15:17   ` Max Krummenacher
2021-01-11 17:38   ` Oleksandr Suvorov
2021-01-11 17:38     ` Oleksandr Suvorov
2021-01-11 17:49   ` Ahmad Fatoum
2021-01-11 17:49     ` Ahmad Fatoum
2021-01-11 18:30     ` Max Krummenacher
2021-01-11 18:30       ` Max Krummenacher
2021-01-18  6:45   ` Shawn Guo
2021-01-18  6:45     ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210111151704.26296-1-max.krummenacher@toradex.com \
    --to=max.oss.09@gmail.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=l.stach@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=max.krummenacher@toradex.com \
    --cc=r.czerwinski@pengutronix.de \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.