aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2012-06-25 16:46:27 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-06-26 18:59:44 -0400
commit24aadc809f270857743e62d0882865fb3ba195d9 (patch)
tree5df3ea0a48d63ccee9ad702deb35b7c1aaa52ba4 /drivers/misc
parent21c66d1be7c586b56c2902ada4ba030a12b00063 (diff)
mei: don't query HCSR for host buffer depth
1. We record host (write) buffer depth during reset so we don't need to query HCSR register later on. The host buffer depth doesn't change after the reset 2. Use mei_hbuf_max_data function to compute payload size in bytes Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/mei/init.c3
-rw-r--r--drivers/misc/mei/interface.c7
-rw-r--r--drivers/misc/mei/interface.h6
-rw-r--r--drivers/misc/mei/interrupt.c6
-rw-r--r--drivers/misc/mei/iorw.c8
-rw-r--r--drivers/misc/mei/main.c9
-rw-r--r--drivers/misc/mei/mei_dev.h6
7 files changed, 24 insertions, 21 deletions
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c
index a7d0bb0880ec..d39b2774535b 100644
--- a/drivers/misc/mei/init.c
+++ b/drivers/misc/mei/init.c
@@ -162,6 +162,9 @@ int mei_hw_init(struct mei_device *dev)
162 if ((dev->host_hw_state & H_IS) == H_IS) 162 if ((dev->host_hw_state & H_IS) == H_IS)
163 mei_reg_write(dev, H_CSR, dev->host_hw_state); 163 mei_reg_write(dev, H_CSR, dev->host_hw_state);
164 164
165 /* Doesn't change in runtime */
166 dev->hbuf_depth = (dev->host_hw_state & H_CBD) >> 24;
167
165 dev->recvd_msg = false; 168 dev->recvd_msg = false;
166 dev_dbg(&dev->pdev->dev, "reset in start the mei device.\n"); 169 dev_dbg(&dev->pdev->dev, "reset in start the mei device.\n");
167 170
diff --git a/drivers/misc/mei/interface.c b/drivers/misc/mei/interface.c
index 6c0569177646..784a60626fa1 100644
--- a/drivers/misc/mei/interface.c
+++ b/drivers/misc/mei/interface.c
@@ -103,15 +103,14 @@ int mei_host_buffer_is_empty(struct mei_device *dev)
103 */ 103 */
104int mei_count_empty_write_slots(struct mei_device *dev) 104int mei_count_empty_write_slots(struct mei_device *dev)
105{ 105{
106 unsigned char buffer_depth, filled_slots, empty_slots; 106 unsigned char filled_slots, empty_slots;
107 107
108 dev->host_hw_state = mei_hcsr_read(dev); 108 dev->host_hw_state = mei_hcsr_read(dev);
109 buffer_depth = (unsigned char) ((dev->host_hw_state & H_CBD) >> 24);
110 filled_slots = _host_get_filled_slots(dev); 109 filled_slots = _host_get_filled_slots(dev);
111 empty_slots = buffer_depth - filled_slots; 110 empty_slots = dev->hbuf_depth - filled_slots;
112 111
113 /* check for overflow */ 112 /* check for overflow */
114 if (filled_slots > buffer_depth) 113 if (filled_slots > dev->hbuf_depth)
115 return -EOVERFLOW; 114 return -EOVERFLOW;
116 115
117 return empty_slots; 116 return empty_slots;
diff --git a/drivers/misc/mei/interface.h b/drivers/misc/mei/interface.h
index ddff5d16616f..8723d8880149 100644
--- a/drivers/misc/mei/interface.h
+++ b/drivers/misc/mei/interface.h
@@ -49,6 +49,12 @@ int mei_count_empty_write_slots(struct mei_device *dev);
49 49
50int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl); 50int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl);
51 51
52static inline size_t mei_hbuf_max_data(const struct mei_device *dev)
53{
54 return dev->hbuf_depth * sizeof(u32) - sizeof(struct mei_msg_hdr);
55}
56
57
52int mei_wd_send(struct mei_device *dev); 58int mei_wd_send(struct mei_device *dev);
53int mei_wd_stop(struct mei_device *dev, bool preserve); 59int mei_wd_stop(struct mei_device *dev, bool preserve);
54int mei_wd_host_init(struct mei_device *dev); 60int mei_wd_host_init(struct mei_device *dev);
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index 8e4dd74b96e5..4ad6a6bab5a3 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -951,7 +951,7 @@ static int _mei_irq_thread_cmpl(struct mei_device *dev, s32 *slots,
951 list_move_tail(&cb_pos->cb_list, 951 list_move_tail(&cb_pos->cb_list,
952 &dev->write_waiting_list.mei_cb.cb_list); 952 &dev->write_waiting_list.mei_cb.cb_list);
953 } 953 }
954 } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) { 954 } else if (*slots == dev->hbuf_depth) {
955 /* buffer is still empty */ 955 /* buffer is still empty */
956 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; 956 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
957 mei_hdr->host_addr = cl->host_client_id; 957 mei_hdr->host_addr = cl->host_client_id;
@@ -1046,8 +1046,8 @@ static int _mei_irq_thread_cmpl_iamthif(struct mei_device *dev, s32 *slots,
1046 &dev->write_waiting_list.mei_cb.cb_list); 1046 &dev->write_waiting_list.mei_cb.cb_list);
1047 1047
1048 } 1048 }
1049 } else if (*slots == ((dev->host_hw_state & H_CBD) >> 24)) { 1049 } else if (*slots == dev->hbuf_depth) {
1050 /* buffer is still empty */ 1050 /* buffer is still empty */
1051 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0]; 1051 mei_hdr = (struct mei_msg_hdr *) &dev->wr_msg_buf[0];
1052 mei_hdr->host_addr = cl->host_client_id; 1052 mei_hdr->host_addr = cl->host_client_id;
1053 mei_hdr->me_addr = cl->me_client_id; 1053 mei_hdr->me_addr = cl->me_client_id;
diff --git a/drivers/misc/mei/iorw.c b/drivers/misc/mei/iorw.c
index f9cced69b65e..50f52e21f587 100644
--- a/drivers/misc/mei/iorw.c
+++ b/drivers/misc/mei/iorw.c
@@ -481,12 +481,8 @@ int amthi_write(struct mei_device *dev, struct mei_cl_cb *cb)
481 if (ret && dev->mei_host_buffer_is_empty) { 481 if (ret && dev->mei_host_buffer_is_empty) {
482 ret = 0; 482 ret = 0;
483 dev->mei_host_buffer_is_empty = false; 483 dev->mei_host_buffer_is_empty = false;
484 if (cb->request_buffer.size > 484 if (cb->request_buffer.size > mei_hbuf_max_data(dev)) {
485 (((dev->host_hw_state & H_CBD) >> 24) * sizeof(u32)) 485 mei_hdr.length = mei_hbuf_max_data(dev);
486 -sizeof(struct mei_msg_hdr)) {
487 mei_hdr.length =
488 (((dev->host_hw_state & H_CBD) >> 24) *
489 sizeof(u32)) - sizeof(struct mei_msg_hdr);
490 mei_hdr.msg_complete = 0; 486 mei_hdr.msg_complete = 0;
491 } else { 487 } else {
492 mei_hdr.length = cb->request_buffer.size; 488 mei_hdr.length = cb->request_buffer.size;
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index c70333228337..aaf2683ea154 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -714,13 +714,8 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
714 if (rets && dev->mei_host_buffer_is_empty) { 714 if (rets && dev->mei_host_buffer_is_empty) {
715 rets = 0; 715 rets = 0;
716 dev->mei_host_buffer_is_empty = false; 716 dev->mei_host_buffer_is_empty = false;
717 if (length > ((((dev->host_hw_state & H_CBD) >> 24) * 717 if (length > mei_hbuf_max_data(dev)) {
718 sizeof(u32)) - sizeof(struct mei_msg_hdr))) { 718 mei_hdr.length = mei_hbuf_max_data(dev);
719
720 mei_hdr.length =
721 (((dev->host_hw_state & H_CBD) >> 24) *
722 sizeof(u32)) -
723 sizeof(struct mei_msg_hdr);
724 mei_hdr.msg_complete = 0; 719 mei_hdr.msg_complete = 0;
725 } else { 720 } else {
726 mei_hdr.length = length; 721 mei_hdr.length = length;
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 4fe653392a49..d60250d663c6 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -167,7 +167,10 @@ struct mei_io_list {
167 struct mei_cl_cb mei_cb; 167 struct mei_cl_cb mei_cb;
168}; 168};
169 169
170/* MEI private device struct */ 170/**
171 * struct mei_deive - MEI private device struct
172 * @hbuf_depth - depth of host(write) buffer
173 */
171struct mei_device { 174struct mei_device {
172 struct pci_dev *pdev; /* pointer to pci device struct */ 175 struct pci_dev *pdev; /* pointer to pci device struct */
173 /* 176 /*
@@ -205,6 +208,7 @@ struct mei_device {
205 */ 208 */
206 u32 host_hw_state; 209 u32 host_hw_state;
207 u32 me_hw_state; 210 u32 me_hw_state;
211 u8 hbuf_depth;
208 /* 212 /*
209 * waiting queue for receive message from FW 213 * waiting queue for receive message from FW
210 */ 214 */