linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Disable modem's watchdog when kernel debugging with KGDB
@ 2012-03-23  9:56 Michal.K.Frynas
  2012-03-27  8:21 ` Michal.K.Frynas
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michal.K.Frynas @ 2012-03-23  9:56 UTC (permalink / raw)
  To: linux-arm-msm

Hi,

I was trying to launch KGDB kernel debugging on MSM 8255 platform.
It works now but I needed to apply a few patches. Among other things
I needed to neutralized AMSS' watchdog for the time the linux kernel
spends on breakpoint. Please have a look at the patch below with code
of a driver controlling modem's watchdog.

It might be useful for everyone willing to debug the kernel 
on Qualcomm's platform.

For it to work there's another patch needed. The patch I've posted
on KGDB mailing list: http://sourceforge.net/mailarchive/message.php?msg_id=28955742
It adds hooks for architecture specific pre and post breakpoint
handlers and invocations before and after the breakpoint.

Best Regards 
Michal Frynas


>From 077f79c950f15ba0f4af08381b16d093a17c3354 Mon Sep 17 00:00:00 2001
From: Michal Frynas <michal.frynas@tieto.com>
Date: Wed, 7 Mar 2012 12:59:28 +0100
Subject: [PATCH] KGDB: modem watchdog immunization against kernel stopping

On Qualcomm's MSM 8255 platform there are two processors running
simultaneously and synchronizing constantly with each other.
The ARM11 CPU executes Linux code while the ARM9 executes modem code.

While debugging Linux code and stopping kernel on a breakpoint
the synchronization breaks causing modem CPU to trigger hard reset.
To avoid this modem_watchdog_control driver registers pre_exception
handler where it instructs modem watchdog to ignore timing issues
from Linux side. That handler is invoked every time the kernel enters
breakpoint and then when leaving breakpoint post_exception handler is 
called restoring modem watchdog to its default behavior.

Change-Id: I8ab73b1c8edcec1fe89b0d2f2dfbd03f0a617f57
Signed-off-by: Michal Frynas <michal.k.frynas@tieto.com>
---
 arch/arm/mach-msm/Makefile                 |    2 +
 arch/arm/mach-msm/modem_watchdog_control.c |   35 +++++++++++++++++++
 arch/arm/mach-msm/modem_watchdog_control.h |   50 ++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-msm/modem_watchdog_control.c
 create mode 100644 arch/arm/mach-msm/modem_watchdog_control.h

diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 7ce284d..9984467 100755
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -208,3 +208,5 @@ endif
 obj-$(CONFIG_PMIC_TIME) += pmic_time.o
 
 obj-$(CONFIG_SEMC_MOGAMI_FELICA_SUPPORT) += semc_mogami_felica.o
+
+obj-$(CONFIG_KGDB) += modem_watchdog_control.o
diff --git a/arch/arm/mach-msm/modem_watchdog_control.c b/arch/arm/mach-msm/modem_watchdog_control.c
new file mode 100644
index 0000000..d64ae7e
--- /dev/null
+++ b/arch/arm/mach-msm/modem_watchdog_control.c
@@ -0,0 +1,35 @@
+#include <proc_comm.h>
+#include <modem_watchdog_control.h>
+
+
+static int modem_watchdog_state;
+
+void modem_watchdog_disable(void)
+{
+	pr_info("kgdb: disabling modem watchdog on breakpoint\n");
+	modem_watchdog_state = DOG_HALT_MONITORING;
+	msm_proc_comm(PCOM_SET_SW_WATCHDOG_STATE, &modem_watchdog_state, 0);
+}
+
+void modem_watchdog_enable(void)
+{
+	pr_info("kgdb: reenabling modem watchdog\n");
+	modem_watchdog_state = DOG_DEFAULT_STATE;
+	msm_proc_comm(PCOM_SET_SW_WATCHDOG_STATE, &modem_watchdog_state, 0);
+}
+
+int get_modem_watchdog_state(void)
+{
+	return modem_watchdog_state;
+}
+
+static int __init modem_watchdog_control_init(void)
+{
+	pr_info("kgdb: initializing modem watchdog control module\n");
+	arch_kgdb_ops.pre_exception = modem_watchdog_disable;
+	arch_kgdb_ops.post_exception = modem_watchdog_enable;
+
+	return 0;
+}
+
+late_initcall(modem_watchdog_control_init);
diff --git a/arch/arm/mach-msm/modem_watchdog_control.h b/arch/arm/mach-msm/modem_watchdog_control.h
new file mode 100644
index 0000000..a42a350
--- /dev/null
+++ b/arch/arm/mach-msm/modem_watchdog_control.h
@@ -0,0 +1,50 @@
+#ifndef MODEM_WATCHDOG_CONTROL_H_
+#define MODEM_WATCHDOG_CONTROL_H_
+
+#include <linux/kgdb.h>
+
+/*----------------------------------------------------------------------------
+    Bits indicating watch dog state as set by remote processors
+    Copied from AMSS source codes:
+    amss/AMSS/products/7x30/core/debugtools/task/src/dog.c
+----------------------------------------------------------------------------*/
+
+/*
+ *  Remote proc is requesting dog task to resume its default state
+ */
+#define DOG_DEFAULT_STATE                       0x00000000
+
+/*
+ * Remote proc is requesting dog monitoring to be halted/enabled
+ */
+#define DOG_HALT_MONITORING                     0x00000001
+
+/* Remote proc is requesting dog task to setup/clear conditions for
+ * entering modem halt state (timer based)
+ */
+#define DOG_HALT_MODEM                          0x00000002
+
+/*
+ * Needed for pre_breakpoint and post_breakpoing hooks.
+ */
+extern struct kgdb_arch		arch_kgdb_ops;
+
+/*
+ * Sends DOG_HALT_MONITORING value to modem site causing the modem watchdog
+ * ignoring tasks timeouts while still kicking the hardware watchdog.
+ */
+extern void modem_watchdog_disable(void);
+
+/*
+ * Sends DOG_DEFAULT_STATE value to modem site causing the modem watchdog
+ * to resume its default tasks processing.
+ */
+extern void modem_watchdog_enable(void);
+
+/*
+ * Returns current status of modem watchdog.
+ */
+extern int get_modem_watchdog_state(void);
+
+
+#endif /* MODEM_WATCHDOG_CONTROL_H_ */
-- 
1.7.8.3

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

* RE: Disable modem's watchdog when kernel debugging with KGDB
  2012-03-23  9:56 Disable modem's watchdog when kernel debugging with KGDB Michal.K.Frynas
@ 2012-03-27  8:21 ` Michal.K.Frynas
       [not found] ` <4F726A88.7000908@gmail.com>
  2012-03-31  1:46 ` Bryan Huntsman
  2 siblings, 0 replies; 4+ messages in thread
From: Michal.K.Frynas @ 2012-03-27  8:21 UTC (permalink / raw)
  To: linux-arm-msm

What do you think about that patch?

Best Regards 
Michal Frynas


-----Original Message-----
From: linux-arm-msm-owner@vger.kernel.org [mailto:linux-arm-msm-owner@vger.kernel.org] On Behalf Of Michal.K.Frynas@tieto.com
Sent: 23 marca 2012 10:56
To: linux-arm-msm@vger.kernel.org
Subject: Disable modem's watchdog when kernel debugging with KGDB

Hi,

I was trying to launch KGDB kernel debugging on MSM 8255 platform.
It works now but I needed to apply a few patches. Among other things
I needed to neutralized AMSS' watchdog for the time the linux kernel
spends on breakpoint. Please have a look at the patch below with code
of a driver controlling modem's watchdog.

It might be useful for everyone willing to debug the kernel 
on Qualcomm's platform.

For it to work there's another patch needed. The patch I've posted
on KGDB mailing list: http://sourceforge.net/mailarchive/message.php?msg_id=28955742
It adds hooks for architecture specific pre and post breakpoint
handlers and invocations before and after the breakpoint.

Best Regards 
Michal Frynas


>From 077f79c950f15ba0f4af08381b16d093a17c3354 Mon Sep 17 00:00:00 2001
From: Michal Frynas <michal.frynas@tieto.com>
Date: Wed, 7 Mar 2012 12:59:28 +0100
Subject: [PATCH] KGDB: modem watchdog immunization against kernel stopping

On Qualcomm's MSM 8255 platform there are two processors running
simultaneously and synchronizing constantly with each other.
The ARM11 CPU executes Linux code while the ARM9 executes modem code.

While debugging Linux code and stopping kernel on a breakpoint
the synchronization breaks causing modem CPU to trigger hard reset.
To avoid this modem_watchdog_control driver registers pre_exception
handler where it instructs modem watchdog to ignore timing issues
from Linux side. That handler is invoked every time the kernel enters
breakpoint and then when leaving breakpoint post_exception handler is 
called restoring modem watchdog to its default behavior.

Change-Id: I8ab73b1c8edcec1fe89b0d2f2dfbd03f0a617f57
Signed-off-by: Michal Frynas <michal.k.frynas@tieto.com>
---
 arch/arm/mach-msm/Makefile                 |    2 +
 arch/arm/mach-msm/modem_watchdog_control.c |   35 +++++++++++++++++++
 arch/arm/mach-msm/modem_watchdog_control.h |   50 ++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-msm/modem_watchdog_control.c
 create mode 100644 arch/arm/mach-msm/modem_watchdog_control.h

diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 7ce284d..9984467 100755
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -208,3 +208,5 @@ endif
 obj-$(CONFIG_PMIC_TIME) += pmic_time.o
 
 obj-$(CONFIG_SEMC_MOGAMI_FELICA_SUPPORT) += semc_mogami_felica.o
+
+obj-$(CONFIG_KGDB) += modem_watchdog_control.o
diff --git a/arch/arm/mach-msm/modem_watchdog_control.c b/arch/arm/mach-msm/modem_watchdog_control.c
new file mode 100644
index 0000000..d64ae7e
--- /dev/null
+++ b/arch/arm/mach-msm/modem_watchdog_control.c
@@ -0,0 +1,35 @@
+#include <proc_comm.h>
+#include <modem_watchdog_control.h>
+
+
+static int modem_watchdog_state;
+
+void modem_watchdog_disable(void)
+{
+	pr_info("kgdb: disabling modem watchdog on breakpoint\n");
+	modem_watchdog_state = DOG_HALT_MONITORING;
+	msm_proc_comm(PCOM_SET_SW_WATCHDOG_STATE, &modem_watchdog_state, 0);
+}
+
+void modem_watchdog_enable(void)
+{
+	pr_info("kgdb: reenabling modem watchdog\n");
+	modem_watchdog_state = DOG_DEFAULT_STATE;
+	msm_proc_comm(PCOM_SET_SW_WATCHDOG_STATE, &modem_watchdog_state, 0);
+}
+
+int get_modem_watchdog_state(void)
+{
+	return modem_watchdog_state;
+}
+
+static int __init modem_watchdog_control_init(void)
+{
+	pr_info("kgdb: initializing modem watchdog control module\n");
+	arch_kgdb_ops.pre_exception = modem_watchdog_disable;
+	arch_kgdb_ops.post_exception = modem_watchdog_enable;
+
+	return 0;
+}
+
+late_initcall(modem_watchdog_control_init);
diff --git a/arch/arm/mach-msm/modem_watchdog_control.h b/arch/arm/mach-msm/modem_watchdog_control.h
new file mode 100644
index 0000000..a42a350
--- /dev/null
+++ b/arch/arm/mach-msm/modem_watchdog_control.h
@@ -0,0 +1,50 @@
+#ifndef MODEM_WATCHDOG_CONTROL_H_
+#define MODEM_WATCHDOG_CONTROL_H_
+
+#include <linux/kgdb.h>
+
+/*----------------------------------------------------------------------------
+    Bits indicating watch dog state as set by remote processors
+    Copied from AMSS source codes:
+    amss/AMSS/products/7x30/core/debugtools/task/src/dog.c
+----------------------------------------------------------------------------*/
+
+/*
+ *  Remote proc is requesting dog task to resume its default state
+ */
+#define DOG_DEFAULT_STATE                       0x00000000
+
+/*
+ * Remote proc is requesting dog monitoring to be halted/enabled
+ */
+#define DOG_HALT_MONITORING                     0x00000001
+
+/* Remote proc is requesting dog task to setup/clear conditions for
+ * entering modem halt state (timer based)
+ */
+#define DOG_HALT_MODEM                          0x00000002
+
+/*
+ * Needed for pre_breakpoint and post_breakpoing hooks.
+ */
+extern struct kgdb_arch		arch_kgdb_ops;
+
+/*
+ * Sends DOG_HALT_MONITORING value to modem site causing the modem watchdog
+ * ignoring tasks timeouts while still kicking the hardware watchdog.
+ */
+extern void modem_watchdog_disable(void);
+
+/*
+ * Sends DOG_DEFAULT_STATE value to modem site causing the modem watchdog
+ * to resume its default tasks processing.
+ */
+extern void modem_watchdog_enable(void);
+
+/*
+ * Returns current status of modem watchdog.
+ */
+extern int get_modem_watchdog_state(void);
+
+
+#endif /* MODEM_WATCHDOG_CONTROL_H_ */
-- 
1.7.8.3

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

* RE: Disable modem's watchdog when kernel debugging with KGDB
       [not found] ` <4F726A88.7000908@gmail.com>
@ 2012-03-28 10:15   ` Michal.K.Frynas
  0 siblings, 0 replies; 4+ messages in thread
From: Michal.K.Frynas @ 2012-03-28 10:15 UTC (permalink / raw)
  To: joey.jiaojg; +Cc: linux-arm-msm

Hi Joey,

Check kernel/kgdb.c. That code should be there.
It was moved to kernel/debug/debug_core.c in kernel 2.6.35: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=c433820971ffa854feda6adc17f5f24201354f11

Best Regards 
Michal Frynas


-----Original Message-----
From: joey.jiaojg [mailto:joey.jiaojg@gmail.com] 
Sent: 28 marca 2012 03:34
To: Frynas Michal K
Subject: Re: Disable modem's watchdog when kernel debugging with KGDB

Hi Michal,
I want to try you method.
But I don't have kernel/debug/debug_core.c in kernel 2.6.32 from caf.

On 2012年03月23日 17:56, Michal.K.Frynas@tieto.com wrote:
> Hi,
>
> I was trying to launch KGDB kernel debugging on MSM 8255 platform.
> It works now but I needed to apply a few patches. Among other things
> I needed to neutralized AMSS' watchdog for the time the linux kernel
> spends on breakpoint. Please have a look at the patch below with code
> of a driver controlling modem's watchdog.
>
> It might be useful for everyone willing to debug the kernel
> on Qualcomm's platform.
>
> For it to work there's another patch needed. The patch I've posted
> on KGDB mailing list: http://sourceforge.net/mailarchive/message.php?msg_id=28955742
> It adds hooks for architecture specific pre and post breakpoint
> handlers and invocations before and after the breakpoint.
>
> Best Regards
> Michal Frynas
>
>
>  From 077f79c950f15ba0f4af08381b16d093a17c3354 Mon Sep 17 00:00:00 2001
> From: Michal Frynas<michal.frynas@tieto.com>
> Date: Wed, 7 Mar 2012 12:59:28 +0100
> Subject: [PATCH] KGDB: modem watchdog immunization against kernel stopping
>
> On Qualcomm's MSM 8255 platform there are two processors running
> simultaneously and synchronizing constantly with each other.
> The ARM11 CPU executes Linux code while the ARM9 executes modem code.
>
> While debugging Linux code and stopping kernel on a breakpoint
> the synchronization breaks causing modem CPU to trigger hard reset.
> To avoid this modem_watchdog_control driver registers pre_exception
> handler where it instructs modem watchdog to ignore timing issues
> from Linux side. That handler is invoked every time the kernel enters
> breakpoint and then when leaving breakpoint post_exception handler is
> called restoring modem watchdog to its default behavior.
>
> Change-Id: I8ab73b1c8edcec1fe89b0d2f2dfbd03f0a617f57
> Signed-off-by: Michal Frynas<michal.k.frynas@tieto.com>
> ---
>   arch/arm/mach-msm/Makefile                 |    2 +
>   arch/arm/mach-msm/modem_watchdog_control.c |   35 +++++++++++++++++++
>   arch/arm/mach-msm/modem_watchdog_control.h |   50 ++++++++++++++++++++++++++++
>   3 files changed, 87 insertions(+), 0 deletions(-)
>   create mode 100644 arch/arm/mach-msm/modem_watchdog_control.c
>   create mode 100644 arch/arm/mach-msm/modem_watchdog_control.h
>
> diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
> index 7ce284d..9984467 100755
> --- a/arch/arm/mach-msm/Makefile
> +++ b/arch/arm/mach-msm/Makefile
> @@ -208,3 +208,5 @@ endif
>   obj-$(CONFIG_PMIC_TIME) += pmic_time.o
>
>   obj-$(CONFIG_SEMC_MOGAMI_FELICA_SUPPORT) += semc_mogami_felica.o
> +
> +obj-$(CONFIG_KGDB) += modem_watchdog_control.o
> diff --git a/arch/arm/mach-msm/modem_watchdog_control.c b/arch/arm/mach-msm/modem_watchdog_control.c
> new file mode 100644
> index 0000000..d64ae7e
> --- /dev/null
> +++ b/arch/arm/mach-msm/modem_watchdog_control.c
> @@ -0,0 +1,35 @@
> +#include<proc_comm.h>
> +#include<modem_watchdog_control.h>
> +
> +
> +static int modem_watchdog_state;
> +
> +void modem_watchdog_disable(void)
> +{
> +	pr_info("kgdb: disabling modem watchdog on breakpoint\n");
> +	modem_watchdog_state = DOG_HALT_MONITORING;
> +	msm_proc_comm(PCOM_SET_SW_WATCHDOG_STATE,&modem_watchdog_state, 0);
> +}
> +
> +void modem_watchdog_enable(void)
> +{
> +	pr_info("kgdb: reenabling modem watchdog\n");
> +	modem_watchdog_state = DOG_DEFAULT_STATE;
> +	msm_proc_comm(PCOM_SET_SW_WATCHDOG_STATE,&modem_watchdog_state, 0);
> +}
> +
> +int get_modem_watchdog_state(void)
> +{
> +	return modem_watchdog_state;
> +}
> +
> +static int __init modem_watchdog_control_init(void)
> +{
> +	pr_info("kgdb: initializing modem watchdog control module\n");
> +	arch_kgdb_ops.pre_exception = modem_watchdog_disable;
> +	arch_kgdb_ops.post_exception = modem_watchdog_enable;
> +
> +	return 0;
> +}
> +
> +late_initcall(modem_watchdog_control_init);
> diff --git a/arch/arm/mach-msm/modem_watchdog_control.h b/arch/arm/mach-msm/modem_watchdog_control.h
> new file mode 100644
> index 0000000..a42a350
> --- /dev/null
> +++ b/arch/arm/mach-msm/modem_watchdog_control.h
> @@ -0,0 +1,50 @@
> +#ifndef MODEM_WATCHDOG_CONTROL_H_
> +#define MODEM_WATCHDOG_CONTROL_H_
> +
> +#include<linux/kgdb.h>
> +
> +/*----------------------------------------------------------------------------
> +    Bits indicating watch dog state as set by remote processors
> +    Copied from AMSS source codes:
> +    amss/AMSS/products/7x30/core/debugtools/task/src/dog.c
> +----------------------------------------------------------------------------*/
> +
> +/*
> + *  Remote proc is requesting dog task to resume its default state
> + */
> +#define DOG_DEFAULT_STATE                       0x00000000
> +
> +/*
> + * Remote proc is requesting dog monitoring to be halted/enabled
> + */
> +#define DOG_HALT_MONITORING                     0x00000001
> +
> +/* Remote proc is requesting dog task to setup/clear conditions for
> + * entering modem halt state (timer based)
> + */
> +#define DOG_HALT_MODEM                          0x00000002
> +
> +/*
> + * Needed for pre_breakpoint and post_breakpoing hooks.
> + */
> +extern struct kgdb_arch		arch_kgdb_ops;
> +
> +/*
> + * Sends DOG_HALT_MONITORING value to modem site causing the modem watchdog
> + * ignoring tasks timeouts while still kicking the hardware watchdog.
> + */
> +extern void modem_watchdog_disable(void);
> +
> +/*
> + * Sends DOG_DEFAULT_STATE value to modem site causing the modem watchdog
> + * to resume its default tasks processing.
> + */
> +extern void modem_watchdog_enable(void);
> +
> +/*
> + * Returns current status of modem watchdog.
> + */
> +extern int get_modem_watchdog_state(void);
> +
> +
> +#endif /* MODEM_WATCHDOG_CONTROL_H_ */


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

* Re: Disable modem's watchdog when kernel debugging with KGDB
  2012-03-23  9:56 Disable modem's watchdog when kernel debugging with KGDB Michal.K.Frynas
  2012-03-27  8:21 ` Michal.K.Frynas
       [not found] ` <4F726A88.7000908@gmail.com>
@ 2012-03-31  1:46 ` Bryan Huntsman
  2 siblings, 0 replies; 4+ messages in thread
From: Bryan Huntsman @ 2012-03-31  1:46 UTC (permalink / raw)
  To: Michal.K.Frynas; +Cc: linux-arm-msm

On 03/23/2012 02:56 AM, Michal.K.Frynas@tieto.com wrote:

snip
> On Qualcomm's MSM 8255 platform there are two processors running
> simultaneously and synchronizing constantly with each other.
> The ARM11 CPU executes Linux code while the ARM9 executes modem code.

Nitpick, 8255 is a Snapdragon S2, not an ARM11.  Big difference.  ;-)

http://www.qualcomm.com/chipsets/snapdragon

snip
> +/*----------------------------------------------------------------------------
> +    Bits indicating watch dog state as set by remote processors
> +    Copied from AMSS source codes:
> +    amss/AMSS/products/7x30/core/debugtools/task/src/dog.c
> +----------------------------------------------------------------------------*/

NAK.  This patch appears to contain content copied or derived from AMSS,
which is proprietary software.  It can't be added to the Linux kernel
since the licensing terms are not compatible.  Sorry.

- Bryan

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

end of thread, other threads:[~2012-03-31  1:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-23  9:56 Disable modem's watchdog when kernel debugging with KGDB Michal.K.Frynas
2012-03-27  8:21 ` Michal.K.Frynas
     [not found] ` <4F726A88.7000908@gmail.com>
2012-03-28 10:15   ` Michal.K.Frynas
2012-03-31  1:46 ` Bryan Huntsman

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).