aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/mei/hw-txe.c
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2014-02-19 10:35:48 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-02-28 18:15:57 -0500
commit9d098192c3d45ab6dd90ae87d649950a9ef70ccb (patch)
treea0f48fbc9a60e411cd499a22ac013f85fbb0aeeb /drivers/misc/mei/hw-txe.c
parent6aae48ff18f2fcfb533d2b448ecae16d1de006c1 (diff)
mei: revamp writing slot counting
Since txe use doorbell and not circular buffer we have to cheat in write slot counting, txe always consume all the slots upon write. In order for it to work we need to track slots using mei_hbuf_empty_slots() instead of tracking it in mei layer Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mei/hw-txe.c')
-rw-r--r--drivers/misc/mei/hw-txe.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/misc/mei/hw-txe.c b/drivers/misc/mei/hw-txe.c
index 8f5e4be9ebc2..f60182a52f96 100644
--- a/drivers/misc/mei/hw-txe.c
+++ b/drivers/misc/mei/hw-txe.c
@@ -566,7 +566,9 @@ static int mei_txe_write(struct mei_device *dev,
566 struct mei_txe_hw *hw = to_txe_hw(dev); 566 struct mei_txe_hw *hw = to_txe_hw(dev);
567 unsigned long rem; 567 unsigned long rem;
568 unsigned long length; 568 unsigned long length;
569 int slots = dev->hbuf_depth;
569 u32 *reg_buf = (u32 *)buf; 570 u32 *reg_buf = (u32 *)buf;
571 u32 dw_cnt;
570 int i; 572 int i;
571 573
572 if (WARN_ON(!header || !buf)) 574 if (WARN_ON(!header || !buf))
@@ -576,11 +578,9 @@ static int mei_txe_write(struct mei_device *dev,
576 578
577 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(header)); 579 dev_dbg(&dev->pdev->dev, MEI_HDR_FMT, MEI_HDR_PRM(header));
578 580
579 if ((length + sizeof(struct mei_msg_hdr)) > PAYLOAD_SIZE) { 581 dw_cnt = mei_data2slots(length);
580 dev_err(&dev->pdev->dev, "write length exceeded = %ld > %d\n", 582 if (dw_cnt > slots)
581 length + sizeof(struct mei_msg_hdr), PAYLOAD_SIZE); 583 return -EMSGSIZE;
582 return -ERANGE;
583 }
584 584
585 if (WARN(!hw->aliveness, "txe write: aliveness not asserted\n")) 585 if (WARN(!hw->aliveness, "txe write: aliveness not asserted\n"))
586 return -EAGAIN; 586 return -EAGAIN;
@@ -605,6 +605,9 @@ static int mei_txe_write(struct mei_device *dev,
605 mei_txe_input_payload_write(dev, i + 1, reg); 605 mei_txe_input_payload_write(dev, i + 1, reg);
606 } 606 }
607 607
608 /* after each write the whole buffer is consumed */
609 hw->slots = 0;
610
608 /* Set Input-Doorbell */ 611 /* Set Input-Doorbell */
609 mei_txe_input_doorbell_set(hw); 612 mei_txe_input_doorbell_set(hw);
610 613
@@ -632,7 +635,8 @@ static size_t mei_txe_hbuf_max_len(const struct mei_device *dev)
632 */ 635 */
633static int mei_txe_hbuf_empty_slots(struct mei_device *dev) 636static int mei_txe_hbuf_empty_slots(struct mei_device *dev)
634{ 637{
635 return dev->hbuf_depth; 638 struct mei_txe_hw *hw = to_txe_hw(dev);
639 return hw->slots;
636} 640}
637 641
638/** 642/**
@@ -978,11 +982,12 @@ irqreturn_t mei_txe_irq_thread_handler(int irq, void *dev_id)
978 } 982 }
979 } 983 }
980 /* Input Ready: Detection if host can write to SeC */ 984 /* Input Ready: Detection if host can write to SeC */
981 if (test_and_clear_bit(TXE_INTR_IN_READY_BIT, &hw->intr_cause)) 985 if (test_and_clear_bit(TXE_INTR_IN_READY_BIT, &hw->intr_cause)) {
982 dev->hbuf_is_ready = true; 986 dev->hbuf_is_ready = true;
987 hw->slots = dev->hbuf_depth;
988 }
983 989
984 if (hw->aliveness && dev->hbuf_is_ready) { 990 if (hw->aliveness && dev->hbuf_is_ready) {
985
986 /* get the real register value */ 991 /* get the real register value */
987 dev->hbuf_is_ready = mei_hbuf_is_ready(dev); 992 dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
988 rets = mei_irq_write_handler(dev, &complete_list); 993 rets = mei_irq_write_handler(dev, &complete_list);