linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/3] powerpc/xmon: improvements and fixes
@ 2017-03-22 19:27 Guilherme G. Piccoli
  2017-03-22 19:27 ` [PATCH v4 1/3] powerpc/xmon: Fix an unexpected xmon on/off state change Guilherme G. Piccoli
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Guilherme G. Piccoli @ 2017-03-22 19:27 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: gpiccoli, xinhui.pan, benh, paulus, mpe

This series contains some improvements and fixes to xmon:

1) Pan Xinhui fixed a long-term bug, in which the xmon debugger got
stuck enabled after invoked by sysrq, regardless the state it was
set in the kernel command-line.

2) A debugfs entry was added in order to allow users to enable/disable
xmon without needing a kernel reload.

3) The nobt option was dropped and some minor issues were fixed, like
a misplacement of __initdata.

@mpe: The series was rebased against powerpc-next.
Also, I sent the patchset before with multiple versions, now
all patches are the same version, v4.


Guilherme G. Piccoli (2):
  powerpc/xmon: drop the nobt option from xmon plus minor fixes
  powerpc/xmon: add debugfs entry for xmon

Pan Xinhui (1):
  powerpc/xmon: Fix an unexpected xmon on/off state change

 arch/powerpc/xmon/xmon.c | 59 +++++++++++++++++++++++++++++++++++-------------
 1 file changed, 43 insertions(+), 16 deletions(-)

-- 
2.11.0

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

* [PATCH v4 1/3] powerpc/xmon: Fix an unexpected xmon on/off state change
  2017-03-22 19:27 [PATCH v4 0/3] powerpc/xmon: improvements and fixes Guilherme G. Piccoli
@ 2017-03-22 19:27 ` Guilherme G. Piccoli
  2017-03-31 12:33   ` [v4, " Michael Ellerman
  2017-03-22 19:27 ` [PATCH v4 2/3] powerpc/xmon: drop the nobt option from xmon plus minor fixes Guilherme G. Piccoli
  2017-03-22 19:27 ` [PATCH v4 3/3] powerpc/xmon: add debugfs entry for xmon Guilherme G. Piccoli
  2 siblings, 1 reply; 8+ messages in thread
From: Guilherme G. Piccoli @ 2017-03-22 19:27 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: gpiccoli, xinhui.pan, benh, paulus, mpe

From: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>

Once xmon is triggered by sysrq-x, it is enabled always afterwards even
if it is disabled during boot. This will cause a system reset interrupt
fail to dump. So keep xmon in its original state after exit.

We have several ways to set xmon on or off.
1) by a build config CONFIG_XMON_DEFAULT.
2) by a boot cmdline with xmon or xmon=early or xmon=on to enable xmon
and xmon=off to disable xmon. This value will override that in step 1.
3) by a debugfs interface, as proposed in this patchset.
And this value can override those in step 1 and 2.

Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
---
v3: changed xmon_off to xmon_on, simplifying the logic [mpe suggestion].

 arch/powerpc/xmon/xmon.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 16321ad9e70c..a89db1b3f66d 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -76,6 +76,7 @@ static int xmon_gate;
 #endif /* CONFIG_SMP */
 
 static unsigned long in_xmon __read_mostly = 0;
+static int xmon_on = IS_ENABLED(CONFIG_XMON_DEFAULT);
 
 static unsigned long adrs;
 static int size = 1;
@@ -3302,6 +3303,8 @@ static void sysrq_handle_xmon(int key)
 	/* ensure xmon is enabled */
 	xmon_init(1);
 	debugger(get_irq_regs());
+	if (!xmon_on)
+		xmon_init(0);
 }
 
 static struct sysrq_key_op sysrq_xmon_op = {
@@ -3318,7 +3321,7 @@ static int __init setup_xmon_sysrq(void)
 __initcall(setup_xmon_sysrq);
 #endif /* CONFIG_MAGIC_SYSRQ */
 
-static int __initdata xmon_early, xmon_off;
+static int __initdata xmon_early;
 
 static int __init early_parse_xmon(char *p)
 {
@@ -3326,10 +3329,12 @@ static int __init early_parse_xmon(char *p)
 		/* just "xmon" is equivalent to "xmon=early" */
 		xmon_init(1);
 		xmon_early = 1;
-	} else if (strncmp(p, "on", 2) == 0)
+		xmon_on = 1;
+	} else if (strncmp(p, "on", 2) == 0) {
 		xmon_init(1);
-	else if (strncmp(p, "off", 3) == 0)
-		xmon_off = 1;
+		xmon_on = 1;
+	} else if (strncmp(p, "off", 3) == 0)
+		xmon_on = 0;
 	else if (strncmp(p, "nobt", 4) == 0)
 		xmon_no_auto_backtrace = 1;
 	else
@@ -3341,10 +3346,8 @@ early_param("xmon", early_parse_xmon);
 
 void __init xmon_setup(void)
 {
-#ifdef CONFIG_XMON_DEFAULT
-	if (!xmon_off)
+	if (xmon_on)
 		xmon_init(1);
-#endif
 	if (xmon_early)
 		debugger(NULL);
 }
-- 
2.11.0

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

* [PATCH v4 2/3] powerpc/xmon: drop the nobt option from xmon plus minor fixes
  2017-03-22 19:27 [PATCH v4 0/3] powerpc/xmon: improvements and fixes Guilherme G. Piccoli
  2017-03-22 19:27 ` [PATCH v4 1/3] powerpc/xmon: Fix an unexpected xmon on/off state change Guilherme G. Piccoli
@ 2017-03-22 19:27 ` Guilherme G. Piccoli
  2017-03-31  0:36   ` Paul Mackerras
  2017-03-22 19:27 ` [PATCH v4 3/3] powerpc/xmon: add debugfs entry for xmon Guilherme G. Piccoli
  2 siblings, 1 reply; 8+ messages in thread
From: Guilherme G. Piccoli @ 2017-03-22 19:27 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: gpiccoli, xinhui.pan, benh, paulus, mpe

The xmon parameter nobt was added long time ago, by commit 26c8af5f01df
("[POWERPC] print backtrace when entering xmon"). The problem that time
was that during a crash in a machine with USB keyboard, xmon wouldn't
respond to commands from the keyboard, so printing the backtrace wouldn't
be possible.

Idea then was to show automatically the backtrace on xmon crash for the
first time it's invoked (if it recovers, next time xmon won't show
backtrace automatically). The nobt parameter was added _only_ to prevent
this automatic trace show. Seems long time ago USB keyboards didn't work
that well!

We don't need this parameter anymore, the feature of auto showing the
backtrace is interesting (imagine a case of auto-reboot script),
so this patch extends the functionality, by always showing the backtrace
automatically when xmon is invoked; it removes the nobt parameter too.

Also, this patch fixes __initdata placement on xmon_early and replaces
__initcall() with modern device_initcall() on sysrq handler.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
---
v4: extended the auto backtrace functionality, by showing the trace
in every xmon invokation [mpe suggestion].

 arch/powerpc/xmon/xmon.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index a89db1b3f66d..25a32815f310 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -185,8 +185,6 @@ static void dump_tlb_44x(void);
 static void dump_tlb_book3e(void);
 #endif
 
-static int xmon_no_auto_backtrace;
-
 #ifdef CONFIG_PPC64
 #define REG		"%.16lx"
 #else
@@ -885,10 +883,7 @@ cmds(struct pt_regs *excp)
 	last_cmd = NULL;
 	xmon_regs = excp;
 
-	if (!xmon_no_auto_backtrace) {
-		xmon_no_auto_backtrace = 1;
-		xmon_show_stack(excp->gpr[1], excp->link, excp->nip);
-	}
+	xmon_show_stack(excp->gpr[1], excp->link, excp->nip);
 
 	for(;;) {
 #ifdef CONFIG_SMP
@@ -3318,10 +3313,10 @@ static int __init setup_xmon_sysrq(void)
 	register_sysrq_key('x', &sysrq_xmon_op);
 	return 0;
 }
-__initcall(setup_xmon_sysrq);
+device_initcall(setup_xmon_sysrq);
 #endif /* CONFIG_MAGIC_SYSRQ */
 
-static int __initdata xmon_early;
+static int xmon_early __initdata;
 
 static int __init early_parse_xmon(char *p)
 {
@@ -3335,8 +3330,6 @@ static int __init early_parse_xmon(char *p)
 		xmon_on = 1;
 	} else if (strncmp(p, "off", 3) == 0)
 		xmon_on = 0;
-	else if (strncmp(p, "nobt", 4) == 0)
-		xmon_no_auto_backtrace = 1;
 	else
 		return 1;
 
-- 
2.11.0

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

* [PATCH v4 3/3] powerpc/xmon: add debugfs entry for xmon
  2017-03-22 19:27 [PATCH v4 0/3] powerpc/xmon: improvements and fixes Guilherme G. Piccoli
  2017-03-22 19:27 ` [PATCH v4 1/3] powerpc/xmon: Fix an unexpected xmon on/off state change Guilherme G. Piccoli
  2017-03-22 19:27 ` [PATCH v4 2/3] powerpc/xmon: drop the nobt option from xmon plus minor fixes Guilherme G. Piccoli
@ 2017-03-22 19:27 ` Guilherme G. Piccoli
  2 siblings, 0 replies; 8+ messages in thread
From: Guilherme G. Piccoli @ 2017-03-22 19:27 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: gpiccoli, xinhui.pan, benh, paulus, mpe

Currently the xmon debugger is set only via kernel boot command-line.
It's disabled by default, and can be enabled with "xmon=on" on the
command-line. Also, xmon may be accessed via sysrq mechanism.
But we cannot enable/disable xmon in runtime, it needs kernel reload.

This patch introduces a debugfs entry for xmon, allowing user to query
its current state and change it if desired. Basically, the "xmon" file
to read from/write to is under the debugfs mount point, on powerpc
directory. It's a simple attribute, value 0 meaning xmon is disabled
and value 1 the opposite. Writing these states to the file will take
immediate effect in the debugger.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
---
v4: fixed a bug in the patch (s/xmon_off/xmon_on/g basically).

v3: logic improved based in the changes made on patch 1.

 arch/powerpc/xmon/xmon.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 25a32815f310..0fab9d7349eb 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -29,6 +29,10 @@
 #include <linux/nmi.h>
 #include <linux/ctype.h>
 
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+#endif
+
 #include <asm/ptrace.h>
 #include <asm/string.h>
 #include <asm/prom.h>
@@ -3316,6 +3320,33 @@ static int __init setup_xmon_sysrq(void)
 device_initcall(setup_xmon_sysrq);
 #endif /* CONFIG_MAGIC_SYSRQ */
 
+#ifdef CONFIG_DEBUG_FS
+static int xmon_dbgfs_set(void *data, u64 val)
+{
+	xmon_on = !!val;
+	xmon_init(xmon_on);
+
+	return 0;
+}
+
+static int xmon_dbgfs_get(void *data, u64 *val)
+{
+	*val = xmon_on;
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(xmon_dbgfs_ops, xmon_dbgfs_get,
+			xmon_dbgfs_set, "%llu\n");
+
+static int __init setup_xmon_dbgfs(void)
+{
+	debugfs_create_file("xmon", 0600, powerpc_debugfs_root, NULL,
+				&xmon_dbgfs_ops);
+	return 0;
+}
+device_initcall(setup_xmon_dbgfs);
+#endif /* CONFIG_DEBUG_FS */
+
 static int xmon_early __initdata;
 
 static int __init early_parse_xmon(char *p)
-- 
2.11.0

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

* Re: [PATCH v4 2/3] powerpc/xmon: drop the nobt option from xmon plus minor fixes
  2017-03-22 19:27 ` [PATCH v4 2/3] powerpc/xmon: drop the nobt option from xmon plus minor fixes Guilherme G. Piccoli
@ 2017-03-31  0:36   ` Paul Mackerras
  2017-03-31 13:06     ` Guilherme G. Piccoli
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Mackerras @ 2017-03-31  0:36 UTC (permalink / raw)
  To: Guilherme G. Piccoli; +Cc: linuxppc-dev, xinhui.pan, benh, mpe

On Wed, Mar 22, 2017 at 04:27:50PM -0300, Guilherme G. Piccoli wrote:
> The xmon parameter nobt was added long time ago, by commit 26c8af5f01df
> ("[POWERPC] print backtrace when entering xmon"). The problem that time
> was that during a crash in a machine with USB keyboard, xmon wouldn't
> respond to commands from the keyboard, so printing the backtrace wouldn't
> be possible.
> 
> Idea then was to show automatically the backtrace on xmon crash for the
> first time it's invoked (if it recovers, next time xmon won't show
> backtrace automatically). The nobt parameter was added _only_ to prevent
> this automatic trace show. Seems long time ago USB keyboards didn't work
> that well!

Xmon still can't use a USB keyboard.  It's not a question of how well
USB keyboards work, it's that having a non-interrupt-driven USB stack
with (at least) an OHCI host controller driver and a keyboard driver
in xmon is impractical.

Paul.

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

* Re: [v4, 1/3] powerpc/xmon: Fix an unexpected xmon on/off state change
  2017-03-22 19:27 ` [PATCH v4 1/3] powerpc/xmon: Fix an unexpected xmon on/off state change Guilherme G. Piccoli
@ 2017-03-31 12:33   ` Michael Ellerman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2017-03-31 12:33 UTC (permalink / raw)
  To: Guilherme G. Piccoli, linuxppc-dev; +Cc: xinhui.pan, paulus, gpiccoli

On Wed, 2017-03-22 at 19:27:49 UTC, "Guilherme G. Piccoli" wrote:
> From: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
> 
> Once xmon is triggered by sysrq-x, it is enabled always afterwards even
> if it is disabled during boot. This will cause a system reset interrupt
> fail to dump. So keep xmon in its original state after exit.
> 
> We have several ways to set xmon on or off.
> 1) by a build config CONFIG_XMON_DEFAULT.
> 2) by a boot cmdline with xmon or xmon=early or xmon=on to enable xmon
> and xmon=off to disable xmon. This value will override that in step 1.
> 3) by a debugfs interface, as proposed in this patchset.
> And this value can override those in step 1 and 2.
> 
> Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
> Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/3b5bf42b81d56085fd58692b5117f6

cheers

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

* Re: [PATCH v4 2/3] powerpc/xmon: drop the nobt option from xmon plus minor fixes
  2017-03-31  0:36   ` Paul Mackerras
@ 2017-03-31 13:06     ` Guilherme G. Piccoli
  2017-04-01 10:31       ` Michael Ellerman
  0 siblings, 1 reply; 8+ messages in thread
From: Guilherme G. Piccoli @ 2017-03-31 13:06 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: xinhui.pan, linuxppc-dev

On 03/30/2017 09:36 PM, Paul Mackerras wrote:
> On Wed, Mar 22, 2017 at 04:27:50PM -0300, Guilherme G. Piccoli wrote:
>> The xmon parameter nobt was added long time ago, by commit 26c8af5f01df
>> ("[POWERPC] print backtrace when entering xmon"). The problem that time
>> was that during a crash in a machine with USB keyboard, xmon wouldn't
>> respond to commands from the keyboard, so printing the backtrace wouldn't
>> be possible.
>>
>> Idea then was to show automatically the backtrace on xmon crash for the
>> first time it's invoked (if it recovers, next time xmon won't show
>> backtrace automatically). The nobt parameter was added _only_ to prevent
>> this automatic trace show. Seems long time ago USB keyboards didn't work
>> that well!
> 
> Xmon still can't use a USB keyboard.  It's not a question of how well
> USB keyboards work, it's that having a non-interrupt-driven USB stack
> with (at least) an OHCI host controller driver and a keyboard driver
> in xmon is impractical.

That's nice to know Paul, thank you. Fortunately, we kept the automatic
trace showing feature!

Seems my commit message was unfortunate/wrong in this aspect, though.
@mpe, if you wanna change, feel free. Although it's not essential...

Cheers,


Guilherme

> 
> Paul.
> 

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

* Re: [PATCH v4 2/3] powerpc/xmon: drop the nobt option from xmon plus minor fixes
  2017-03-31 13:06     ` Guilherme G. Piccoli
@ 2017-04-01 10:31       ` Michael Ellerman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2017-04-01 10:31 UTC (permalink / raw)
  To: Guilherme G. Piccoli, Paul Mackerras; +Cc: xinhui.pan, linuxppc-dev

"Guilherme G. Piccoli" <gpiccoli@linux.vnet.ibm.com> writes:

> On 03/30/2017 09:36 PM, Paul Mackerras wrote:
>> On Wed, Mar 22, 2017 at 04:27:50PM -0300, Guilherme G. Piccoli wrote:
>>> The xmon parameter nobt was added long time ago, by commit 26c8af5f01df
>>> ("[POWERPC] print backtrace when entering xmon"). The problem that time
>>> was that during a crash in a machine with USB keyboard, xmon wouldn't
>>> respond to commands from the keyboard, so printing the backtrace wouldn't
>>> be possible.
>>>
>>> Idea then was to show automatically the backtrace on xmon crash for the
>>> first time it's invoked (if it recovers, next time xmon won't show
>>> backtrace automatically). The nobt parameter was added _only_ to prevent
>>> this automatic trace show. Seems long time ago USB keyboards didn't work
>>> that well!
>> 
>> Xmon still can't use a USB keyboard.  It's not a question of how well
>> USB keyboards work, it's that having a non-interrupt-driven USB stack
>> with (at least) an OHCI host controller driver and a keyboard driver
>> in xmon is impractical.
>
> That's nice to know Paul, thank you. Fortunately, we kept the automatic
> trace showing feature!
>
> Seems my commit message was unfortunate/wrong in this aspect, though.
> @mpe, if you wanna change, feel free. Although it's not essential...

It's already merged, so it is what it is.

I do remember not quite understanding what you meant with the "long time
ago" bit, but didn't think much more of it.

cheers

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

end of thread, other threads:[~2017-04-01 10:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-22 19:27 [PATCH v4 0/3] powerpc/xmon: improvements and fixes Guilherme G. Piccoli
2017-03-22 19:27 ` [PATCH v4 1/3] powerpc/xmon: Fix an unexpected xmon on/off state change Guilherme G. Piccoli
2017-03-31 12:33   ` [v4, " Michael Ellerman
2017-03-22 19:27 ` [PATCH v4 2/3] powerpc/xmon: drop the nobt option from xmon plus minor fixes Guilherme G. Piccoli
2017-03-31  0:36   ` Paul Mackerras
2017-03-31 13:06     ` Guilherme G. Piccoli
2017-04-01 10:31       ` Michael Ellerman
2017-03-22 19:27 ` [PATCH v4 3/3] powerpc/xmon: add debugfs entry for xmon Guilherme G. Piccoli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).