All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] TCO watchdog pretimeout handler
@ 2015-06-15 15:00 Francois-Nicolas Muller
  2015-06-15 18:29 ` Guenter Roeck
  0 siblings, 1 reply; 8+ messages in thread
From: Francois-Nicolas Muller @ 2015-06-15 15:00 UTC (permalink / raw)
  To: wim; +Cc: linux-watchdog, linux-kernel, Francois-Nicolas Muller

Use TCO watchdog first timeout (pretimeout) to dump CPU backtraces and ease
debug of watchdog expiration causes.
TCO logic generates a SCI interrupt, then its handler dumps all CPU backtraces
and calls panic (in order to execute registered panic callbacks).
SCI interrupt number (GPE) is configured from ACPI tables.

Change-Id: If7badb962008ff38560a02575d0d41f6aaa5f7fd
Signed-off-by: Francois-Nicolas Muller <francois-nicolas.muller@intel.com>
---
 drivers/watchdog/iTCO_wdt.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index cf8c50d..3dd4175 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -67,6 +67,8 @@
 #include <linux/io.h>			/* For inb/outb/... */
 #include <linux/mfd/core.h>
 #include <linux/mfd/lpc_ich.h>
+#include <linux/nmi.h>
+#include <linux/acpi.h>
 
 #include "iTCO_vendor.h"
 
@@ -124,6 +126,13 @@ module_param(turn_SMI_watchdog_clear_off, int, 0);
 MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
 	"Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
 
+#define DEFAULT_PRETIMEOUT 0
+static bool pretimeout = DEFAULT_PRETIMEOUT;
+module_param(pretimeout, bool, 0);
+MODULE_PARM_DESC(pretimeout,
+	"Enable watchdog pretimeout (default="
+	__MODULE_STRING(DEFAULT_PRETIMEOUT) ")");
+
 static int iTCO_wdt_active = 0;
 
 /*
@@ -200,6 +209,45 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
 	return ret; /* returns: 0 = OK, -EIO = Error */
 }
 
+static unsigned char *tco_hid = "8086229C";
+
+static u32 iTCO_wdt_pretimeout_handler(acpi_handle gpe_device, u32 gpe,
+					void *context)
+{
+	/* dump backtraces for all available cores */
+	trigger_all_cpu_backtrace();
+
+	/* call panic notifiers */
+	panic("Kernel Watchdog");
+
+	return ACPI_INTERRUPT_HANDLED;
+}
+
+static acpi_status __init iTCO_wdt_register_gpe(acpi_handle handle,
+					u32 lvl, void *context, void **rv)
+{
+	unsigned long long gpe;
+	acpi_status status;
+	union acpi_object object = { 0 };
+	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
+
+	status = acpi_evaluate_object(handle, "_GPE", NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	if (object.type != ACPI_TYPE_INTEGER)
+		return AE_BAD_DATA;
+
+	gpe = object.integer.value;
+	status = acpi_install_gpe_handler(NULL, gpe, ACPI_GPE_EDGE_TRIGGERED,
+					  iTCO_wdt_pretimeout_handler, NULL);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	acpi_enable_gpe(NULL, gpe);
+	return AE_OK;
+}
+
 static int iTCO_wdt_start(struct watchdog_device *wd_dev)
 {
 	unsigned int val;
@@ -625,6 +673,9 @@ static int __init iTCO_wdt_init_module(void)
 	if (err)
 		return err;
 
+	if (pretimeout)
+		acpi_get_devices(tco_hid, iTCO_wdt_register_gpe, NULL, NULL);
+
 	return 0;
 }
 
-- 
1.9.1


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

* Re: [PATCH] TCO watchdog pretimeout handler
  2015-06-15 15:00 [PATCH] TCO watchdog pretimeout handler Francois-Nicolas Muller
@ 2015-06-15 18:29 ` Guenter Roeck
  2015-06-16 13:45   ` [PATCH v2] " Francois-Nicolas Muller
  0 siblings, 1 reply; 8+ messages in thread
From: Guenter Roeck @ 2015-06-15 18:29 UTC (permalink / raw)
  To: Francois-Nicolas Muller; +Cc: wim, linux-watchdog, linux-kernel

On Mon, Jun 15, 2015 at 05:00:29PM +0200, Francois-Nicolas Muller wrote:
> Use TCO watchdog first timeout (pretimeout) to dump CPU backtraces and ease
> debug of watchdog expiration causes.
> TCO logic generates a SCI interrupt, then its handler dumps all CPU backtraces
> and calls panic (in order to execute registered panic callbacks).
> SCI interrupt number (GPE) is configured from ACPI tables.
> 
> Change-Id: If7badb962008ff38560a02575d0d41f6aaa5f7fd

ERROR: Remove Gerrit Change-Id's before submitting upstream.

I am unable to apply your patch to any version of the kernel
I can think of. Please rebase to the latest mainline, or at least
to a recent tag and let us know what it is based on. If it depends
on some other patch which needs to be applied first, please let us
know which one.

If I recall correctly, the iTCO watchdog can also generate an NMI.
Would it make sense to add support for handling this NMI as well ?

Some more minor comments below.

Thanks,
Guenter

> Signed-off-by: Francois-Nicolas Muller <francois-nicolas.muller@intel.com>
> ---
>  drivers/watchdog/iTCO_wdt.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
> 
> diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
> index cf8c50d..3dd4175 100644
> --- a/drivers/watchdog/iTCO_wdt.c
> +++ b/drivers/watchdog/iTCO_wdt.c
> @@ -67,6 +67,8 @@
>  #include <linux/io.h>			/* For inb/outb/... */
>  #include <linux/mfd/core.h>
>  #include <linux/mfd/lpc_ich.h>
> +#include <linux/nmi.h>
> +#include <linux/acpi.h>
>  
>  #include "iTCO_vendor.h"
>  
> @@ -124,6 +126,13 @@ module_param(turn_SMI_watchdog_clear_off, int, 0);
>  MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
>  	"Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
>  
> +#define DEFAULT_PRETIMEOUT 0
> +static bool pretimeout = DEFAULT_PRETIMEOUT;
> +module_param(pretimeout, bool, 0);
> +MODULE_PARM_DESC(pretimeout,
> +	"Enable watchdog pretimeout (default="
> +	__MODULE_STRING(DEFAULT_PRETIMEOUT) ")");
> +

CHECK: Alignment should match open parenthesis

>  static int iTCO_wdt_active = 0;
>  
>  /*
> @@ -200,6 +209,45 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
>  	return ret; /* returns: 0 = OK, -EIO = Error */
>  }
>  
> +static unsigned char *tco_hid = "8086229C";
> +
> +static u32 iTCO_wdt_pretimeout_handler(acpi_handle gpe_device, u32 gpe,
> +					void *context)

CHECK: Alignment should match open parenthesis

> +{
> +	/* dump backtraces for all available cores */
> +	trigger_all_cpu_backtrace();
> +
> +	/* call panic notifiers */
> +	panic("Kernel Watchdog");
> +
> +	return ACPI_INTERRUPT_HANDLED;
> +}
> +
> +static acpi_status __init iTCO_wdt_register_gpe(acpi_handle handle,
> +					u32 lvl, void *context, void **rv)
> +{
> +	unsigned long long gpe;
> +	acpi_status status;
> +	union acpi_object object = { 0 };
> +	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
> +
> +	status = acpi_evaluate_object(handle, "_GPE", NULL, &buffer);
> +	if (ACPI_FAILURE(status))
> +		return status;
> +
> +	if (object.type != ACPI_TYPE_INTEGER)
> +		return AE_BAD_DATA;
> +
> +	gpe = object.integer.value;
> +	status = acpi_install_gpe_handler(NULL, gpe, ACPI_GPE_EDGE_TRIGGERED,
> +					  iTCO_wdt_pretimeout_handler, NULL);
> +	if (ACPI_FAILURE(status))
> +		return status;
> +
> +	acpi_enable_gpe(NULL, gpe);
> +	return AE_OK;
> +}
> +
>  static int iTCO_wdt_start(struct watchdog_device *wd_dev)
>  {
>  	unsigned int val;
> @@ -625,6 +673,9 @@ static int __init iTCO_wdt_init_module(void)
>  	if (err)
>  		return err;
>  
> +	if (pretimeout)
> +		acpi_get_devices(tco_hid, iTCO_wdt_register_gpe, NULL, NULL);
> +
>  	return 0;
>  }
>  
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2] TCO watchdog pretimeout handler
  2015-06-15 18:29 ` Guenter Roeck
@ 2015-06-16 13:45   ` Francois-Nicolas Muller
  2015-06-17  5:14     ` Guenter Roeck
  0 siblings, 1 reply; 8+ messages in thread
From: Francois-Nicolas Muller @ 2015-06-16 13:45 UTC (permalink / raw)
  To: linux; +Cc: wim, linux-watchdog, linux-kernel, Francois-Nicolas Muller

Use TCO watchdog first timeout (pretimeout) to dump CPU backtraces
and ease debug of watchdog expiration causes.
TCO logic generates a SCI interrupt, then its handler dumps all CPU
backtraces and calls panic (in order to execute registered panic
callbacks).
SCI interrupt number (GPE) is configured from ACPI tables.

Signed-off-by: Francois-Nicolas Muller <francois-nicolas.muller@intel.com>
---
Thanks Guenter for your review.

> If I recall correctly, the iTCO watchdog can also generate an NMI.
> Would it make sense to add support for handling this NMI as well ?

As far as I know, there is no NMI option for TCO watchdog interrupt.
Do you have any documentation about this ?

Here is a new version (v2) of the patch:
- rebased on latest kernel
- fixed coding style issues

Francois-Nicolas
---
 drivers/watchdog/iTCO_wdt.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 3c3fd41..cd2569a 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -68,6 +68,8 @@
 #include <linux/io.h>			/* For inb/outb/... */
 #include <linux/mfd/core.h>
 #include <linux/mfd/lpc_ich.h>
+#include <linux/nmi.h>
+#include <linux/acpi.h>
 
 #include "iTCO_vendor.h"
 
@@ -127,6 +129,12 @@ module_param(turn_SMI_watchdog_clear_off, int, 0);
 MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
 	"Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
 
+#define DEFAULT_PRETIMEOUT 0
+static bool pretimeout = DEFAULT_PRETIMEOUT;
+module_param(pretimeout, bool, 0);
+MODULE_PARM_DESC(pretimeout, "Enable watchdog pretimeout (default="
+				__MODULE_STRING(DEFAULT_PRETIMEOUT) ")");
+
 /*
  * Some TCO specific functions
  */
@@ -201,6 +209,45 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
 	return ret; /* returns: 0 = OK, -EIO = Error */
 }
 
+static unsigned char *tco_hid = "8086229C";
+
+static u32 iTCO_wdt_pretimeout_handler(acpi_handle gpe_device, u32 gpe,
+				       void *context)
+{
+	/* dump backtraces for all available cores */
+	trigger_all_cpu_backtrace();
+
+	/* call panic notifiers */
+	panic("Kernel Watchdog");
+
+	return ACPI_INTERRUPT_HANDLED;
+}
+
+static acpi_status __init iTCO_wdt_register_gpe(acpi_handle handle,
+					u32 lvl, void *context, void **rv)
+{
+	unsigned long long gpe;
+	acpi_status status;
+	union acpi_object object = { 0 };
+	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
+
+	status = acpi_evaluate_object(handle, "_GPE", NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	if (object.type != ACPI_TYPE_INTEGER)
+		return AE_BAD_DATA;
+
+	gpe = object.integer.value;
+	status = acpi_install_gpe_handler(NULL, gpe, ACPI_GPE_EDGE_TRIGGERED,
+					  iTCO_wdt_pretimeout_handler, NULL);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	acpi_enable_gpe(NULL, gpe);
+	return AE_OK;
+}
+
 static int iTCO_wdt_start(struct watchdog_device *wd_dev)
 {
 	unsigned int val;
@@ -641,6 +688,9 @@ static int __init iTCO_wdt_init_module(void)
 	if (err)
 		return err;
 
+	if (pretimeout)
+		acpi_get_devices(tco_hid, iTCO_wdt_register_gpe, NULL, NULL);
+
 	return 0;
 }
 
-- 
1.9.1


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

* Re: [PATCH v2] TCO watchdog pretimeout handler
  2015-06-16 13:45   ` [PATCH v2] " Francois-Nicolas Muller
@ 2015-06-17  5:14     ` Guenter Roeck
  2015-06-17 13:34       ` [PATCH v3] " Francois-Nicolas Muller
  0 siblings, 1 reply; 8+ messages in thread
From: Guenter Roeck @ 2015-06-17  5:14 UTC (permalink / raw)
  To: Francois-Nicolas Muller; +Cc: wim, linux-watchdog, linux-kernel

On 06/16/2015 06:45 AM, Francois-Nicolas Muller wrote:
> Use TCO watchdog first timeout (pretimeout) to dump CPU backtraces
> and ease debug of watchdog expiration causes.
> TCO logic generates a SCI interrupt, then its handler dumps all CPU
> backtraces and calls panic (in order to execute registered panic
> callbacks).
> SCI interrupt number (GPE) is configured from ACPI tables.
>
> Signed-off-by: Francois-Nicolas Muller <francois-nicolas.muller@intel.com>
> ---
> Thanks Guenter for your review.
>
>> If I recall correctly, the iTCO watchdog can also generate an NMI.
>> Would it make sense to add support for handling this NMI as well ?
>
> As far as I know, there is no NMI option for TCO watchdog interrupt.
> Do you have any documentation about this ?
>

Actually that was a miscommunication, sorry. I confused it waith another watchdog.

I assume you took out all mention of SMI because it is not (yet) supported.
Would be interesting to know what systems out there actually use / configure.

  Here is a new version (v2) of the patch:
> - rebased on latest kernel
> - fixed coding style issues
>
> Francois-Nicolas
> ---
>   drivers/watchdog/iTCO_wdt.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 50 insertions(+)
>
> diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
> index 3c3fd41..cd2569a 100644
> --- a/drivers/watchdog/iTCO_wdt.c
> +++ b/drivers/watchdog/iTCO_wdt.c
> @@ -68,6 +68,8 @@
>   #include <linux/io.h>			/* For inb/outb/... */
>   #include <linux/mfd/core.h>
>   #include <linux/mfd/lpc_ich.h>
> +#include <linux/nmi.h>
> +#include <linux/acpi.h>
>
>   #include "iTCO_vendor.h"
>
> @@ -127,6 +129,12 @@ module_param(turn_SMI_watchdog_clear_off, int, 0);
>   MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
>   	"Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
>
> +#define DEFAULT_PRETIMEOUT 0
> +static bool pretimeout = DEFAULT_PRETIMEOUT;
> +module_param(pretimeout, bool, 0);
> +MODULE_PARM_DESC(pretimeout, "Enable watchdog pretimeout (default="
> +				__MODULE_STRING(DEFAULT_PRETIMEOUT) ")");
> +
>   /*
>    * Some TCO specific functions
>    */
> @@ -201,6 +209,45 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
>   	return ret; /* returns: 0 = OK, -EIO = Error */
>   }
>
> +static unsigned char *tco_hid = "8086229C";
> +

Do people understand what this means ? Is that some Intel magic string ?
Does this work for all instances of iTCO watchdogs, or only for a specific
system or iTCO version ?

Rafael asked this question as well, but I don't recall seeing an answer.

I see that it maps to a PCI ID for Intel Braswell, but I have no idea
how that translates to something useful for ACPI. Is this a well defined
(and allocated) ACPI HID ? How about other chips (non-Braswell)
which are supported by this driver ?

> +static u32 iTCO_wdt_pretimeout_handler(acpi_handle gpe_device, u32 gpe,
> +				       void *context)
> +{
> +	/* dump backtraces for all available cores */
> +	trigger_all_cpu_backtrace();
> +
> +	/* call panic notifiers */
> +	panic("Kernel Watchdog");
> +
> +	return ACPI_INTERRUPT_HANDLED;
> +}
> +
> +static acpi_status __init iTCO_wdt_register_gpe(acpi_handle handle,
> +					u32 lvl, void *context, void **rv)
> +{
> +	unsigned long long gpe;
> +	acpi_status status;
> +	union acpi_object object = { 0 };
> +	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
> +
> +	status = acpi_evaluate_object(handle, "_GPE", NULL, &buffer);
> +	if (ACPI_FAILURE(status))
> +		return status;
> +
> +	if (object.type != ACPI_TYPE_INTEGER)
> +		return AE_BAD_DATA;
> +
> +	gpe = object.integer.value;
> +	status = acpi_install_gpe_handler(NULL, gpe, ACPI_GPE_EDGE_TRIGGERED,
> +					  iTCO_wdt_pretimeout_handler, NULL);

Do we know for sure that _GPE is always associated with the watchdog ?
Is that because of tco_hid ?

Thanks,
Guenter

> +	if (ACPI_FAILURE(status))
> +		return status;
> +
> +	acpi_enable_gpe(NULL, gpe);
> +	return AE_OK;
> +}
> +
>   static int iTCO_wdt_start(struct watchdog_device *wd_dev)
>   {
>   	unsigned int val;
> @@ -641,6 +688,9 @@ static int __init iTCO_wdt_init_module(void)
>   	if (err)
>   		return err;
>
> +	if (pretimeout)
> +		acpi_get_devices(tco_hid, iTCO_wdt_register_gpe, NULL, NULL);
> +
>   	return 0;
>   }
>
>


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

* [PATCH v3] TCO watchdog pretimeout handler
  2015-06-17  5:14     ` Guenter Roeck
@ 2015-06-17 13:34       ` Francois-Nicolas Muller
  2015-06-17 16:06         ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Francois-Nicolas Muller @ 2015-06-17 13:34 UTC (permalink / raw)
  To: linux; +Cc: wim, linux-watchdog, linux-kernel, Francois-Nicolas Muller

Use TCO watchdog first timeout (pretimeout) to dump CPU backtraces
and ease debug of watchdog expiration causes.
On Intel Cherrytrail, TCO logic generates a SMI, then SMI handler
triggers a SCI to the kernel, on a specific GPE.
The GPE handler dumps all CPU backtraces and calls panic (in order
to execute registered panic callbacks).
GPE number is configured from ACPI tables if LPC HID exists.

Signed-off-by: Francois-Nicolas Muller <francois-nicolas.muller@intel.com>
---
SMI is not supported by the driver, only SCI.

On Intel Cherrytrail, TCO watchdog raises an SMI, then the SMI handler
in Bios trigs a SCI to the kernel (in Android OS configuration).

The patch has some effect only on Cherrytrail platform.
On Braswell, the TCO HID exists in ACPI tables, so SCI is configured. But
the SMI handler does not trig the SCI.
On other platforms, the HID does not exist in ACPI tables, and the SMI
handler does not trig the SCI.

In ACPI tables, _GPE is associated to this HID, so no possible confusion.

François-Nicolas
---
 drivers/watchdog/iTCO_wdt.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index 3c3fd41..3e9ec8b 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -68,6 +68,8 @@
 #include <linux/io.h>			/* For inb/outb/... */
 #include <linux/mfd/core.h>
 #include <linux/mfd/lpc_ich.h>
+#include <linux/nmi.h>
+#include <linux/acpi.h>
 
 #include "iTCO_vendor.h"
 
@@ -127,6 +129,12 @@ module_param(turn_SMI_watchdog_clear_off, int, 0);
 MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
 	"Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
 
+#define DEFAULT_PRETIMEOUT 0
+static bool pretimeout = DEFAULT_PRETIMEOUT;
+module_param(pretimeout, bool, 0);
+MODULE_PARM_DESC(pretimeout, "Enable watchdog pretimeout (default="
+				__MODULE_STRING(DEFAULT_PRETIMEOUT) ")");
+
 /*
  * Some TCO specific functions
  */
@@ -201,6 +209,45 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
 	return ret; /* returns: 0 = OK, -EIO = Error */
 }
 
+static unsigned char *tco_hid = "8086229C"; /* Intel Cherrytrail LPC */
+
+static u32 iTCO_wdt_pretimeout_handler(acpi_handle gpe_device, u32 gpe,
+				       void *context)
+{
+	/* dump backtraces for all available cores */
+	trigger_all_cpu_backtrace();
+
+	/* call panic notifiers */
+	panic("Kernel Watchdog");
+
+	return ACPI_INTERRUPT_HANDLED;
+}
+
+static acpi_status __init iTCO_wdt_register_gpe(acpi_handle handle,
+					u32 lvl, void *context, void **rv)
+{
+	unsigned long long gpe;
+	acpi_status status;
+	union acpi_object object = { 0 };
+	struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
+
+	status = acpi_evaluate_object(handle, "_GPE", NULL, &buffer);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	if (object.type != ACPI_TYPE_INTEGER)
+		return AE_BAD_DATA;
+
+	gpe = object.integer.value;
+	status = acpi_install_gpe_handler(NULL, gpe, ACPI_GPE_EDGE_TRIGGERED,
+					  iTCO_wdt_pretimeout_handler, NULL);
+	if (ACPI_FAILURE(status))
+		return status;
+
+	acpi_enable_gpe(NULL, gpe);
+	return AE_OK;
+}
+
 static int iTCO_wdt_start(struct watchdog_device *wd_dev)
 {
 	unsigned int val;
@@ -641,6 +688,9 @@ static int __init iTCO_wdt_init_module(void)
 	if (err)
 		return err;
 
+	if (pretimeout)
+		acpi_get_devices(tco_hid, iTCO_wdt_register_gpe, NULL, NULL);
+
 	return 0;
 }
 
-- 
1.9.1


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

* Re: [PATCH v3] TCO watchdog pretimeout handler
  2015-06-17 13:34       ` [PATCH v3] " Francois-Nicolas Muller
@ 2015-06-17 16:06         ` Andy Shevchenko
  2015-06-18 12:41             ` Muller, Francois-nicolas
  0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2015-06-17 16:06 UTC (permalink / raw)
  To: Francois-Nicolas Muller
  Cc: linux, wim, linux-watchdog, linux-kernel@vger.kernel.org

On Wed, Jun 17, 2015 at 4:34 PM, Francois-Nicolas Muller
<francois-nicolas.muller@intel.com> wrote:

First of all it would be nice to start a new thread per iteration.

> Use TCO watchdog first timeout (pretimeout) to dump CPU backtraces
> and ease debug of watchdog expiration causes.
> On Intel Cherrytrail, TCO logic generates a SMI, then SMI handler
> triggers a SCI to the kernel, on a specific GPE.
> The GPE handler dumps all CPU backtraces and calls panic (in order
> to execute registered panic callbacks).
> GPE number is configured from ACPI tables if LPC HID exists.
>
> Signed-off-by: Francois-Nicolas Muller <francois-nicolas.muller@intel.com>
> ---
> SMI is not supported by the driver, only SCI.
>
> On Intel Cherrytrail, TCO watchdog raises an SMI, then the SMI handler
> in Bios trigs a SCI to the kernel (in Android OS configuration).
>
> The patch has some effect only on Cherrytrail platform.
> On Braswell, the TCO HID exists in ACPI tables, so SCI is configured. But
> the SMI handler does not trig the SCI.
> On other platforms, the HID does not exist in ACPI tables, and the SMI
> handler does not trig the SCI.
>
> In ACPI tables, _GPE is associated to this HID, so no possible confusion.
>
> François-Nicolas
> ---
>  drivers/watchdog/iTCO_wdt.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
>
> diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
> index 3c3fd41..3e9ec8b 100644
> --- a/drivers/watchdog/iTCO_wdt.c
> +++ b/drivers/watchdog/iTCO_wdt.c
> @@ -68,6 +68,8 @@
>  #include <linux/io.h>                  /* For inb/outb/... */
>  #include <linux/mfd/core.h>
>  #include <linux/mfd/lpc_ich.h>
> +#include <linux/nmi.h>
> +#include <linux/acpi.h>
>
>  #include "iTCO_vendor.h"
>
> @@ -127,6 +129,12 @@ module_param(turn_SMI_watchdog_clear_off, int, 0);
>  MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
>         "Turn off SMI clearing watchdog (depends on TCO-version)(default=1)");
>
> +#define DEFAULT_PRETIMEOUT 0
> +static bool pretimeout = DEFAULT_PRETIMEOUT;

Static variables should not be assigned to zero explicitly (it doesn't
make sense).
Moreover you have integer -> boolean implicit conversion.

> +module_param(pretimeout, bool, 0);
> +MODULE_PARM_DESC(pretimeout, "Enable watchdog pretimeout (default="
> +                               __MODULE_STRING(DEFAULT_PRETIMEOUT) ")");

Since it's boolean, I suppose to use direct value here. It would be one line.

> +
>  /*
>   * Some TCO specific functions
>   */
> @@ -201,6 +209,45 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
>         return ret; /* returns: 0 = OK, -EIO = Error */
>  }
>

The below should go under CONFIG_ACPI.

> +static unsigned char *tco_hid = "8086229C"; /* Intel Cherrytrail LPC */

Why not to use acpi_device_id ?

> +
> +static u32 iTCO_wdt_pretimeout_handler(acpi_handle gpe_device, u32 gpe,
> +                                      void *context)
> +{
> +       /* dump backtraces for all available cores */
> +       trigger_all_cpu_backtrace();
> +
> +       /* call panic notifiers */
> +       panic("Kernel Watchdog");
> +
> +       return ACPI_INTERRUPT_HANDLED;
> +}
> +
> +static acpi_status __init iTCO_wdt_register_gpe(acpi_handle handle,
> +                                       u32 lvl, void *context, void **rv)
> +{
> +       unsigned long long gpe;
> +       acpi_status status;
> +       union acpi_object object = { 0 };
> +       struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
> +
> +       status = acpi_evaluate_object(handle, "_GPE", NULL, &buffer);
> +       if (ACPI_FAILURE(status))
> +               return status;
> +
> +       if (object.type != ACPI_TYPE_INTEGER)
> +               return AE_BAD_DATA;

Do we really need this right now? Existing users of _GPE are
considering the result as integer w/o an additional check.

> +
> +       gpe = object.integer.value;
> +       status = acpi_install_gpe_handler(NULL, gpe, ACPI_GPE_EDGE_TRIGGERED,
> +                                         iTCO_wdt_pretimeout_handler, NULL);

> +       if (ACPI_FAILURE(status))
> +               return status;
> +
> +       acpi_enable_gpe(NULL, gpe);
> +       return AE_OK;
> +}
> +
>  static int iTCO_wdt_start(struct watchdog_device *wd_dev)
>  {
>         unsigned int val;
> @@ -641,6 +688,9 @@ static int __init iTCO_wdt_init_module(void)
>         if (err)
>                 return err;
>
> +       if (pretimeout)
> +               acpi_get_devices(tco_hid, iTCO_wdt_register_gpe, NULL, NULL);
> +
>         return 0;
>  }
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko

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

* RE: [PATCH v3] TCO watchdog pretimeout handler
  2015-06-17 16:06         ` Andy Shevchenko
@ 2015-06-18 12:41             ` Muller, Francois-nicolas
  0 siblings, 0 replies; 8+ messages in thread
From: Muller, Francois-nicolas @ 2015-06-18 12:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux@roeck-us.net, wim@iguana.be, linux-watchdog@vger.kernel.org,
	linux-kernel@vger.kernel.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 6639 bytes --]

On Wed, June 17, 2015 6:06 PM, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Wed, Jun 17, 2015 at 4:34 PM, Francois-Nicolas Muller <francois-nicolas.muller@intel.com> wrote:
>
>> +#define DEFAULT_PRETIMEOUT 0
>> +static bool pretimeout = DEFAULT_PRETIMEOUT;
>
> Static variables should not be assigned to zero explicitly (it doesn't make sense).
> Moreover you have integer -> boolean implicit conversion.

Agree, I will remove the DEFAULT_PRETIMEOUT define.

> The below should go under CONFIG_ACPI.
>
>> +static unsigned char *tco_hid = "8086229C"; /* Intel Cherrytrail LPC 
>> +*/

This codes also compiles with CONFIG_ACPI not defined, #if CONFIG_ACPI is not required here.

>> +static unsigned char *tco_hid = "8086229C"; /* Intel Cherrytrail LPC 
>> +*/
>
> Why not to use acpi_device_id ?

As long as there is only one id, I think this is not required.
Anyway I will use acpi_device_id instead to be prepared for future ids.

>> +       if (object.type != ACPI_TYPE_INTEGER)
>> +               return AE_BAD_DATA;
>
> Do we really need this right now? Existing users of _GPE are considering the result as integer w/o an additional check.

Right, as this is already done elsewhere without the check, I will remove it.
 
Thanks,
Francois-Nicolas

-----Original Message-----
From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com] 
Sent: Wednesday, June 17, 2015 6:06 PM
To: Muller, Francois-nicolas
Cc: linux@roeck-us.net; wim@iguana.be; linux-watchdog@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] TCO watchdog pretimeout handler

On Wed, Jun 17, 2015 at 4:34 PM, Francois-Nicolas Muller <francois-nicolas.muller@intel.com> wrote:

First of all it would be nice to start a new thread per iteration.

> Use TCO watchdog first timeout (pretimeout) to dump CPU backtraces and 
> ease debug of watchdog expiration causes.
> On Intel Cherrytrail, TCO logic generates a SMI, then SMI handler 
> triggers a SCI to the kernel, on a specific GPE.
> The GPE handler dumps all CPU backtraces and calls panic (in order to 
> execute registered panic callbacks).
> GPE number is configured from ACPI tables if LPC HID exists.
>
> Signed-off-by: Francois-Nicolas Muller 
> <francois-nicolas.muller@intel.com>
> ---
> SMI is not supported by the driver, only SCI.
>
> On Intel Cherrytrail, TCO watchdog raises an SMI, then the SMI handler 
> in Bios trigs a SCI to the kernel (in Android OS configuration).
>
> The patch has some effect only on Cherrytrail platform.
> On Braswell, the TCO HID exists in ACPI tables, so SCI is configured. 
> But the SMI handler does not trig the SCI.
> On other platforms, the HID does not exist in ACPI tables, and the SMI 
> handler does not trig the SCI.
>
> In ACPI tables, _GPE is associated to this HID, so no possible confusion.
>
> François-Nicolas
> ---
>  drivers/watchdog/iTCO_wdt.c | 50 
> +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
>
> diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c 
> index 3c3fd41..3e9ec8b 100644
> --- a/drivers/watchdog/iTCO_wdt.c
> +++ b/drivers/watchdog/iTCO_wdt.c
> @@ -68,6 +68,8 @@
>  #include <linux/io.h>                  /* For inb/outb/... */
>  #include <linux/mfd/core.h>
>  #include <linux/mfd/lpc_ich.h>
> +#include <linux/nmi.h>
> +#include <linux/acpi.h>
>
>  #include "iTCO_vendor.h"
>
> @@ -127,6 +129,12 @@ module_param(turn_SMI_watchdog_clear_off, int, 
> 0);  MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
>         "Turn off SMI clearing watchdog (depends on 
> TCO-version)(default=1)");
>
> +#define DEFAULT_PRETIMEOUT 0
> +static bool pretimeout = DEFAULT_PRETIMEOUT;

Static variables should not be assigned to zero explicitly (it doesn't make sense).
Moreover you have integer -> boolean implicit conversion.

> +module_param(pretimeout, bool, 0);
> +MODULE_PARM_DESC(pretimeout, "Enable watchdog pretimeout (default="
> +                               __MODULE_STRING(DEFAULT_PRETIMEOUT) 
> +")");

Since it's boolean, I suppose to use direct value here. It would be one line.

> +
>  /*
>   * Some TCO specific functions
>   */
> @@ -201,6 +209,45 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
>         return ret; /* returns: 0 = OK, -EIO = Error */  }
>

The below should go under CONFIG_ACPI.

> +static unsigned char *tco_hid = "8086229C"; /* Intel Cherrytrail LPC 
> +*/

Why not to use acpi_device_id ?

> +
> +static u32 iTCO_wdt_pretimeout_handler(acpi_handle gpe_device, u32 gpe,
> +                                      void *context) {
> +       /* dump backtraces for all available cores */
> +       trigger_all_cpu_backtrace();
> +
> +       /* call panic notifiers */
> +       panic("Kernel Watchdog");
> +
> +       return ACPI_INTERRUPT_HANDLED; }
> +
> +static acpi_status __init iTCO_wdt_register_gpe(acpi_handle handle,
> +                                       u32 lvl, void *context, void 
> +**rv) {
> +       unsigned long long gpe;
> +       acpi_status status;
> +       union acpi_object object = { 0 };
> +       struct acpi_buffer buffer = { sizeof(union acpi_object), 
> +&object };
> +
> +       status = acpi_evaluate_object(handle, "_GPE", NULL, &buffer);
> +       if (ACPI_FAILURE(status))
> +               return status;
> +
> +       if (object.type != ACPI_TYPE_INTEGER)
> +               return AE_BAD_DATA;

Do we really need this right now? Existing users of _GPE are considering the result as integer w/o an additional check.

> +
> +       gpe = object.integer.value;
> +       status = acpi_install_gpe_handler(NULL, gpe, ACPI_GPE_EDGE_TRIGGERED,
> +                                         iTCO_wdt_pretimeout_handler, 
> + NULL);

> +       if (ACPI_FAILURE(status))
> +               return status;
> +
> +       acpi_enable_gpe(NULL, gpe);
> +       return AE_OK;
> +}
> +
>  static int iTCO_wdt_start(struct watchdog_device *wd_dev)  {
>         unsigned int val;
> @@ -641,6 +688,9 @@ static int __init iTCO_wdt_init_module(void)
>         if (err)
>                 return err;
>
> +       if (pretimeout)
> +               acpi_get_devices(tco_hid, iTCO_wdt_register_gpe, NULL, 
> + NULL);
> +
>         return 0;
>  }
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in the body of a message to majordomo@vger.kernel.org 
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



--
With Best Regards,
Andy Shevchenko
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* RE: [PATCH v3] TCO watchdog pretimeout handler
@ 2015-06-18 12:41             ` Muller, Francois-nicolas
  0 siblings, 0 replies; 8+ messages in thread
From: Muller, Francois-nicolas @ 2015-06-18 12:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux@roeck-us.net, wim@iguana.be, linux-watchdog@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, June 17, 2015 6:06 PM, Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Wed, Jun 17, 2015 at 4:34 PM, Francois-Nicolas Muller <francois-nicolas.muller@intel.com> wrote:
>
>> +#define DEFAULT_PRETIMEOUT 0
>> +static bool pretimeout = DEFAULT_PRETIMEOUT;
>
> Static variables should not be assigned to zero explicitly (it doesn't make sense).
> Moreover you have integer -> boolean implicit conversion.

Agree, I will remove the DEFAULT_PRETIMEOUT define.

> The below should go under CONFIG_ACPI.
>
>> +static unsigned char *tco_hid = "8086229C"; /* Intel Cherrytrail LPC 
>> +*/

This codes also compiles with CONFIG_ACPI not defined, #if CONFIG_ACPI is not required here.

>> +static unsigned char *tco_hid = "8086229C"; /* Intel Cherrytrail LPC 
>> +*/
>
> Why not to use acpi_device_id ?

As long as there is only one id, I think this is not required.
Anyway I will use acpi_device_id instead to be prepared for future ids.

>> +       if (object.type != ACPI_TYPE_INTEGER)
>> +               return AE_BAD_DATA;
>
> Do we really need this right now? Existing users of _GPE are considering the result as integer w/o an additional check.

Right, as this is already done elsewhere without the check, I will remove it.
 
Thanks,
Francois-Nicolas

-----Original Message-----
From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com] 
Sent: Wednesday, June 17, 2015 6:06 PM
To: Muller, Francois-nicolas
Cc: linux@roeck-us.net; wim@iguana.be; linux-watchdog@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] TCO watchdog pretimeout handler

On Wed, Jun 17, 2015 at 4:34 PM, Francois-Nicolas Muller <francois-nicolas.muller@intel.com> wrote:

First of all it would be nice to start a new thread per iteration.

> Use TCO watchdog first timeout (pretimeout) to dump CPU backtraces and 
> ease debug of watchdog expiration causes.
> On Intel Cherrytrail, TCO logic generates a SMI, then SMI handler 
> triggers a SCI to the kernel, on a specific GPE.
> The GPE handler dumps all CPU backtraces and calls panic (in order to 
> execute registered panic callbacks).
> GPE number is configured from ACPI tables if LPC HID exists.
>
> Signed-off-by: Francois-Nicolas Muller 
> <francois-nicolas.muller@intel.com>
> ---
> SMI is not supported by the driver, only SCI.
>
> On Intel Cherrytrail, TCO watchdog raises an SMI, then the SMI handler 
> in Bios trigs a SCI to the kernel (in Android OS configuration).
>
> The patch has some effect only on Cherrytrail platform.
> On Braswell, the TCO HID exists in ACPI tables, so SCI is configured. 
> But the SMI handler does not trig the SCI.
> On other platforms, the HID does not exist in ACPI tables, and the SMI 
> handler does not trig the SCI.
>
> In ACPI tables, _GPE is associated to this HID, so no possible confusion.
>
> François-Nicolas
> ---
>  drivers/watchdog/iTCO_wdt.c | 50 
> +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
>
> diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c 
> index 3c3fd41..3e9ec8b 100644
> --- a/drivers/watchdog/iTCO_wdt.c
> +++ b/drivers/watchdog/iTCO_wdt.c
> @@ -68,6 +68,8 @@
>  #include <linux/io.h>                  /* For inb/outb/... */
>  #include <linux/mfd/core.h>
>  #include <linux/mfd/lpc_ich.h>
> +#include <linux/nmi.h>
> +#include <linux/acpi.h>
>
>  #include "iTCO_vendor.h"
>
> @@ -127,6 +129,12 @@ module_param(turn_SMI_watchdog_clear_off, int, 
> 0);  MODULE_PARM_DESC(turn_SMI_watchdog_clear_off,
>         "Turn off SMI clearing watchdog (depends on 
> TCO-version)(default=1)");
>
> +#define DEFAULT_PRETIMEOUT 0
> +static bool pretimeout = DEFAULT_PRETIMEOUT;

Static variables should not be assigned to zero explicitly (it doesn't make sense).
Moreover you have integer -> boolean implicit conversion.

> +module_param(pretimeout, bool, 0);
> +MODULE_PARM_DESC(pretimeout, "Enable watchdog pretimeout (default="
> +                               __MODULE_STRING(DEFAULT_PRETIMEOUT) 
> +")");

Since it's boolean, I suppose to use direct value here. It would be one line.

> +
>  /*
>   * Some TCO specific functions
>   */
> @@ -201,6 +209,45 @@ static int iTCO_wdt_unset_NO_REBOOT_bit(void)
>         return ret; /* returns: 0 = OK, -EIO = Error */  }
>

The below should go under CONFIG_ACPI.

> +static unsigned char *tco_hid = "8086229C"; /* Intel Cherrytrail LPC 
> +*/

Why not to use acpi_device_id ?

> +
> +static u32 iTCO_wdt_pretimeout_handler(acpi_handle gpe_device, u32 gpe,
> +                                      void *context) {
> +       /* dump backtraces for all available cores */
> +       trigger_all_cpu_backtrace();
> +
> +       /* call panic notifiers */
> +       panic("Kernel Watchdog");
> +
> +       return ACPI_INTERRUPT_HANDLED; }
> +
> +static acpi_status __init iTCO_wdt_register_gpe(acpi_handle handle,
> +                                       u32 lvl, void *context, void 
> +**rv) {
> +       unsigned long long gpe;
> +       acpi_status status;
> +       union acpi_object object = { 0 };
> +       struct acpi_buffer buffer = { sizeof(union acpi_object), 
> +&object };
> +
> +       status = acpi_evaluate_object(handle, "_GPE", NULL, &buffer);
> +       if (ACPI_FAILURE(status))
> +               return status;
> +
> +       if (object.type != ACPI_TYPE_INTEGER)
> +               return AE_BAD_DATA;

Do we really need this right now? Existing users of _GPE are considering the result as integer w/o an additional check.

> +
> +       gpe = object.integer.value;
> +       status = acpi_install_gpe_handler(NULL, gpe, ACPI_GPE_EDGE_TRIGGERED,
> +                                         iTCO_wdt_pretimeout_handler, 
> + NULL);

> +       if (ACPI_FAILURE(status))
> +               return status;
> +
> +       acpi_enable_gpe(NULL, gpe);
> +       return AE_OK;
> +}
> +
>  static int iTCO_wdt_start(struct watchdog_device *wd_dev)  {
>         unsigned int val;
> @@ -641,6 +688,9 @@ static int __init iTCO_wdt_init_module(void)
>         if (err)
>                 return err;
>
> +       if (pretimeout)
> +               acpi_get_devices(tco_hid, iTCO_wdt_register_gpe, NULL, 
> + NULL);
> +
>         return 0;
>  }
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in the body of a message to majordomo@vger.kernel.org 
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



--
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2015-06-18 12:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15 15:00 [PATCH] TCO watchdog pretimeout handler Francois-Nicolas Muller
2015-06-15 18:29 ` Guenter Roeck
2015-06-16 13:45   ` [PATCH v2] " Francois-Nicolas Muller
2015-06-17  5:14     ` Guenter Roeck
2015-06-17 13:34       ` [PATCH v3] " Francois-Nicolas Muller
2015-06-17 16:06         ` Andy Shevchenko
2015-06-18 12:41           ` Muller, Francois-nicolas
2015-06-18 12:41             ` Muller, Francois-nicolas

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.