hil: add mutex lock to hil_proc
authorWendy Liang <jliang@xilinx.com>
Wed, 25 Jan 2017 00:10:28 +0000 (16:10 -0800)
committerWendy Liang <jliang@xilinx.com>
Fri, 3 Feb 2017 21:41:23 +0000 (13:41 -0800)
Add mutex lock to hil_proc

Signed-off-by: Wendy Liang <jliang@xilinx.com>
lib/common/hil.c
lib/include/openamp/hil.h

index a8f06c425b6989f66358e568e0c6f931078333bc..7dafe15386d0b0be2fc8136c4144e82ea0a7b66e 100644 (file)
@@ -108,6 +108,7 @@ struct hil_proc *hil_create_proc(struct hil_platform_ops *ops,
        for (i = 0; i < HIL_MAX_NUM_VRINGS; i++)
                proc->vdev.vring_info[i].io = &hil_devmem_generic_io;
 
+       metal_mutex_init(&proc->lock);
        metal_list_add_tail(&procs, &proc->node);
 
        return proc;
@@ -133,6 +134,7 @@ void hil_delete_proc(struct hil_proc *proc)
                if (proc ==
                        metal_container_of(node, struct hil_proc, node)) {
                        metal_list_del(&proc->node);
+                       metal_mutex_acquire(&proc->lock);
                        proc->ops->release(proc);
                        /* Close shmem device */
                        dev = proc->sh_buff.dev;
@@ -155,6 +157,8 @@ void hil_delete_proc(struct hil_proc *proc)
                                }
                        }
 
+                       metal_mutex_release(&proc->lock);
+                       metal_mutex_deinit(&proc->lock);
                        metal_free_memory(proc);
                        return;
                }
index 9f5809fe9c73d3442d302b2a9178cababcef783a..0d82900d0cc57ad67aa851c5c6a8090939fe1fde 100644 (file)
@@ -47,6 +47,7 @@
 #include "metal/list.h"
 #include "metal/io.h"
 #include "metal/device.h"
+#include "metal/mutex.h"
 
 /* Configurable parameters */
 #define HIL_MAX_CORES                   2
@@ -183,6 +184,8 @@ struct hil_proc {
        struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
        /* Initialized status */
        int is_initialized;
+       /* hil_proc lock */
+       metal_mutex_t lock;
        /* private data */
        void *pdata;
        /* List node */