* [PATCH 01/12 v2] staging: mei: removing dependency between WD and AMTHI init function.
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 02/12 v2] staging: mei: fix register access function comments Oren Weil
` (10 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
AMTHI need to be initialized after WD Client was initialized, moving the AMTHI outside
of the WD initialization function.
in order to remove the coupling between the initialization of those clients.
AMTHI is getting initialized (getting connected to the FW feature/client) in two ways:
1) if mei driver fails to send connect message to watchdog client (WD initialization), then
immediately the AMTHI client getting initialized right after the watchdog initialization function.
2) if Watchdog client success to send connect message to watchdog client, then only after
the driver is getting the connect response message the AMTHI client is getting initialized
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/init.c | 8 +++++++-
drivers/staging/mei/interface.h | 2 +-
drivers/staging/mei/wd.c | 16 ++++++++++++----
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c
index 0fa8216..69a57e7 100644
--- a/drivers/staging/mei/init.c
+++ b/drivers/staging/mei/init.c
@@ -521,7 +521,13 @@ void mei_host_client_properties(struct mei_device *dev)
bitmap_set(dev->host_clients_map, 0, 3);
dev->mei_state = MEI_ENABLED;
- mei_wd_host_init(dev);
+ /* if wd initialization fails, initialization the AMTHI client,
+ * otherwise the AMTHI client will be initialized after the WD client connect response
+ * will be received
+ */
+ if (mei_wd_host_init(dev))
+ mei_host_init_iamthif(dev);
+
return;
}
diff --git a/drivers/staging/mei/interface.h b/drivers/staging/mei/interface.h
index d0bf5cf..7bcf096 100644
--- a/drivers/staging/mei/interface.h
+++ b/drivers/staging/mei/interface.h
@@ -48,7 +48,7 @@ int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
int mei_wd_send(struct mei_device *dev);
int mei_wd_stop(struct mei_device *dev, bool preserve);
-void mei_wd_host_init(struct mei_device *dev);
+bool mei_wd_host_init(struct mei_device *dev);
void mei_wd_start_setup(struct mei_device *dev);
int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl);
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index 42f04ef..721487d 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -63,8 +63,10 @@ void mei_wd_start_setup(struct mei_device *dev)
*
* @dev: the device structure
*/
-void mei_wd_host_init(struct mei_device *dev)
+bool mei_wd_host_init(struct mei_device *dev)
{
+ bool ret = false;
+
mei_cl_init(&dev->wd_cl, dev);
/* look for WD client and connect to it */
@@ -83,19 +85,25 @@ void mei_wd_host_init(struct mei_device *dev)
dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n");
dev->wd_cl.state = MEI_FILE_DISCONNECTED;
dev->wd_cl.host_client_id = 0;
- mei_host_init_iamthif(dev) ;
+ ret = false;
+ goto end;
} else {
dev->wd_cl.timer_count = CONNECT_TIMEOUT;
}
} else {
dev_dbg(&dev->pdev->dev, "Failed to find WD client\n");
- mei_host_init_iamthif(dev) ;
+ ret = false;
+ goto end;
}
} else {
dev->wd_bypass = true;
dev_dbg(&dev->pdev->dev, "WD requested to be disabled\n");
- mei_host_init_iamthif(dev) ;
+ ret = false;
+ goto end;
}
+
+end:
+ return ret;
}
/**
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 02/12 v2] staging: mei: fix register access function comments
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
2011-09-07 6:03 ` [PATCH 01/12 v2] staging: mei: removing dependency between WD and AMTHI init function Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 03/12 v2] staging: mei: registering the MEI driver with the kernel watchdog core interface Oren Weil
` (9 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/mei_dev.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h
index d7bc10c..2e11077 100644
--- a/drivers/staging/mei/mei_dev.h
+++ b/drivers/staging/mei/mei_dev.h
@@ -356,7 +356,7 @@ int mei_find_me_client_index(const struct mei_device *dev, uuid_le cuuid);
* @dev: the device structure
* @offset: offset from which to read the data
*
- * returns the byte read.
+ * returns register value (u32)
*/
static inline u32 mei_reg_read(struct mei_device *dev, unsigned long offset)
{
@@ -368,7 +368,7 @@ static inline u32 mei_reg_read(struct mei_device *dev, unsigned long offset)
*
* @dev: the device structure
* @offset: offset from which to write the data
- * @value: the byte to write
+ * @value: register value to write (u32)
*/
static inline void mei_reg_write(struct mei_device *dev,
unsigned long offset, u32 value)
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 03/12 v2] staging: mei: registering the MEI driver with the kernel watchdog core interface
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
2011-09-07 6:03 ` [PATCH 01/12 v2] staging: mei: removing dependency between WD and AMTHI init function Oren Weil
2011-09-07 6:03 ` [PATCH 02/12 v2] staging: mei: fix register access function comments Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 04/12 v2] staging: mei: adding watchdog ops Oren Weil
` (8 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
Adding kernel watchdog interface (/dev/watchdog) to the MEI Driver to support AMT Watchdog feature.
This patch and the following one will replace MEI Driver self management of the AMT watchdog
with the standard kernel watchdog interface.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/init.c | 1 +
drivers/staging/mei/interface.h | 4 +++-
drivers/staging/mei/interrupt.c | 12 ++++++++++++
drivers/staging/mei/main.c | 4 ++++
drivers/staging/mei/mei_dev.h | 9 +++++++++
drivers/staging/mei/wd.c | 20 ++++++++++++++++++--
6 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/mei/init.c b/drivers/staging/mei/init.c
index 69a57e7..cb0ebbe 100644
--- a/drivers/staging/mei/init.c
+++ b/drivers/staging/mei/init.c
@@ -133,6 +133,7 @@ struct mei_device *mei_device_init(struct pci_dev *pdev)
init_waitqueue_head(&dev->wait_stop_wd);
dev->mei_state = MEI_INITIALIZING;
dev->iamthif_state = MEI_IAMTHIF_IDLE;
+ dev->wd_interface_reg = false;
mei_io_list_init(&dev->read_list);
diff --git a/drivers/staging/mei/interface.h b/drivers/staging/mei/interface.h
index 7bcf096..2b5a22c 100644
--- a/drivers/staging/mei/interface.h
+++ b/drivers/staging/mei/interface.h
@@ -23,7 +23,9 @@
#include "mei_dev.h"
-#define AMT_WD_VALUE 120 /* seconds */
+#define AMT_WD_DEFAULT_TIMEOUT 120 /* seconds */
+#define AMT_WD_MIN_TIMEOUT 120 /* seconds */
+#define AMT_WD_MAX_TIMEOUT 65535 /* seconds */
#define MEI_WATCHDOG_DATA_SIZE 16
#define MEI_START_WD_DATA_SIZE 20
diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c
index ca1e0c9..958a7e2 100644
--- a/drivers/staging/mei/interrupt.c
+++ b/drivers/staging/mei/interrupt.c
@@ -396,6 +396,18 @@ static void mei_client_connect_response(struct mei_device *dev,
dev->wd_due_counter = (dev->wd_timeout) ? 1 : 0;
dev_dbg(&dev->pdev->dev, "successfully connected to WD client.\n");
+
+ /* Registering watchdog interface device once we got connection
+ to the WD Client
+ */
+ if (watchdog_register_device(&amt_wd_dev)) {
+ printk(KERN_ERR "mei: unable to register watchdog device.\n");
+ dev->wd_interface_reg = false;
+ } else {
+ dev_dbg(&dev->pdev->dev, "successfully register watchdog interface.\n");
+ dev->wd_interface_reg = true;
+ }
+
mei_host_init_iamthif(dev);
return;
}
diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
index 8d76785..37f07da 100644
--- a/drivers/staging/mei/main.c
+++ b/drivers/staging/mei/main.c
@@ -241,6 +241,10 @@ static void __devexit mei_remove(struct pci_dev *pdev)
mei_disconnect_host_client(dev, &dev->wd_cl);
}
+ /* Unregistering watchdog device */
+ if (dev->wd_interface_reg)
+ watchdog_unregister_device(&amt_wd_dev);
+
/* remove entry if already in list */
dev_dbg(&pdev->dev, "list del iamthif and wd file list.\n");
mei_remove_client_from_file_list(dev, dev->wd_cl.host_client_id);
diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h
index 2e11077..d434afc 100644
--- a/drivers/staging/mei/mei_dev.h
+++ b/drivers/staging/mei/mei_dev.h
@@ -18,6 +18,7 @@
#define _MEI_DEV_H_
#include <linux/types.h>
+#include <linux/watchdog.h>
#include "mei.h"
#include "hw.h"
@@ -37,6 +38,12 @@
#define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)
/*
+ * AMT Watchdog Device
+ */
+#define INTEL_AMT_WATCHDOG_ID "INTCAMT"
+extern struct watchdog_device amt_wd_dev;
+
+/*
* AMTHI Client UUID
*/
extern const uuid_le mei_amthi_guid;
@@ -258,6 +265,8 @@ struct mei_device {
bool iamthif_flow_control_pending;
bool iamthif_ioctl;
bool iamthif_canceled;
+
+ bool wd_interface_reg;
};
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index 721487d..d9e41a7 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -19,6 +19,7 @@
#include <linux/device.h>
#include <linux/pci.h>
#include <linux/sched.h>
+#include <linux/watchdog.h>
#include "mei_dev.h"
#include "hw.h"
@@ -26,13 +27,28 @@
#include "mei.h"
/*
+ * Watchdog Device structs
+ */
+const struct watchdog_info wd_info = {
+ .identity = INTEL_AMT_WATCHDOG_ID,
+};
+
+struct watchdog_device amt_wd_dev = {
+ .info = &wd_info,
+ .timeout = AMT_WD_DEFAULT_TIMEOUT,
+ .min_timeout = AMT_WD_MIN_TIMEOUT,
+ .max_timeout = AMT_WD_MAX_TIMEOUT,
+};
+
+
+/*
* MEI Watchdog Module Parameters
*/
-static u16 watchdog_timeout = AMT_WD_VALUE;
+static u16 watchdog_timeout = AMT_WD_DEFAULT_TIMEOUT;
module_param(watchdog_timeout, ushort, 0);
MODULE_PARM_DESC(watchdog_timeout,
"Intel(R) AMT Watchdog timeout value in seconds. (default="
- __MODULE_STRING(AMT_WD_VALUE)
+ __MODULE_STRING(AMT_WD_DEFAULT_TIMEOUT)
", disable=0)");
static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 };
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 04/12 v2] staging: mei: adding watchdog ops
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (2 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 03/12 v2] staging: mei: registering the MEI driver with the kernel watchdog core interface Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 05/12 v2] staging: mei: adding watchdog ping Oren Weil
` (7 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
adding start and stop function.
start - check if AMT wd client is connected, which is been connected on driver
load.
stop - send stop command to AMT wd.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/main.c | 2 +-
drivers/staging/mei/mei_dev.h | 5 ++
drivers/staging/mei/wd.c | 95 ++++++++++++++++++++++++++++++++++------
3 files changed, 86 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
index 37f07da..60003cd 100644
--- a/drivers/staging/mei/main.c
+++ b/drivers/staging/mei/main.c
@@ -58,7 +58,7 @@ static struct cdev mei_cdev;
static int mei_major;
/* The device pointer */
/* Currently this driver works as long as there is only a single AMT device. */
-static struct pci_dev *mei_device;
+struct pci_dev *mei_device;
static struct class *mei_class;
diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h
index d434afc..43d7e1c 100644
--- a/drivers/staging/mei/mei_dev.h
+++ b/drivers/staging/mei/mei_dev.h
@@ -38,6 +38,11 @@
#define MEI_WD_STATE_INDEPENDENCE_MSG_SENT (1 << 0)
/*
+ * MEI PCI Device object
+ */
+extern struct pci_dev *mei_device;
+
+/*
* AMT Watchdog Device
*/
#define INTEL_AMT_WATCHDOG_ID "INTCAMT"
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index d9e41a7..fb2bd3d 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -27,21 +27,6 @@
#include "mei.h"
/*
- * Watchdog Device structs
- */
-const struct watchdog_info wd_info = {
- .identity = INTEL_AMT_WATCHDOG_ID,
-};
-
-struct watchdog_device amt_wd_dev = {
- .info = &wd_info,
- .timeout = AMT_WD_DEFAULT_TIMEOUT,
- .min_timeout = AMT_WD_MIN_TIMEOUT,
- .max_timeout = AMT_WD_MAX_TIMEOUT,
-};
-
-
-/*
* MEI Watchdog Module Parameters
*/
static u16 watchdog_timeout = AMT_WD_DEFAULT_TIMEOUT;
@@ -210,3 +195,83 @@ out:
return ret;
}
+/*
+ * mei_wd_ops_start - wd start command from the watchdog core.
+ *
+ * @wd_dev - watchdog device struct
+ *
+ * returns 0 if success, negative errno code for failure
+ */
+static int mei_wd_ops_start(struct watchdog_device *wd_dev)
+{
+ int err = -ENODEV;
+ struct mei_device *dev;
+
+ dev = pci_get_drvdata(mei_device);
+ if (!dev)
+ return -ENODEV;
+
+ mutex_lock(&dev->device_lock);
+
+ if (dev->mei_state != MEI_ENABLED) {
+ dev_dbg(&dev->pdev->dev, "mei_state != MEI_ENABLED mei_state= %d\n",
+ dev->mei_state);
+ goto end_unlock;
+ }
+
+ if (dev->wd_cl.state != MEI_FILE_CONNECTED) {
+ dev_dbg(&dev->pdev->dev, "MEI Driver is not connected to Watchdog Client\n");
+ goto end_unlock;
+ }
+
+ mei_wd_start_setup(dev);
+
+ err = 0;
+end_unlock:
+ mutex_unlock(&dev->device_lock);
+ return err;
+}
+
+/*
+ * mei_wd_ops_stop - wd stop command from the watchdog core.
+ *
+ * @wd_dev - watchdog device struct
+ *
+ * returns 0 if success, negative errno code for failure
+ */
+static int mei_wd_ops_stop(struct watchdog_device *wd_dev)
+{
+ struct mei_device *dev;
+ dev = pci_get_drvdata(mei_device);
+
+ if (!dev)
+ return -ENODEV;
+
+ mutex_lock(&dev->device_lock);
+ mei_wd_stop(dev, false);
+ mutex_unlock(&dev->device_lock);
+
+ return 0;
+}
+
+/*
+ * Watchdog Device structs
+ */
+const struct watchdog_ops wd_ops = {
+ .owner = THIS_MODULE,
+ .start = mei_wd_ops_start,
+ .stop = mei_wd_ops_stop,
+};
+const struct watchdog_info wd_info = {
+ .identity = INTEL_AMT_WATCHDOG_ID,
+};
+
+struct watchdog_device amt_wd_dev = {
+ .info = &wd_info,
+ .ops = &wd_ops,
+ .timeout = AMT_WD_DEFAULT_TIMEOUT,
+ .min_timeout = AMT_WD_MIN_TIMEOUT,
+ .max_timeout = AMT_WD_MAX_TIMEOUT,
+};
+
+
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 05/12 v2] staging: mei: adding watchdog ping
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (3 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 04/12 v2] staging: mei: adding watchdog ops Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 06/12 v2] staging: mei: adding set_timeout watchdog function Oren Weil
` (6 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
adding watchdog ping to send ping/heartbeat to the the AMT watchdog client.
in addition removing the heartbeat sending from the driver timers function.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/interrupt.c | 27 -------------------
drivers/staging/mei/wd.c | 54 +++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 27 deletions(-)
diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c
index 958a7e2..62b8001 100644
--- a/drivers/staging/mei/interrupt.c
+++ b/drivers/staging/mei/interrupt.c
@@ -1430,33 +1430,6 @@ void mei_wd_timer(struct work_struct *work)
}
}
- if (dev->wd_cl.state != MEI_FILE_CONNECTED)
- goto out;
-
- /* Watchdog */
- if (dev->wd_due_counter && !dev->wd_bypass) {
- if (--dev->wd_due_counter == 0) {
- if (dev->mei_host_buffer_is_empty &&
- mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
- dev->mei_host_buffer_is_empty = false;
- dev_dbg(&dev->pdev->dev, "send watchdog.\n");
-
- if (mei_wd_send(dev))
- dev_dbg(&dev->pdev->dev, "wd send failed.\n");
- else
- if (mei_flow_ctrl_reduce(dev, &dev->wd_cl))
- goto out;
-
- if (dev->wd_timeout)
- dev->wd_due_counter = 2;
- else
- dev->wd_due_counter = 0;
-
- } else
- dev->wd_pending = true;
-
- }
- }
if (dev->iamthif_stall_timer) {
if (--dev->iamthif_stall_timer == 0) {
dev_dbg(&dev->pdev->dev, "reseting because of hang to amthi.\n");
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index fb2bd3d..9338394 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -255,15 +255,69 @@ static int mei_wd_ops_stop(struct watchdog_device *wd_dev)
}
/*
+ * mei_wd_ops_ping - wd ping command from the watchdog core.
+ *
+ * @wd_dev - watchdog device struct
+ *
+ * returns 0 if success, negative errno code for failure
+ */
+static int mei_wd_ops_ping(struct watchdog_device *wd_dev)
+{
+ int ret = 0;
+ struct mei_device *dev;
+ dev = pci_get_drvdata(mei_device);
+
+ if (!dev)
+ return -ENODEV;
+
+ mutex_lock(&dev->device_lock);
+
+ if (dev->wd_cl.state != MEI_FILE_CONNECTED) {
+ dev_dbg(&dev->pdev->dev, "wd is not connected.\n");
+ ret = -ENODEV;
+ goto end;
+ }
+
+ /* Check if we can send the ping to HW*/
+ if (dev->mei_host_buffer_is_empty &&
+ mei_flow_ctrl_creds(dev, &dev->wd_cl) > 0) {
+
+ dev->mei_host_buffer_is_empty = false;
+ dev_dbg(&dev->pdev->dev, "sending watchdog ping\n");
+
+ if (mei_wd_send(dev)) {
+ dev_dbg(&dev->pdev->dev, "wd send failed.\n");
+ ret = -EIO;
+ goto end;
+ }
+
+ if (mei_flow_ctrl_reduce(dev, &dev->wd_cl)) {
+ dev_dbg(&dev->pdev->dev, "mei_flow_ctrl_reduce() failed.\n");
+ ret = -EIO;
+ goto end;
+ }
+
+ } else {
+ dev->wd_pending = true;
+ }
+
+end:
+ mutex_unlock(&dev->device_lock);
+ return ret;
+}
+
+/*
* Watchdog Device structs
*/
const struct watchdog_ops wd_ops = {
.owner = THIS_MODULE,
.start = mei_wd_ops_start,
.stop = mei_wd_ops_stop,
+ .ping = mei_wd_ops_ping,
};
const struct watchdog_info wd_info = {
.identity = INTEL_AMT_WATCHDOG_ID,
+ .options = WDIOF_KEEPALIVEPING,
};
struct watchdog_device amt_wd_dev = {
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 06/12 v2] staging: mei: adding set_timeout watchdog function
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (4 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 05/12 v2] staging: mei: adding watchdog ping Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 07/12 v2] staging: mei: renaming delayed work field and function to a meaningful name Oren Weil
` (5 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
add the ability to let the watchdog core set
the AMT watchdog timeout value.
the default value will be only set in the start function.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/interface.h | 2 +-
drivers/staging/mei/main.c | 1 -
drivers/staging/mei/wd.c | 40 ++++++++++++++++++++++++++++++++++----
3 files changed, 36 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/mei/interface.h b/drivers/staging/mei/interface.h
index 2b5a22c..7bd38ae 100644
--- a/drivers/staging/mei/interface.h
+++ b/drivers/staging/mei/interface.h
@@ -51,7 +51,7 @@ int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
int mei_wd_send(struct mei_device *dev);
int mei_wd_stop(struct mei_device *dev, bool preserve);
bool mei_wd_host_init(struct mei_device *dev);
-void mei_wd_start_setup(struct mei_device *dev);
+void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout);
int mei_flow_ctrl_reduce(struct mei_device *dev, struct mei_cl *cl);
diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
index 60003cd..8d124724 100644
--- a/drivers/staging/mei/main.c
+++ b/drivers/staging/mei/main.c
@@ -1153,7 +1153,6 @@ static int mei_pci_resume(struct device *device)
/* Start watchdog if stopped in suspend */
if (dev->wd_timeout) {
- mei_wd_start_setup(dev);
dev->wd_due_counter = 1;
schedule_delayed_work(&dev->wd_work, HZ);
}
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index 9338394..6643f7a 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -51,12 +51,12 @@ const uuid_le mei_wd_guid = UUID_LE(0x05B79A6F, 0x4628, 0x4D7F, 0x89,
0x32, 0xAB);
-void mei_wd_start_setup(struct mei_device *dev)
+void mei_wd_set_start_timeout(struct mei_device *dev, u16 timeout)
{
- dev_dbg(&dev->pdev->dev, "dev->wd_timeout=%d.\n", dev->wd_timeout);
+ dev_dbg(&dev->pdev->dev, "timeout=%d.\n", timeout);
memcpy(dev->wd_data, mei_start_wd_params, MEI_WD_PARAMS_SIZE);
memcpy(dev->wd_data + MEI_WD_PARAMS_SIZE,
- &dev->wd_timeout, sizeof(u16));
+ &timeout, sizeof(u16));
}
/**
@@ -75,7 +75,6 @@ bool mei_wd_host_init(struct mei_device *dev)
dev->wd_timeout = watchdog_timeout;
if (dev->wd_timeout > 0) {
- mei_wd_start_setup(dev);
/* find ME WD client */
mei_find_me_client_update_filext(dev, &dev->wd_cl,
&mei_wd_guid, MEI_WD_HOST_CLIENT_ID);
@@ -224,7 +223,7 @@ static int mei_wd_ops_start(struct watchdog_device *wd_dev)
goto end_unlock;
}
- mei_wd_start_setup(dev);
+ mei_wd_set_start_timeout(dev, dev->wd_timeout);
err = 0;
end_unlock:
@@ -307,6 +306,36 @@ end:
}
/*
+ * mei_wd_ops_set_timeout - wd set timeout command from the watchdog core.
+ *
+ * @wd_dev - watchdog device struct
+ * @timeout - timeout value to set
+ *
+ * returns 0 if success, negative errno code for failure
+ */
+static int mei_wd_ops_set_timeout(struct watchdog_device *wd_dev, unsigned int timeout)
+{
+ struct mei_device *dev;
+ dev = pci_get_drvdata(mei_device);
+
+ if (!dev)
+ return -ENODEV;
+
+ /* Check Timeout value */
+ if (timeout < AMT_WD_MIN_TIMEOUT || timeout > AMT_WD_MAX_TIMEOUT)
+ return -EINVAL;
+
+ mutex_lock(&dev->device_lock);
+
+ dev->wd_timeout = timeout;
+ mei_wd_set_start_timeout(dev, dev->wd_timeout);
+
+ mutex_unlock(&dev->device_lock);
+
+ return 0;
+}
+
+/*
* Watchdog Device structs
*/
const struct watchdog_ops wd_ops = {
@@ -314,6 +343,7 @@ const struct watchdog_ops wd_ops = {
.start = mei_wd_ops_start,
.stop = mei_wd_ops_stop,
.ping = mei_wd_ops_ping,
+ .set_timeout = mei_wd_ops_set_timeout,
};
const struct watchdog_info wd_info = {
.identity = INTEL_AMT_WATCHDOG_ID,
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 07/12 v2] staging: mei: renaming delayed work field and function to a meaningful name.
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (5 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 06/12 v2] staging: mei: adding set_timeout watchdog function Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 08/12 v2] staging: mei: resuming timer regardless of the watchdog timeout value Oren Weil
` (4 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
the wd_work and mei_wd_timer() function was not just for watchdog.
mei managing the AMT watchdog going to be replace by the kernel watchdog
interface.
the mei_timer() will still manage the mei driver timeouts.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/interrupt.c | 6 +++---
drivers/staging/mei/main.c | 6 +++---
drivers/staging/mei/mei_dev.h | 4 ++--
drivers/staging/mei/wd.c | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/mei/interrupt.c b/drivers/staging/mei/interrupt.c
index 62b8001..d1da3aa 100644
--- a/drivers/staging/mei/interrupt.c
+++ b/drivers/staging/mei/interrupt.c
@@ -1393,7 +1393,7 @@ static int mei_irq_thread_write_handler(struct mei_io_list *cmpl_list,
*
* NOTE: This function is called by timer interrupt work
*/
-void mei_wd_timer(struct work_struct *work)
+void mei_timer(struct work_struct *work)
{
unsigned long timeout;
struct mei_cl *cl_pos = NULL;
@@ -1403,7 +1403,7 @@ void mei_wd_timer(struct work_struct *work)
struct mei_cl_cb *cb_next = NULL;
struct mei_device *dev = container_of(work,
- struct mei_device, wd_work.work);
+ struct mei_device, timer_work.work);
mutex_lock(&dev->device_lock);
@@ -1495,7 +1495,7 @@ void mei_wd_timer(struct work_struct *work)
}
}
out:
- schedule_delayed_work(&dev->wd_work, 2 * HZ);
+ schedule_delayed_work(&dev->timer_work, 2 * HZ);
mutex_unlock(&dev->device_lock);
}
diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
index 8d124724..7009937 100644
--- a/drivers/staging/mei/main.c
+++ b/drivers/staging/mei/main.c
@@ -170,7 +170,7 @@ static int __devinit mei_probe(struct pci_dev *pdev,
pdev->irq);
goto unmap_memory;
}
- INIT_DELAYED_WORK(&dev->wd_work, mei_wd_timer);
+ INIT_DELAYED_WORK(&dev->timer_work, mei_timer);
if (mei_hw_init(dev)) {
printk(KERN_ERR "mei: Init hw failure.\n");
err = -ENODEV;
@@ -178,7 +178,7 @@ static int __devinit mei_probe(struct pci_dev *pdev,
}
mei_device = pdev;
pci_set_drvdata(pdev, dev);
- schedule_delayed_work(&dev->wd_work, HZ);
+ schedule_delayed_work(&dev->timer_work, HZ);
mutex_unlock(&mei_mutex);
@@ -1154,7 +1154,7 @@ static int mei_pci_resume(struct device *device)
/* Start watchdog if stopped in suspend */
if (dev->wd_timeout) {
dev->wd_due_counter = 1;
- schedule_delayed_work(&dev->wd_work, HZ);
+ schedule_delayed_work(&dev->timer_work, HZ);
}
return err;
}
diff --git a/drivers/staging/mei/mei_dev.h b/drivers/staging/mei/mei_dev.h
index 43d7e1c..6487be1 100644
--- a/drivers/staging/mei/mei_dev.h
+++ b/drivers/staging/mei/mei_dev.h
@@ -209,7 +209,7 @@ struct mei_device {
* lock for the device
*/
struct mutex device_lock; /* device lock */
- struct delayed_work wd_work; /* watch dog deleye work */
+ struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */
bool recvd_msg;
/*
* hw states of host and fw(ME)
@@ -336,7 +336,7 @@ void mei_host_client_properties(struct mei_device *dev);
*/
irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id);
irqreturn_t mei_interrupt_thread_handler(int irq, void *dev_id);
-void mei_wd_timer(struct work_struct *work);
+void mei_timer(struct work_struct *work);
/*
* MEI input output function prototype
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index 6643f7a..68c177b 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -142,7 +142,7 @@ int mei_wd_stop(struct mei_device *dev, bool preserve)
int ret;
u16 wd_timeout = dev->wd_timeout;
- cancel_delayed_work(&dev->wd_work);
+ cancel_delayed_work(&dev->timer_work);
if (dev->wd_cl.state != MEI_FILE_CONNECTED || !dev->wd_timeout)
return 0;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 08/12 v2] staging: mei: resuming timer regardless of the watchdog timeout value.
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (6 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 07/12 v2] staging: mei: renaming delayed work field and function to a meaningful name Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 09/12 v2] stagign: mei: client init code cleanup Oren Weil
` (3 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
the timer_work does not only handle watchdog but also handles mei timeouts.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/main.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/mei/main.c b/drivers/staging/mei/main.c
index 7009937..3b0b703 100644
--- a/drivers/staging/mei/main.c
+++ b/drivers/staging/mei/main.c
@@ -1151,11 +1151,9 @@ static int mei_pci_resume(struct device *device)
mei_reset(dev, 1);
mutex_unlock(&dev->device_lock);
- /* Start watchdog if stopped in suspend */
- if (dev->wd_timeout) {
- dev->wd_due_counter = 1;
- schedule_delayed_work(&dev->timer_work, HZ);
- }
+ /* Start timer if stopped in suspend */
+ schedule_delayed_work(&dev->timer_work, HZ);
+
return err;
}
static SIMPLE_DEV_PM_OPS(mei_pm_ops, mei_pci_suspend, mei_pci_resume);
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 09/12 v2] stagign: mei: client init code cleanup
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (7 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 08/12 v2] staging: mei: resuming timer regardless of the watchdog timeout value Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 10/12 v2] staging: mei: removing wd module parameters Oren Weil
` (2 subsequent siblings)
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
starting removing the dependency from the module parameters.
setting the default timeout on init so don't need to check if it is bigger
then zero.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/wd.c | 33 +++++++++++++--------------------
1 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index 68c177b..fd67952 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -72,32 +72,25 @@ bool mei_wd_host_init(struct mei_device *dev)
/* look for WD client and connect to it */
dev->wd_cl.state = MEI_FILE_DISCONNECTED;
- dev->wd_timeout = watchdog_timeout;
-
- if (dev->wd_timeout > 0) {
- /* find ME WD client */
- mei_find_me_client_update_filext(dev, &dev->wd_cl,
- &mei_wd_guid, MEI_WD_HOST_CLIENT_ID);
-
- dev_dbg(&dev->pdev->dev, "check wd_cl\n");
- if (MEI_FILE_CONNECTING == dev->wd_cl.state) {
- if (!mei_connect(dev, &dev->wd_cl)) {
- dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n");
- dev->wd_cl.state = MEI_FILE_DISCONNECTED;
- dev->wd_cl.host_client_id = 0;
- ret = false;
- goto end;
- } else {
- dev->wd_cl.timer_count = CONNECT_TIMEOUT;
- }
- } else {
- dev_dbg(&dev->pdev->dev, "Failed to find WD client\n");
+ dev->wd_timeout = AMT_WD_DEFAULT_TIMEOUT;
+
+ /* find ME WD client */
+ mei_find_me_client_update_filext(dev, &dev->wd_cl,
+ &mei_wd_guid, MEI_WD_HOST_CLIENT_ID);
+
+ dev_dbg(&dev->pdev->dev, "check wd_cl\n");
+ if (MEI_FILE_CONNECTING == dev->wd_cl.state) {
+ if (!mei_connect(dev, &dev->wd_cl)) {
+ dev_dbg(&dev->pdev->dev, "Failed to connect to WD client\n");
+ dev->wd_cl.state = MEI_FILE_DISCONNECTED;
+ dev->wd_cl.host_client_id = 0;
ret = false;
goto end;
+ } else {
+ dev->wd_cl.timer_count = CONNECT_TIMEOUT;
}
} else {
- dev->wd_bypass = true;
- dev_dbg(&dev->pdev->dev, "WD requested to be disabled\n");
+ dev_dbg(&dev->pdev->dev, "Failed to find WD client\n");
ret = false;
goto end;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 10/12 v2] staging: mei: removing wd module parameters
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (8 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 09/12 v2] stagign: mei: client init code cleanup Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` [PATCH 11/12 v2] staging: mei: adding mei_wd_stop function comment Oren Weil
2011-09-07 6:03 ` Oren Weil
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
wd module parameter is not needed now that driver is using watchdog core.
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/wd.c | 10 ----------
1 files changed, 0 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index fd67952..b56b1cc 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -26,16 +26,6 @@
#include "interface.h"
#include "mei.h"
-/*
- * MEI Watchdog Module Parameters
- */
-static u16 watchdog_timeout = AMT_WD_DEFAULT_TIMEOUT;
-module_param(watchdog_timeout, ushort, 0);
-MODULE_PARM_DESC(watchdog_timeout,
- "Intel(R) AMT Watchdog timeout value in seconds. (default="
- __MODULE_STRING(AMT_WD_DEFAULT_TIMEOUT)
- ", disable=0)");
-
static const u8 mei_start_wd_params[] = { 0x02, 0x12, 0x13, 0x10 };
static const u8 mei_stop_wd_params[] = { 0x02, 0x02, 0x14, 0x10 };
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/12 v2] staging: mei: adding mei_wd_stop function comment
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (9 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 10/12 v2] staging: mei: removing wd module parameters Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
2011-09-07 6:03 ` Oren Weil
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/wd.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/mei/wd.c b/drivers/staging/mei/wd.c
index b56b1cc..ffca7ca 100644
--- a/drivers/staging/mei/wd.c
+++ b/drivers/staging/mei/wd.c
@@ -120,6 +120,16 @@ int mei_wd_send(struct mei_device *dev)
return -EIO;
}
+/**
+ * mei_wd_stop - sends watchdog stop message to fw.
+ *
+ * @dev: the device structure
+ * @preserve: indicate if to keep the timeout value
+ *
+ * returns 0 if success,
+ * -EIO when message send fails
+ * -EINVAL when invalid message is to be sent
+ */
int mei_wd_stop(struct mei_device *dev, bool preserve)
{
int ret;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 11/12 v2] staging: mei: adding mei_wd_stop function comment
2011-09-07 6:03 [PATCH 00/12 v2] staging: mei: adding new watchdog core support Oren Weil
` (10 preceding siblings ...)
2011-09-07 6:03 ` [PATCH 11/12 v2] staging: mei: adding mei_wd_stop function comment Oren Weil
@ 2011-09-07 6:03 ` Oren Weil
11 siblings, 0 replies; 15+ messages in thread
From: Oren Weil @ 2011-09-07 6:03 UTC (permalink / raw)
To: gregkh
Cc: devel, linux-kernel, linux-watchdog, alan, wim, tomas.winkler, Oren Weil
>From 0d425f09d49b13b0dd8282e946bc87947a20a4a3 Mon Sep 17 00:00:00 2001
From: Oren Weil <oren.jer.weil@intel.com>
Date: Wed, 17 Aug 2011 13:22:12 +0300
Subject: [PATCH 12/12 v2] staging: mei: adding watchdog core dependency to kconfig
Signed-off-by: Oren Weil <oren.jer.weil@intel.com>
Acked-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/staging/mei/Kconfig | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/mei/Kconfig b/drivers/staging/mei/Kconfig
index 3f3f170..47d78a7 100644
--- a/drivers/staging/mei/Kconfig
+++ b/drivers/staging/mei/Kconfig
@@ -1,6 +1,6 @@
config INTEL_MEI
tristate "Intel Management Engine Interface (Intel MEI)"
- depends on X86 && PCI && EXPERIMENTAL
+ depends on X86 && PCI && EXPERIMENTAL && WATCHDOG_CORE
help
The Intel Management Engine (Intel ME) provides Manageability,
Security and Media services for system containing Intel chipsets.
--
1.7.4.1
^ permalink raw reply related [flat|nested] 15+ messages in thread