aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/hbm.c
diff options
context:
space:
mode:
authorAlexander Usyskin <alexander.usyskin@intel.com>2014-08-21 07:29:19 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-09-24 01:57:48 -0400
commitcb02efc3a6e96a0dc4aba8ebf0c1136b72fbe8ba (patch)
treedd60c108aece5a5ba0e6af58c8a8217d45c2835c /drivers/misc/mei/hbm.c
parent12f45ed414c8d2eac1a98bf2deaf4117e8c0324f (diff)
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: Alexander Usyskin <alexander.usyskin@intel.com> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/hbm.c')
-rw-r--r--drivers/misc/mei/hbm.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index cda914191a2f..2968b52fc12a 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -172,21 +172,27 @@ bool mei_hbm_cl_addr_equal(struct mei_cl *cl, void *buf)
172 cl->me_client_id == cmd->me_addr; 172 cl->me_client_id == cmd->me_addr;
173} 173}
174 174
175 175/**
176 * mei_hbm_start_wait - wait for start response message.
177 *
178 * @dev: the device structure
179 *
180 * returns 0 on success and < 0 on failure
181 */
176int mei_hbm_start_wait(struct mei_device *dev) 182int mei_hbm_start_wait(struct mei_device *dev)
177{ 183{
178 int ret; 184 int ret;
179 if (dev->hbm_state > MEI_HBM_START) 185
186 if (dev->hbm_state > MEI_HBM_STARTING)
180 return 0; 187 return 0;
181 188
182 mutex_unlock(&dev->device_lock); 189 mutex_unlock(&dev->device_lock);
183 ret = wait_event_interruptible_timeout(dev->wait_recvd_msg, 190 ret = wait_event_timeout(dev->wait_hbm_start,
184 dev->hbm_state == MEI_HBM_IDLE || 191 dev->hbm_state != MEI_HBM_STARTING,
185 dev->hbm_state >= MEI_HBM_STARTED,
186 mei_secs_to_jiffies(MEI_HBM_TIMEOUT)); 192 mei_secs_to_jiffies(MEI_HBM_TIMEOUT));
187 mutex_lock(&dev->device_lock); 193 mutex_lock(&dev->device_lock);
188 194
189 if (ret <= 0 && (dev->hbm_state <= MEI_HBM_START)) { 195 if (ret == 0 && (dev->hbm_state <= MEI_HBM_STARTING)) {
190 dev->hbm_state = MEI_HBM_IDLE; 196 dev->hbm_state = MEI_HBM_IDLE;
191 dev_err(&dev->pdev->dev, "waiting for mei start failed\n"); 197 dev_err(&dev->pdev->dev, "waiting for mei start failed\n");
192 return -ETIME; 198 return -ETIME;
@@ -227,7 +233,7 @@ int mei_hbm_start_req(struct mei_device *dev)
227 return ret; 233 return ret;
228 } 234 }
229 235
230 dev->hbm_state = MEI_HBM_START; 236 dev->hbm_state = MEI_HBM_STARTING;
231 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT; 237 dev->init_clients_timer = MEI_CLIENTS_INIT_TIMEOUT;
232 return 0; 238 return 0;
233} 239}
@@ -726,7 +732,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
726 } 732 }
727 733
728 if (dev->dev_state != MEI_DEV_INIT_CLIENTS || 734 if (dev->dev_state != MEI_DEV_INIT_CLIENTS ||
729 dev->hbm_state != MEI_HBM_START) { 735 dev->hbm_state != MEI_HBM_STARTING) {
730 dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n", 736 dev_err(&dev->pdev->dev, "hbm: start: state mismatch, [%d, %d]\n",
731 dev->dev_state, dev->hbm_state); 737 dev->dev_state, dev->hbm_state);
732 return -EPROTO; 738 return -EPROTO;
@@ -739,7 +745,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
739 return -EIO; 745 return -EIO;
740 } 746 }
741 747
742 wake_up_interruptible(&dev->wait_recvd_msg); 748 wake_up(&dev->wait_hbm_start);
743 break; 749 break;
744 750
745 case CLIENT_CONNECT_RES_CMD: 751 case CLIENT_CONNECT_RES_CMD:
@@ -866,7 +872,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr)
866 dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n"); 872 dev_dbg(&dev->pdev->dev, "hbm: stop request: message received\n");
867 dev->hbm_state = MEI_HBM_STOPPED; 873 dev->hbm_state = MEI_HBM_STOPPED;
868 if (mei_hbm_stop_req(dev)) { 874 if (mei_hbm_stop_req(dev)) {
869 dev_err(&dev->pdev->dev, "hbm: start: failed to send stop request\n"); 875 dev_err(&dev->pdev->dev, "hbm: stop request: failed to send stop request\n");
870 return -EIO; 876 return -EIO;
871 } 877 }
872 break; 878 break;