Skip to content

Commit c3749a4

Browse files
Yu Qiaoweirkhuangtao
authored andcommitted
video: rockchip: rga3: Support soft batch mode
Split the request into multiple jobs and execute them. Signed-off-by: Yu Qiaowei <[email protected]> Change-Id: I96d044cb52ed20e452154c400a1454bcea014bfa
1 parent fdb920e commit c3749a4

File tree

7 files changed

+540
-522
lines changed

7 files changed

+540
-522
lines changed

drivers/video/rockchip/rga3/include/rga.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515
#define RGA_IOC_GET_HW_VERSION RGA_IOR(0x2, struct rga_hw_versions_t)
1616
#define RGA_IOC_IMPORT_BUFFER RGA_IOWR(0x3, struct rga_buffer_pool)
1717
#define RGA_IOC_RELEASE_BUFFER RGA_IOW(0x4, struct rga_buffer_pool)
18-
19-
#define RGA_START_CONFIG RGA_IOR(0x5, uint32_t)
20-
#define RGA_END_CONFIG RGA_IOWR(0x6, struct rga_user_ctx_t)
21-
#define RGA_CMD_CONFIG RGA_IOWR(0x7, struct rga_user_ctx_t)
22-
#define RGA_CANCEL_CONFIG RGA_IOWR(0x8, uint32_t)
18+
#define RGA_IOC_REQUEST_CREATE RGA_IOR(0x5, uint32_t)
19+
#define RGA_IOC_REQUEST_SUBMIT RGA_IOWR(0x6, struct rga_user_request)
20+
#define RGA_IOC_REQUEST_CONFIG RGA_IOWR(0x7, struct rga_user_request)
21+
#define RGA_IOC_REQUEST_CANCEL RGA_IOWR(0x8, uint32_t)
2322

2423
#define RGA_BLIT_SYNC 0x5017
2524
#define RGA_BLIT_ASYNC 0x5018
@@ -32,7 +31,7 @@
3231
#define RGA_IMPORT_DMA 0x601d
3332
#define RGA_RELEASE_DMA 0x601e
3433

35-
#define RGA_CMD_NUM_MAX 1
34+
#define RGA_TASK_NUM_MAX 50
3635

3736
#define RGA_OUT_OF_RESOURCES -10
3837
#define RGA_MALLOC_ERROR -11
@@ -848,16 +847,18 @@ struct rga_mpi_job_t {
848847
int ctx_id;
849848
};
850849

851-
struct rga_user_ctx_t {
852-
uint64_t cmd_ptr;
853-
uint32_t cmd_num;
850+
struct rga_user_request {
851+
uint64_t task_ptr;
852+
uint32_t task_num;
854853
uint32_t id;
855854
uint32_t sync_mode;
856-
uint32_t out_fence_fd;
855+
uint32_t release_fence_fd;
857856

858857
uint32_t mpi_config_flags;
859858

860-
uint8_t reservr[124];
859+
uint32_t acquire_fence_fd;
860+
861+
uint8_t reservr[120];
861862
};
862863

863864
int rga_mpi_commit(struct rga_mpi_job_t *mpi_job);

drivers/video/rockchip/rga3/include/rga_debugger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static inline int rga_procfs_init(void)
129129
#endif /* #ifdef CONFIG_ROCKCHIP_RGA_DEBUGGER */
130130

131131
void rga_cmd_print_debug_info(struct rga_req *req);
132-
void rga_ctx_cache_cmd_debug_info(struct seq_file *m, struct rga_req *req);
132+
void rga_request_task_debug_info(struct seq_file *m, struct rga_req *req);
133133
void rga_dump_external_buffer(struct rga_external_buffer *buffer);
134134

135135
#endif /* #ifndef _RGA_DEBUGGER_H_ */

drivers/video/rockchip/rga3/include/rga_drv.h

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ struct rga_job {
267267
/* The time only for hrtimer to calculate the load */
268268
ktime_t hw_recoder_time;
269269
unsigned int flags;
270-
int ctx_id;
270+
int request_id;
271271
int priority;
272272
int core;
273273
int ret;
@@ -310,24 +310,26 @@ struct rga_scheduler_t {
310310
struct rga_timer timer;
311311
};
312312

313-
struct rga_internal_ctx_t {
314-
struct rga_req *cached_cmd;
315-
struct rga_session *session;
316-
317-
int cmd_num;
318-
int flags;
319-
int id;
313+
struct rga_request {
314+
struct rga_req *task_list;
315+
int task_count;
316+
uint32_t finished_task_count;
320317

321-
uint8_t mpi_config_flags;
318+
bool use_batch_mode;
319+
bool is_running;
322320
uint32_t sync_mode;
323321

324-
uint32_t finished_job_count;
322+
int32_t acquire_fence_fd;
323+
int32_t release_fence_fd;
324+
struct dma_fence *release_fence;
325+
spinlock_t fence_lock;
325326

326-
bool use_batch_mode;
327-
bool is_running;
327+
wait_queue_head_t finished_wq;
328328

329-
struct dma_fence *out_fence;
330-
int32_t out_fence_fd;
329+
int flags;
330+
uint8_t mpi_config_flags;
331+
int id;
332+
struct rga_session *session;
331333

332334
spinlock_t lock;
333335
struct kref refcount;
@@ -336,18 +338,18 @@ struct rga_internal_ctx_t {
336338
/* TODO: add some common work */
337339
};
338340

339-
struct rga_pending_ctx_manager {
341+
struct rga_pending_request_manager {
340342
struct mutex lock;
341343

342344
/*
343-
* @ctx_id_idr:
345+
* @request_idr:
344346
*
345-
* Mapping of ctx id to object pointers. Used by the GEM
347+
* Mapping of request id to object pointers. Used by the GEM
346348
* subsystem. Protected by @lock.
347349
*/
348-
struct idr ctx_id_idr;
350+
struct idr request_idr;
349351

350-
int ctx_count;
352+
int request_count;
351353
};
352354

353355
struct rga_session_manager {
@@ -370,7 +372,7 @@ struct rga_drvdata_t {
370372
struct rga_mm *mm;
371373

372374
/* rga_job pending manager, import by RGA_START_CONFIG */
373-
struct rga_pending_ctx_manager *pend_ctx_manager;
375+
struct rga_pending_request_manager *pend_request_manager;
374376

375377
struct rga_session_manager *session_manager;
376378

drivers/video/rockchip/rga3/include/rga_job.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,27 @@ struct rga_scheduler_t *rga_job_get_scheduler(struct rga_job *job);
2626
void rga_job_session_destroy(struct rga_session *session);
2727

2828
void rga_job_done(struct rga_scheduler_t *scheduler, int ret);
29-
int rga_job_commit(struct rga_req *rga_command_base, struct rga_internal_ctx_t *ctx);
30-
31-
int rga_job_mpi_commit(struct rga_req *rga_command_base, struct rga_internal_ctx_t *ctx);
29+
struct rga_job *rga_job_commit(struct rga_req *rga_command_base, struct rga_request *request);
30+
int rga_job_mpi_commit(struct rga_req *rga_command_base, struct rga_request *request);
3231

3332
int rga_job_assign(struct rga_job *job);
3433

35-
int rga_ctx_manager_init(struct rga_pending_ctx_manager **ctx_manager_session);
36-
int rga_ctx_manager_remove(struct rga_pending_ctx_manager **ctx_manager_session);
3734

38-
struct rga_internal_ctx_t *
39-
rga_internal_ctx_lookup(struct rga_pending_ctx_manager *ctx_manager, uint32_t id);
35+
int rga_request_check(struct rga_user_request *req);
36+
struct rga_request *rga_request_lookup(struct rga_pending_request_manager *request_manager,
37+
uint32_t id);
38+
39+
int rga_request_commit(struct rga_request *user_request);
40+
int rga_request_put(struct rga_request *request);
41+
void rga_request_get(struct rga_request *request);
42+
uint32_t rga_request_alloc(uint32_t flags, struct rga_session *session);
4043

41-
uint32_t rga_internal_ctx_alloc_to_get_idr_id(uint32_t flags, struct rga_session *session);
44+
struct rga_request *rga_request_config(struct rga_user_request *user_request);
45+
int rga_request_submit(struct rga_request *request);
46+
int rga_request_release_signal(struct rga_scheduler_t *scheduler, struct rga_job *job);
4247

43-
void rga_internal_ctx_kref_release(struct kref *ref);
44-
int rga_internal_ctx_config_by_user_ctx(struct rga_user_ctx_t *user_ctx);
45-
int rga_internal_ctx_commit_by_user_ctx(struct rga_user_ctx_t *user_ctx);
46-
int rga_internal_ctx_cancel_by_user_ctx(uint32_t ctx_id);
47-
int rga_internal_ctx_signal(struct rga_scheduler_t *scheduler, struct rga_job *job);
48+
int rga_request_manager_init(struct rga_pending_request_manager **request_manager_session);
49+
int rga_request_manager_remove(struct rga_pending_request_manager **request_manager_session);
4850

4951
struct rga_job *
5052
rga_scheduler_get_pending_job_list(struct rga_scheduler_t *scheduler);

drivers/video/rockchip/rga3/rga_debugger.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -277,51 +277,51 @@ static int rga_mm_session_show(struct seq_file *m, void *data)
277277
return 0;
278278
}
279279

280-
static int rga_ctx_manager_show(struct seq_file *m, void *data)
280+
static int rga_request_manager_show(struct seq_file *m, void *data)
281281
{
282282
int id, i;
283-
struct rga_pending_ctx_manager *ctx_manager;
284-
struct rga_internal_ctx_t *ctx;
285-
struct rga_req *cached_cmd;
283+
struct rga_pending_request_manager *request_manager;
284+
struct rga_request *request;
285+
struct rga_req *task_list;
286286
unsigned long flags;
287-
int cmd_num = 0;
288-
int finished_job_count = 0;
287+
int task_count = 0;
288+
int finished_task_count = 0;
289289

290-
ctx_manager = rga_drvdata->pend_ctx_manager;
290+
request_manager = rga_drvdata->pend_request_manager;
291291

292-
seq_puts(m, "rga internal ctx dump:\n");
293-
seq_printf(m, "ctx count = %d\n", ctx_manager->ctx_count);
292+
seq_puts(m, "rga internal request dump:\n");
293+
seq_printf(m, "request count = %d\n", request_manager->request_count);
294294
seq_puts(m, "===============================================================\n");
295295

296-
mutex_lock(&ctx_manager->lock);
296+
mutex_lock(&request_manager->lock);
297297

298-
idr_for_each_entry(&ctx_manager->ctx_id_idr, ctx, id) {
299-
seq_printf(m, "------------------ ctx: %d ------------------\n", ctx->id);
298+
idr_for_each_entry(&request_manager->request_idr, request, id) {
299+
seq_printf(m, "------------------ request: %d ------------------\n", request->id);
300300

301-
spin_lock_irqsave(&ctx->lock, flags);
301+
spin_lock_irqsave(&request->lock, flags);
302302

303-
cmd_num = ctx->cmd_num;
304-
finished_job_count = ctx->finished_job_count;
305-
cached_cmd = ctx->cached_cmd;
303+
task_count = request->task_count;
304+
finished_task_count = request->finished_task_count;
305+
task_list = request->task_list;
306306

307-
spin_unlock_irqrestore(&ctx->lock, flags);
307+
spin_unlock_irqrestore(&request->lock, flags);
308308

309-
if (cached_cmd == NULL) {
310-
seq_puts(m, "\t can not find cached cmd from id\n");
309+
if (task_list == NULL) {
310+
seq_puts(m, "\t can not find task list from id\n");
311311
continue;
312312
}
313313

314314
seq_printf(m, "\t set cmd num: %d, finish job sum: %d\n",
315-
cmd_num, finished_job_count);
315+
task_count, finished_task_count);
316316

317317
seq_puts(m, "\t cmd dump:\n\n");
318318

319-
for (i = 0; i < ctx->cmd_num; i++)
320-
rga_ctx_cache_cmd_debug_info(m, &(cached_cmd[i]));
319+
for (i = 0; i < request->task_count; i++)
320+
rga_request_task_debug_info(m, &(task_list[i]));
321321

322322
}
323323

324-
mutex_unlock(&ctx_manager->lock);
324+
mutex_unlock(&request_manager->lock);
325325

326326
return 0;
327327
}
@@ -333,7 +333,7 @@ struct rga_debugger_list rga_debugger_root_list[] = {
333333
{"load", rga_load_show, NULL, NULL},
334334
{"scheduler_status", rga_scheduler_show, NULL, NULL},
335335
{"mm_session", rga_mm_session_show, NULL, NULL},
336-
{"ctx_manager", rga_ctx_manager_show, NULL, NULL},
336+
{"request_manager", rga_request_manager_show, NULL, NULL},
337337
};
338338

339339
static ssize_t rga_debugger_write(struct file *file, const char __user *ubuf,
@@ -604,7 +604,7 @@ int rga_procfs_init(void)
604604
}
605605
#endif /* #ifdef CONFIG_ROCKCHIP_RGA_PROC_FS */
606606

607-
void rga_ctx_cache_cmd_debug_info(struct seq_file *m, struct rga_req *req)
607+
void rga_request_task_debug_info(struct seq_file *m, struct rga_req *req)
608608
{
609609
seq_printf(m, "\t\t rotate_mode = %d\n", req->rotate_mode);
610610
seq_printf(m, "\t\t src: y = %lx uv = %lx v = %lx aw = %d ah = %d vw = %d vh = %d\n",

0 commit comments

Comments
 (0)