camera: rockchip: camsys driver v0.0x22.0
authorzhangyunlong <dalon.zhang@rock-chips.com>
Wed, 31 May 2017 03:56:14 +0000 (11:56 +0800)
committerDalon.zhang <dalon.zhang@rock-chips.com>
Wed, 31 May 2017 06:29:43 +0000 (14:29 +0800)
delete node in irqpool list when thread disconnect

Change-Id: I5602e138ab9bce751e24f6dc0a0f7348755be97a
Signed-off-by: zhangyunlong <dalon.zhang@rock-chips.com>
drivers/media/video/rk_camsys/camsys_drv.c
drivers/media/video/rk_camsys/camsys_internal.h
drivers/media/video/rk_camsys/camsys_marvin.c

index 915f92154b34e3ba2fc43fc9be7cca068efc818e..cd04f06895cd9bd75dde68c2989b73560e11bd4d 100644 (file)
@@ -548,7 +548,8 @@ static int camsys_irq_connect(camsys_irqcnnt_t *irqcnnt, camsys_dev_t
        *camsys_dev)
 {
        int err = 0, i;
-       camsys_irqpool_t *irqpool;
+       bool find_pool = false;
+       camsys_irqpool_t *irqpool, *n;
        unsigned long int flags;
 
        if ((irqcnnt->mis != MRV_ISP_MIS) &&
@@ -567,18 +568,26 @@ static int camsys_irq_connect(camsys_irqcnnt_t *irqcnnt, camsys_dev_t
 
        spin_lock_irqsave(&camsys_dev->irq.lock, flags);
        if (!list_empty(&camsys_dev->irq.irq_pool)) {
-               list_for_each_entry(irqpool, &camsys_dev->irq.irq_pool, list) {
-                       if (irqpool->pid == irqcnnt->pid) {
-                               camsys_warn("this thread(pid: %d) had been connect irq!",
-                                            current->pid);
-                               spin_unlock_irqrestore(&camsys_dev->irq.lock,
-                                                      flags);
-                               goto end;
+               list_for_each_entry_safe(irqpool, n,
+                                       &camsys_dev->irq.irq_pool, list) {
+                       if (irqpool->pid == -1) {
+                               list_del_init(&irqpool->list);
+                               kfree(irqpool);
+                               irqpool = NULL;
+                       } else {
+                               if (irqpool->pid == irqcnnt->pid)
+                                       find_pool = true;
                        }
                }
        }
        spin_unlock_irqrestore(&camsys_dev->irq.lock, flags);
 
+       if (find_pool) {
+               camsys_warn("this thread(pid: %d) had been connect irq!",
+                                                    irqcnnt->pid);
+               goto end;
+       }
+
        irqpool = kzalloc(sizeof(camsys_irqpool_t), GFP_KERNEL);
        if (!irqpool) {
                err = -ENOMEM;
@@ -712,7 +721,7 @@ static int camsys_irq_disconnect(camsys_irqcnnt_t *irqcnnt, camsys_dev_t
                list_for_each_entry(irqpool, &camsys_dev->irq.irq_pool, list) {
                        if (irqpool->pid == irqcnnt->pid) {
                                find_pool = true;
-                               irqpool->pid = 0;
+                               irqpool->pid = -1;
                                break;
                        }
                }
@@ -723,7 +732,7 @@ static int camsys_irq_disconnect(camsys_irqcnnt_t *irqcnnt, camsys_dev_t
                camsys_err(
                        "this thread(pid: %d) have not been connect irq!"
                        "disconnect failed",
-                       current->pid);
+                       irqcnnt->pid);
        } else {
                wake_up_all(&irqpool->done);
        }
index 7bb1a2821b4b49576f449f3de88f9c09c03a39eb..43f6c8d9f20e890d58c7b7f4c9d1a2181b21a0a2 100644 (file)
        2) add csi-phy timing setting for 3368.
 *v0.0x21.0xf:
        1) add reference count for marvin.
+*v0.0x22.0:
+       1) delete node in irqpool list when thread disconnect.
 */
-#define CAMSYS_DRIVER_VERSION                   KERNEL_VERSION(0, 0x21, 0xf)
+#define CAMSYS_DRIVER_VERSION                   KERNEL_VERSION(0, 0x22, 0)
 
 #define CAMSYS_PLATFORM_DRV_NAME                "RockChip-CamSys"
 #define CAMSYS_PLATFORM_MARVIN_NAME             "Platform_MarvinDev"
index fa3475fe3f9a7d90e1e51f97346af55515653ef5..bc388414b71f818151e43b852c38d5f68e2b9406 100644 (file)
@@ -405,6 +405,16 @@ static int camsys_mrv_drm_iommu_cb(void *ptr, camsys_sysctrl_t *devctl)
                        attach = camsys_dev->dma_buf[index].attach;
                        dma_buf = camsys_dev->dma_buf[index].dma_buf;
                        sgt = camsys_dev->dma_buf[index].sgt;
+                       camsys_trace
+                       (
+                       2,
+                       "exist mapped buf, release it before map: attach %p,"
+                       "dma_buf %p,sgt %p,fd %d,index %d",
+                       attach,
+                       dma_buf,
+                       sgt,
+                       iommu->map_fd,
+                       index);
                        dma_buf_unmap_attachment
                                (attach,
                                sgt,
@@ -477,7 +487,7 @@ static int camsys_mrv_drm_iommu_cb(void *ptr, camsys_sysctrl_t *devctl)
                }
                if (index == camsys_dev->dma_buf_cnt) {
                        camsys_warn("can't find map fd %d", iommu->map_fd);
-                       return 0;
+                       return -EINVAL;
                }
                attach = camsys_dev->dma_buf[index].attach;
                dma_buf = camsys_dev->dma_buf[index].dma_buf;