]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
staging: mei: registering the MEI driver with the kernel watchdog core interface
authorOren Weil <oren.jer.weil@intel.com>
Wed, 7 Sep 2011 06:03:09 +0000 (09:03 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 9 Sep 2011 20:28:20 +0000 (13:28 -0700)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/mei/init.c
drivers/staging/mei/interface.h
drivers/staging/mei/interrupt.c
drivers/staging/mei/main.c
drivers/staging/mei/mei_dev.h
drivers/staging/mei/wd.c

index 69a57e77a09d78b561a971b84e4afdcc169f6a34..cb0ebbedf6708ebb2f37b7accaccf21074a9f00d 100644 (file)
@@ -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);
index 7bcf0966030a218901fe366ccf2b34d268a7c045..2b5a22c23f754e170415cffbde37e85af1be75cf 100644 (file)
@@ -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
index ca1e0c90a94143a223465747ca29949624426029..958a7e2958b6958895639945bf3ca3c46d7cf3b0 100644 (file)
@@ -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;
        }
index 78028f8c0b8f0294d0d158a0f6f709128763a9b5..c4ebd07a2ddc64fdd960423593001fd3101ad65a 100644 (file)
@@ -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);
index 2e1107762efd0df6d03715e02e6ab72c58ecbea2..d434afc3ffea0a55d23e8e06d536da4716070c94 100644 (file)
@@ -18,6 +18,7 @@
 #define _MEI_DEV_H_
 
 #include <linux/types.h>
+#include <linux/watchdog.h>
 #include "mei.h"
 #include "hw.h"
 
 #define MEI_WD_PARAMS_SIZE             4
 #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
  */
@@ -258,6 +265,8 @@ struct mei_device {
        bool iamthif_flow_control_pending;
        bool iamthif_ioctl;
        bool iamthif_canceled;
+
+       bool wd_interface_reg;
 };
 
 
index 721487d05ba8c99ffd548a564b17bf7a75d996db..d9e41a7a5afca24f883c0dd384797ac0b16d7715 100644 (file)
 #include <linux/device.h>
 #include <linux/pci.h>
 #include <linux/sched.h>
+#include <linux/watchdog.h>
 
 #include "mei_dev.h"
 #include "hw.h"
 #include "interface.h"
 #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 };