aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/misc/mei/amthif.c8
-rw-r--r--drivers/misc/mei/client.c13
-rw-r--r--drivers/misc/mei/hw-me.c2
-rw-r--r--drivers/misc/mei/main.c4
-rw-r--r--drivers/misc/mei/mei_dev.h14
-rw-r--r--drivers/misc/mei/wd.c9
6 files changed, 27 insertions, 23 deletions
diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index a7c483850083..c86d7e3839a4 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -297,9 +297,9 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
297 if (ret < 0) 297 if (ret < 0)
298 return ret; 298 return ret;
299 299
300 if (ret && dev->mei_host_buffer_is_empty) { 300 if (ret && dev->hbuf_is_ready) {
301 ret = 0; 301 ret = 0;
302 dev->mei_host_buffer_is_empty = false; 302 dev->hbuf_is_ready = false;
303 if (cb->request_buffer.size > mei_hbuf_max_len(dev)) { 303 if (cb->request_buffer.size > mei_hbuf_max_len(dev)) {
304 mei_hdr.length = mei_hbuf_max_len(dev); 304 mei_hdr.length = mei_hbuf_max_len(dev);
305 mei_hdr.msg_complete = 0; 305 mei_hdr.msg_complete = 0;
@@ -330,7 +330,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
330 list_add_tail(&cb->list, &dev->write_list.list); 330 list_add_tail(&cb->list, &dev->write_list.list);
331 } 331 }
332 } else { 332 } else {
333 if (!(dev->mei_host_buffer_is_empty)) 333 if (!dev->hbuf_is_ready)
334 dev_dbg(&dev->pdev->dev, "host buffer is not empty"); 334 dev_dbg(&dev->pdev->dev, "host buffer is not empty");
335 335
336 dev_dbg(&dev->pdev->dev, "No flow control credentials, so add iamthif cb to write list.\n"); 336 dev_dbg(&dev->pdev->dev, "No flow control credentials, so add iamthif cb to write list.\n");
@@ -583,7 +583,7 @@ int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)
583 dev->iamthif_msg_buf_index = 0; 583 dev->iamthif_msg_buf_index = 0;
584 dev->iamthif_msg_buf_size = 0; 584 dev->iamthif_msg_buf_size = 0;
585 dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER; 585 dev->iamthif_stall_timer = MEI_IAMTHIF_STALL_TIMER;
586 dev->mei_host_buffer_is_empty = mei_hbuf_is_ready(dev); 586 dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
587 return 0; 587 return 0;
588} 588}
589 589
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index a921001053ba..e46663ee76de 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -393,8 +393,8 @@ int mei_cl_disconnect(struct mei_cl *cl)
393 return -ENOMEM; 393 return -ENOMEM;
394 394
395 cb->fop_type = MEI_FOP_CLOSE; 395 cb->fop_type = MEI_FOP_CLOSE;
396 if (dev->mei_host_buffer_is_empty) { 396 if (dev->hbuf_is_ready) {
397 dev->mei_host_buffer_is_empty = false; 397 dev->hbuf_is_ready = false;
398 if (mei_hbm_cl_disconnect_req(dev, cl)) { 398 if (mei_hbm_cl_disconnect_req(dev, cl)) {
399 rets = -ENODEV; 399 rets = -ENODEV;
400 dev_err(&dev->pdev->dev, "failed to disconnect.\n"); 400 dev_err(&dev->pdev->dev, "failed to disconnect.\n");
@@ -496,9 +496,8 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)
496 496
497 cb->fop_type = MEI_FOP_IOCTL; 497 cb->fop_type = MEI_FOP_IOCTL;
498 498
499 if (dev->mei_host_buffer_is_empty && 499 if (dev->hbuf_is_ready && !mei_cl_is_other_connecting(cl)) {
500 !mei_cl_is_other_connecting(cl)) { 500 dev->hbuf_is_ready = false;
501 dev->mei_host_buffer_is_empty = false;
502 501
503 if (mei_hbm_cl_connect_req(dev, cl)) { 502 if (mei_hbm_cl_connect_req(dev, cl)) {
504 rets = -ENODEV; 503 rets = -ENODEV;
@@ -661,8 +660,8 @@ int mei_cl_read_start(struct mei_cl *cl)
661 660
662 cb->fop_type = MEI_FOP_READ; 661 cb->fop_type = MEI_FOP_READ;
663 cl->read_cb = cb; 662 cl->read_cb = cb;
664 if (dev->mei_host_buffer_is_empty) { 663 if (dev->hbuf_is_ready) {
665 dev->mei_host_buffer_is_empty = false; 664 dev->hbuf_is_ready = false;
666 if (mei_hbm_cl_flow_control_req(dev, cl)) { 665 if (mei_hbm_cl_flow_control_req(dev, cl)) {
667 rets = -ENODEV; 666 rets = -ENODEV;
668 goto err; 667 goto err;
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index 3bebf8d85ff9..45ea7185c003 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -486,7 +486,7 @@ irqreturn_t mei_me_irq_thread_handler(int irq, void *dev_id)
486 rets = mei_irq_write_handler(dev, &complete_list); 486 rets = mei_irq_write_handler(dev, &complete_list);
487end: 487end:
488 dev_dbg(&dev->pdev->dev, "end of bottom half function.\n"); 488 dev_dbg(&dev->pdev->dev, "end of bottom half function.\n");
489 dev->mei_host_buffer_is_empty = mei_hbuf_is_ready(dev); 489 dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
490 490
491 bus_message_received = false; 491 bus_message_received = false;
492 if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) { 492 if (dev->recvd_msg && waitqueue_active(&dev->wait_recvd_msg)) {
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 843ae2febc70..903f809b21f7 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -454,14 +454,14 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
454 if (rets < 0) 454 if (rets < 0)
455 goto err; 455 goto err;
456 456
457 if (rets == 0 || dev->mei_host_buffer_is_empty == false) { 457 if (rets == 0 || !dev->hbuf_is_ready) {
458 write_cb->buf_idx = 0; 458 write_cb->buf_idx = 0;
459 mei_hdr.msg_complete = 0; 459 mei_hdr.msg_complete = 0;
460 cl->writing_state = MEI_WRITING; 460 cl->writing_state = MEI_WRITING;
461 goto out; 461 goto out;
462 } 462 }
463 463
464 dev->mei_host_buffer_is_empty = false; 464 dev->hbuf_is_ready = false;
465 if (length > mei_hbuf_max_len(dev)) { 465 if (length > mei_hbuf_max_len(dev)) {
466 mei_hdr.length = mei_hbuf_max_len(dev); 466 mei_hdr.length = mei_hbuf_max_len(dev);
467 mei_hdr.msg_complete = 0; 467 mei_hdr.msg_complete = 0;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 7d07cef75664..cb80166161f0 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -265,9 +265,13 @@ struct mei_hw_ops {
265 265
266/** 266/**
267 * struct mei_device - MEI private device struct 267 * struct mei_device - MEI private device struct
268
268 * @mem_addr - mem mapped base register address 269 * @mem_addr - mem mapped base register address
269 * @hbuf_depth - depth of host(write) buffer 270
270 * @wr_ext_msg - buffer for hbm control responses (set in read cycle) 271 * @hbuf_depth - depth of hardware host/write buffer is slots
272 * @hbuf_is_ready - query if the host host/write buffer is ready
273 * @wr_msg - the buffer for hbm control messages
274 * @wr_ext_msg - the buffer for hbm control responses (set in read cycle)
271 */ 275 */
272struct mei_device { 276struct mei_device {
273 struct pci_dev *pdev; /* pointer to pci device struct */ 277 struct pci_dev *pdev; /* pointer to pci device struct */
@@ -294,7 +298,6 @@ struct mei_device {
294 struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ 298 struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */
295 bool recvd_msg; 299 bool recvd_msg;
296 300
297 u8 hbuf_depth;
298 /* 301 /*
299 * waiting queue for receive message from FW 302 * waiting queue for receive message from FW
300 */ 303 */
@@ -311,6 +314,10 @@ struct mei_device {
311 unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */ 314 unsigned char rd_msg_buf[MEI_RD_MSG_BUF_SIZE]; /* control messages */
312 u32 rd_msg_hdr; 315 u32 rd_msg_hdr;
313 316
317 /* write buffer */
318 u8 hbuf_depth;
319 bool hbuf_is_ready;
320
314 /* used for control messages */ 321 /* used for control messages */
315 struct { 322 struct {
316 struct mei_msg_hdr hdr; 323 struct mei_msg_hdr hdr;
@@ -330,7 +337,6 @@ struct mei_device {
330 u8 me_clients_num; 337 u8 me_clients_num;
331 u8 me_client_presentation_num; 338 u8 me_client_presentation_num;
332 u8 me_client_index; 339 u8 me_client_index;
333 bool mei_host_buffer_is_empty;
334 340
335 struct mei_cl wd_cl; 341 struct mei_cl wd_cl;
336 enum mei_wd_states wd_state; 342 enum mei_wd_states wd_state;
diff --git a/drivers/misc/mei/wd.c b/drivers/misc/mei/wd.c
index 77b3820380b0..2413247fc392 100644
--- a/drivers/misc/mei/wd.c
+++ b/drivers/misc/mei/wd.c
@@ -157,9 +157,9 @@ int mei_wd_stop(struct mei_device *dev)
157 if (ret < 0) 157 if (ret < 0)
158 goto out; 158 goto out;
159 159
160 if (ret && dev->mei_host_buffer_is_empty) { 160 if (ret && dev->hbuf_is_ready) {
161 ret = 0; 161 ret = 0;
162 dev->mei_host_buffer_is_empty = false; 162 dev->hbuf_is_ready = false;
163 163
164 if (!mei_wd_send(dev)) { 164 if (!mei_wd_send(dev)) {
165 ret = mei_cl_flow_ctrl_reduce(&dev->wd_cl); 165 ret = mei_cl_flow_ctrl_reduce(&dev->wd_cl);
@@ -282,10 +282,9 @@ static int mei_wd_ops_ping(struct watchdog_device *wd_dev)
282 dev->wd_state = MEI_WD_RUNNING; 282 dev->wd_state = MEI_WD_RUNNING;
283 283
284 /* Check if we can send the ping to HW*/ 284 /* Check if we can send the ping to HW*/
285 if (dev->mei_host_buffer_is_empty && 285 if (dev->hbuf_is_ready && mei_cl_flow_ctrl_creds(&dev->wd_cl) > 0) {
286 mei_cl_flow_ctrl_creds(&dev->wd_cl) > 0) {
287 286
288 dev->mei_host_buffer_is_empty = false; 287 dev->hbuf_is_ready = false;
289 dev_dbg(&dev->pdev->dev, "wd: sending ping\n"); 288 dev_dbg(&dev->pdev->dev, "wd: sending ping\n");
290 289
291 if (mei_wd_send(dev)) { 290 if (mei_wd_send(dev)) {