summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2018-07-31 02:35:33 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-08-02 04:18:29 -0400
commit98e70866aacb1fcaa7b710fc6bca9862bf47421a (patch)
tree877e70ee1236f04a09ce277181542e66a8fcb51e
parentb34e9a15b37b8ddbf06a4da142b0c39c74211eb4 (diff)
mei: add support for variable length mei headers.
Remove header size knowledge from me and txe hw layers, this requires to change the write handler to accept header and its length as well as data and its length. HBM messages are fixed to use basic header, hence we add mei_hbm2slots() that converts HBM message length and mei message header, while mei_data2slots() converts data length directly to the slots. Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/misc/mei/client.c31
-rw-r--r--drivers/misc/mei/hbm.c30
-rw-r--r--drivers/misc/mei/hw-me.c34
-rw-r--r--drivers/misc/mei/hw-txe.c42
-rw-r--r--drivers/misc/mei/interrupt.c4
-rw-r--r--drivers/misc/mei/mei_dev.h25
6 files changed, 102 insertions, 64 deletions
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 207d2f5d5702..0a9173827461 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -863,7 +863,7 @@ int mei_cl_irq_disconnect(struct mei_cl *cl, struct mei_cl_cb *cb,
863 int slots; 863 int slots;
864 int ret; 864 int ret;
865 865
866 msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_request)); 866 msg_slots = mei_hbm2slots(sizeof(struct hbm_client_connect_request));
867 slots = mei_hbuf_empty_slots(dev); 867 slots = mei_hbuf_empty_slots(dev);
868 if (slots < 0) 868 if (slots < 0)
869 return -EOVERFLOW; 869 return -EOVERFLOW;
@@ -1055,11 +1055,10 @@ int mei_cl_irq_connect(struct mei_cl *cl, struct mei_cl_cb *cb,
1055 int slots; 1055 int slots;
1056 int rets; 1056 int rets;
1057 1057
1058 msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_request));
1059
1060 if (mei_cl_is_other_connecting(cl)) 1058 if (mei_cl_is_other_connecting(cl))
1061 return 0; 1059 return 0;
1062 1060
1061 msg_slots = mei_hbm2slots(sizeof(struct hbm_client_connect_request));
1063 slots = mei_hbuf_empty_slots(dev); 1062 slots = mei_hbuf_empty_slots(dev);
1064 if (slots < 0) 1063 if (slots < 0)
1065 return -EOVERFLOW; 1064 return -EOVERFLOW;
@@ -1299,7 +1298,7 @@ int mei_cl_irq_notify(struct mei_cl *cl, struct mei_cl_cb *cb,
1299 int ret; 1298 int ret;
1300 bool request; 1299 bool request;
1301 1300
1302 msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_request)); 1301 msg_slots = mei_hbm2slots(sizeof(struct hbm_client_connect_request));
1303 slots = mei_hbuf_empty_slots(dev); 1302 slots = mei_hbuf_empty_slots(dev);
1304 if (slots < 0) 1303 if (slots < 0)
1305 return -EOVERFLOW; 1304 return -EOVERFLOW;
@@ -1571,6 +1570,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1571 struct mei_device *dev; 1570 struct mei_device *dev;
1572 struct mei_msg_data *buf; 1571 struct mei_msg_data *buf;
1573 struct mei_msg_hdr mei_hdr; 1572 struct mei_msg_hdr mei_hdr;
1573 size_t hdr_len = sizeof(mei_hdr);
1574 size_t len; 1574 size_t len;
1575 size_t hbuf_len; 1575 size_t hbuf_len;
1576 int hbuf_slots; 1576 int hbuf_slots;
@@ -1601,7 +1601,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1601 rets = -EOVERFLOW; 1601 rets = -EOVERFLOW;
1602 goto err; 1602 goto err;
1603 } 1603 }
1604 hbuf_len = mei_slots2data(hbuf_slots) - sizeof(struct mei_msg_hdr); 1604
1605 hbuf_len = mei_slots2data(hbuf_slots);
1605 1606
1606 mei_msg_hdr_init(&mei_hdr, cb); 1607 mei_msg_hdr_init(&mei_hdr, cb);
1607 1608
@@ -1609,11 +1610,11 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1609 * Split the message only if we can write the whole host buffer 1610 * Split the message only if we can write the whole host buffer
1610 * otherwise wait for next time the host buffer is empty. 1611 * otherwise wait for next time the host buffer is empty.
1611 */ 1612 */
1612 if (hbuf_len >= len) { 1613 if (len + hdr_len <= hbuf_len) {
1613 mei_hdr.length = len; 1614 mei_hdr.length = len;
1614 mei_hdr.msg_complete = 1; 1615 mei_hdr.msg_complete = 1;
1615 } else if ((u32)hbuf_slots == mei_hbuf_depth(dev)) { 1616 } else if ((u32)hbuf_slots == mei_hbuf_depth(dev)) {
1616 mei_hdr.length = hbuf_len; 1617 mei_hdr.length = hbuf_len - hdr_len;
1617 } else { 1618 } else {
1618 return 0; 1619 return 0;
1619 } 1620 }
@@ -1621,7 +1622,8 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
1621 cl_dbg(dev, cl, "buf: size = %zu idx = %zu\n", 1622 cl_dbg(dev, cl, "buf: size = %zu idx = %zu\n",
1622 cb->buf.size, cb->buf_idx); 1623 cb->buf.size, cb->buf_idx);
1623 1624
1624 rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx); 1625 rets = mei_write_message(dev, &mei_hdr, hdr_len,
1626 buf->data + cb->buf_idx, mei_hdr.length);
1625 if (rets) 1627 if (rets)
1626 goto err; 1628 goto err;
1627 1629
@@ -1661,6 +1663,7 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
1661 struct mei_device *dev; 1663 struct mei_device *dev;
1662 struct mei_msg_data *buf; 1664 struct mei_msg_data *buf;
1663 struct mei_msg_hdr mei_hdr; 1665 struct mei_msg_hdr mei_hdr;
1666 size_t hdr_len = sizeof(mei_hdr);
1664 size_t len; 1667 size_t len;
1665 size_t hbuf_len; 1668 size_t hbuf_len;
1666 int hbuf_slots; 1669 int hbuf_slots;
@@ -1716,15 +1719,17 @@ ssize_t mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb)
1716 goto out; 1719 goto out;
1717 } 1720 }
1718 1721
1719 hbuf_len = mei_slots2data(hbuf_slots) - sizeof(struct mei_msg_hdr); 1722 hbuf_len = mei_slots2data(hbuf_slots);
1720 if (hbuf_len >= len) { 1723
1724 if (len + hdr_len <= hbuf_len) {
1721 mei_hdr.length = len; 1725 mei_hdr.length = len;
1722 mei_hdr.msg_complete = 1; 1726 mei_hdr.msg_complete = 1;
1723 } else { 1727 } else {
1724 mei_hdr.length = hbuf_len; 1728 mei_hdr.length = hbuf_len - hdr_len;
1725 } 1729 }
1726 1730
1727 rets = mei_write_message(dev, &mei_hdr, buf->data); 1731 rets = mei_write_message(dev, &mei_hdr, hdr_len,
1732 buf->data, mei_hdr.length);
1728 if (rets) 1733 if (rets)
1729 goto err; 1734 goto err;
1730 1735
@@ -1761,7 +1766,7 @@ out:
1761 } 1766 }
1762 } 1767 }
1763 1768
1764 rets = len; 1769 rets = buf->size;
1765err: 1770err:
1766 cl_dbg(dev, cl, "rpm: autosuspend\n"); 1771 cl_dbg(dev, cl, "rpm: autosuspend\n");
1767 pm_runtime_mark_last_busy(dev->dev); 1772 pm_runtime_mark_last_busy(dev->dev);
diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c
index fe6595fe94f1..8b3fd9ff6566 100644
--- a/drivers/misc/mei/hbm.c
+++ b/drivers/misc/mei/hbm.c
@@ -96,6 +96,20 @@ static int mei_cl_conn_status_to_errno(enum mei_cl_connect_status status)
96} 96}
97 97
98/** 98/**
99 * mei_hbm_write_message - wrapper for sending hbm messages.
100 *
101 * @dev: mei device
102 * @hdr: mei header
103 * @data: payload
104 */
105static inline int mei_hbm_write_message(struct mei_device *dev,
106 struct mei_msg_hdr *hdr,
107 const void *data)
108{
109 return mei_write_message(dev, hdr, sizeof(*hdr), data, hdr->length);
110}
111
112/**
99 * mei_hbm_idle - set hbm to idle state 113 * mei_hbm_idle - set hbm to idle state
100 * 114 *
101 * @dev: the device structure 115 * @dev: the device structure
@@ -174,7 +188,7 @@ static inline int mei_hbm_cl_write(struct mei_device *dev, struct mei_cl *cl,
174 mei_hbm_hdr(&mei_hdr, len); 188 mei_hbm_hdr(&mei_hdr, len);
175 mei_hbm_cl_hdr(cl, hbm_cmd, buf, len); 189 mei_hbm_cl_hdr(cl, hbm_cmd, buf, len);
176 190
177 return mei_write_message(dev, &mei_hdr, buf); 191 return mei_hbm_write_message(dev, &mei_hdr, buf);
178} 192}
179 193
180/** 194/**
@@ -267,7 +281,7 @@ int mei_hbm_start_req(struct mei_device *dev)
267 start_req.host_version.minor_version = HBM_MINOR_VERSION; 281 start_req.host_version.minor_version = HBM_MINOR_VERSION;
268 282
269 dev->hbm_state = MEI_HBM_IDLE; 283 dev->hbm_state = MEI_HBM_IDLE;
270 ret = mei_write_message(dev, &mei_hdr, &start_req); 284 ret = mei_hbm_write_message(dev, &mei_hdr, &start_req);
271 if (ret) { 285 if (ret) {
272 dev_err(dev->dev, "version message write failed: ret = %d\n", 286 dev_err(dev->dev, "version message write failed: ret = %d\n",
273 ret); 287 ret);
@@ -304,7 +318,7 @@ static int mei_hbm_enum_clients_req(struct mei_device *dev)
304 enum_req.flags |= dev->hbm_f_ie_supported ? 318 enum_req.flags |= dev->hbm_f_ie_supported ?
305 MEI_HBM_ENUM_F_IMMEDIATE_ENUM : 0; 319 MEI_HBM_ENUM_F_IMMEDIATE_ENUM : 0;
306 320
307 ret = mei_write_message(dev, &mei_hdr, &enum_req); 321 ret = mei_hbm_write_message(dev, &mei_hdr, &enum_req);
308 if (ret) { 322 if (ret) {
309 dev_err(dev->dev, "enumeration request write failed: ret = %d.\n", 323 dev_err(dev->dev, "enumeration request write failed: ret = %d.\n",
310 ret); 324 ret);
@@ -373,7 +387,7 @@ static int mei_hbm_add_cl_resp(struct mei_device *dev, u8 addr, u8 status)
373 resp.me_addr = addr; 387 resp.me_addr = addr;
374 resp.status = status; 388 resp.status = status;
375 389
376 ret = mei_write_message(dev, &mei_hdr, &resp); 390 ret = mei_hbm_write_message(dev, &mei_hdr, &resp);
377 if (ret) 391 if (ret)
378 dev_err(dev->dev, "add client response write failed: ret = %d\n", 392 dev_err(dev->dev, "add client response write failed: ret = %d\n",
379 ret); 393 ret);
@@ -430,7 +444,7 @@ int mei_hbm_cl_notify_req(struct mei_device *dev,
430 444
431 req.start = start; 445 req.start = start;
432 446
433 ret = mei_write_message(dev, &mei_hdr, &req); 447 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
434 if (ret) 448 if (ret)
435 dev_err(dev->dev, "notify request failed: ret = %d\n", ret); 449 dev_err(dev->dev, "notify request failed: ret = %d\n", ret);
436 450
@@ -555,7 +569,7 @@ static int mei_hbm_prop_req(struct mei_device *dev, unsigned long start_idx)
555 prop_req.hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD; 569 prop_req.hbm_cmd = HOST_CLIENT_PROPERTIES_REQ_CMD;
556 prop_req.me_addr = addr; 570 prop_req.me_addr = addr;
557 571
558 ret = mei_write_message(dev, &mei_hdr, &prop_req); 572 ret = mei_hbm_write_message(dev, &mei_hdr, &prop_req);
559 if (ret) { 573 if (ret) {
560 dev_err(dev->dev, "properties request write failed: ret = %d\n", 574 dev_err(dev->dev, "properties request write failed: ret = %d\n",
561 ret); 575 ret);
@@ -592,7 +606,7 @@ int mei_hbm_pg(struct mei_device *dev, u8 pg_cmd)
592 memset(&req, 0, len); 606 memset(&req, 0, len);
593 req.hbm_cmd = pg_cmd; 607 req.hbm_cmd = pg_cmd;
594 608
595 ret = mei_write_message(dev, &mei_hdr, &req); 609 ret = mei_hbm_write_message(dev, &mei_hdr, &req);
596 if (ret) 610 if (ret)
597 dev_err(dev->dev, "power gate command write failed.\n"); 611 dev_err(dev->dev, "power gate command write failed.\n");
598 return ret; 612 return ret;
@@ -618,7 +632,7 @@ static int mei_hbm_stop_req(struct mei_device *dev)
618 req.hbm_cmd = HOST_STOP_REQ_CMD; 632 req.hbm_cmd = HOST_STOP_REQ_CMD;
619 req.reason = DRIVER_STOP_REQUEST; 633 req.reason = DRIVER_STOP_REQUEST;
620 634
621 return mei_write_message(dev, &mei_hdr, &req); 635 return mei_hbm_write_message(dev, &mei_hdr, &req);
622} 636}
623 637
624/** 638/**
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c
index c50671cf47eb..0e3c31595dda 100644
--- a/drivers/misc/mei/hw-me.c
+++ b/drivers/misc/mei/hw-me.c
@@ -517,28 +517,31 @@ static u32 mei_me_hbuf_depth(const struct mei_device *dev)
517 return hw->hbuf_depth; 517 return hw->hbuf_depth;
518} 518}
519 519
520
521/** 520/**
522 * mei_me_hbuf_write - writes a message to host hw buffer. 521 * mei_me_hbuf_write - writes a message to host hw buffer.
523 * 522 *
524 * @dev: the device structure 523 * @dev: the device structure
525 * @header: mei HECI header of message 524 * @hdr: header of message
526 * @buf: message payload will be written 525 * @hdr_len: header length in bytes: must be multiplication of a slot (4bytes)
526 * @data: payload
527 * @data_len: payload length in bytes
527 * 528 *
528 * Return: -EIO if write has failed 529 * Return: 0 if success, < 0 - otherwise.
529 */ 530 */
530static int mei_me_hbuf_write(struct mei_device *dev, 531static int mei_me_hbuf_write(struct mei_device *dev,
531 struct mei_msg_hdr *header, 532 const void *hdr, size_t hdr_len,
532 const unsigned char *buf) 533 const void *data, size_t data_len)
533{ 534{
534 unsigned long rem; 535 unsigned long rem;
535 unsigned long length = header->length;
536 unsigned long i; 536 unsigned long i;
537 u32 *reg_buf = (u32 *)buf; 537 const u32 *reg_buf;
538 u32 dw_cnt; 538 u32 dw_cnt;
539 int empty_slots; 539 int empty_slots;
540 540
541 dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM(header)); 541 if (WARN_ON(!hdr || !data || hdr_len & 0x3))
542 return -EINVAL;
543
544 dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM((struct mei_msg_hdr *)hdr));
542 545
543 empty_slots = mei_hbuf_empty_slots(dev); 546 empty_slots = mei_hbuf_empty_slots(dev);
544 dev_dbg(dev->dev, "empty slots = %hu.\n", empty_slots); 547 dev_dbg(dev->dev, "empty slots = %hu.\n", empty_slots);
@@ -546,20 +549,23 @@ static int mei_me_hbuf_write(struct mei_device *dev,
546 if (empty_slots < 0) 549 if (empty_slots < 0)
547 return -EOVERFLOW; 550 return -EOVERFLOW;
548 551
549 dw_cnt = mei_data2slots(length); 552 dw_cnt = mei_data2slots(hdr_len + data_len);
550 if (dw_cnt > (u32)empty_slots) 553 if (dw_cnt > (u32)empty_slots)
551 return -EMSGSIZE; 554 return -EMSGSIZE;
552 555
553 mei_me_hcbww_write(dev, *((u32 *) header)); 556 reg_buf = hdr;
557 for (i = 0; i < hdr_len / MEI_SLOT_SIZE; i++)
558 mei_me_hcbww_write(dev, reg_buf[i]);
554 559
555 for (i = 0; i < length / MEI_SLOT_SIZE; i++) 560 reg_buf = data;
561 for (i = 0; i < data_len / MEI_SLOT_SIZE; i++)
556 mei_me_hcbww_write(dev, reg_buf[i]); 562 mei_me_hcbww_write(dev, reg_buf[i]);
557 563
558 rem = length & 0x3; 564 rem = data_len & 0x3;
559 if (rem > 0) { 565 if (rem > 0) {
560 u32 reg = 0; 566 u32 reg = 0;
561 567
562 memcpy(&reg, &buf[length - rem], rem); 568 memcpy(&reg, (const u8 *)data + data_len - rem, rem);
563 mei_me_hcbww_write(dev, reg); 569 mei_me_hcbww_write(dev, reg);
564 } 570 }
565 571
diff --git a/drivers/misc/mei/hw-txe.c b/drivers/misc/mei/hw-txe.c
index 7e2026894e9f..8449fe0367ff 100644
--- a/drivers/misc/mei/hw-txe.c
+++ b/drivers/misc/mei/hw-txe.c
@@ -689,37 +689,34 @@ static void mei_txe_hw_config(struct mei_device *dev)
689 hw->aliveness, hw->readiness); 689 hw->aliveness, hw->readiness);
690} 690}
691 691
692
693/** 692/**
694 * mei_txe_write - writes a message to device. 693 * mei_txe_write - writes a message to device.
695 * 694 *
696 * @dev: the device structure 695 * @dev: the device structure
697 * @header: header of message 696 * @hdr: header of message
698 * @buf: message buffer will be written 697 * @hdr_len: header length in bytes - must multiplication of a slot (4bytes)
698 * @data: payload
699 * @data_len: paylead length in bytes
699 * 700 *
700 * Return: 0 if success, <0 - otherwise. 701 * Return: 0 if success, < 0 - otherwise.
701 */ 702 */
702
703static int mei_txe_write(struct mei_device *dev, 703static int mei_txe_write(struct mei_device *dev,
704 struct mei_msg_hdr *header, 704 const void *hdr, size_t hdr_len,
705 const unsigned char *buf) 705 const void *data, size_t data_len)
706{ 706{
707 struct mei_txe_hw *hw = to_txe_hw(dev); 707 struct mei_txe_hw *hw = to_txe_hw(dev);
708 unsigned long rem; 708 unsigned long rem;
709 unsigned long length; 709 const u32 *reg_buf;
710 unsigned long i;
711 u32 slots = TXE_HBUF_DEPTH; 710 u32 slots = TXE_HBUF_DEPTH;
712 u32 *reg_buf = (u32 *)buf;
713 u32 dw_cnt; 711 u32 dw_cnt;
712 unsigned long i, j;
714 713
715 if (WARN_ON(!header || !buf)) 714 if (WARN_ON(!hdr || !data || hdr_len & 0x3))
716 return -EINVAL; 715 return -EINVAL;
717 716
718 length = header->length; 717 dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM((struct mei_msg_hdr *)hdr));
719
720 dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM(header));
721 718
722 dw_cnt = mei_data2slots(length); 719 dw_cnt = mei_data2slots(hdr_len + data_len);
723 if (dw_cnt > slots) 720 if (dw_cnt > slots)
724 return -EMSGSIZE; 721 return -EMSGSIZE;
725 722
@@ -737,17 +734,20 @@ static int mei_txe_write(struct mei_device *dev,
737 return -EAGAIN; 734 return -EAGAIN;
738 } 735 }
739 736
740 mei_txe_input_payload_write(dev, 0, *((u32 *)header)); 737 reg_buf = hdr;
738 for (i = 0; i < hdr_len / MEI_SLOT_SIZE; i++)
739 mei_txe_input_payload_write(dev, i, reg_buf[i]);
741 740
742 for (i = 0; i < length / 4; i++) 741 reg_buf = data;
743 mei_txe_input_payload_write(dev, i + 1, reg_buf[i]); 742 for (j = 0; j < data_len / MEI_SLOT_SIZE; j++)
743 mei_txe_input_payload_write(dev, i + j, reg_buf[j]);
744 744
745 rem = length & 0x3; 745 rem = data_len & 0x3;
746 if (rem > 0) { 746 if (rem > 0) {
747 u32 reg = 0; 747 u32 reg = 0;
748 748
749 memcpy(&reg, &buf[length - rem], rem); 749 memcpy(&reg, (const u8 *)data + data_len - rem, rem);
750 mei_txe_input_payload_write(dev, i + 1, reg); 750 mei_txe_input_payload_write(dev, i + j, reg);
751 } 751 }
752 752
753 /* after each write the whole buffer is consumed */ 753 /* after each write the whole buffer is consumed */
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 6217cebcad3d..5a661cbdf2ae 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -173,7 +173,7 @@ static int mei_cl_irq_disconnect_rsp(struct mei_cl *cl, struct mei_cl_cb *cb,
173 int slots; 173 int slots;
174 int ret; 174 int ret;
175 175
176 msg_slots = mei_data2slots(sizeof(struct hbm_client_connect_response)); 176 msg_slots = mei_hbm2slots(sizeof(struct hbm_client_connect_response));
177 slots = mei_hbuf_empty_slots(dev); 177 slots = mei_hbuf_empty_slots(dev);
178 if (slots < 0) 178 if (slots < 0)
179 return -EOVERFLOW; 179 return -EOVERFLOW;
@@ -208,7 +208,7 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
208 if (!list_empty(&cl->rd_pending)) 208 if (!list_empty(&cl->rd_pending))
209 return 0; 209 return 0;
210 210
211 msg_slots = mei_data2slots(sizeof(struct hbm_flow_control)); 211 msg_slots = mei_hbm2slots(sizeof(struct hbm_flow_control));
212 slots = mei_hbuf_empty_slots(dev); 212 slots = mei_hbuf_empty_slots(dev);
213 if (slots < 0) 213 if (slots < 0)
214 return -EOVERFLOW; 214 return -EOVERFLOW;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index e9f37085a628..06fb5fc67fe9 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -300,8 +300,8 @@ struct mei_hw_ops {
300 bool (*hbuf_is_ready)(struct mei_device *dev); 300 bool (*hbuf_is_ready)(struct mei_device *dev);
301 u32 (*hbuf_depth)(const struct mei_device *dev); 301 u32 (*hbuf_depth)(const struct mei_device *dev);
302 int (*write)(struct mei_device *dev, 302 int (*write)(struct mei_device *dev,
303 struct mei_msg_hdr *hdr, 303 const void *hdr, size_t hdr_len,
304 const unsigned char *buf); 304 const void *data, size_t data_len);
305 305
306 int (*rdbuf_full_slots)(struct mei_device *dev); 306 int (*rdbuf_full_slots)(struct mei_device *dev);
307 307
@@ -528,8 +528,7 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
528} 528}
529 529
530/** 530/**
531 * mei_data2slots - get slots - number of (dwords) from a message length 531 * mei_data2slots - get slots number from a message length
532 * + size of the mei header
533 * 532 *
534 * @length: size of the messages in bytes 533 * @length: size of the messages in bytes
535 * 534 *
@@ -537,6 +536,19 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec)
537 */ 536 */
538static inline u32 mei_data2slots(size_t length) 537static inline u32 mei_data2slots(size_t length)
539{ 538{
539 return DIV_ROUND_UP(length, MEI_SLOT_SIZE);
540}
541
542/**
543 * mei_hbm2slots - get slots number from a hbm message length
544 * length + size of the mei message header
545 *
546 * @length: size of the messages in bytes
547 *
548 * Return: number of slots
549 */
550static inline u32 mei_hbm2slots(size_t length)
551{
540 return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, MEI_SLOT_SIZE); 552 return DIV_ROUND_UP(sizeof(struct mei_msg_hdr) + length, MEI_SLOT_SIZE);
541} 553}
542 554
@@ -656,9 +668,10 @@ static inline u32 mei_hbuf_depth(const struct mei_device *dev)
656} 668}
657 669
658static inline int mei_write_message(struct mei_device *dev, 670static inline int mei_write_message(struct mei_device *dev,
659 struct mei_msg_hdr *hdr, const void *buf) 671 const void *hdr, size_t hdr_len,
672 const void *data, size_t data_len)
660{ 673{
661 return dev->ops->write(dev, hdr, buf); 674 return dev->ops->write(dev, hdr, hdr_len, data, data_len);
662} 675}
663 676
664static inline u32 mei_read_hdr(const struct mei_device *dev) 677static inline u32 mei_read_hdr(const struct mei_device *dev)