\r
\r
/* Logging */\r
-#define RGA_DEBUG 1\r
+#define RGA_DEBUG 0\r
#if RGA_DEBUG\r
#define DBG(format, args...) printk(KERN_DEBUG "%s: " format, DRIVER_NAME, ## args)\r
#define ERR(format, args...) printk(KERN_ERR "%s: " format, DRIVER_NAME, ## args)\r
running = atomic_read(&rga_service.total_running);\r
printk("rga total_running %d\n", running);\r
\r
- return;\r
-\r
/* Dump waiting list info */\r
if (!list_empty(&rga_service.waiting))\r
{ \r
}\r
while(!list_empty(next)); \r
}\r
- \r
-\r
+ \r
list_for_each_entry_safe(session, session_tmp, &rga_service.session, list_session) \r
{\r
printk("session pid %d:\n", session->pid);\r
}\r
\r
\r
-static void rga_power_off(void)\r
+static void rga_power_off(struct work_struct *work)\r
{\r
int total_running;\r
\r
\r
total_running = atomic_read(&rga_service.total_running);\r
if (total_running) {\r
- pr_alert("power off when %d task running!!\n", total_running); \r
+ pr_err("power off when %d task running!!\n", total_running); \r
mdelay(50);\r
- pr_alert("delay 50 ms for running task\n"); \r
+ pr_err("delay 50 ms for running task\n"); \r
rga_dump();\r
}\r
\r
{ \r
int ret = 0;\r
int ret_timeout;\r
+ unsigned long flag;\r
\r
#if RGA_TEST_FLUSH_TIME\r
ktime_t start;\r
\r
if (unlikely(ret_timeout < 0)) {\r
pr_err("flush pid %d wait task ret %d\n", session->pid, ret); \r
+ spin_lock_irqsave(&rga_service.lock, flag);\r
rga_del_running_list();\r
+ spin_unlock_irqrestore(&rga_service.lock, flag);\r
ret = -ETIMEDOUT;\r
} else if (0 == ret_timeout) {\r
pr_err("flush pid %d wait %d task done timeout\n", session->pid, atomic_read(&session->task_running));\r
printk("bus = %.8x\n", rga_read(RGA_INT));\r
+ spin_lock_irqsave(&rga_service.lock, flag);\r
rga_del_running_list_timeout();\r
+ spin_unlock_irqrestore(&rga_service.lock, flag);\r
rga_try_set_reg(1);\r
ret = -ETIMEDOUT;\r
}\r
uint32_t i;\r
uint32_t *cmd_buf;\r
uint32_t *reg_p;\r
+\r
+ if(atomic_read(®->session->task_running) != 0)\r
+ {\r
+ printk(KERN_ERR "task_running is no zero\n");\r
+ }\r
\r
atomic_add(1, &rga_service.cmd_num);\r
- atomic_add(1, ®->session->task_running);\r
- atomic_add(1, &rga_service.total_running);\r
- \r
+ atomic_add(1, ®->session->task_running); \r
+ \r
cmd_buf = (uint32_t *)rga_service.cmd_buff + offset*28;\r
reg_p = (uint32_t *)reg->cmd_reg;\r
\r
if(reg->MMU_base != NULL)\r
{\r
kfree(reg->MMU_base);\r
+ reg->MMU_base = NULL;\r
}\r
- \r
atomic_sub(1, ®->session->task_running);\r
atomic_sub(1, &rga_service.total_running);\r
\r
int num = 0; \r
struct rga_reg *reg;\r
struct rga_req *req2;\r
+ unsigned long flag;\r
\r
uint32_t saw, sah, daw, dah;\r
\r
num = 1; \r
} \r
\r
- atomic_set(®->int_enable, 1); \r
+ //atomic_set(®->int_enable, 1);\r
+ \r
+ spin_lock_irqsave(&rga_service.lock, flag);\r
+ atomic_add(num, &rga_service.total_running);\r
+ spin_unlock_irqrestore(&rga_service.lock, flag);\r
+ \r
rga_try_set_reg(num);\r
\r
return 0; \r
{\r
int ret = -1;\r
int ret_timeout = 0;\r
+ unsigned long flag;\r
\r
#if RGA_TEST\r
printk("*** rga_blit_sync proc ***\n");\r
if (unlikely(ret_timeout< 0)) \r
{\r
pr_err("sync pid %d wait task ret %d\n", session->pid, ret_timeout); \r
+ spin_lock_irqsave(&rga_service.lock, flag);\r
rga_del_running_list();\r
+ spin_unlock_irqrestore(&rga_service.lock, flag);\r
ret = -ETIMEDOUT;\r
} \r
else if (0 == ret_timeout)\r
{\r
pr_err("sync pid %d wait %d task done timeout\n", session->pid, atomic_read(&session->task_running));\r
+ spin_lock_irqsave(&rga_service.lock, flag);\r
rga_del_running_list_timeout();\r
+ spin_unlock_irqrestore(&rga_service.lock, flag);\r
rga_try_set_reg(1);\r
ret = -ETIMEDOUT;\r
}\r
return -ENOMEM;\r
}\r
\r
+ memset(session, 0x0, sizeof(rga_session));\r
+\r
session->pid = current->pid;\r
+ //printk(KERN_DEBUG "+");\r
+ \r
INIT_LIST_HEAD(&session->waiting);\r
INIT_LIST_HEAD(&session->running);\r
INIT_LIST_HEAD(&session->list_session);\r
init_waitqueue_head(&session->wait);\r
- \r
- spin_lock_irqsave(&rga_service.lock, flag);\r
- list_add_tail(&session->list_session, &rga_service.session);\r
+ spin_lock_irqsave(&rga_service.lock, flag);\r
+ list_add_tail(&session->list_session, &rga_service.session); \r
spin_unlock_irqrestore(&rga_service.lock, flag);\r
- \r
atomic_set(&session->task_running, 0);\r
atomic_set(&session->num_done, 0);\r
+ \r
file->private_data = (void *)session;\r
\r
- DBG("*** rga dev opened by pid %d *** \n", session->pid); \r
+ //DBG("*** rga dev opened by pid %d *** \n", session->pid); \r
return nonseekable_open(inode, file);\r
\r
}\r
rga_session *session = (rga_session *)file->private_data;\r
if (NULL == session)\r
return -EINVAL;\r
- \r
+ //printk(KERN_DEBUG "-");\r
task_running = atomic_read(&session->task_running);\r
\r
if (task_running) \r
{\r
- pr_err("rga_service session %d still has %d task running when closing\n", session->pid, task_running);\r
+ pr_err("rga_service session %d still has %d task running when closing\n", session->pid, task_running); \r
msleep(100);\r
/*ͬ²½*/ \r
}\r
kfree(session);\r
spin_unlock_irqrestore(&rga_service.lock, flag);\r
\r
- DBG("*** rga dev close ***\n");\r
+ //DBG("*** rga dev close ***\n");\r
return 0;\r
}\r
\r
static irqreturn_t rga_irq(int irq, void *dev_id)\r
{\r
unsigned long flag;\r
- \r
- #if RGA_TEST\r
- printk("rga_irq is valid\n");\r
- #endif \r
-\r
- #if 0//RGA_INFO_BUS_ERROR\r
- if(rga_read(RGA_INT) & 0x1)\r
- {\r
- printk("bus Error interrupt is occur\n");\r
- rga_soft_reset();\r
- }\r
- #endif\r
-\r
+ \r
/*clear INT */\r
rga_write(rga_read(RGA_INT) | (0x1<<6) | (0x1<<7) | (0x1<<4), RGA_INT);\r
\r
- spin_lock_irqsave(&rga_service.lock, flag); \r
+ spin_lock_irqsave(&rga_service.lock, flag);\r
rga_del_running_list();\r
\r
if(!list_empty(&rga_service.waiting))\r
uint32_t enable;\r
\r
enable = rga_service.enable; \r
- rga_power_off();\r
+ rga_power_off(NULL);\r
rga_service.enable = enable;\r
\r
return 0;\r
static void rga_shutdown(struct platform_device *pdev)\r
{\r
pr_cont("shutdown..."); \r
- rga_power_off(); \r
+ rga_power_off(NULL); \r
pr_cont("done\n");\r
}\r
\r
goto err_misc_register;\r
}\r
\r
- rga_power_off();\r
+ rga_power_off(NULL);\r
\r
DBG("RGA Driver loaded succesfully\n");\r
\r
{\r
uint32_t i;\r
\r
- rga_power_off();\r
+ rga_power_off(NULL);\r
\r
for(i=0; i<2048; i++)\r
{\r