1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2015 - 2020 Intel Corporation
4 #include <linux/bitmap.h>
5 #include <linux/errno.h>
7 #include <linux/slab.h>
8 #include <linux/device.h>
10 #include <uapi/linux/ipu-psys.h>
12 #include "ipu-fw-psys.h"
15 struct ipu6_psys_hw_res_variant hw_var
;
16 void ipu6_psys_hw_res_variant_init(void)
18 if (ipu_ver
== IPU_VER_6SE
) {
19 hw_var
.queue_num
= IPU6SE_FW_PSYS_N_PSYS_CMD_QUEUE_ID
;
20 hw_var
.cell_num
= IPU6SE_FW_PSYS_N_CELL_ID
;
21 hw_var
.set_proc_dev_chn
= ipu6se_fw_psys_set_proc_dev_chn
;
22 hw_var
.set_proc_dfm_bitmap
= ipu6se_fw_psys_set_proc_dfm_bitmap
;
23 hw_var
.set_proc_ext_mem
= ipu6se_fw_psys_set_process_ext_mem
;
24 hw_var
.get_pgm_by_proc
=
25 ipu6se_fw_psys_get_program_manifest_by_process
;
27 } else if (ipu_ver
== IPU_VER_6
) {
28 hw_var
.queue_num
= IPU6_FW_PSYS_N_PSYS_CMD_QUEUE_ID
;
29 hw_var
.cell_num
= IPU6_FW_PSYS_N_CELL_ID
;
30 hw_var
.set_proc_dev_chn
= ipu6_fw_psys_set_proc_dev_chn
;
31 hw_var
.set_proc_dfm_bitmap
= ipu6_fw_psys_set_proc_dfm_bitmap
;
32 hw_var
.set_proc_ext_mem
= ipu6_fw_psys_set_process_ext_mem
;
33 hw_var
.get_pgm_by_proc
=
34 ipu6_fw_psys_get_program_manifest_by_process
;
36 } else if (ipu_ver
== IPU_VER_6EP
) {
37 hw_var
.queue_num
= IPU6_FW_PSYS_N_PSYS_CMD_QUEUE_ID
;
38 hw_var
.cell_num
= IPU6EP_FW_PSYS_N_CELL_ID
;
39 hw_var
.set_proc_dev_chn
= ipu6_fw_psys_set_proc_dev_chn
;
40 hw_var
.set_proc_dfm_bitmap
= ipu6_fw_psys_set_proc_dfm_bitmap
;
41 hw_var
.set_proc_ext_mem
= ipu6_fw_psys_set_process_ext_mem
;
42 hw_var
.get_pgm_by_proc
=
43 ipu6_fw_psys_get_program_manifest_by_process
;
47 WARN(1, "ipu6 psys res var is not initialised correctly.");
50 static const struct ipu_fw_resource_definitions
*get_res(void)
52 if (ipu_ver
== IPU_VER_6SE
)
53 return ipu6se_res_defs
;
55 if (ipu_ver
== IPU_VER_6EP
)
56 return ipu6ep_res_defs
;
61 static int ipu_resource_init(struct ipu_resource
*res
, u32 id
, int elements
)
68 res
->bitmap
= bitmap_zalloc(elements
, GFP_KERNEL
);
71 res
->elements
= elements
;
77 ipu_resource_alloc_with_pos(struct ipu_resource
*res
, int n
,
79 struct ipu_resource_alloc
*alloc
,
80 enum ipu_resource_type type
)
89 if (!res
->bitmap
|| pos
>= res
->elements
)
90 return (unsigned long)(-ENOSPC
);
92 p
= bitmap_find_next_zero_area(res
->bitmap
, res
->elements
, pos
, n
, 0);
93 alloc
->resource
= NULL
;
96 return (unsigned long)(-ENOSPC
);
97 bitmap_set(res
->bitmap
, p
, n
);
98 alloc
->resource
= res
;
107 ipu_resource_alloc(struct ipu_resource
*res
, int n
,
108 struct ipu_resource_alloc
*alloc
,
109 enum ipu_resource_type type
)
119 return (unsigned long)(-ENOSPC
);
121 p
= bitmap_find_next_zero_area(res
->bitmap
, res
->elements
, 0, n
, 0);
122 alloc
->resource
= NULL
;
124 if (p
>= res
->elements
)
125 return (unsigned long)(-ENOSPC
);
126 bitmap_set(res
->bitmap
, p
, n
);
127 alloc
->resource
= res
;
135 static void ipu_resource_free(struct ipu_resource_alloc
*alloc
)
137 if (alloc
->elements
<= 0)
140 if (alloc
->type
== IPU_RESOURCE_DFM
)
141 *alloc
->resource
->bitmap
&= ~(unsigned long)(alloc
->elements
);
143 bitmap_clear(alloc
->resource
->bitmap
, alloc
->pos
,
145 alloc
->resource
= NULL
;
148 static void ipu_resource_cleanup(struct ipu_resource
*res
)
150 bitmap_free(res
->bitmap
);
154 /********** IPU PSYS-specific resource handling **********/
155 static DEFINE_SPINLOCK(cq_bitmap_lock
);
156 int ipu_psys_resource_pool_init(struct ipu_psys_resource_pool
160 const struct ipu_fw_resource_definitions
*res_defs
;
162 res_defs
= get_res();
166 for (i
= 0; i
< res_defs
->num_dev_channels
; i
++) {
167 ret
= ipu_resource_init(&pool
->dev_channels
[i
], i
,
168 res_defs
->dev_channels
[i
]);
173 for (j
= 0; j
< res_defs
->num_ext_mem_ids
; j
++) {
174 ret
= ipu_resource_init(&pool
->ext_memory
[j
], j
,
175 res_defs
->ext_mem_ids
[j
]);
180 for (k
= 0; k
< res_defs
->num_dfm_ids
; k
++) {
181 ret
= ipu_resource_init(&pool
->dfms
[k
], k
, res_defs
->dfms
[k
]);
186 spin_lock(&cq_bitmap_lock
);
187 if (ipu_ver
== IPU_VER_6SE
)
188 bitmap_zero(pool
->cmd_queues
,
189 IPU6SE_FW_PSYS_N_PSYS_CMD_QUEUE_ID
);
191 bitmap_zero(pool
->cmd_queues
,
192 IPU6_FW_PSYS_N_PSYS_CMD_QUEUE_ID
);
193 spin_unlock(&cq_bitmap_lock
);
198 for (k
--; k
>= 0; k
--)
199 ipu_resource_cleanup(&pool
->dfms
[k
]);
202 for (j
--; j
>= 0; j
--)
203 ipu_resource_cleanup(&pool
->ext_memory
[j
]);
206 for (i
--; i
>= 0; i
--)
207 ipu_resource_cleanup(&pool
->dev_channels
[i
]);
211 void ipu_psys_resource_copy(struct ipu_psys_resource_pool
*src
,
212 struct ipu_psys_resource_pool
*dest
)
215 const struct ipu_fw_resource_definitions
*res_defs
;
217 res_defs
= get_res();
219 dest
->cells
= src
->cells
;
220 for (i
= 0; i
< res_defs
->num_dev_channels
; i
++)
221 *dest
->dev_channels
[i
].bitmap
= *src
->dev_channels
[i
].bitmap
;
223 for (i
= 0; i
< res_defs
->num_ext_mem_ids
; i
++)
224 *dest
->ext_memory
[i
].bitmap
= *src
->ext_memory
[i
].bitmap
;
226 for (i
= 0; i
< res_defs
->num_dfm_ids
; i
++)
227 *dest
->dfms
[i
].bitmap
= *src
->dfms
[i
].bitmap
;
230 void ipu_psys_resource_pool_cleanup(struct ipu_psys_resource_pool
234 const struct ipu_fw_resource_definitions
*res_defs
;
236 res_defs
= get_res();
237 for (i
= 0; i
< res_defs
->num_dev_channels
; i
++)
238 ipu_resource_cleanup(&pool
->dev_channels
[i
]);
240 for (i
= 0; i
< res_defs
->num_ext_mem_ids
; i
++)
241 ipu_resource_cleanup(&pool
->ext_memory
[i
]);
243 for (i
= 0; i
< res_defs
->num_dfm_ids
; i
++)
244 ipu_resource_cleanup(&pool
->dfms
[i
]);
247 static int __alloc_one_resrc(const struct device
*dev
,
248 struct ipu_fw_psys_process
*process
,
249 struct ipu_resource
*resource
,
250 struct ipu_fw_generic_program_manifest
*pm
,
252 struct ipu_psys_resource_alloc
*alloc
)
254 const u16 resource_req
= pm
->dev_chn_size
[resource_id
];
255 const u16 resource_offset_req
= pm
->dev_chn_offset
[resource_id
];
258 if (resource_req
<= 0)
261 if (alloc
->resources
>= IPU_MAX_RESOURCES
) {
262 dev_err(dev
, "out of resource handles\n");
265 if (resource_offset_req
!= (u16
)(-1))
266 retl
= ipu_resource_alloc_with_pos
270 &alloc
->resource_alloc
[alloc
->resources
],
271 IPU_RESOURCE_DEV_CHN
);
273 retl
= ipu_resource_alloc
274 (resource
, resource_req
,
275 &alloc
->resource_alloc
[alloc
->resources
],
276 IPU_RESOURCE_DEV_CHN
);
277 if (IS_ERR_VALUE(retl
)) {
278 dev_dbg(dev
, "out of device channel resources\n");
286 static inline unsigned int bit_count(unsigned int n
)
288 unsigned int counter
= 0;
297 static int ipu_psys_allocate_one_dfm(const struct device
*dev
,
298 struct ipu_fw_psys_process
*process
,
299 struct ipu_resource
*resource
,
300 struct ipu_fw_generic_program_manifest
*pm
,
302 struct ipu_psys_resource_alloc
*alloc
)
304 u32 dfm_bitmap_req
= pm
->dfm_port_bitmap
[resource_id
];
305 u32 active_dfm_bitmap_req
= pm
->dfm_active_port_bitmap
[resource_id
];
306 const u8 is_relocatable
= pm
->is_dfm_relocatable
[resource_id
];
307 struct ipu_resource_alloc
*alloc_resource
;
310 if (dfm_bitmap_req
== 0)
313 if (alloc
->resources
>= IPU_MAX_RESOURCES
) {
314 dev_err(dev
, "out of resource handles\n");
318 if (!resource
->bitmap
)
321 if (!is_relocatable
) {
322 if (*resource
->bitmap
& dfm_bitmap_req
) {
324 "out of dfm resources, req 0x%x, get 0x%lx\n",
325 dfm_bitmap_req
, *resource
->bitmap
);
328 *resource
->bitmap
|= dfm_bitmap_req
;
330 unsigned int n
= bit_count(dfm_bitmap_req
);
332 p
= bitmap_find_next_zero_area(resource
->bitmap
,
333 resource
->elements
, 0, n
, 0);
335 if (p
>= resource
->elements
)
338 bitmap_set(resource
->bitmap
, p
, n
);
339 dfm_bitmap_req
= dfm_bitmap_req
<< p
;
340 active_dfm_bitmap_req
= active_dfm_bitmap_req
<< p
;
343 alloc_resource
= &alloc
->resource_alloc
[alloc
->resources
];
344 alloc_resource
->resource
= resource
;
345 /* Using elements to indicate the bitmap */
346 alloc_resource
->elements
= dfm_bitmap_req
;
347 alloc_resource
->pos
= p
;
348 alloc_resource
->type
= IPU_RESOURCE_DFM
;
356 * ext_mem_type_id is a generic type id for memory (like DMEM, VMEM)
357 * ext_mem_bank_id is detailed type id for memory (like DMEM0, DMEM1 etc.)
359 static int __alloc_mem_resrc(const struct device
*dev
,
360 struct ipu_fw_psys_process
*process
,
361 struct ipu_resource
*resource
,
362 struct ipu_fw_generic_program_manifest
*pm
,
363 u32 ext_mem_type_id
, u32 ext_mem_bank_id
,
364 struct ipu_psys_resource_alloc
*alloc
)
366 const u16 memory_resource_req
= pm
->ext_mem_size
[ext_mem_type_id
];
367 const u16 memory_offset_req
= pm
->ext_mem_offset
[ext_mem_type_id
];
371 if (memory_resource_req
<= 0)
374 if (alloc
->resources
>= IPU_MAX_RESOURCES
) {
375 dev_err(dev
, "out of resource handles\n");
378 if (memory_offset_req
!= (u16
)(-1))
379 retl
= ipu_resource_alloc_with_pos
381 memory_resource_req
, memory_offset_req
,
382 &alloc
->resource_alloc
[alloc
->resources
],
383 IPU_RESOURCE_EXT_MEM
);
385 retl
= ipu_resource_alloc
386 (resource
, memory_resource_req
,
387 &alloc
->resource_alloc
[alloc
->resources
],
388 IPU_RESOURCE_EXT_MEM
);
389 if (IS_ERR_VALUE(retl
)) {
390 dev_dbg(dev
, "out of memory resources\n");
399 int ipu_psys_allocate_cmd_queue_resource(struct ipu_psys_resource_pool
*pool
)
404 size
= IPU6_FW_PSYS_N_PSYS_CMD_QUEUE_ID
;
405 start
= IPU6_FW_PSYS_CMD_QUEUE_PPG0_COMMAND_ID
;
407 if (ipu_ver
== IPU_VER_6SE
) {
408 size
= IPU6SE_FW_PSYS_N_PSYS_CMD_QUEUE_ID
;
409 start
= IPU6SE_FW_PSYS_CMD_QUEUE_PPG0_COMMAND_ID
;
412 spin_lock(&cq_bitmap_lock
);
413 /* find available cmd queue from ppg0_cmd_id */
414 p
= bitmap_find_next_zero_area(pool
->cmd_queues
, size
, start
, 1, 0);
417 spin_unlock(&cq_bitmap_lock
);
421 bitmap_set(pool
->cmd_queues
, p
, 1);
422 spin_unlock(&cq_bitmap_lock
);
427 void ipu_psys_free_cmd_queue_resource(struct ipu_psys_resource_pool
*pool
,
430 spin_lock(&cq_bitmap_lock
);
431 bitmap_clear(pool
->cmd_queues
, queue_id
, 1);
432 spin_unlock(&cq_bitmap_lock
);
435 int ipu_psys_try_allocate_resources(struct device
*dev
,
436 struct ipu_fw_psys_process_group
*pg
,
438 struct ipu_psys_resource_pool
*pool
)
443 u16
*process_offset_table
;
446 struct ipu_psys_resource_alloc
*alloc
;
447 const struct ipu_fw_resource_definitions
*res_defs
;
451 process_offset_table
= (u16
*)((u8
*)pg
+ pg
->processes_offset
);
452 processes
= pg
->process_count
;
454 alloc
= kzalloc(sizeof(*alloc
), GFP_KERNEL
);
458 res_defs
= get_res();
459 for (i
= 0; i
< processes
; i
++) {
461 struct ipu_fw_psys_process
*process
=
462 (struct ipu_fw_psys_process
*)
463 ((char *)pg
+ process_offset_table
[i
]);
464 struct ipu_fw_generic_program_manifest pm
;
466 memset(&pm
, 0, sizeof(pm
));
469 dev_err(dev
, "can not get process\n");
474 ret
= ipu_fw_psys_get_program_manifest_by_process
475 (&pm
, pg_manifest
, process
);
477 dev_err(dev
, "can not get manifest\n");
481 if (pm
.cell_id
== res_defs
->num_cells
&&
482 pm
.cell_type_id
== res_defs
->num_cells_type
) {
483 cell
= res_defs
->num_cells
;
484 } else if ((pm
.cell_id
!= res_defs
->num_cells
&&
485 pm
.cell_type_id
== res_defs
->num_cells_type
)) {
488 /* Find a free cell of desired type */
489 u32 type
= pm
.cell_type_id
;
491 for (cell
= 0; cell
< res_defs
->num_cells
; cell
++)
492 if (res_defs
->cells
[cell
] == type
&&
493 ((pool
->cells
| cells
) & (1 << cell
)) == 0)
495 if (cell
>= res_defs
->num_cells
) {
496 dev_dbg(dev
, "no free cells of right type\n");
501 if (cell
< res_defs
->num_cells
)
503 if (pool
->cells
& cells
) {
504 dev_dbg(dev
, "out of cell resources\n");
509 if (pm
.dev_chn_size
) {
510 for (id
= 0; id
< res_defs
->num_dev_channels
; id
++) {
511 ret
= __alloc_one_resrc(dev
, process
,
512 &pool
->dev_channels
[id
],
519 if (pm
.dfm_port_bitmap
) {
520 for (id
= 0; id
< res_defs
->num_dfm_ids
; id
++) {
521 ret
= ipu_psys_allocate_one_dfm
523 &pool
->dfms
[id
], &pm
, id
, alloc
);
529 if (pm
.ext_mem_size
) {
530 for (mem_type_id
= 0;
531 mem_type_id
< res_defs
->num_ext_mem_types
;
533 u32 bank
= res_defs
->num_ext_mem_ids
;
535 if (cell
!= res_defs
->num_cells
) {
536 idx
= res_defs
->cell_mem_row
* cell
+
538 bank
= res_defs
->cell_mem
[idx
];
541 if (bank
== res_defs
->num_ext_mem_ids
)
544 ret
= __alloc_mem_resrc(dev
, process
,
545 &pool
->ext_memory
[bank
],
546 &pm
, mem_type_id
, bank
,
553 alloc
->cells
|= cells
;
554 pool
->cells
|= cells
;
560 dev_dbg(dev
, "failed to try_allocate resource\n");
566 * Allocate resources for pg from `pool'. Mark the allocated
567 * resources into `alloc'. Returns 0 on success, -ENOSPC
568 * if there are no enough resources, in which cases resources
569 * are not allocated at all, or some other error on other conditions.
571 int ipu_psys_allocate_resources(const struct device
*dev
,
572 struct ipu_fw_psys_process_group
*pg
,
574 struct ipu_psys_resource_alloc
575 *alloc
, struct ipu_psys_resource_pool
581 u16
*process_offset_table
;
586 const struct ipu_fw_resource_definitions
*res_defs
;
591 res_defs
= get_res();
592 process_offset_table
= (u16
*)((u8
*)pg
+ pg
->processes_offset
);
593 processes
= pg
->process_count
;
595 for (i
= 0; i
< processes
; i
++) {
597 struct ipu_fw_psys_process
*process
=
598 (struct ipu_fw_psys_process
*)
599 ((char *)pg
+ process_offset_table
[i
]);
600 struct ipu_fw_generic_program_manifest pm
;
602 memset(&pm
, 0, sizeof(pm
));
604 dev_err(dev
, "can not get process\n");
609 ret
= ipu_fw_psys_get_program_manifest_by_process
610 (&pm
, pg_manifest
, process
);
612 dev_err(dev
, "can not get manifest\n");
616 if (pm
.cell_id
== res_defs
->num_cells
&&
617 pm
.cell_type_id
== res_defs
->num_cells_type
) {
618 cell
= res_defs
->num_cells
;
619 } else if ((pm
.cell_id
!= res_defs
->num_cells
&&
620 pm
.cell_type_id
== res_defs
->num_cells_type
)) {
623 /* Find a free cell of desired type */
624 u32 type
= pm
.cell_type_id
;
626 for (cell
= 0; cell
< res_defs
->num_cells
; cell
++)
627 if (res_defs
->cells
[cell
] == type
&&
628 ((pool
->cells
| cells
) & (1 << cell
)) == 0)
630 if (cell
>= res_defs
->num_cells
) {
631 dev_dbg(dev
, "no free cells of right type\n");
635 ret
= ipu_fw_psys_set_process_cell_id(process
, 0, cell
);
639 if (cell
< res_defs
->num_cells
)
641 if (pool
->cells
& cells
) {
642 dev_dbg(dev
, "out of cell resources\n");
647 if (pm
.dev_chn_size
) {
648 for (id
= 0; id
< res_defs
->num_dev_channels
; id
++) {
649 ret
= __alloc_one_resrc(dev
, process
,
650 &pool
->dev_channels
[id
],
655 idx
= alloc
->resources
- 1;
656 p
= alloc
->resource_alloc
[idx
].pos
;
657 ret
= ipu_fw_psys_set_proc_dev_chn(process
, id
,
664 if (pm
.dfm_port_bitmap
) {
665 for (id
= 0; id
< res_defs
->num_dfm_ids
; id
++) {
666 ret
= ipu_psys_allocate_one_dfm(dev
, process
,
672 idx
= alloc
->resources
- 1;
673 p
= alloc
->resource_alloc
[idx
].pos
;
674 bmp
= pm
.dfm_port_bitmap
[id
];
676 a_bmp
= pm
.dfm_active_port_bitmap
[id
];
678 ret
= ipu_fw_psys_set_proc_dfm_bitmap(process
,
686 if (pm
.ext_mem_size
) {
687 for (mem_type_id
= 0;
688 mem_type_id
< res_defs
->num_ext_mem_types
;
690 u32 bank
= res_defs
->num_ext_mem_ids
;
692 if (cell
!= res_defs
->num_cells
) {
693 idx
= res_defs
->cell_mem_row
* cell
+
695 bank
= res_defs
->cell_mem
[idx
];
697 if (bank
== res_defs
->num_ext_mem_ids
)
700 ret
= __alloc_mem_resrc(dev
, process
,
701 &pool
->ext_memory
[bank
],
706 /* no return value check here because fw api
707 * will do some checks, and would return
708 * non-zero except mem_type_id == 0.
709 * This maybe caused by that above flow of
710 * allocating mem_bank_id is improper.
712 idx
= alloc
->resources
- 1;
713 p
= alloc
->resource_alloc
[idx
].pos
;
714 ipu_fw_psys_set_process_ext_mem(process
,
720 alloc
->cells
|= cells
;
721 pool
->cells
|= cells
;
725 dev_err(dev
, "failed to allocate resources, ret %d\n", ret
);
726 ipu_psys_reset_process_cell(dev
, pg
, pg_manifest
, i
+ 1);
727 ipu_psys_free_resources(alloc
, pool
);
731 int ipu_psys_move_resources(const struct device
*dev
,
732 struct ipu_psys_resource_alloc
*alloc
,
733 struct ipu_psys_resource_pool
734 *source_pool
, struct ipu_psys_resource_pool
739 if (target_pool
->cells
& alloc
->cells
) {
740 dev_dbg(dev
, "out of cell resources\n");
744 for (i
= 0; i
< alloc
->resources
; i
++) {
745 unsigned long bitmap
= 0;
746 unsigned int id
= alloc
->resource_alloc
[i
].resource
->id
;
747 unsigned long fbit
, end
;
749 switch (alloc
->resource_alloc
[i
].type
) {
750 case IPU_RESOURCE_DEV_CHN
:
751 bitmap_set(&bitmap
, alloc
->resource_alloc
[i
].pos
,
752 alloc
->resource_alloc
[i
].elements
);
753 if (*target_pool
->dev_channels
[id
].bitmap
& bitmap
)
756 case IPU_RESOURCE_EXT_MEM
:
757 end
= alloc
->resource_alloc
[i
].elements
+
758 alloc
->resource_alloc
[i
].pos
;
760 fbit
= find_next_bit(target_pool
->ext_memory
[id
].bitmap
,
761 end
, alloc
->resource_alloc
[i
].pos
);
762 /* if find_next_bit returns "end" it didn't find 1bit */
766 case IPU_RESOURCE_DFM
:
767 bitmap
= alloc
->resource_alloc
[i
].elements
;
768 if (*target_pool
->dfms
[id
].bitmap
& bitmap
)
772 dev_err(dev
, "Illegal resource type\n");
777 for (i
= 0; i
< alloc
->resources
; i
++) {
778 u32 id
= alloc
->resource_alloc
[i
].resource
->id
;
780 switch (alloc
->resource_alloc
[i
].type
) {
781 case IPU_RESOURCE_DEV_CHN
:
782 bitmap_set(target_pool
->dev_channels
[id
].bitmap
,
783 alloc
->resource_alloc
[i
].pos
,
784 alloc
->resource_alloc
[i
].elements
);
785 ipu_resource_free(&alloc
->resource_alloc
[i
]);
786 alloc
->resource_alloc
[i
].resource
=
787 &target_pool
->dev_channels
[id
];
789 case IPU_RESOURCE_EXT_MEM
:
790 bitmap_set(target_pool
->ext_memory
[id
].bitmap
,
791 alloc
->resource_alloc
[i
].pos
,
792 alloc
->resource_alloc
[i
].elements
);
793 ipu_resource_free(&alloc
->resource_alloc
[i
]);
794 alloc
->resource_alloc
[i
].resource
=
795 &target_pool
->ext_memory
[id
];
797 case IPU_RESOURCE_DFM
:
798 *target_pool
->dfms
[id
].bitmap
|=
799 alloc
->resource_alloc
[i
].elements
;
800 *alloc
->resource_alloc
[i
].resource
->bitmap
&=
801 ~(alloc
->resource_alloc
[i
].elements
);
802 alloc
->resource_alloc
[i
].resource
=
803 &target_pool
->dfms
[id
];
807 * Just keep compiler happy. This case failed already
814 target_pool
->cells
|= alloc
->cells
;
815 source_pool
->cells
&= ~alloc
->cells
;
820 void ipu_psys_reset_process_cell(const struct device
*dev
,
821 struct ipu_fw_psys_process_group
*pg
,
826 u16
*process_offset_table
;
827 const struct ipu_fw_resource_definitions
*res_defs
;
832 res_defs
= get_res();
833 process_offset_table
= (u16
*)((u8
*)pg
+ pg
->processes_offset
);
834 for (i
= 0; i
< process_count
; i
++) {
835 struct ipu_fw_psys_process
*process
=
836 (struct ipu_fw_psys_process
*)
837 ((char *)pg
+ process_offset_table
[i
]);
838 struct ipu_fw_generic_program_manifest pm
;
844 ret
= ipu_fw_psys_get_program_manifest_by_process(&pm
,
848 dev_err(dev
, "can not get manifest\n");
851 if ((pm
.cell_id
!= res_defs
->num_cells
&&
852 pm
.cell_type_id
== res_defs
->num_cells_type
))
854 /* no return value check here because if finding free cell
855 * failed, process cell would not set then calling clear_cell
856 * will return non-zero.
858 ipu_fw_psys_clear_process_cell(process
);
862 /* Free resources marked in `alloc' from `resources' */
863 void ipu_psys_free_resources(struct ipu_psys_resource_alloc
864 *alloc
, struct ipu_psys_resource_pool
*pool
)
868 pool
->cells
&= ~alloc
->cells
;
870 for (i
= 0; i
< alloc
->resources
; i
++)
871 ipu_resource_free(&alloc
->resource_alloc
[i
]);
872 alloc
->resources
= 0;