hil_proc: initialize with proc->ops->initialize()
authorWendy Liang <jliang@xilinx.com>
Wed, 6 Jul 2016 05:58:57 +0000 (22:58 -0700)
committerWendy Liang <jliang@xilinx.com>
Thu, 13 Oct 2016 05:01:44 +0000 (22:01 -0700)
Use proc->ops->initialize() for the remote processor initialization,
which will initialize the hil_proc and memory map the shared
memory specified in proc_shm.

The hil_create_proc() will only link the initialized hil_proc
to the hil_proc list.

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

index 724040686c76b87cdd2846c3184995d09facd8d4..1cf9dabe3259840f2bfc988e386c2e0151066351 100644 (file)
@@ -71,9 +71,8 @@ unsigned long long shutdown_time_stamp;
  */
 struct hil_proc *hil_create_proc(void *pdata, int cpu_id)
 {
-       struct hil_proc *proc, *proc_data;
+       struct hil_proc *proc = 0, *proc_data;
        struct metal_list *node;
-       int status;
 
        /* If proc already exists then return it */
        metal_list_for_each(&procs, node) {
@@ -83,32 +82,10 @@ struct hil_proc *hil_create_proc(void *pdata, int cpu_id)
                }
        }
 
-       if (!pdata)
-               return NULL;
        proc_data = (struct hil_proc *)pdata;
-       if (!proc_data->ops || !proc_data->ops->initialize)
-               return NULL;
-
-       /* Allocate memory for proc instance */
-       proc = env_allocate_memory(sizeof(struct hil_proc));
-       if (!proc) {
-               return NULL;
-       }
-
-       /* Get HW specfic info */
-       status = proc_data->ops->initialize(pdata,
-                                 proc, cpu_id);
-       if (status) {
-               env_free_memory(proc);
-               return NULL;
-       }
-
-       /* Enable mapping for the shared memory region */
-       env_map_memory((unsigned int)proc->sh_buff.start_addr,
-                      (unsigned int)proc->sh_buff.start_addr,
-                      proc->sh_buff.size, (SHARED_MEM | UNCACHED));
-
-       metal_list_add_tail(&procs, &proc->node);
+       proc = proc_data->ops->initialize(pdata, cpu_id);
+       if (proc)
+               metal_list_add_tail(&procs, &proc->node);
 
        return proc;
 }
index 22409cb3262d668aa5b40b10c32861471f70cf70..fc8efd58f3767c8fbd80ab71ddc55ddcbc90e706 100644 (file)
@@ -462,15 +462,12 @@ struct hil_platform_ops {
      *  This function initialize remote processor with platform data.
      *
      * @param[in] pdata - platform data
-     * @param[in] proc - pointer to the remote processor
      * @param[in] cpu_id - CPU id
      *
-     * @return 0 on sucess, otherwise on failure
+     * @return NULL on failure, hil_proc pointer otherwise
      *
      */
-       int (*initialize) (void *pdata,
-                                 struct hil_proc *proc,
-                                 int cpu_id);
+       struct hil_proc *(*initialize) (void *pdata, int cpu_id);
 
     /**
      * release
index 8c36c0b8ce5fc9661c3bf0257bf9b44dff1e5a31..fe47cc2af8e6e28f8de485a4dcfb76acd6bfb377 100644 (file)
@@ -82,7 +82,7 @@ static int _enable_interrupt(struct proc_vring *vring_hw);
 static void _notify(int cpu_id, struct proc_intr *intr_info);
 static int _boot_cpu(int cpu_id, unsigned int load_addr);
 static void _shutdown_cpu(int cpu_id);
-static int _initialize(void *pdata, struct hil_proc *proc, int cpu_id);
+static struct hil_proc * _initialize(void *pdata, int cpu_id);
 static void _release(struct hil_proc *proc);
 
 /*--------------------------- Globals ---------------------------------- */
@@ -177,13 +177,24 @@ static void _shutdown_cpu(int cpu_id)
        lock_slcr();
 }
 
-static int _initialize(void *pdata,
-                             struct hil_proc *proc,
-                             int cpu_id)
+static struct hil_proc * _initialize(void *pdata, int cpu_id)
 {
        (void) cpu_id;
+
+       struct hil_proc *proc;
+       /* Allocate memory for proc instance */
+       proc = env_allocate_memory(sizeof(struct hil_proc));
+       if (!proc) {
+               return NULL;
+       }
+
        memcpy(proc, pdata, sizeof(struct hil_proc));
-       return 0;
+       /* Enable mapping for the shared memory region */
+       if (proc->sh_buff.size)
+               env_map_memory((unsigned int)proc->sh_buff.start_addr,
+                           (unsigned int)proc->sh_buff.start_addr,
+                           proc->sh_buff.size, (SHARED_MEM | UNCACHED));
+       return proc;
 }
 
 static void _release(struct hil_proc *proc)
index 03b03214a5b9a5af9cef6f9f729758830ab5abbf..3be73e513e11ac968e6e5145298563546540f64d 100644 (file)
@@ -56,7 +56,7 @@ static void _reg_ipi_after_deinit(struct proc_vring *vring_hw);
 static void _notify(int cpu_id, struct proc_intr *intr_info);
 static int _boot_cpu(int cpu_id, unsigned int load_addr);
 static void _shutdown_cpu(int cpu_id);
-static int _initialize(void *pdata, struct hil_proc *proc, int cpu_id);
+static struct hil_proc *_initialize(void *pdata, int cpu_id);
 static void _release(struct hil_proc *proc);
 
 static void _ipi_handler(int vect_id, void *data);
@@ -181,13 +181,24 @@ static void _shutdown_cpu(int cpu_id)
        return;
 }
 
-static int _initialize(void *pdata,
-                             struct hil_proc *proc,
-                             int cpu_id)
+static struct hil_proc * _initialize(void *pdata, int cpu_id)
 {
        (void) cpu_id;
+
+       struct hil_proc *proc;
+       /* Allocate memory for proc instance */
+       proc = env_allocate_memory(sizeof(struct hil_proc));
+       if (!proc) {
+               return NULL;
+       }
+
        memcpy(proc, pdata, sizeof(struct hil_proc));
-       return 0;
+       /* Enable mapping for the shared memory region */
+       if (proc->sh_buff.size)
+               env_map_memory((unsigned int)proc->sh_buff.start_addr,
+                           (unsigned int)proc->sh_buff.start_addr,
+                           proc->sh_buff.size, (SHARED_MEM | UNCACHED));
+       return proc;
 }
 
 static void _release(struct hil_proc *proc)