}
}
-/* Caller must hold rga_service.lock */
static void rga2_del_running_list(void)
{
+ struct rga2_mmu_buf_t *tbuf = &rga2_mmu_buf;
struct rga2_reg *reg;
- while(!list_empty(&rga2_service.running))
- {
- reg = list_entry(rga2_service.running.next, struct rga2_reg, status_link);
-
- if(reg->MMU_len != 0)
- {
- if (rga2_mmu_buf.back + reg->MMU_len > 2*rga2_mmu_buf.size)
- rga2_mmu_buf.back = reg->MMU_len + rga2_mmu_buf.size;
+ while (!list_empty(&rga2_service.running)) {
+ reg = list_entry(rga2_service.running.next, struct rga2_reg,
+ status_link);
+ if (reg->MMU_len && tbuf) {
+ if (tbuf->back + reg->MMU_len > 2 * tbuf->size)
+ tbuf->back = reg->MMU_len + tbuf->size;
else
- rga2_mmu_buf.back += reg->MMU_len;
+ tbuf->back += reg->MMU_len;
}
atomic_sub(1, ®->session->task_running);
atomic_sub(1, &rga2_service.total_running);
}
}
-/* Caller must hold rga_service.lock */
static void rga2_del_running_list_timeout(void)
{
- struct rga2_reg *reg;
-
- while(!list_empty(&rga2_service.running))
- {
- reg = list_entry(rga2_service.running.next, struct rga2_reg, status_link);
-
- if(reg->MMU_base != NULL)
- {
- kfree(reg->MMU_base);
- }
-
- atomic_sub(1, ®->session->task_running);
- atomic_sub(1, &rga2_service.total_running);
-
- rga2_soft_reset();
-
- if(list_empty(®->session->waiting))
- {
- atomic_set(®->session->done, 1);
- wake_up(®->session->wait);
- }
+ struct rga2_mmu_buf_t *tbuf = &rga2_mmu_buf;
+ struct rga2_reg *reg;
- rga2_reg_deinit(reg);
- }
+ while (!list_empty(&rga2_service.running)) {
+ reg = list_entry(rga2_service.running.next, struct rga2_reg,
+ status_link);
+ kfree(reg->MMU_base);
+ if (reg->MMU_len && tbuf) {
+ if (tbuf->back + reg->MMU_len > 2 * tbuf->size)
+ tbuf->back = reg->MMU_len + tbuf->size;
+ else
+ tbuf->back += reg->MMU_len;
+ }
+ atomic_sub(1, ®->session->task_running);
+ atomic_sub(1, &rga2_service.total_running);
+ rga2_soft_reset();
+ if (list_empty(®->session->waiting)) {
+ atomic_set(®->session->done, 1);
+ wake_up(®->session->wait);
+ }
+ rga2_reg_deinit(reg);
+ }
+ return;
}
static int rga2_convert_dma_buf(struct rga2_req *req)
return 0;\r
}\r
\r
-static int rga2_mmu_buf_get_try(struct rga2_mmu_buf_t *t, uint32_t size)\r
-{\r
- mutex_lock(&rga2_service.lock);\r
- if((t->back - t->front) > t->size) {\r
- if(t->front + size > t->back - t->size) {\r
- pr_info("front %d, back %d dsize %d size %d", t->front, t->back, t->size, size);\r
- return -1;\r
- }\r
- }\r
- else {\r
- if((t->front + size) > t->back) {\r
- pr_info("front %d, back %d dsize %d size %d", t->front, t->back, t->size, size);\r
- return -1;\r
- }\r
-\r
- if(t->front + size > t->size) {\r
- if (size > (t->back - t->size)) {\r
- pr_info("front %d, back %d dsize %d size %d", t->front, t->back, t->size, size);\r
- return -1;\r
- }\r
- t->front = 0;\r
- }\r
- }\r
- mutex_unlock(&rga2_service.lock);\r
-\r
- return 0;\r
-}\r
-\r
+static int rga2_mmu_buf_get_try(struct rga2_mmu_buf_t *t, uint32_t size)
+{
+ int ret = 0;
+
+ mutex_lock(&rga2_service.lock);
+ if ((t->back - t->front) > t->size) {
+ if (t->front + size > t->back - t->size) {
+ pr_info("front %d, back %d dsize %d size %d",
+ t->front, t->back, t->size, size);
+ ret = -ENOMEM;
+ goto out;
+ }
+ } else {
+ if ((t->front + size) > t->back) {
+ pr_info("front %d, back %d dsize %d size %d",
+ t->front, t->back, t->size, size);
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ if (t->front + size > t->size) {
+ if (size > (t->back - t->size)) {
+ pr_info("front %d, back %d dsize %d size %d",
+ t->front, t->back, t->size, size);
+ ret = -ENOMEM;
+ goto out;
+ }
+ t->front = 0;
+ }
+ }
+out:
+ mutex_unlock(&rga2_service.lock);
+ return ret;
+}
+
static int rga2_mem_size_cal(unsigned long Mem, uint32_t MemSize, unsigned long *StartAddr)\r
{\r
unsigned long start, end;\r