]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mei: wd: fix stop completion failure
authorTomas Winkler <tomas.winkler@intel.com>
Wed, 19 Feb 2014 15:35:51 +0000 (17:35 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Feb 2014 23:15:57 +0000 (15:15 -0800)
While running Documentation/watchdog/src/watchdog-simple.c
and quiting by Ctrl-C, fallowing error is displayed:
mei_me 0000:00:16.0: wd: stop failed to complete ret=-512.

The whatchdog core framework is not able to propagate
-ESYSRESTART or -EINTR. Also There is no much sense in
restarting the close system call so instead of using
wait_event_interruptible_timeout we can use wait_event_timeout
with reasonable 10 msecs timeout.

Reported-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/interrupt.c
drivers/misc/mei/wd.c

index 834220af814f1e3d95a1448d95ff44adcc1a4e04..5aab335f585baba6984d43ce4f626e5866e5aaa6 100644 (file)
@@ -474,7 +474,7 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
 
        if (dev->wd_state == MEI_WD_STOPPING) {
                dev->wd_state = MEI_WD_IDLE;
-               wake_up_interruptible(&dev->wait_stop_wd);
+               wake_up(&dev->wait_stop_wd);
        }
 
        if (mei_cl_is_connected(&dev->wd_cl)) {
index 13bb7a91ae12d624905e53d021e084677dc77785..e084adf2725944510e8d151370b445c55e3e4bb9 100644 (file)
@@ -155,9 +155,11 @@ int mei_wd_send(struct mei_device *dev)
  * @dev: the device structure
  * @preserve: indicate if to keep the timeout value
  *
- * returns 0 if success,
- *     -EIO when message send fails
+ * returns 0 if success
+ * on error:
+ *     -EIO    when message send fails
  *     -EINVAL when invalid message is to be sent
+ *     -ETIME  on message timeout
  */
 int mei_wd_stop(struct mei_device *dev)
 {
@@ -173,12 +175,12 @@ int mei_wd_stop(struct mei_device *dev)
 
        ret = mei_cl_flow_ctrl_creds(&dev->wd_cl);
        if (ret < 0)
-               goto out;
+               goto err;
 
        if (ret && mei_hbuf_acquire(dev)) {
                ret = mei_wd_send(dev);
                if (ret)
-                       goto out;
+                       goto err;
                dev->wd_pending = false;
        } else {
                dev->wd_pending = true;
@@ -186,21 +188,21 @@ int mei_wd_stop(struct mei_device *dev)
 
        mutex_unlock(&dev->device_lock);
 
-       ret = wait_event_interruptible_timeout(dev->wait_stop_wd,
-                                       dev->wd_state == MEI_WD_IDLE,
-                                       msecs_to_jiffies(MEI_WD_STOP_TIMEOUT));
+       ret = wait_event_timeout(dev->wait_stop_wd,
+                               dev->wd_state == MEI_WD_IDLE,
+                               msecs_to_jiffies(MEI_WD_STOP_TIMEOUT));
        mutex_lock(&dev->device_lock);
-       if (dev->wd_state == MEI_WD_IDLE) {
-               dev_dbg(&dev->pdev->dev, "wd: stop completed ret=%d.\n", ret);
-               ret = 0;
-       } else {
-               if (!ret)
-                       ret = -ETIME;
+       if (dev->wd_state != MEI_WD_IDLE) {
+               /* timeout */
+               ret = -ETIME;
                dev_warn(&dev->pdev->dev,
                        "wd: stop failed to complete ret=%d.\n", ret);
+               goto err;
        }
-
-out:
+       dev_dbg(&dev->pdev->dev, "wd: stop completed after %u msec\n",
+                       MEI_WD_STOP_TIMEOUT - jiffies_to_msecs(ret));
+       return 0;
+err:
        return ret;
 }