Commit cb02efc3 authored by Alexander Usyskin's avatar Alexander Usyskin Committed by Greg Kroah-Hartman

mei: wait for hbm start non-interruptible

We cannot handle user interrupt in context of hbm start
so we only wait for time out which is reasonably short.

1. Add kdoc
2. Rename state to better reflect its function
3. Simplify wait condition and rename
   wait_recvd_msg to wait_hbm_start
Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 12f45ed4
...@@ -172,21 +172,27 @@ bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf) ...@@ -172,21 +172,27 @@ bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
cl->me_client_id == cmd->me_addr; cl->me_client_id == cmd->me_addr;
} }
/**
* mei_hbm_start_wait - wait for start response message.
*
* @dev: the device structure
*
* returns 0 on success and < 0 on failure
*/
int mei_hbm_start_wait(struct mei_device *dev) int mei_hbm_start_wait(struct mei_device *dev)
{ {
int ret; int ret;
if (dev->hbm_state > MEI_HBM_START)
if (dev->hbm_state > MEI_HBM_STARTING)
return 0; return 0;
mutex_unlock(&dev->device_lock); mutex_unlock(&dev->device_lock);
ret = wait_event_interruptible_timeout(dev->wait_recvd_msg, ret = wait_event_timeout(dev->wait_hbm_start,
dev->hbm_state == MEI_HBM_IDLE || dev->hbm_state != MEI_HBM_STARTING,
dev->hbm_state >= MEI_HBM_STARTED,
mei_secs_to_jiffies(MEI_HBM_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_STARTING)) {
dev->hbm_state = MEI_HBM_IDLE; dev->hbm_state = MEI_HBM_IDLE;
dev_err(&dev->pdev->dev, "waiting for mei start failed\n"); dev_err(&dev->pdev->dev, "waiting for mei start failed\n");
return -ETIME; return -ETIME;
...@@ -227,7 +233,7 @@ int mei_hbm_start_req(struct mei_device *dev) ...@@ -227,7 +233,7 @@ int mei_hbm_start_req(struct mei_device *dev)
return ret; return ret;
} }
dev->hbm_state = MEI_HBM_START; dev->hbm_state = MEI_HBM_STARTING;
dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT; dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
return 0; return 0;
} }
...@@ -726,7 +732,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) ...@@ -726,7 +732,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
} }
if (dev->dev_state != MEI_DEV_INIT_CLIENTS || if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
dev->hbm_state != MEI_HBM_START) { dev->hbm_state != MEI_HBM_STARTING) {
dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n", dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n",
dev->dev_state, dev->hbm_state); dev->dev_state, dev->hbm_state);
return -EPROTO; return -EPROTO;
...@@ -739,7 +745,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) ...@@ -739,7 +745,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
return -EIO; return -EIO;
} }
wake_up_interruptible(&dev->wait_recvd_msg); wake_up(&dev->wait_hbm_start);
break; break;
case CLIENT_CONNECT_RES_CMD: case CLIENT_CONNECT_RES_CMD:
...@@ -866,7 +872,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) ...@@ -866,7 +872,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n"); dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n");
dev->hbm_state = MEI_HBM_STOPPED; dev->hbm_state = MEI_HBM_STOPPED;
if (mei_hbm_stop_req(dev)) { if (mei_hbm_stop_req(dev)) {
dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n"); dev_err(&dev->pdev->dev, "hbm: stop request: failed to send stop request\n");
return -EIO; return -EIO;
} }
break; break;
......
...@@ -25,13 +25,15 @@ struct mei_cl; ...@@ -25,13 +25,15 @@ struct mei_cl;
* enum mei_hbm_state - host bus message protocol state * enum mei_hbm_state - host bus message protocol state
* *
* @MEI_HBM_IDLE : protocol not started * @MEI_HBM_IDLE : protocol not started
* @MEI_HBM_START : start request message was sent * @MEI_HBM_STARTING : start request message was sent
* @MEI_HBM_STARTED : start reply message was received
* @MEI_HBM_ENUM_CLIENTS : enumeration request was sent * @MEI_HBM_ENUM_CLIENTS : enumeration request was sent
* @MEI_HBM_CLIENT_PROPERTIES : acquiring clients properties * @MEI_HBM_CLIENT_PROPERTIES : acquiring clients properties
* @MEI_HBM_STOPPED : stopping exchange
*/ */
enum mei_hbm_state { enum mei_hbm_state {
MEI_HBM_IDLE = 0, MEI_HBM_IDLE = 0,
MEI_HBM_START, MEI_HBM_STARTING,
MEI_HBM_STARTED, MEI_HBM_STARTED,
MEI_HBM_ENUM_CLIENTS, MEI_HBM_ENUM_CLIENTS,
MEI_HBM_CLIENT_PROPERTIES, MEI_HBM_CLIENT_PROPERTIES,
......
...@@ -360,7 +360,7 @@ void mei_device_init(struct mei_device *dev, const struct mei_cfg *cfg) ...@@ -360,7 +360,7 @@ void mei_device_init(struct mei_device *dev, const struct mei_cfg *cfg)
mutex_init(&dev->device_lock); mutex_init(&dev->device_lock);
init_waitqueue_head(&dev->wait_hw_ready); init_waitqueue_head(&dev->wait_hw_ready);
init_waitqueue_head(&dev->wait_pg); init_waitqueue_head(&dev->wait_pg);
init_waitqueue_head(&dev->wait_recvd_msg); init_waitqueue_head(&dev->wait_hbm_start);
init_waitqueue_head(&dev->wait_stop_wd); init_waitqueue_head(&dev->wait_stop_wd);
dev->dev_state = MEI_DEV_INITIALIZING; dev->dev_state = MEI_DEV_INITIALIZING;
dev->reset_count = 0; dev->reset_count = 0;
......
...@@ -443,7 +443,7 @@ struct mei_device { ...@@ -443,7 +443,7 @@ struct mei_device {
*/ */
wait_queue_head_t wait_hw_ready; wait_queue_head_t wait_hw_ready;
wait_queue_head_t wait_pg; wait_queue_head_t wait_pg;
wait_queue_head_t wait_recvd_msg; wait_queue_head_t wait_hbm_start;
wait_queue_head_t wait_stop_wd; wait_queue_head_t wait_stop_wd;
/* /*
......
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