]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/ccree/ssi_request_mgr.c
UBUNTU: Ubuntu-4.13.0-45.50
[mirror_ubuntu-artful-kernel.git] / drivers / staging / ccree / ssi_request_mgr.c
1 /*
2 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include "ssi_config.h"
18 #include <linux/kernel.h>
19 #include <linux/platform_device.h>
20 #include <linux/interrupt.h>
21 #include <linux/delay.h>
22 #include <crypto/ctr.h>
23 #ifdef FLUSH_CACHE_ALL
24 #include <asm/cacheflush.h>
25 #endif
26 #include <linux/pm_runtime.h>
27 #include "ssi_driver.h"
28 #include "ssi_buffer_mgr.h"
29 #include "ssi_request_mgr.h"
30 #include "ssi_sysfs.h"
31 #include "ssi_ivgen.h"
32 #include "ssi_pm.h"
33 #include "ssi_fips.h"
34 #include "ssi_fips_local.h"
35
36 #define SSI_MAX_POLL_ITER 10
37
38 struct ssi_request_mgr_handle {
39 /* Request manager resources */
40 unsigned int hw_queue_size; /* HW capability */
41 unsigned int min_free_hw_slots;
42 unsigned int max_used_sw_slots;
43 struct ssi_crypto_req req_queue[MAX_REQUEST_QUEUE_SIZE];
44 u32 req_queue_head;
45 u32 req_queue_tail;
46 u32 axi_completed;
47 u32 q_free_slots;
48 spinlock_t hw_lock;
49 struct cc_hw_desc compl_desc;
50 u8 *dummy_comp_buff;
51 dma_addr_t dummy_comp_buff_dma;
52 struct cc_hw_desc monitor_desc;
53
54 volatile unsigned long monitor_lock;
55 #ifdef COMP_IN_WQ
56 struct workqueue_struct *workq;
57 struct delayed_work compwork;
58 #else
59 struct tasklet_struct comptask;
60 #endif
61 #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
62 bool is_runtime_suspended;
63 #endif
64 };
65
66 static void comp_handler(unsigned long devarg);
67 #ifdef COMP_IN_WQ
68 static void comp_work_handler(struct work_struct *work);
69 #endif
70
71 void request_mgr_fini(struct ssi_drvdata *drvdata)
72 {
73 struct ssi_request_mgr_handle *req_mgr_h = drvdata->request_mgr_handle;
74
75 if (!req_mgr_h)
76 return; /* Not allocated */
77
78 if (req_mgr_h->dummy_comp_buff_dma != 0) {
79 dma_free_coherent(&drvdata->plat_dev->dev,
80 sizeof(u32), req_mgr_h->dummy_comp_buff,
81 req_mgr_h->dummy_comp_buff_dma);
82 }
83
84 SSI_LOG_DEBUG("max_used_hw_slots=%d\n", (req_mgr_h->hw_queue_size -
85 req_mgr_h->min_free_hw_slots));
86 SSI_LOG_DEBUG("max_used_sw_slots=%d\n", req_mgr_h->max_used_sw_slots);
87
88 #ifdef COMP_IN_WQ
89 flush_workqueue(req_mgr_h->workq);
90 destroy_workqueue(req_mgr_h->workq);
91 #else
92 /* Kill tasklet */
93 tasklet_kill(&req_mgr_h->comptask);
94 #endif
95 memset(req_mgr_h, 0, sizeof(struct ssi_request_mgr_handle));
96 kfree(req_mgr_h);
97 drvdata->request_mgr_handle = NULL;
98 }
99
100 int request_mgr_init(struct ssi_drvdata *drvdata)
101 {
102 struct ssi_request_mgr_handle *req_mgr_h;
103 int rc = 0;
104
105 req_mgr_h = kzalloc(sizeof(struct ssi_request_mgr_handle), GFP_KERNEL);
106 if (!req_mgr_h) {
107 rc = -ENOMEM;
108 goto req_mgr_init_err;
109 }
110
111 drvdata->request_mgr_handle = req_mgr_h;
112
113 spin_lock_init(&req_mgr_h->hw_lock);
114 #ifdef COMP_IN_WQ
115 SSI_LOG_DEBUG("Initializing completion workqueue\n");
116 req_mgr_h->workq = create_singlethread_workqueue("arm_cc7x_wq");
117 if (unlikely(!req_mgr_h->workq)) {
118 SSI_LOG_ERR("Failed creating work queue\n");
119 rc = -ENOMEM;
120 goto req_mgr_init_err;
121 }
122 INIT_DELAYED_WORK(&req_mgr_h->compwork, comp_work_handler);
123 #else
124 SSI_LOG_DEBUG("Initializing completion tasklet\n");
125 tasklet_init(&req_mgr_h->comptask, comp_handler, (unsigned long)drvdata);
126 #endif
127 req_mgr_h->hw_queue_size = READ_REGISTER(drvdata->cc_base +
128 CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_SRAM_SIZE));
129 SSI_LOG_DEBUG("hw_queue_size=0x%08X\n", req_mgr_h->hw_queue_size);
130 if (req_mgr_h->hw_queue_size < MIN_HW_QUEUE_SIZE) {
131 SSI_LOG_ERR("Invalid HW queue size = %u (Min. required is %u)\n",
132 req_mgr_h->hw_queue_size, MIN_HW_QUEUE_SIZE);
133 rc = -ENOMEM;
134 goto req_mgr_init_err;
135 }
136 req_mgr_h->min_free_hw_slots = req_mgr_h->hw_queue_size;
137 req_mgr_h->max_used_sw_slots = 0;
138
139 /* Allocate DMA word for "dummy" completion descriptor use */
140 req_mgr_h->dummy_comp_buff = dma_alloc_coherent(&drvdata->plat_dev->dev,
141 sizeof(u32), &req_mgr_h->dummy_comp_buff_dma, GFP_KERNEL);
142 if (!req_mgr_h->dummy_comp_buff) {
143 SSI_LOG_ERR("Not enough memory to allocate DMA (%zu) dropped "
144 "buffer\n", sizeof(u32));
145 rc = -ENOMEM;
146 goto req_mgr_init_err;
147 }
148
149 /* Init. "dummy" completion descriptor */
150 hw_desc_init(&req_mgr_h->compl_desc);
151 set_din_const(&req_mgr_h->compl_desc, 0, sizeof(u32));
152 set_dout_dlli(&req_mgr_h->compl_desc, req_mgr_h->dummy_comp_buff_dma,
153 sizeof(u32), NS_BIT, 1);
154 set_flow_mode(&req_mgr_h->compl_desc, BYPASS);
155 set_queue_last_ind(&req_mgr_h->compl_desc);
156
157 return 0;
158
159 req_mgr_init_err:
160 request_mgr_fini(drvdata);
161 return rc;
162 }
163
164 static inline void enqueue_seq(
165 void __iomem *cc_base,
166 struct cc_hw_desc seq[], unsigned int seq_len)
167 {
168 int i;
169
170 for (i = 0; i < seq_len; i++) {
171 writel_relaxed(seq[i].word[0], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0)));
172 writel_relaxed(seq[i].word[1], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0)));
173 writel_relaxed(seq[i].word[2], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0)));
174 writel_relaxed(seq[i].word[3], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0)));
175 writel_relaxed(seq[i].word[4], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0)));
176 wmb();
177 writel_relaxed(seq[i].word[5], (volatile void __iomem *)(cc_base + CC_REG_OFFSET(CRY_KERNEL, DSCRPTR_QUEUE_WORD0)));
178 #ifdef DX_DUMP_DESCS
179 SSI_LOG_DEBUG("desc[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n", i,
180 seq[i].word[0], seq[i].word[1], seq[i].word[2], seq[i].word[3], seq[i].word[4], seq[i].word[5]);
181 #endif
182 }
183 }
184
185 /*!
186 * Completion will take place if and only if user requested completion
187 * by setting "is_dout = 0" in send_request().
188 *
189 * \param dev
190 * \param dx_compl_h The completion event to signal
191 */
192 static void request_mgr_complete(struct device *dev, void *dx_compl_h, void __iomem *cc_base)
193 {
194 struct completion *this_compl = dx_compl_h;
195
196 complete(this_compl);
197 }
198
199 static inline int request_mgr_queues_status_check(
200 struct ssi_request_mgr_handle *req_mgr_h,
201 void __iomem *cc_base,
202 unsigned int total_seq_len)
203 {
204 unsigned long poll_queue;
205
206 /* SW queue is checked only once as it will not
207 * be chaned during the poll becasue the spinlock_bh
208 * is held by the thread
209 */
210 if (unlikely(((req_mgr_h->req_queue_head + 1) &
211 (MAX_REQUEST_QUEUE_SIZE - 1)) ==
212 req_mgr_h->req_queue_tail)) {
213 SSI_LOG_ERR("SW FIFO is full. req_queue_head=%d sw_fifo_len=%d\n",
214 req_mgr_h->req_queue_head, MAX_REQUEST_QUEUE_SIZE);
215 return -EBUSY;
216 }
217
218 if ((likely(req_mgr_h->q_free_slots >= total_seq_len)))
219 return 0;
220
221 /* Wait for space in HW queue. Poll constant num of iterations. */
222 for (poll_queue = 0; poll_queue < SSI_MAX_POLL_ITER ; poll_queue++) {
223 req_mgr_h->q_free_slots =
224 CC_HAL_READ_REGISTER(
225 CC_REG_OFFSET(CRY_KERNEL,
226 DSCRPTR_QUEUE_CONTENT));
227 if (unlikely(req_mgr_h->q_free_slots <
228 req_mgr_h->min_free_hw_slots)) {
229 req_mgr_h->min_free_hw_slots = req_mgr_h->q_free_slots;
230 }
231
232 if (likely(req_mgr_h->q_free_slots >= total_seq_len)) {
233 /* If there is enough place return */
234 return 0;
235 }
236
237 SSI_LOG_DEBUG("HW FIFO is full. q_free_slots=%d total_seq_len=%d\n",
238 req_mgr_h->q_free_slots, total_seq_len);
239 }
240 /* No room in the HW queue try again later */
241 SSI_LOG_DEBUG("HW FIFO full, timeout. req_queue_head=%d "
242 "sw_fifo_len=%d q_free_slots=%d total_seq_len=%d\n",
243 req_mgr_h->req_queue_head,
244 MAX_REQUEST_QUEUE_SIZE,
245 req_mgr_h->q_free_slots,
246 total_seq_len);
247 return -EAGAIN;
248 }
249
250 /*!
251 * Enqueue caller request to crypto hardware.
252 *
253 * \param drvdata
254 * \param ssi_req The request to enqueue
255 * \param desc The crypto sequence
256 * \param len The crypto sequence length
257 * \param is_dout If "true": completion is handled by the caller
258 * If "false": this function adds a dummy descriptor completion
259 * and waits upon completion signal.
260 *
261 * \return int Returns -EINPROGRESS if "is_dout=true"; "0" if "is_dout=false"
262 */
263 int send_request(
264 struct ssi_drvdata *drvdata, struct ssi_crypto_req *ssi_req,
265 struct cc_hw_desc *desc, unsigned int len, bool is_dout)
266 {
267 void __iomem *cc_base = drvdata->cc_base;
268 struct ssi_request_mgr_handle *req_mgr_h = drvdata->request_mgr_handle;
269 unsigned int used_sw_slots;
270 unsigned int iv_seq_len = 0;
271 unsigned int total_seq_len = len; /*initial sequence length*/
272 struct cc_hw_desc iv_seq[SSI_IVPOOL_SEQ_LEN];
273 int rc;
274 unsigned int max_required_seq_len = (total_seq_len +
275 ((ssi_req->ivgen_dma_addr_len == 0) ? 0 :
276 SSI_IVPOOL_SEQ_LEN) +
277 ((is_dout == 0) ? 1 : 0));
278
279 #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
280 rc = ssi_power_mgr_runtime_get(&drvdata->plat_dev->dev);
281 if (rc != 0) {
282 SSI_LOG_ERR("ssi_power_mgr_runtime_get returned %x\n", rc);
283 return rc;
284 }
285 #endif
286
287 do {
288 spin_lock_bh(&req_mgr_h->hw_lock);
289
290 /* Check if there is enough place in the SW/HW queues
291 * in case iv gen add the max size and in case of no dout add 1
292 * for the internal completion descriptor
293 */
294 rc = request_mgr_queues_status_check(req_mgr_h,
295 cc_base,
296 max_required_seq_len);
297 if (likely(rc == 0))
298 /* There is enough place in the queue */
299 break;
300 /* something wrong release the spinlock*/
301 spin_unlock_bh(&req_mgr_h->hw_lock);
302
303 if (rc != -EAGAIN) {
304 /* Any error other than HW queue full
305 * (SW queue is full)
306 */
307 #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
308 ssi_power_mgr_runtime_put_suspend(&drvdata->plat_dev->dev);
309 #endif
310 return rc;
311 }
312
313 /* HW queue is full - short sleep */
314 msleep(1);
315 } while (1);
316
317 /* Additional completion descriptor is needed incase caller did not
318 * enabled any DLLI/MLLI DOUT bit in the given sequence
319 */
320 if (!is_dout) {
321 init_completion(&ssi_req->seq_compl);
322 ssi_req->user_cb = request_mgr_complete;
323 ssi_req->user_arg = &(ssi_req->seq_compl);
324 total_seq_len++;
325 }
326
327 if (ssi_req->ivgen_dma_addr_len > 0) {
328 SSI_LOG_DEBUG("Acquire IV from pool into %d DMA addresses 0x%llX, 0x%llX, 0x%llX, IV-size=%u\n",
329 ssi_req->ivgen_dma_addr_len,
330 (unsigned long long)ssi_req->ivgen_dma_addr[0],
331 (unsigned long long)ssi_req->ivgen_dma_addr[1],
332 (unsigned long long)ssi_req->ivgen_dma_addr[2],
333 ssi_req->ivgen_size);
334
335 /* Acquire IV from pool */
336 rc = ssi_ivgen_getiv(drvdata, ssi_req->ivgen_dma_addr, ssi_req->ivgen_dma_addr_len,
337 ssi_req->ivgen_size, iv_seq, &iv_seq_len);
338
339 if (unlikely(rc != 0)) {
340 SSI_LOG_ERR("Failed to generate IV (rc=%d)\n", rc);
341 spin_unlock_bh(&req_mgr_h->hw_lock);
342 #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
343 ssi_power_mgr_runtime_put_suspend(&drvdata->plat_dev->dev);
344 #endif
345 return rc;
346 }
347
348 total_seq_len += iv_seq_len;
349 }
350
351 used_sw_slots = ((req_mgr_h->req_queue_head - req_mgr_h->req_queue_tail) & (MAX_REQUEST_QUEUE_SIZE - 1));
352 if (unlikely(used_sw_slots > req_mgr_h->max_used_sw_slots))
353 req_mgr_h->max_used_sw_slots = used_sw_slots;
354
355 /* Enqueue request - must be locked with HW lock*/
356 req_mgr_h->req_queue[req_mgr_h->req_queue_head] = *ssi_req;
357 req_mgr_h->req_queue_head = (req_mgr_h->req_queue_head + 1) & (MAX_REQUEST_QUEUE_SIZE - 1);
358 /* TODO: Use circ_buf.h ? */
359
360 SSI_LOG_DEBUG("Enqueue request head=%u\n", req_mgr_h->req_queue_head);
361
362 #ifdef FLUSH_CACHE_ALL
363 flush_cache_all();
364 #endif
365
366 /* STAT_PHASE_4: Push sequence */
367 enqueue_seq(cc_base, iv_seq, iv_seq_len);
368 enqueue_seq(cc_base, desc, len);
369 enqueue_seq(cc_base, &req_mgr_h->compl_desc, (is_dout ? 0 : 1));
370
371 if (unlikely(req_mgr_h->q_free_slots < total_seq_len)) {
372 /*This means that there was a problem with the resume*/
373 BUG();
374 }
375 /* Update the free slots in HW queue */
376 req_mgr_h->q_free_slots -= total_seq_len;
377
378 spin_unlock_bh(&req_mgr_h->hw_lock);
379
380 if (!is_dout) {
381 /* Wait upon sequence completion.
382 * Return "0" -Operation done successfully.
383 */
384 wait_for_completion(&ssi_req->seq_compl);
385 return 0;
386 } else {
387 /* Operation still in process */
388 return -EINPROGRESS;
389 }
390 }
391
392 /*!
393 * Enqueue caller request to crypto hardware during init process.
394 * assume this function is not called in middle of a flow,
395 * since we set QUEUE_LAST_IND flag in the last descriptor.
396 *
397 * \param drvdata
398 * \param desc The crypto sequence
399 * \param len The crypto sequence length
400 *
401 * \return int Returns "0" upon success
402 */
403 int send_request_init(
404 struct ssi_drvdata *drvdata, struct cc_hw_desc *desc, unsigned int len)
405 {
406 void __iomem *cc_base = drvdata->cc_base;
407 struct ssi_request_mgr_handle *req_mgr_h = drvdata->request_mgr_handle;
408 unsigned int total_seq_len = len; /*initial sequence length*/
409 int rc = 0;
410
411 /* Wait for space in HW and SW FIFO. Poll for as much as FIFO_TIMEOUT. */
412 rc = request_mgr_queues_status_check(req_mgr_h, cc_base, total_seq_len);
413 if (unlikely(rc != 0))
414 return rc;
415
416 set_queue_last_ind(&desc[(len - 1)]);
417
418 enqueue_seq(cc_base, desc, len);
419
420 /* Update the free slots in HW queue */
421 req_mgr_h->q_free_slots = CC_HAL_READ_REGISTER(
422 CC_REG_OFFSET(CRY_KERNEL,
423 DSCRPTR_QUEUE_CONTENT));
424
425 return 0;
426 }
427
428 void complete_request(struct ssi_drvdata *drvdata)
429 {
430 struct ssi_request_mgr_handle *request_mgr_handle =
431 drvdata->request_mgr_handle;
432 #ifdef COMP_IN_WQ
433 queue_delayed_work(request_mgr_handle->workq, &request_mgr_handle->compwork, 0);
434 #else
435 tasklet_schedule(&request_mgr_handle->comptask);
436 #endif
437 }
438
439 #ifdef COMP_IN_WQ
440 static void comp_work_handler(struct work_struct *work)
441 {
442 struct ssi_drvdata *drvdata =
443 container_of(work, struct ssi_drvdata, compwork.work);
444
445 comp_handler((unsigned long)drvdata);
446 }
447 #endif
448
449 static void proc_completions(struct ssi_drvdata *drvdata)
450 {
451 struct ssi_crypto_req *ssi_req;
452 struct platform_device *plat_dev = drvdata->plat_dev;
453 struct ssi_request_mgr_handle *request_mgr_handle =
454 drvdata->request_mgr_handle;
455 #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
456 int rc = 0;
457 #endif
458
459 while (request_mgr_handle->axi_completed) {
460 request_mgr_handle->axi_completed--;
461
462 /* Dequeue request */
463 if (unlikely(request_mgr_handle->req_queue_head == request_mgr_handle->req_queue_tail)) {
464 SSI_LOG_ERR("Request queue is empty req_queue_head==req_queue_tail==%u\n", request_mgr_handle->req_queue_head);
465 BUG();
466 }
467
468 ssi_req = &request_mgr_handle->req_queue[request_mgr_handle->req_queue_tail];
469
470 #ifdef FLUSH_CACHE_ALL
471 flush_cache_all();
472 #endif
473
474 #ifdef COMPLETION_DELAY
475 /* Delay */
476 {
477 u32 axi_err;
478 int i;
479
480 SSI_LOG_INFO("Delay\n");
481 for (i = 0; i < 1000000; i++)
482 axi_err = READ_REGISTER(drvdata->cc_base + CC_REG_OFFSET(CRY_KERNEL, AXIM_MON_ERR));
483 }
484 #endif /* COMPLETION_DELAY */
485
486 if (likely(ssi_req->user_cb))
487 ssi_req->user_cb(&plat_dev->dev, ssi_req->user_arg, drvdata->cc_base);
488 request_mgr_handle->req_queue_tail = (request_mgr_handle->req_queue_tail + 1) & (MAX_REQUEST_QUEUE_SIZE - 1);
489 SSI_LOG_DEBUG("Dequeue request tail=%u\n", request_mgr_handle->req_queue_tail);
490 SSI_LOG_DEBUG("Request completed. axi_completed=%d\n", request_mgr_handle->axi_completed);
491 #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
492 rc = ssi_power_mgr_runtime_put_suspend(&plat_dev->dev);
493 if (rc != 0)
494 SSI_LOG_ERR("Failed to set runtime suspension %d\n", rc);
495 #endif
496 }
497 }
498
499 static inline u32 cc_axi_comp_count(void __iomem *cc_base)
500 {
501 /* The CC_HAL_READ_REGISTER macro implictly requires and uses
502 * a base MMIO register address variable named cc_base.
503 */
504 return FIELD_GET(AXIM_MON_COMP_VALUE,
505 CC_HAL_READ_REGISTER(AXIM_MON_BASE_OFFSET));
506 }
507
508 /* Deferred service handler, run as interrupt-fired tasklet */
509 static void comp_handler(unsigned long devarg)
510 {
511 struct ssi_drvdata *drvdata = (struct ssi_drvdata *)devarg;
512 void __iomem *cc_base = drvdata->cc_base;
513 struct ssi_request_mgr_handle *request_mgr_handle =
514 drvdata->request_mgr_handle;
515
516 u32 irq;
517
518 irq = (drvdata->irq & SSI_COMP_IRQ_MASK);
519
520 if (irq & SSI_COMP_IRQ_MASK) {
521 /* To avoid the interrupt from firing as we unmask it, we clear it now */
522 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), SSI_COMP_IRQ_MASK);
523
524 /* Avoid race with above clear: Test completion counter once more */
525 request_mgr_handle->axi_completed +=
526 cc_axi_comp_count(cc_base);
527
528 while (request_mgr_handle->axi_completed) {
529 do {
530 proc_completions(drvdata);
531 /* At this point (after proc_completions()),
532 * request_mgr_handle->axi_completed is 0.
533 */
534 request_mgr_handle->axi_completed =
535 cc_axi_comp_count(cc_base);
536 } while (request_mgr_handle->axi_completed > 0);
537
538 /* To avoid the interrupt from firing as we unmask it, we clear it now */
539 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), SSI_COMP_IRQ_MASK);
540
541 /* Avoid race with above clear: Test completion counter once more */
542 request_mgr_handle->axi_completed +=
543 cc_axi_comp_count(cc_base);
544 }
545 }
546 /* after verifing that there is nothing to do, Unmask AXI completion interrupt */
547 CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR),
548 CC_HAL_READ_REGISTER(
549 CC_REG_OFFSET(HOST_RGF, HOST_IMR)) & ~irq);
550 }
551
552 /*
553 * resume the queue configuration - no need to take the lock as this happens inside
554 * the spin lock protection
555 */
556 #if defined(CONFIG_PM_RUNTIME) || defined(CONFIG_PM_SLEEP)
557 int ssi_request_mgr_runtime_resume_queue(struct ssi_drvdata *drvdata)
558 {
559 struct ssi_request_mgr_handle *request_mgr_handle = drvdata->request_mgr_handle;
560
561 spin_lock_bh(&request_mgr_handle->hw_lock);
562 request_mgr_handle->is_runtime_suspended = false;
563 spin_unlock_bh(&request_mgr_handle->hw_lock);
564
565 return 0;
566 }
567
568 /*
569 * suspend the queue configuration. Since it is used for the runtime suspend
570 * only verify that the queue can be suspended.
571 */
572 int ssi_request_mgr_runtime_suspend_queue(struct ssi_drvdata *drvdata)
573 {
574 struct ssi_request_mgr_handle *request_mgr_handle =
575 drvdata->request_mgr_handle;
576
577 /* lock the send_request */
578 spin_lock_bh(&request_mgr_handle->hw_lock);
579 if (request_mgr_handle->req_queue_head !=
580 request_mgr_handle->req_queue_tail) {
581 spin_unlock_bh(&request_mgr_handle->hw_lock);
582 return -EBUSY;
583 }
584 request_mgr_handle->is_runtime_suspended = true;
585 spin_unlock_bh(&request_mgr_handle->hw_lock);
586
587 return 0;
588 }
589
590 bool ssi_request_mgr_is_queue_runtime_suspend(struct ssi_drvdata *drvdata)
591 {
592 struct ssi_request_mgr_handle *request_mgr_handle =
593 drvdata->request_mgr_handle;
594
595 return request_mgr_handle->is_runtime_suspended;
596 }
597
598 #endif
599