Commit 6ae49ae7 authored by C A Subramaniam's avatar C A Subramaniam Committed by Hari Kanigeri

SYSLINK: PROCMGR - Patch to move to syslink version 2.0.0.12

Thi patch has changes to migrate to syslink version 2.0.0.12
Also added some additional checks. Added -EINVAL return code
for invalid arguments.
Signed-off-by: default avatarC A Subramaniam <subramaniam.ca@gmail.com>
parent 41638be7
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <syslink/multiproc.h> #include <syslink/multiproc.h>
#include <syslink/ducatienabler.h> #include <syslink/ducatienabler.h>
#include <syslink/platform_mem.h> #include <syslink/platform_mem.h>
#include <syslink/atomic_linux.h>
#define DUCATI_DMM_START_ADDR 0xa0000000 #define DUCATI_DMM_START_ADDR 0xa0000000
#define DUCATI_DMM_POOL_SIZE 0x6000000 #define DUCATI_DMM_POOL_SIZE 0x6000000
...@@ -47,6 +48,10 @@ ...@@ -47,6 +48,10 @@
#define RM_MPU_M3_RST2 0x2 #define RM_MPU_M3_RST2 0x2
#define RM_MPU_M3_RST3 0x4 #define RM_MPU_M3_RST3 0x4
#define OMAP4430PROC_MODULEID (u16) 0xbbec
/* Macro to make a correct module magic number with refCount */
#define OMAP4430PROC_MAKE_MAGICSTAMP(x) ((OMAP4430PROC_MODULEID << 12u) | (x))
/*OMAP4430 Module state object */ /*OMAP4430 Module state object */
struct proc4430_module_object { struct proc4430_module_object {
...@@ -58,12 +63,11 @@ struct proc4430_module_object { ...@@ -58,12 +63,11 @@ struct proc4430_module_object {
/* Default module configuration */ /* Default module configuration */
struct proc4430_params def_inst_params; struct proc4430_params def_inst_params;
/* Default parameters for the OMAP4430 instances */ /* Default parameters for the OMAP4430 instances */
bool is_setup;
/* Indicates whether the OMAP4430 module is setup. */
void *proc_handles[MULTIPROC_MAXPROCESSORS]; void *proc_handles[MULTIPROC_MAXPROCESSORS];
/* Processor handle array. */ /* Processor handle array. */
struct mutex *gate_handle; struct mutex *gate_handle;
/* void * of gate to be used for local thread safety */ /* void * of gate to be used for local thread safety */
atomic_t ref_count;
}; };
/* /*
...@@ -84,7 +88,6 @@ struct proc4430_object { ...@@ -84,7 +88,6 @@ struct proc4430_object {
*/ */
static struct proc4430_module_object proc4430_state = { static struct proc4430_module_object proc4430_state = {
.is_setup = false,
.config_size = sizeof(struct proc4430_config), .config_size = sizeof(struct proc4430_config),
.gate_handle = NULL, .gate_handle = NULL,
.def_inst_params.num_mem_entries = 0u, .def_inst_params.num_mem_entries = 0u,
...@@ -134,6 +137,14 @@ int proc4430_setup(struct proc4430_config *cfg) ...@@ -134,6 +137,14 @@ int proc4430_setup(struct proc4430_config *cfg)
{ {
int retval = 0; int retval = 0;
struct proc4430_config tmp_cfg; struct proc4430_config tmp_cfg;
atomic_cmpmask_and_set(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(0));
if (atomic_inc_return(&proc4430_state.ref_count) !=
OMAP4430PROC_MAKE_MAGICSTAMP(1)) {
return 1;
}
if (cfg == NULL) { if (cfg == NULL) {
proc4430_get_config(&tmp_cfg); proc4430_get_config(&tmp_cfg);
...@@ -141,24 +152,35 @@ int proc4430_setup(struct proc4430_config *cfg) ...@@ -141,24 +152,35 @@ int proc4430_setup(struct proc4430_config *cfg)
} }
/* Put SYS-M3 and APP M3 in reset */ /* Put SYS-M3 and APP M3 in reset */
__raw_writel(0x03, CORE_PRM_BASE + RM_MPU_M3_RSTCTRL_OFFSET); __raw_writel(0x03, CORE_PRM_BASE + RM_MPU_M3_RSTCTRL_OFFSET);
if (proc4430_state.is_setup == false) { dmm_create();
dmm_create(); dmm_create_tables(DUCATI_DMM_START_ADDR, DUCATI_DMM_POOL_SIZE);
dmm_create_tables(DUCATI_DMM_START_ADDR, DUCATI_DMM_POOL_SIZE);
/* Create a default gate handle for local module protection. */
proc4430_state.gate_handle =
kmalloc(sizeof(struct mutex), GFP_KERNEL);
if (proc4430_state.gate_handle == NULL) {
retval = -ENOMEM;
goto error;
}
/* Create a default gate handle for local module protection. */ mutex_init(proc4430_state.gate_handle);
proc4430_state.gate_handle = ducati_setup();
kmalloc(sizeof(struct mutex), GFP_KERNEL);
mutex_init(proc4430_state.gate_handle); /* Initialize the name to handles mapping array. */
ducati_setup(); memset(&proc4430_state.proc_handles, 0,
(sizeof(void *) * MULTIPROC_MAXPROCESSORS));
/* Initialize the name to handles mapping array. */
memset(&proc4430_state.proc_handles, 0,
(sizeof(void *) * MULTIPROC_MAXPROCESSORS));
proc4430_state.is_setup = true;
}
/* Copy the user provided values into the state object. */ /* Copy the user provided values into the state object. */
memcpy(&proc4430_state.cfg, cfg, memcpy(&proc4430_state.cfg, cfg,
sizeof(struct proc4430_config)); sizeof(struct proc4430_config));
return 0;
error:
atomic_dec_return(&proc4430_state.ref_count);
dmm_delete_tables();
dmm_destroy();
return retval; return retval;
} }
EXPORT_SYMBOL(proc4430_setup); EXPORT_SYMBOL(proc4430_setup);
...@@ -175,9 +197,24 @@ int proc4430_destroy(void) ...@@ -175,9 +197,24 @@ int proc4430_destroy(void)
int retval = 0; int retval = 0;
u16 i; u16 i;
/* Check if any OMAP4430 instances have not been deleted so far. If not, if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
* delete them. OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
retval = -ENODEV;
goto exit;
}
if (!(atomic_dec_return(&proc4430_state.ref_count)
== OMAP4430PROC_MAKE_MAGICSTAMP(0))) {
retval = 1;
goto exit;
}
/* Check if any OMAP4430 instances have not been
* deleted so far. If not,delete them.
*/ */
for (i = 0; i < MULTIPROC_MAXPROCESSORS; i++) { for (i = 0; i < MULTIPROC_MAXPROCESSORS; i++) {
if (proc4430_state.proc_handles[i] == NULL) if (proc4430_state.proc_handles[i] == NULL)
continue; continue;
...@@ -189,9 +226,9 @@ int proc4430_destroy(void) ...@@ -189,9 +226,9 @@ int proc4430_destroy(void)
mutex_destroy(proc4430_state.gate_handle); mutex_destroy(proc4430_state.gate_handle);
kfree(proc4430_state.gate_handle); kfree(proc4430_state.gate_handle);
} }
ducati_destroy(); ducati_destroy();
proc4430_state.is_setup = false;
exit:
return retval; return retval;
} }
EXPORT_SYMBOL(proc4430_destroy); EXPORT_SYMBOL(proc4430_destroy);
...@@ -204,7 +241,22 @@ void proc4430_params_init(void *handle, struct proc4430_params *params) ...@@ -204,7 +241,22 @@ void proc4430_params_init(void *handle, struct proc4430_params *params)
{ {
struct proc4430_object *proc_object = (struct proc4430_object *)handle; struct proc4430_object *proc_object = (struct proc4430_object *)handle;
BUG_ON(params == NULL); if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_params_init failed "
"Module not initialized");
return;
}
if (WARN_ON(params == NULL)) {
printk(KERN_ERR "proc4430_params_init failed "
"Argument of type proc4430_params * "
"is NULL");
return;
}
if (handle == NULL) if (handle == NULL)
memcpy(params, &(proc4430_state.def_inst_params), memcpy(params, &(proc4430_state.def_inst_params),
sizeof(struct proc4430_params)); sizeof(struct proc4430_params));
...@@ -226,6 +278,15 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params) ...@@ -226,6 +278,15 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
BUG_ON(!IS_VALID_PROCID(proc_id)); BUG_ON(!IS_VALID_PROCID(proc_id));
BUG_ON(params == NULL); BUG_ON(params == NULL);
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_create failed "
"Module not initialized");
goto error;
}
/* Enter critical section protection. */ /* Enter critical section protection. */
WARN_ON(mutex_lock_interruptible(proc4430_state.gate_handle)); WARN_ON(mutex_lock_interruptible(proc4430_state.gate_handle));
if (proc4430_state.proc_handles[proc_id] != NULL) { if (proc4430_state.proc_handles[proc_id] != NULL) {
...@@ -251,8 +312,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params) ...@@ -251,8 +312,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
handle->proc_fxn_table.procinfo = &proc4430_proc_info; handle->proc_fxn_table.procinfo = &proc4430_proc_info;
handle->proc_fxn_table.virt_to_phys = &proc4430_virt_to_phys; handle->proc_fxn_table.virt_to_phys = &proc4430_virt_to_phys;
handle->state = PROC_MGR_STATE_UNKNOWN; handle->state = PROC_MGR_STATE_UNKNOWN;
handle->object = vmalloc handle->object = vmalloc(sizeof(struct proc4430_object));
(sizeof(struct proc4430_object));
handle->proc_id = proc_id; handle->proc_id = proc_id;
object = (struct proc4430_object *)handle->object; object = (struct proc4430_object *)handle->object;
if (params != NULL) { if (params != NULL) {
...@@ -278,6 +338,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params) ...@@ -278,6 +338,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
func_end: func_end:
mutex_unlock(proc4430_state.gate_handle); mutex_unlock(proc4430_state.gate_handle);
error:
return (void *)handle; return (void *)handle;
} }
EXPORT_SYMBOL(proc4430_create); EXPORT_SYMBOL(proc4430_create);
...@@ -298,6 +359,15 @@ int proc4430_delete(void **handle_ptr) ...@@ -298,6 +359,15 @@ int proc4430_delete(void **handle_ptr)
BUG_ON(handle_ptr == NULL); BUG_ON(handle_ptr == NULL);
BUG_ON(*handle_ptr == NULL); BUG_ON(*handle_ptr == NULL);
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_delete failed "
"Module not initialized");
return -ENODEV;
}
handle = (struct processor_object *)(*handle_ptr); handle = (struct processor_object *)(*handle_ptr);
BUG_ON(!IS_VALID_PROCID(handle->proc_id)); BUG_ON(!IS_VALID_PROCID(handle->proc_id));
/* Enter critical section protection. */ /* Enter critical section protection. */
...@@ -335,6 +405,15 @@ int proc4430_open(void **handle_ptr, u16 proc_id) ...@@ -335,6 +405,15 @@ int proc4430_open(void **handle_ptr, u16 proc_id)
BUG_ON(handle_ptr == NULL); BUG_ON(handle_ptr == NULL);
BUG_ON(!IS_VALID_PROCID(proc_id)); BUG_ON(!IS_VALID_PROCID(proc_id));
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_open failed "
"Module not initialized");
return -ENODEV;
}
/* Initialize return parameter handle. */ /* Initialize return parameter handle. */
*handle_ptr = NULL; *handle_ptr = NULL;
...@@ -358,6 +437,16 @@ int proc4430_close(void *handle) ...@@ -358,6 +437,16 @@ int proc4430_close(void *handle)
int retval = 0; int retval = 0;
BUG_ON(handle == NULL); BUG_ON(handle == NULL);
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_close failed "
"Module not initialized");
return -ENODEV;
}
/* nothing to be done for now */ /* nothing to be done for now */
return retval; return retval;
} }
...@@ -374,13 +463,36 @@ EXPORT_SYMBOL(proc4430_close); ...@@ -374,13 +463,36 @@ EXPORT_SYMBOL(proc4430_close);
int proc4430_attach(void *handle, struct processor_attach_params *params) int proc4430_attach(void *handle, struct processor_attach_params *params)
{ {
int retval = 0; int retval = 0;
struct processor_object *proc_handle =
(struct processor_object *)handle; struct processor_object *proc_handle = NULL;
struct proc4430_object *object = NULL; struct proc4430_object *object = NULL;
u32 map_count = 0; u32 map_count = 0;
u32 i; u32 i;
memory_map_info map_info; memory_map_info map_info;
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_attach failed "
"Module not initialized");
return -ENODEV;
}
if (WARN_ON(handle == NULL)) {
printk(KERN_ERR "proc4430_attach failed "
"Driver handle is NULL");
return -EINVAL;
}
if (WARN_ON(params == NULL)) {
printk(KERN_ERR "proc4430_attach failed "
"Argument processor_attach_params * is NULL");
return -EINVAL;
}
proc_handle = (struct processor_object *)handle;
object = (struct proc4430_object *)proc_handle->object; object = (struct proc4430_object *)proc_handle->object;
/* Return memory information in params. */ /* Return memory information in params. */
for (i = 0; (i < object->params.num_mem_entries); i++) { for (i = 0; (i < object->params.num_mem_entries); i++) {
...@@ -390,7 +502,6 @@ int proc4430_attach(void *handle, struct processor_attach_params *params) ...@@ -390,7 +502,6 @@ int proc4430_attach(void *handle, struct processor_attach_params *params)
*/ */
if ((object->params.mem_entries[i].master_virt_addr == (u32)-1) if ((object->params.mem_entries[i].master_virt_addr == (u32)-1)
&& (object->params.mem_entries[i].shared == true)) { && (object->params.mem_entries[i].shared == true)) {
map_count++;
map_info.src = object->params.mem_entries[i].phys_addr; map_info.src = object->params.mem_entries[i].phys_addr;
map_info.size = object->params.mem_entries[i].size; map_info.size = object->params.mem_entries[i].size;
map_info.is_cached = false; map_info.is_cached = false;
...@@ -399,6 +510,7 @@ int proc4430_attach(void *handle, struct processor_attach_params *params) ...@@ -399,6 +510,7 @@ int proc4430_attach(void *handle, struct processor_attach_params *params)
printk(KERN_ERR "proc4430_attach failed\n"); printk(KERN_ERR "proc4430_attach failed\n");
return -EFAULT; return -EFAULT;
} }
map_count++;
object->params.mem_entries[i].master_virt_addr = object->params.mem_entries[i].master_virt_addr =
map_info.dst; map_info.dst;
params->mem_entries[i].addr params->mem_entries[i].addr
...@@ -428,12 +540,28 @@ int proc4430_attach(void *handle, struct processor_attach_params *params) ...@@ -428,12 +540,28 @@ int proc4430_attach(void *handle, struct processor_attach_params *params)
*/ */
int proc4430_detach(void *handle) int proc4430_detach(void *handle)
{ {
struct processor_object *proc_handle = struct processor_object *proc_handle = NULL;
(struct processor_object *)handle;
struct proc4430_object *object = NULL; struct proc4430_object *object = NULL;
u32 i; u32 i;
memory_unmap_info unmap_info; memory_unmap_info unmap_info;
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_detach failed "
"Module not initialized");
return -ENODEV;
}
if (WARN_ON(handle == NULL)) {
printk(KERN_ERR "proc4430_attach failed "
"Argument Driverhandle is NULL");
return -EINVAL;
}
proc_handle = (struct processor_object *)handle;
object = (struct proc4430_object *)proc_handle->object; object = (struct proc4430_object *)proc_handle->object;
for (i = 0; (i < object->params.num_mem_entries); i++) { for (i = 0; (i < object->params.num_mem_entries); i++) {
if ((object->params.mem_entries[i].master_virt_addr == (u32)-1) if ((object->params.mem_entries[i].master_virt_addr == (u32)-1)
...@@ -462,6 +590,23 @@ int proc4430_detach(void *handle) ...@@ -462,6 +590,23 @@ int proc4430_detach(void *handle)
int proc4430_start(void *handle, u32 entry_pt, int proc4430_start(void *handle, u32 entry_pt,
struct processor_start_params *start_params) struct processor_start_params *start_params)
{ {
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_start failed "
"Module not initialized");
return -ENODEV;
}
/*FIXME: Remove handle and entry_pt if not used */
if (WARN_ON(start_params == NULL)) {
printk(KERN_ERR "proc4430_attach failed "
"Argument processor_start_params * is NULL");
return -EINVAL;
}
switch (start_params->params->proc_id) { switch (start_params->params->proc_id) {
case SYS_M3: case SYS_M3:
/* De-assert RST2 */ /* De-assert RST2 */
...@@ -491,6 +636,15 @@ int proc4430_start(void *handle, u32 entry_pt, ...@@ -491,6 +636,15 @@ int proc4430_start(void *handle, u32 entry_pt,
int int
proc4430_stop(void *handle) proc4430_stop(void *handle)
{ {
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_stop failed "
"Module not initialized");
return -ENODEV;
}
/* Stoppping both SYS M3 and APP M3 */ /* Stoppping both SYS M3 and APP M3 */
/* FIX ME: this needs to be changed to handle reset /* FIX ME: this needs to be changed to handle reset
* of only APPM3 case too * of only APPM3 case too
...@@ -510,6 +664,15 @@ int proc4430_read(void *handle, u32 proc_addr, u32 *num_bytes, ...@@ -510,6 +664,15 @@ int proc4430_read(void *handle, u32 proc_addr, u32 *num_bytes,
void *buffer) void *buffer)
{ {
int retval = 0; int retval = 0;
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_read failed "
"Module not initialized");
return -ENODEV;
}
/* TODO */ /* TODO */
return retval; return retval;
} }
...@@ -527,6 +690,15 @@ int proc4430_write(void *handle, u32 proc_addr, u32 *num_bytes, ...@@ -527,6 +690,15 @@ int proc4430_write(void *handle, u32 proc_addr, u32 *num_bytes,
{ {
int retval = 0; int retval = 0;
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_write failed "
"Module not initialized");
return -ENODEV;
}
/* TODO */ /* TODO */
return retval; return retval;
} }
...@@ -542,6 +714,16 @@ int proc4430_control(void *handle, int cmd, void *arg) ...@@ -542,6 +714,16 @@ int proc4430_control(void *handle, int cmd, void *arg)
{ {
int retval = 0; int retval = 0;
/*FIXME: Remove handle,etc if not used */
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_control failed "
"Module not initialized");
return -ENODEV;
}
return retval; return retval;
} }
...@@ -557,8 +739,7 @@ int proc4430_translate_addr(void *handle, ...@@ -557,8 +739,7 @@ int proc4430_translate_addr(void *handle,
void *src_addr, enum proc_mgr_addr_type src_addr_type) void *src_addr, enum proc_mgr_addr_type src_addr_type)
{ {
int retval = 0; int retval = 0;
struct processor_object *proc_handle = struct processor_object *proc_handle = NULL;
(struct processor_object *)handle;
struct proc4430_object *object = NULL; struct proc4430_object *object = NULL;
struct proc4430_mem_entry *entry = NULL; struct proc4430_mem_entry *entry = NULL;
bool found = false; bool found = false;
...@@ -566,17 +747,38 @@ int proc4430_translate_addr(void *handle, ...@@ -566,17 +747,38 @@ int proc4430_translate_addr(void *handle,
u32 to_addr_base = (u32)NULL; u32 to_addr_base = (u32)NULL;
u32 i; u32 i;
if (WARN_ON(handle == NULL)) if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_translate_addr failed "
"Module not initialized");
retval = -ENODEV;
goto error_exit; goto error_exit;
if (WARN_ON(dst_addr == NULL)) }
if (WARN_ON(handle == NULL)) {
retval = -EINVAL;
goto error_exit; goto error_exit;
if (WARN_ON(dst_addr_type > PROC_MGR_ADDRTYPE_ENDVALUE)) }
if (WARN_ON(dst_addr == NULL)) {
retval = -EINVAL;
goto error_exit; goto error_exit;
if (WARN_ON(src_addr == NULL)) }
if (WARN_ON(dst_addr_type > PROC_MGR_ADDRTYPE_ENDVALUE)) {
retval = -EINVAL;
goto error_exit; goto error_exit;
if (WARN_ON(src_addr_type > PROC_MGR_ADDRTYPE_ENDVALUE)) }
if (WARN_ON(src_addr == NULL)) {
retval = -EINVAL;
goto error_exit; goto error_exit;
}
if (WARN_ON(src_addr_type > PROC_MGR_ADDRTYPE_ENDVALUE)) {
retval = -EINVAL;
goto error_exit;
}
proc_handle = (struct processor_object *)handle;
object = (struct proc4430_object *)proc_handle->object; object = (struct proc4430_object *)proc_handle->object;
*dst_addr = NULL; *dst_addr = NULL;
for (i = 0 ; i < object->params.num_mem_entries ; i++) { for (i = 0 ; i < object->params.num_mem_entries ; i++) {
...@@ -604,6 +806,7 @@ int proc4430_translate_addr(void *handle, ...@@ -604,6 +806,7 @@ int proc4430_translate_addr(void *handle,
goto error_exit; goto error_exit;
} }
return 0; return 0;
error_exit: error_exit:
return retval; return retval;
} }
...@@ -624,6 +827,18 @@ int proc4430_map(void *handle, u32 proc_addr, ...@@ -624,6 +827,18 @@ int proc4430_map(void *handle, u32 proc_addr,
u32 va_align; u32 va_align;
u32 size_align; u32 size_align;
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_map failed "
"Module not initialized");
retval = -ENODEV;
goto error_exit;
}
/*FIXME: Remove handle,etc if not used */
/* FIX ME: Temporary work around until the dynamic memory mapping /* FIX ME: Temporary work around until the dynamic memory mapping
* for Tiler address space is available * for Tiler address space is available
*/ */
...@@ -645,6 +860,8 @@ int proc4430_map(void *handle, u32 proc_addr, ...@@ -645,6 +860,8 @@ int proc4430_map(void *handle, u32 proc_addr,
/* Mapped address = MSB of DA | LSB of VA */ /* Mapped address = MSB of DA | LSB of VA */
*mapped_addr = (da_align | (proc_addr & (PAGE_SIZE - 1))); *mapped_addr = (da_align | (proc_addr & (PAGE_SIZE - 1)));
error_exit:
return retval; return retval;
} }
...@@ -660,6 +877,18 @@ int proc4430_unmap(void *handle, u32 mapped_addr) ...@@ -660,6 +877,18 @@ int proc4430_unmap(void *handle, u32 mapped_addr)
int ret_val = 0; int ret_val = 0;
int size_align; int size_align;
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_map failed "
"Module not initialized");
ret_val = -1;
goto error_exit;
}
/*FIXME: Remove handle,etc if not used */
da_align = PG_ALIGN_LOW((u32)mapped_addr, PAGE_SIZE); da_align = PG_ALIGN_LOW((u32)mapped_addr, PAGE_SIZE);
ret_val = dmm_unreserve_memory(da_align, &size_align); ret_val = dmm_unreserve_memory(da_align, &size_align);
if (WARN_ON(ret_val < 0)) if (WARN_ON(ret_val < 0))
...@@ -668,6 +897,7 @@ int proc4430_unmap(void *handle, u32 mapped_addr) ...@@ -668,6 +897,7 @@ int proc4430_unmap(void *handle, u32 mapped_addr)
if (WARN_ON(ret_val < 0)) if (WARN_ON(ret_val < 0))
goto error_exit; goto error_exit;
return 0; return 0;
error_exit: error_exit:
printk(KERN_WARNING "proc4430_unmap failed !!!!\n"); printk(KERN_WARNING "proc4430_unmap failed !!!!\n");
return ret_val; return ret_val;
...@@ -687,6 +917,16 @@ int proc4430_virt_to_phys(void *handle, u32 da, u32 *mapped_entries, ...@@ -687,6 +917,16 @@ int proc4430_virt_to_phys(void *handle, u32 da, u32 *mapped_entries,
int i; int i;
int ret_val = 0; int ret_val = 0;
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_virt_to_phys failed "
"Module not initialized");
ret_val = -EFAULT;
goto error_exit;
}
if (handle == NULL || mapped_entries == NULL || num_of_entries == 0) { if (handle == NULL || mapped_entries == NULL || num_of_entries == 0) {
ret_val = -EFAULT; ret_val = -EFAULT;
goto error_exit; goto error_exit;
...@@ -697,6 +937,7 @@ int proc4430_virt_to_phys(void *handle, u32 da, u32 *mapped_entries, ...@@ -697,6 +937,7 @@ int proc4430_virt_to_phys(void *handle, u32 da, u32 *mapped_entries,
da_align += PAGE_SIZE; da_align += PAGE_SIZE;
} }
return 0; return 0;
error_exit: error_exit:
printk(KERN_WARNING "proc4430_virtToPhys failed !!!!\n"); printk(KERN_WARNING "proc4430_virtToPhys failed !!!!\n");
return ret_val; return ret_val;
...@@ -709,17 +950,27 @@ error_exit: ...@@ -709,17 +950,27 @@ error_exit:
*/ */
int proc4430_proc_info(void *handle, struct proc_mgr_proc_info *procinfo) int proc4430_proc_info(void *handle, struct proc_mgr_proc_info *procinfo)
{ {
struct processor_object *proc_handle = struct processor_object *proc_handle = NULL;
(struct processor_object *)handle;
struct proc4430_object *object = NULL; struct proc4430_object *object = NULL;
struct proc4430_mem_entry *entry = NULL; struct proc4430_mem_entry *entry = NULL;
int i; int i;
if (atomic_cmpmask_and_lt(&proc4430_state.ref_count,
OMAP4430PROC_MAKE_MAGICSTAMP(0),
OMAP4430PROC_MAKE_MAGICSTAMP(1))
== true) {
printk(KERN_ERR "proc4430_proc_info failed "
"Module not initialized");
goto error_exit;
}
if (WARN_ON(handle == NULL)) if (WARN_ON(handle == NULL))
goto error_exit; goto error_exit;
if (WARN_ON(procinfo == NULL)) if (WARN_ON(procinfo == NULL))
goto error_exit; goto error_exit;
proc_handle = (struct processor_object *)handle;
object = (struct proc4430_object *)proc_handle->object; object = (struct proc4430_object *)proc_handle->object;
for (i = 0 ; i < object->params.num_mem_entries ; i++) { for (i = 0 ; i < object->params.num_mem_entries ; i++) {
...@@ -733,6 +984,7 @@ int proc4430_proc_info(void *handle, struct proc_mgr_proc_info *procinfo) ...@@ -733,6 +984,7 @@ int proc4430_proc_info(void *handle, struct proc_mgr_proc_info *procinfo)
procinfo->num_mem_entries = object->params.num_mem_entries; procinfo->num_mem_entries = object->params.num_mem_entries;
procinfo->boot_mode = proc_handle->boot_mode; procinfo->boot_mode = proc_handle->boot_mode;
return 0; return 0;
error_exit: error_exit:
printk(KERN_WARNING "proc4430_proc_info failed !!!!\n"); printk(KERN_WARNING "proc4430_proc_info failed !!!!\n");
return -EFAULT; return -EFAULT;
......
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