diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2013-02-06 07:06:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-02-06 14:23:14 -0500 |
commit | 52c34561415b420301f1580413a9d1891d079494 (patch) | |
tree | cef4f13fd27d9ff22670af73a98d6adc879ba573 | |
parent | 2703d4b2e673cc240ad06d79d131fd1d0f77d65d (diff) |
mei: initial extract of ME hw specifics from mei_device
This is initial step of move the ME hw specifics
out of mei_device structure into mei_me_hw
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/misc/mei/hw-me.c | 131 | ||||
-rw-r--r-- | drivers/misc/mei/hw-me.h | 12 | ||||
-rw-r--r-- | drivers/misc/mei/init.c | 28 | ||||
-rw-r--r-- | drivers/misc/mei/mei_dev.h | 10 | ||||
-rw-r--r-- | drivers/misc/mei/pci-me.c | 21 |
5 files changed, 114 insertions, 88 deletions
diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index 94b203ec9b1f..3bdf22848a91 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c | |||
@@ -28,10 +28,10 @@ | |||
28 | * | 28 | * |
29 | * returns register value (u32) | 29 | * returns register value (u32) |
30 | */ | 30 | */ |
31 | static inline u32 mei_reg_read(const struct mei_device *dev, | 31 | static inline u32 mei_reg_read(const struct mei_me_hw *hw, |
32 | unsigned long offset) | 32 | unsigned long offset) |
33 | { | 33 | { |
34 | return ioread32(dev->mem_addr + offset); | 34 | return ioread32(hw->mem_addr + offset); |
35 | } | 35 | } |
36 | 36 | ||
37 | 37 | ||
@@ -42,10 +42,10 @@ static inline u32 mei_reg_read(const struct mei_device *dev, | |||
42 | * @offset: offset from which to write the data | 42 | * @offset: offset from which to write the data |
43 | * @value: register value to write (u32) | 43 | * @value: register value to write (u32) |
44 | */ | 44 | */ |
45 | static inline void mei_reg_write(const struct mei_device *dev, | 45 | static inline void mei_reg_write(const struct mei_me_hw *hw, |
46 | unsigned long offset, u32 value) | 46 | unsigned long offset, u32 value) |
47 | { | 47 | { |
48 | iowrite32(value, dev->mem_addr + offset); | 48 | iowrite32(value, hw->mem_addr + offset); |
49 | } | 49 | } |
50 | 50 | ||
51 | /** | 51 | /** |
@@ -58,7 +58,7 @@ static inline void mei_reg_write(const struct mei_device *dev, | |||
58 | */ | 58 | */ |
59 | u32 mei_mecbrw_read(const struct mei_device *dev) | 59 | u32 mei_mecbrw_read(const struct mei_device *dev) |
60 | { | 60 | { |
61 | return mei_reg_read(dev, ME_CB_RW); | 61 | return mei_reg_read(to_me_hw(dev), ME_CB_RW); |
62 | } | 62 | } |
63 | /** | 63 | /** |
64 | * mei_mecsr_read - Reads 32bit data from the ME CSR | 64 | * mei_mecsr_read - Reads 32bit data from the ME CSR |
@@ -67,9 +67,9 @@ u32 mei_mecbrw_read(const struct mei_device *dev) | |||
67 | * | 67 | * |
68 | * returns ME_CSR_HA register value (u32) | 68 | * returns ME_CSR_HA register value (u32) |
69 | */ | 69 | */ |
70 | static inline u32 mei_mecsr_read(const struct mei_device *dev) | 70 | static inline u32 mei_mecsr_read(const struct mei_me_hw *hw) |
71 | { | 71 | { |
72 | return mei_reg_read(dev, ME_CSR_HA); | 72 | return mei_reg_read(hw, ME_CSR_HA); |
73 | } | 73 | } |
74 | 74 | ||
75 | /** | 75 | /** |
@@ -79,9 +79,9 @@ static inline u32 mei_mecsr_read(const struct mei_device *dev) | |||
79 | * | 79 | * |
80 | * returns H_CSR register value (u32) | 80 | * returns H_CSR register value (u32) |
81 | */ | 81 | */ |
82 | static inline u32 mei_hcsr_read(const struct mei_device *dev) | 82 | static inline u32 mei_hcsr_read(const struct mei_me_hw *hw) |
83 | { | 83 | { |
84 | return mei_reg_read(dev, H_CSR); | 84 | return mei_reg_read(hw, H_CSR); |
85 | } | 85 | } |
86 | 86 | ||
87 | /** | 87 | /** |
@@ -90,10 +90,10 @@ static inline u32 mei_hcsr_read(const struct mei_device *dev) | |||
90 | * | 90 | * |
91 | * @dev: the device structure | 91 | * @dev: the device structure |
92 | */ | 92 | */ |
93 | static inline void mei_hcsr_set(struct mei_device *dev, u32 hcsr) | 93 | static inline void mei_hcsr_set(struct mei_me_hw *hw, u32 hcsr) |
94 | { | 94 | { |
95 | hcsr &= ~H_IS; | 95 | hcsr &= ~H_IS; |
96 | mei_reg_write(dev, H_CSR, hcsr); | 96 | mei_reg_write(hw, H_CSR, hcsr); |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
@@ -104,7 +104,7 @@ static inline void mei_hcsr_set(struct mei_device *dev, u32 hcsr) | |||
104 | */ | 104 | */ |
105 | void mei_hw_config(struct mei_device *dev) | 105 | void mei_hw_config(struct mei_device *dev) |
106 | { | 106 | { |
107 | u32 hcsr = mei_hcsr_read(dev); | 107 | u32 hcsr = mei_hcsr_read(to_me_hw(dev)); |
108 | /* Doesn't change in runtime */ | 108 | /* Doesn't change in runtime */ |
109 | dev->hbuf_depth = (hcsr & H_CBD) >> 24; | 109 | dev->hbuf_depth = (hcsr & H_CBD) >> 24; |
110 | } | 110 | } |
@@ -115,9 +115,10 @@ void mei_hw_config(struct mei_device *dev) | |||
115 | */ | 115 | */ |
116 | void mei_clear_interrupts(struct mei_device *dev) | 116 | void mei_clear_interrupts(struct mei_device *dev) |
117 | { | 117 | { |
118 | u32 hcsr = mei_hcsr_read(dev); | 118 | struct mei_me_hw *hw = to_me_hw(dev); |
119 | u32 hcsr = mei_hcsr_read(hw); | ||
119 | if ((hcsr & H_IS) == H_IS) | 120 | if ((hcsr & H_IS) == H_IS) |
120 | mei_reg_write(dev, H_CSR, hcsr); | 121 | mei_reg_write(hw, H_CSR, hcsr); |
121 | } | 122 | } |
122 | 123 | ||
123 | /** | 124 | /** |
@@ -127,9 +128,10 @@ void mei_clear_interrupts(struct mei_device *dev) | |||
127 | */ | 128 | */ |
128 | void mei_enable_interrupts(struct mei_device *dev) | 129 | void mei_enable_interrupts(struct mei_device *dev) |
129 | { | 130 | { |
130 | u32 hcsr = mei_hcsr_read(dev); | 131 | struct mei_me_hw *hw = to_me_hw(dev); |
132 | u32 hcsr = mei_hcsr_read(hw); | ||
131 | hcsr |= H_IE; | 133 | hcsr |= H_IE; |
132 | mei_hcsr_set(dev, hcsr); | 134 | mei_hcsr_set(hw, hcsr); |
133 | } | 135 | } |
134 | 136 | ||
135 | /** | 137 | /** |
@@ -139,9 +141,10 @@ void mei_enable_interrupts(struct mei_device *dev) | |||
139 | */ | 141 | */ |
140 | void mei_disable_interrupts(struct mei_device *dev) | 142 | void mei_disable_interrupts(struct mei_device *dev) |
141 | { | 143 | { |
142 | u32 hcsr = mei_hcsr_read(dev); | 144 | struct mei_me_hw *hw = to_me_hw(dev); |
145 | u32 hcsr = mei_hcsr_read(hw); | ||
143 | hcsr &= ~H_IE; | 146 | hcsr &= ~H_IE; |
144 | mei_hcsr_set(dev, hcsr); | 147 | mei_hcsr_set(hw, hcsr); |
145 | } | 148 | } |
146 | 149 | ||
147 | /** | 150 | /** |
@@ -152,7 +155,8 @@ void mei_disable_interrupts(struct mei_device *dev) | |||
152 | */ | 155 | */ |
153 | void mei_hw_reset(struct mei_device *dev, bool intr_enable) | 156 | void mei_hw_reset(struct mei_device *dev, bool intr_enable) |
154 | { | 157 | { |
155 | u32 hcsr = mei_hcsr_read(dev); | 158 | struct mei_me_hw *hw = to_me_hw(dev); |
159 | u32 hcsr = mei_hcsr_read(hw); | ||
156 | 160 | ||
157 | dev_dbg(&dev->pdev->dev, "before reset HCSR = 0x%08x.\n", hcsr); | 161 | dev_dbg(&dev->pdev->dev, "before reset HCSR = 0x%08x.\n", hcsr); |
158 | 162 | ||
@@ -163,14 +167,14 @@ void mei_hw_reset(struct mei_device *dev, bool intr_enable) | |||
163 | else | 167 | else |
164 | hcsr &= ~H_IE; | 168 | hcsr &= ~H_IE; |
165 | 169 | ||
166 | mei_hcsr_set(dev, hcsr); | 170 | mei_hcsr_set(hw, hcsr); |
167 | 171 | ||
168 | hcsr = mei_hcsr_read(dev) | H_IG; | 172 | hcsr = mei_hcsr_read(hw) | H_IG; |
169 | hcsr &= ~H_RST; | 173 | hcsr &= ~H_RST; |
170 | 174 | ||
171 | mei_hcsr_set(dev, hcsr); | 175 | mei_hcsr_set(hw, hcsr); |
172 | 176 | ||
173 | hcsr = mei_hcsr_read(dev); | 177 | hcsr = mei_hcsr_read(hw); |
174 | 178 | ||
175 | dev_dbg(&dev->pdev->dev, "current HCSR = 0x%08x.\n", hcsr); | 179 | dev_dbg(&dev->pdev->dev, "current HCSR = 0x%08x.\n", hcsr); |
176 | } | 180 | } |
@@ -184,8 +188,9 @@ void mei_hw_reset(struct mei_device *dev, bool intr_enable) | |||
184 | 188 | ||
185 | void mei_host_set_ready(struct mei_device *dev) | 189 | void mei_host_set_ready(struct mei_device *dev) |
186 | { | 190 | { |
187 | dev->host_hw_state |= H_IE | H_IG | H_RDY; | 191 | struct mei_me_hw *hw = to_me_hw(dev); |
188 | mei_hcsr_set(dev, dev->host_hw_state); | 192 | hw->host_hw_state |= H_IE | H_IG | H_RDY; |
193 | mei_hcsr_set(hw, hw->host_hw_state); | ||
189 | } | 194 | } |
190 | /** | 195 | /** |
191 | * mei_host_is_ready - check whether the host has turned ready | 196 | * mei_host_is_ready - check whether the host has turned ready |
@@ -195,8 +200,9 @@ void mei_host_set_ready(struct mei_device *dev) | |||
195 | */ | 200 | */ |
196 | bool mei_host_is_ready(struct mei_device *dev) | 201 | bool mei_host_is_ready(struct mei_device *dev) |
197 | { | 202 | { |
198 | dev->host_hw_state = mei_hcsr_read(dev); | 203 | struct mei_me_hw *hw = to_me_hw(dev); |
199 | return (dev->host_hw_state & H_RDY) == H_RDY; | 204 | hw->host_hw_state = mei_hcsr_read(hw); |
205 | return (hw->host_hw_state & H_RDY) == H_RDY; | ||
200 | } | 206 | } |
201 | 207 | ||
202 | /** | 208 | /** |
@@ -207,8 +213,9 @@ bool mei_host_is_ready(struct mei_device *dev) | |||
207 | */ | 213 | */ |
208 | bool mei_me_is_ready(struct mei_device *dev) | 214 | bool mei_me_is_ready(struct mei_device *dev) |
209 | { | 215 | { |
210 | dev->me_hw_state = mei_mecsr_read(dev); | 216 | struct mei_me_hw *hw = to_me_hw(dev); |
211 | return (dev->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA; | 217 | hw->me_hw_state = mei_mecsr_read(hw); |
218 | return (hw->me_hw_state & ME_RDY_HRA) == ME_RDY_HRA; | ||
212 | } | 219 | } |
213 | 220 | ||
214 | /** | 221 | /** |
@@ -222,13 +229,14 @@ bool mei_me_is_ready(struct mei_device *dev) | |||
222 | irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id) | 229 | irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id) |
223 | { | 230 | { |
224 | struct mei_device *dev = (struct mei_device *) dev_id; | 231 | struct mei_device *dev = (struct mei_device *) dev_id; |
225 | u32 csr_reg = mei_hcsr_read(dev); | 232 | struct mei_me_hw *hw = to_me_hw(dev); |
233 | u32 csr_reg = mei_hcsr_read(hw); | ||
226 | 234 | ||
227 | if ((csr_reg & H_IS) != H_IS) | 235 | if ((csr_reg & H_IS) != H_IS) |
228 | return IRQ_NONE; | 236 | return IRQ_NONE; |
229 | 237 | ||
230 | /* clear H_IS bit in H_CSR */ | 238 | /* clear H_IS bit in H_CSR */ |
231 | mei_reg_write(dev, H_CSR, csr_reg); | 239 | mei_reg_write(hw, H_CSR, csr_reg); |
232 | 240 | ||
233 | return IRQ_WAKE_THREAD; | 241 | return IRQ_WAKE_THREAD; |
234 | } | 242 | } |
@@ -242,12 +250,13 @@ irqreturn_t mei_interrupt_quick_handler(int irq, void *dev_id) | |||
242 | */ | 250 | */ |
243 | static unsigned char mei_hbuf_filled_slots(struct mei_device *dev) | 251 | static unsigned char mei_hbuf_filled_slots(struct mei_device *dev) |
244 | { | 252 | { |
253 | struct mei_me_hw *hw = to_me_hw(dev); | ||
245 | char read_ptr, write_ptr; | 254 | char read_ptr, write_ptr; |
246 | 255 | ||
247 | dev->host_hw_state = mei_hcsr_read(dev); | 256 | hw->host_hw_state = mei_hcsr_read(hw); |
248 | 257 | ||
249 | read_ptr = (char) ((dev->host_hw_state & H_CBRP) >> 8); | 258 | read_ptr = (char) ((hw->host_hw_state & H_CBRP) >> 8); |
250 | write_ptr = (char) ((dev->host_hw_state & H_CBWP) >> 16); | 259 | write_ptr = (char) ((hw->host_hw_state & H_CBWP) >> 16); |
251 | 260 | ||
252 | return (unsigned char) (write_ptr - read_ptr); | 261 | return (unsigned char) (write_ptr - read_ptr); |
253 | } | 262 | } |
@@ -297,6 +306,7 @@ int mei_hbuf_empty_slots(struct mei_device *dev) | |||
297 | int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, | 306 | int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, |
298 | unsigned char *buf) | 307 | unsigned char *buf) |
299 | { | 308 | { |
309 | struct mei_me_hw *hw = to_me_hw(dev); | ||
300 | unsigned long rem, dw_cnt; | 310 | unsigned long rem, dw_cnt; |
301 | unsigned long length = header->length; | 311 | unsigned long length = header->length; |
302 | u32 *reg_buf = (u32 *)buf; | 312 | u32 *reg_buf = (u32 *)buf; |
@@ -313,20 +323,20 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, | |||
313 | if (empty_slots < 0 || dw_cnt > empty_slots) | 323 | if (empty_slots < 0 || dw_cnt > empty_slots) |
314 | return -EIO; | 324 | return -EIO; |
315 | 325 | ||
316 | mei_reg_write(dev, H_CB_WW, *((u32 *) header)); | 326 | mei_reg_write(hw, H_CB_WW, *((u32 *) header)); |
317 | 327 | ||
318 | for (i = 0; i < length / 4; i++) | 328 | for (i = 0; i < length / 4; i++) |
319 | mei_reg_write(dev, H_CB_WW, reg_buf[i]); | 329 | mei_reg_write(hw, H_CB_WW, reg_buf[i]); |
320 | 330 | ||
321 | rem = length & 0x3; | 331 | rem = length & 0x3; |
322 | if (rem > 0) { | 332 | if (rem > 0) { |
323 | u32 reg = 0; | 333 | u32 reg = 0; |
324 | memcpy(®, &buf[length - rem], rem); | 334 | memcpy(®, &buf[length - rem], rem); |
325 | mei_reg_write(dev, H_CB_WW, reg); | 335 | mei_reg_write(hw, H_CB_WW, reg); |
326 | } | 336 | } |
327 | 337 | ||
328 | hcsr = mei_hcsr_read(dev) | H_IG; | 338 | hcsr = mei_hcsr_read(hw) | H_IG; |
329 | mei_hcsr_set(dev, hcsr); | 339 | mei_hcsr_set(hw, hcsr); |
330 | if (!mei_me_is_ready(dev)) | 340 | if (!mei_me_is_ready(dev)) |
331 | return -EIO; | 341 | return -EIO; |
332 | 342 | ||
@@ -342,13 +352,14 @@ int mei_write_message(struct mei_device *dev, struct mei_msg_hdr *header, | |||
342 | */ | 352 | */ |
343 | int mei_count_full_read_slots(struct mei_device *dev) | 353 | int mei_count_full_read_slots(struct mei_device *dev) |
344 | { | 354 | { |
355 | struct mei_me_hw *hw = to_me_hw(dev); | ||
345 | char read_ptr, write_ptr; | 356 | char read_ptr, write_ptr; |
346 | unsigned char buffer_depth, filled_slots; | 357 | unsigned char buffer_depth, filled_slots; |
347 | 358 | ||
348 | dev->me_hw_state = mei_mecsr_read(dev); | 359 | hw->me_hw_state = mei_mecsr_read(hw); |
349 | buffer_depth = (unsigned char)((dev->me_hw_state & ME_CBD_HRA) >> 24); | 360 | buffer_depth = (unsigned char)((hw->me_hw_state & ME_CBD_HRA) >> 24); |
350 | read_ptr = (char) ((dev->me_hw_state & ME_CBRP_HRA) >> 8); | 361 | read_ptr = (char) ((hw->me_hw_state & ME_CBRP_HRA) >> 8); |
351 | write_ptr = (char) ((dev->me_hw_state & ME_CBWP_HRA) >> 16); | 362 | write_ptr = (char) ((hw->me_hw_state & ME_CBWP_HRA) >> 16); |
352 | filled_slots = (unsigned char) (write_ptr - read_ptr); | 363 | filled_slots = (unsigned char) (write_ptr - read_ptr); |
353 | 364 | ||
354 | /* check for overflow */ | 365 | /* check for overflow */ |
@@ -369,6 +380,7 @@ int mei_count_full_read_slots(struct mei_device *dev) | |||
369 | void mei_read_slots(struct mei_device *dev, unsigned char *buffer, | 380 | void mei_read_slots(struct mei_device *dev, unsigned char *buffer, |
370 | unsigned long buffer_length) | 381 | unsigned long buffer_length) |
371 | { | 382 | { |
383 | struct mei_me_hw *hw = to_me_hw(dev); | ||
372 | u32 *reg_buf = (u32 *)buffer; | 384 | u32 *reg_buf = (u32 *)buffer; |
373 | u32 hcsr; | 385 | u32 hcsr; |
374 | 386 | ||
@@ -380,7 +392,36 @@ void mei_read_slots(struct mei_device *dev, unsigned char *buffer, | |||
380 | memcpy(reg_buf, ®, buffer_length); | 392 | memcpy(reg_buf, ®, buffer_length); |
381 | } | 393 | } |
382 | 394 | ||
383 | hcsr = mei_hcsr_read(dev) | H_IG; | 395 | hcsr = mei_hcsr_read(hw) | H_IG; |
384 | mei_hcsr_set(dev, hcsr); | 396 | mei_hcsr_set(hw, hcsr); |
385 | } | 397 | } |
386 | 398 | ||
399 | /** | ||
400 | * init_mei_device - allocates and initializes the mei device structure | ||
401 | * | ||
402 | * @pdev: The pci device structure | ||
403 | * | ||
404 | * returns The mei_device_device pointer on success, NULL on failure. | ||
405 | */ | ||
406 | struct mei_device *mei_me_dev_init(struct pci_dev *pdev) | ||
407 | { | ||
408 | struct mei_device *dev; | ||
409 | |||
410 | dev = kzalloc(sizeof(struct mei_device) + | ||
411 | sizeof(struct mei_me_hw), GFP_KERNEL); | ||
412 | if (!dev) | ||
413 | return NULL; | ||
414 | |||
415 | mei_device_init(dev); | ||
416 | |||
417 | INIT_LIST_HEAD(&dev->wd_cl.link); | ||
418 | INIT_LIST_HEAD(&dev->iamthif_cl.link); | ||
419 | mei_io_list_init(&dev->amthif_cmd_list); | ||
420 | mei_io_list_init(&dev->amthif_rd_complete_list); | ||
421 | |||
422 | INIT_DELAYED_WORK(&dev->timer_work, mei_timer); | ||
423 | INIT_WORK(&dev->init_work, mei_host_client_init); | ||
424 | |||
425 | dev->pdev = pdev; | ||
426 | return dev; | ||
427 | } | ||
diff --git a/drivers/misc/mei/hw-me.h b/drivers/misc/mei/hw-me.h index 73bef545e4d5..53bcc0087e26 100644 --- a/drivers/misc/mei/hw-me.h +++ b/drivers/misc/mei/hw-me.h | |||
@@ -21,8 +21,20 @@ | |||
21 | 21 | ||
22 | #include <linux/mei.h> | 22 | #include <linux/mei.h> |
23 | #include "mei_dev.h" | 23 | #include "mei_dev.h" |
24 | #include "client.h" | ||
24 | 25 | ||
26 | struct mei_me_hw { | ||
27 | void __iomem *mem_addr; | ||
28 | /* | ||
29 | * hw states of host and fw(ME) | ||
30 | */ | ||
31 | u32 host_hw_state; | ||
32 | u32 me_hw_state; | ||
33 | }; | ||
25 | 34 | ||
35 | #define to_me_hw(dev) (struct mei_me_hw *)((dev)->hw) | ||
36 | |||
37 | struct mei_device *mei_me_dev_init(struct pci_dev *pdev); | ||
26 | 38 | ||
27 | void mei_read_slots(struct mei_device *dev, | 39 | void mei_read_slots(struct mei_device *dev, |
28 | unsigned char *buffer, | 40 | unsigned char *buffer, |
diff --git a/drivers/misc/mei/init.c b/drivers/misc/mei/init.c index 5d08db5b314e..1e1876ff25b1 100644 --- a/drivers/misc/mei/init.c +++ b/drivers/misc/mei/init.c | |||
@@ -42,28 +42,10 @@ const char *mei_dev_state_str(int state) | |||
42 | #undef MEI_DEV_STATE | 42 | #undef MEI_DEV_STATE |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | void mei_device_init(struct mei_device *dev) | |
46 | |||
47 | |||
48 | /** | ||
49 | * init_mei_device - allocates and initializes the mei device structure | ||
50 | * | ||
51 | * @pdev: The pci device structure | ||
52 | * | ||
53 | * returns The mei_device_device pointer on success, NULL on failure. | ||
54 | */ | ||
55 | struct mei_device *mei_device_init(struct pci_dev *pdev) | ||
56 | { | 46 | { |
57 | struct mei_device *dev; | ||
58 | |||
59 | dev = kzalloc(sizeof(struct mei_device), GFP_KERNEL); | ||
60 | if (!dev) | ||
61 | return NULL; | ||
62 | |||
63 | /* setup our list array */ | 47 | /* setup our list array */ |
64 | INIT_LIST_HEAD(&dev->file_list); | 48 | INIT_LIST_HEAD(&dev->file_list); |
65 | INIT_LIST_HEAD(&dev->wd_cl.link); | ||
66 | INIT_LIST_HEAD(&dev->iamthif_cl.link); | ||
67 | mutex_init(&dev->device_lock); | 49 | mutex_init(&dev->device_lock); |
68 | init_waitqueue_head(&dev->wait_recvd_msg); | 50 | init_waitqueue_head(&dev->wait_recvd_msg); |
69 | init_waitqueue_head(&dev->wait_stop_wd); | 51 | init_waitqueue_head(&dev->wait_stop_wd); |
@@ -74,14 +56,6 @@ struct mei_device *mei_device_init(struct pci_dev *pdev) | |||
74 | mei_io_list_init(&dev->write_waiting_list); | 56 | mei_io_list_init(&dev->write_waiting_list); |
75 | mei_io_list_init(&dev->ctrl_wr_list); | 57 | mei_io_list_init(&dev->ctrl_wr_list); |
76 | mei_io_list_init(&dev->ctrl_rd_list); | 58 | mei_io_list_init(&dev->ctrl_rd_list); |
77 | mei_io_list_init(&dev->amthif_cmd_list); | ||
78 | mei_io_list_init(&dev->amthif_rd_complete_list); | ||
79 | |||
80 | INIT_DELAYED_WORK(&dev->timer_work, mei_timer); | ||
81 | INIT_WORK(&dev->init_work, mei_host_client_init); | ||
82 | |||
83 | dev->pdev = pdev; | ||
84 | return dev; | ||
85 | } | 59 | } |
86 | 60 | ||
87 | /** | 61 | /** |
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index 3b2bca386e5a..bb759fd9ee4a 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h | |||
@@ -235,18 +235,13 @@ struct mei_device { | |||
235 | struct list_head file_list; | 235 | struct list_head file_list; |
236 | long open_handle_count; | 236 | long open_handle_count; |
237 | 237 | ||
238 | void __iomem *mem_addr; | ||
239 | /* | 238 | /* |
240 | * lock for the device | 239 | * lock for the device |
241 | */ | 240 | */ |
242 | struct mutex device_lock; /* device lock */ | 241 | struct mutex device_lock; /* device lock */ |
243 | struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ | 242 | struct delayed_work timer_work; /* MEI timer delayed work (timeouts) */ |
244 | bool recvd_msg; | 243 | bool recvd_msg; |
245 | /* | 244 | |
246 | * hw states of host and fw(ME) | ||
247 | */ | ||
248 | u32 host_hw_state; | ||
249 | u32 me_hw_state; | ||
250 | u8 hbuf_depth; | 245 | u8 hbuf_depth; |
251 | /* | 246 | /* |
252 | * waiting queue for receive message from FW | 247 | * waiting queue for receive message from FW |
@@ -311,6 +306,7 @@ struct mei_device { | |||
311 | bool iamthif_canceled; | 306 | bool iamthif_canceled; |
312 | 307 | ||
313 | struct work_struct init_work; | 308 | struct work_struct init_work; |
309 | char hw[0] __aligned(sizeof(void *)); | ||
314 | }; | 310 | }; |
315 | 311 | ||
316 | static inline unsigned long mei_secs_to_jiffies(unsigned long sec) | 312 | static inline unsigned long mei_secs_to_jiffies(unsigned long sec) |
@@ -322,7 +318,7 @@ static inline unsigned long mei_secs_to_jiffies(unsigned long sec) | |||
322 | /* | 318 | /* |
323 | * mei init function prototypes | 319 | * mei init function prototypes |
324 | */ | 320 | */ |
325 | struct mei_device *mei_device_init(struct pci_dev *pdev); | 321 | void mei_device_init(struct mei_device *dev); |
326 | void mei_reset(struct mei_device *dev, int interrupts); | 322 | void mei_reset(struct mei_device *dev, int interrupts); |
327 | int mei_hw_init(struct mei_device *dev); | 323 | int mei_hw_init(struct mei_device *dev); |
328 | 324 | ||
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c index eaed398bed6b..27ac71767981 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c | |||
@@ -90,7 +90,6 @@ MODULE_DEVICE_TABLE(pci, mei_pci_tbl); | |||
90 | 90 | ||
91 | static DEFINE_MUTEX(mei_mutex); | 91 | static DEFINE_MUTEX(mei_mutex); |
92 | 92 | ||
93 | |||
94 | /** | 93 | /** |
95 | * mei_quirk_probe - probe for devices that doesn't valid ME interface | 94 | * mei_quirk_probe - probe for devices that doesn't valid ME interface |
96 | * @pdev: PCI device structure | 95 | * @pdev: PCI device structure |
@@ -120,10 +119,10 @@ static bool mei_quirk_probe(struct pci_dev *pdev, | |||
120 | * | 119 | * |
121 | * returns 0 on success, <0 on failure. | 120 | * returns 0 on success, <0 on failure. |
122 | */ | 121 | */ |
123 | static int mei_probe(struct pci_dev *pdev, | 122 | static int mei_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
124 | const struct pci_device_id *ent) | ||
125 | { | 123 | { |
126 | struct mei_device *dev; | 124 | struct mei_device *dev; |
125 | struct mei_me_hw *hw; | ||
127 | int err; | 126 | int err; |
128 | 127 | ||
129 | mutex_lock(&mei_mutex); | 128 | mutex_lock(&mei_mutex); |
@@ -152,14 +151,15 @@ static int mei_probe(struct pci_dev *pdev, | |||
152 | goto disable_device; | 151 | goto disable_device; |
153 | } | 152 | } |
154 | /* allocates and initializes the mei dev structure */ | 153 | /* allocates and initializes the mei dev structure */ |
155 | dev = mei_device_init(pdev); | 154 | dev = mei_me_dev_init(pdev); |
156 | if (!dev) { | 155 | if (!dev) { |
157 | err = -ENOMEM; | 156 | err = -ENOMEM; |
158 | goto release_regions; | 157 | goto release_regions; |
159 | } | 158 | } |
159 | hw = to_me_hw(dev); | ||
160 | /* mapping IO device memory */ | 160 | /* mapping IO device memory */ |
161 | dev->mem_addr = pci_iomap(pdev, 0, 0); | 161 | hw->mem_addr = pci_iomap(pdev, 0, 0); |
162 | if (!dev->mem_addr) { | 162 | if (!hw->mem_addr) { |
163 | dev_err(&pdev->dev, "mapping I/O device memory failure.\n"); | 163 | dev_err(&pdev->dev, "mapping I/O device memory failure.\n"); |
164 | err = -ENOMEM; | 164 | err = -ENOMEM; |
165 | goto free_device; | 165 | goto free_device; |
@@ -212,7 +212,7 @@ release_irq: | |||
212 | free_irq(pdev->irq, dev); | 212 | free_irq(pdev->irq, dev); |
213 | disable_msi: | 213 | disable_msi: |
214 | pci_disable_msi(pdev); | 214 | pci_disable_msi(pdev); |
215 | pci_iounmap(pdev, dev->mem_addr); | 215 | pci_iounmap(pdev, hw->mem_addr); |
216 | free_device: | 216 | free_device: |
217 | kfree(dev); | 217 | kfree(dev); |
218 | release_regions: | 218 | release_regions: |
@@ -236,6 +236,7 @@ end: | |||
236 | static void mei_remove(struct pci_dev *pdev) | 236 | static void mei_remove(struct pci_dev *pdev) |
237 | { | 237 | { |
238 | struct mei_device *dev; | 238 | struct mei_device *dev; |
239 | struct mei_me_hw *hw; | ||
239 | 240 | ||
240 | if (mei_pdev != pdev) | 241 | if (mei_pdev != pdev) |
241 | return; | 242 | return; |
@@ -244,6 +245,8 @@ static void mei_remove(struct pci_dev *pdev) | |||
244 | if (!dev) | 245 | if (!dev) |
245 | return; | 246 | return; |
246 | 247 | ||
248 | hw = to_me_hw(dev); | ||
249 | |||
247 | mutex_lock(&dev->device_lock); | 250 | mutex_lock(&dev->device_lock); |
248 | 251 | ||
249 | cancel_delayed_work(&dev->timer_work); | 252 | cancel_delayed_work(&dev->timer_work); |
@@ -289,8 +292,8 @@ static void mei_remove(struct pci_dev *pdev) | |||
289 | pci_disable_msi(pdev); | 292 | pci_disable_msi(pdev); |
290 | pci_set_drvdata(pdev, NULL); | 293 | pci_set_drvdata(pdev, NULL); |
291 | 294 | ||
292 | if (dev->mem_addr) | 295 | if (hw->mem_addr) |
293 | pci_iounmap(pdev, dev->mem_addr); | 296 | pci_iounmap(pdev, hw->mem_addr); |
294 | 297 | ||
295 | kfree(dev); | 298 | kfree(dev); |
296 | 299 | ||