Commit 7d93e58d authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: allow multiple retries if the hw reset has failed

In some rare case mei hw reset may take long time to settle.
Instead of blocking resume flow we span another driver reset flow in
separate work context

This allows as to shorten hw reset timeout to something more acceptable
by DPM_WATCHDOG_TIMEOUT
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 92ab5130
...@@ -147,7 +147,7 @@ int mei_hbm_start_wait(struct mei_device *dev) ...@@ -147,7 +147,7 @@ int mei_hbm_start_wait(struct mei_device *dev)
ret = wait_event_interruptible_timeout(dev->wait_recvd_msg, ret = wait_event_interruptible_timeout(dev->wait_recvd_msg,
dev->hbm_state == MEI_HBM_IDLE || dev->hbm_state == MEI_HBM_IDLE ||
dev->hbm_state >= MEI_HBM_STARTED, dev->hbm_state >= MEI_HBM_STARTED,
mei_secs_to_jiffies(MEI_INTEROP_TIMEOUT)); mei_secs_to_jiffies(MEI_HBM_TIMEOUT));
mutex_lock(&dev->device_lock); mutex_lock(&dev->device_lock);
if (ret <= 0 && (dev->hbm_state <= MEI_HBM_START)) { if (ret <= 0 && (dev->hbm_state <= MEI_HBM_START)) {
......
...@@ -240,7 +240,7 @@ static int mei_me_hw_ready_wait(struct mei_device *dev) ...@@ -240,7 +240,7 @@ static int mei_me_hw_ready_wait(struct mei_device *dev)
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
err = wait_event_interruptible_timeout(dev->wait_hw_ready, err = wait_event_interruptible_timeout(dev->wait_hw_ready,
dev->recvd_hw_ready, dev->recvd_hw_ready,
mei_secs_to_jiffies(MEI_INTEROP_TIMEOUT)); mei_secs_to_jiffies(MEI_HW_READY_TIMEOUT));
mutex_lock(&dev->device_lock); mutex_lock(&dev->device_lock);
if (!err && !dev->recvd_hw_ready) { if (!err && !dev->recvd_hw_ready) {
if (!err) if (!err)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
/* /*
* Timeouts in Seconds * Timeouts in Seconds
*/ */
#define MEI_INTEROP_TIMEOUT 7 /* Timeout on ready message */ #define MEI_HW_READY_TIMEOUT 2 /* Timeout on ready message */
#define MEI_CONNECT_TIMEOUT 3 /* HPS: at least 2 seconds */ #define MEI_CONNECT_TIMEOUT 3 /* HPS: at least 2 seconds */
#define MEI_CL_CONNECT_TIMEOUT 15 /* HPS: Client Connect Timeout */ #define MEI_CL_CONNECT_TIMEOUT 15 /* HPS: Client Connect Timeout */
...@@ -31,13 +31,13 @@ ...@@ -31,13 +31,13 @@
#define MEI_IAMTHIF_STALL_TIMER 12 /* HPS */ #define MEI_IAMTHIF_STALL_TIMER 12 /* HPS */
#define MEI_IAMTHIF_READ_TIMER 10 /* HPS */ #define MEI_IAMTHIF_READ_TIMER 10 /* HPS */
#define MEI_HBM_TIMEOUT 1 /* 1 second */
/* /*
* MEI Version * MEI Version
*/ */
#define HBM_MINOR_VERSION 0 #define HBM_MINOR_VERSION 0
#define HBM_MAJOR_VERSION 1 #define HBM_MAJOR_VERSION 1
#define HBM_TIMEOUT 1 /* 1 second */
/* Host bus message command opcode */ /* Host bus message command opcode */
#define MEI_HBM_CMD_OP_MSK 0x7f #define MEI_HBM_CMD_OP_MSK 0x7f
......
...@@ -126,7 +126,6 @@ int mei_reset(struct mei_device *dev) ...@@ -126,7 +126,6 @@ int mei_reset(struct mei_device *dev)
if (ret) { if (ret) {
dev_err(&dev->pdev->dev, "hw_reset failed ret = %d\n", ret); dev_err(&dev->pdev->dev, "hw_reset failed ret = %d\n", ret);
dev->dev_state = MEI_DEV_DISABLED;
return ret; return ret;
} }
...@@ -139,7 +138,6 @@ int mei_reset(struct mei_device *dev) ...@@ -139,7 +138,6 @@ int mei_reset(struct mei_device *dev)
ret = mei_hw_start(dev); ret = mei_hw_start(dev);
if (ret) { if (ret) {
dev_err(&dev->pdev->dev, "hw_start failed ret = %d\n", ret); dev_err(&dev->pdev->dev, "hw_start failed ret = %d\n", ret);
dev->dev_state = MEI_DEV_DISABLED;
return ret; return ret;
} }
...@@ -149,7 +147,7 @@ int mei_reset(struct mei_device *dev) ...@@ -149,7 +147,7 @@ int mei_reset(struct mei_device *dev)
ret = mei_hbm_start_req(dev); ret = mei_hbm_start_req(dev);
if (ret) { if (ret) {
dev_err(&dev->pdev->dev, "hbm_start failed ret = %d\n", ret); dev_err(&dev->pdev->dev, "hbm_start failed ret = %d\n", ret);
dev->dev_state = MEI_DEV_DISABLED; dev->dev_state = MEI_DEV_RESETTING;
return ret; return ret;
} }
...@@ -166,6 +164,7 @@ EXPORT_SYMBOL_GPL(mei_reset); ...@@ -166,6 +164,7 @@ EXPORT_SYMBOL_GPL(mei_reset);
*/ */
int mei_start(struct mei_device *dev) int mei_start(struct mei_device *dev)
{ {
int ret;
mutex_lock(&dev->device_lock); mutex_lock(&dev->device_lock);
/* acknowledge interrupt and stop interrupts */ /* acknowledge interrupt and stop interrupts */
...@@ -175,10 +174,18 @@ int mei_start(struct mei_device *dev) ...@@ -175,10 +174,18 @@ int mei_start(struct mei_device *dev)
dev_dbg(&dev->pdev->dev, "reset in start the mei device.\n"); dev_dbg(&dev->pdev->dev, "reset in start the mei device.\n");
dev->dev_state = MEI_DEV_INITIALIZING;
dev->reset_count = 0; dev->reset_count = 0;
mei_reset(dev); do {
dev->dev_state = MEI_DEV_INITIALIZING;
ret = mei_reset(dev);
if (ret == -ENODEV || dev->dev_state == MEI_DEV_DISABLED) {
dev_err(&dev->pdev->dev, "reset failed ret = %d", ret);
goto err;
}
} while (ret);
/* we cannot start the device w/o hbm start message completed */
if (dev->dev_state == MEI_DEV_DISABLED) { if (dev->dev_state == MEI_DEV_DISABLED) {
dev_err(&dev->pdev->dev, "reset failed"); dev_err(&dev->pdev->dev, "reset failed");
goto err; goto err;
...@@ -238,27 +245,40 @@ int mei_restart(struct mei_device *dev) ...@@ -238,27 +245,40 @@ int mei_restart(struct mei_device *dev)
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
if (err || dev->dev_state == MEI_DEV_DISABLED) if (err == -ENODEV || dev->dev_state == MEI_DEV_DISABLED) {
dev_err(&dev->pdev->dev, "device disabled = %d\n", err);
return -ENODEV; return -ENODEV;
}
/* try to start again */
if (err)
schedule_work(&dev->reset_work);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mei_restart); EXPORT_SYMBOL_GPL(mei_restart);
static void mei_reset_work(struct work_struct *work) static void mei_reset_work(struct work_struct *work)
{ {
struct mei_device *dev = struct mei_device *dev =
container_of(work, struct mei_device, reset_work); container_of(work, struct mei_device, reset_work);
int ret;
mutex_lock(&dev->device_lock); mutex_lock(&dev->device_lock);
mei_reset(dev); ret = mei_reset(dev);
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
if (dev->dev_state == MEI_DEV_DISABLED) if (dev->dev_state == MEI_DEV_DISABLED) {
dev_err(&dev->pdev->dev, "reset failed"); dev_err(&dev->pdev->dev, "device disabled = %d\n", ret);
return;
}
/* retry reset in case of failure */
if (ret)
schedule_work(&dev->reset_work);
} }
void mei_stop(struct mei_device *dev) void mei_stop(struct mei_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment