diff options
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/mei/init.c | 3 | ||||
-rw-r--r-- | drivers/misc/mei/interface.c | 7 | ||||
-rw-r--r-- | drivers/misc/mei/interface.h | 6 | ||||
-rw-r--r-- | drivers/misc/mei/interrupt.c | 6 | ||||
-rw-r--r-- | drivers/misc/mei/iorw.c | 8 | ||||
-rw-r--r-- | drivers/misc/mei/main.c | 9 | ||||
-rw-r--r-- | drivers/misc/mei/mei_dev.h | 6 |
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 | */ |
104 | int mei_count_empty_write_slots(struct mei_device *dev) | 104 | int 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 | ||
50 | int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl); | 50 | int mei_flow_ctrl_creds(struct mei_device *dev, struct mei_cl *cl); |
51 | 51 | ||
52 | static 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 | |||
52 | int mei_wd_send(struct mei_device *dev); | 58 | int mei_wd_send(struct mei_device *dev); |
53 | int mei_wd_stop(struct mei_device *dev, bool preserve); | 59 | int mei_wd_stop(struct mei_device *dev, bool preserve); |
54 | int mei_wd_host_init(struct mei_device *dev); | 60 | int 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 | */ | ||
171 | struct mei_device { | 174 | struct 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 | */ |