Commit fe5d10cc authored by Hari Kanigeri's avatar Hari Kanigeri

SYSLINK:proc-fix the issue with mem entries

This patch fixes the issue with getting mem_entries for
a proc instance.
Signed-off-by: default avatarHari Kanigeri <h-kanigeri2@ti.com>
parent ce510fef
......@@ -211,7 +211,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
{
struct processor_object *handle = NULL;
struct proc4430_object *object = NULL;
int ret_val = 0;
BUG_ON(!IS_VALID_PROCID(proc_id));
BUG_ON(params == NULL);
......@@ -240,6 +240,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
&proc4430_translate_addr;
handle->proc_fxn_table.map = &proc4430_map;
handle->proc_fxn_table.unmap = &proc4430_unmap;
handle->proc_fxn_table.procinfo = &proc4430_proc_info;
handle->state = PROC_MGR_STATE_UNKNOWN;
handle->object = vmalloc
(sizeof(struct proc4430_object));
......@@ -254,11 +255,13 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
object->params.mem_entries = vmalloc(
sizeof(struct proc4430_mem_entry) *
params->num_mem_entries);
copy_from_user(object->params.mem_entries,
ret_val = copy_from_user(object->params.mem_entries,
params->mem_entries,
(sizeof(struct proc4430_mem_entry)
* params->num_mem_entries));
WARN_ON(ret_val < 0);
}
handle->boot_mode = PROC_MGR_BOOTMODE_NOLOAD;
/* Set the handle in the state object. */
proc4430_state.proc_handles[proc_id] = handle;
}
......@@ -579,3 +582,39 @@ error_exit:
return ret_val;
}
/*=================================================
* Function to return PROC4430 mem_entries info
*
*/
int proc4430_proc_info(void *handle, struct proc_mgr_proc_info *procinfo)
{
struct processor_object *proc_handle =
(struct processor_object *)handle;
struct proc4430_object *object = NULL;
struct proc4430_mem_entry *entry = NULL;
int i;
if (WARN_ON(handle == NULL))
goto error_exit;
if (WARN_ON(procinfo == NULL))
goto error_exit;
object = (struct proc4430_object *)proc_handle->object;
for (i = 0 ; i < object->params.num_mem_entries ; i++) {
entry = &(object->params.mem_entries[i]);
procinfo->mem_entries[i].is_init = true;
procinfo->mem_entries[i].addr[PROC_MGR_ADDRTYPE_MASTERKNLVIRT]
= entry->phys_addr;
procinfo->mem_entries[i].addr[PROC_MGR_ADDRTYPE_MASTERUSRVIRT]
= entry->master_virt_addr;
procinfo->mem_entries[i].addr[PROC_MGR_ADDRTYPE_SLAVEVIRT]
= entry->slave_virt_addr;
procinfo->mem_entries[i].size = entry->size;
}
procinfo->num_mem_entries = object->params.num_mem_entries;
procinfo->boot_mode = proc_handle->boot_mode;
return 0;
error_exit:
printk(KERN_WARNING "proc4430_proc_info failed !!!!\n");
return -EFAULT;
}
......@@ -136,4 +136,7 @@ int proc4430_open(void **handle_ptr, u16 proc_id);
/* Function to close an instance of this processor. */
int proc4430_close(void *handle);
/* Function to get the proc info */
int proc4430_proc_info(void *handle, struct proc_mgr_proc_info *procinfo);
#endif
......@@ -126,6 +126,12 @@ typedef int (*processor_map_fxn) (void *handle, u32 proc_addr, u32 size,
*/
typedef int (*processor_unmap_fxn) (void *handle, u32 mapped_addr);
/*
*Function pointer type for the function that returns proc info
*/
typedef int (*processor_proc_info) (void *handle,
struct proc_mgr_proc_info *proc_info);
/* =============================
* Function table interface
* =============================
......@@ -154,6 +160,7 @@ struct processor_fxn_table {
/* Function to map slave addresses to master address space */
processor_unmap_fxn unmap;
/* Function to unmap slave addresses to master address space */
processor_proc_info procinfo;
};
/* =============================
......
......@@ -367,3 +367,15 @@ inline int processor_register_notify(void *handle, proc_mgr_callback_fxn fxn,
/* TODO: TBD: To be implemented. */
return retval;
}
/*
* Function that returns the proc instance mem info
*/
int processor_get_proc_info(void *handle, struct proc_mgr_proc_info *procinfo)
{
struct processor_object *proc_handle =
(struct processor_object *)handle;
int retval;
retval = proc_handle->proc_fxn_table.procinfo(proc_handle, procinfo);
return retval;
}
......@@ -73,4 +73,8 @@ int processor_unmap(void *handle, u32 mapped_addr);
*/
int processor_register_notify(void *handle, proc_mgr_callback_fxn fxn,
void *args, enum proc_mgr_state state[]);
/* Function that returns the return value of specific processor info
*/
int processor_get_proc_info(void *handle, struct proc_mgr_proc_info *procinfo);
#endif
......@@ -728,20 +728,23 @@ int proc_mgr_get_proc_info(void *handle, struct proc_mgr_proc_info *proc_info)
{
int retval = 0;
struct proc_mgr_object *proc_mgr_handle =
(struct proc_mgr_object *)handle;
(struct proc_mgr_object *)handle;
struct processor_object *proc_handle;
int i = 0;
BUG_ON(handle == NULL);
BUG_ON(proc_info == NULL);
if (WARN_ON(handle == NULL))
goto error_exit;
if (WARN_ON(proc_info == NULL))
goto error_exit;
proc_handle = proc_mgr_handle->proc_handle;
if (WARN_ON(proc_handle == NULL))
goto error_exit;
WARN_ON(mutex_lock_interruptible(proc_mgr_obj_state.gate_handle));
/* Return boot_mode information. */
proc_info->boot_mode = proc_mgr_handle->attach_params.boot_mode;
/* Return memory information. */
proc_info->num_mem_entries = proc_mgr_handle->num_mem_entries;
memcpy(&(proc_info->mem_entries),
&(proc_mgr_handle->mem_entries),
sizeof(proc_mgr_handle->mem_entries));
processor_get_proc_info(proc_handle, proc_info);
mutex_unlock(proc_mgr_obj_state.gate_handle);
return retval;;
return 0;
error_exit:
return -EFAULT;
}
EXPORT_SYMBOL(proc_mgr_get_proc_info);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment