Commit 31ba0ef8 authored by Hari Kanigeri's avatar Hari Kanigeri

SYSLINK-Proc-fixes in proc4430 driver

This patch handles the following.
   - Calling the proc4430 setup multiple twice.
   - Fixes the bugs in proc4430 create function that were
     causing segmentation fault.
   - Handled wrong check for return value of kmalloc.
Signed-off-by: default avatarHari Kanigeri <h-kanigeri2@ti.com>
Signed-off-by: default avatarArun Radhakrishnan <x0051460@ti.com>
parent 8580a48a
......@@ -19,6 +19,7 @@
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/vmalloc.h>
#include <linux/uaccess.h>
/* Module level headers */
#include "../procdefs.h"
......@@ -125,6 +126,7 @@ int proc4430_setup(struct proc4430_config *cfg)
proc4430_get_config(&tmp_cfg);
cfg = &tmp_cfg;
}
if (proc4430_state.is_setup == false) {
dmm_create();
dmm_create_tables(DUCATI_DMM_START_ADDR, DUCATI_DMM_POOL_SIZE);
if (cfg->gate_handle != NULL) {
......@@ -132,17 +134,19 @@ int proc4430_setup(struct proc4430_config *cfg)
} else {
/* User has not provided any gate handle, so create a
* default handle. */
proc4430_state.gate_handle = kmalloc(sizeof(struct mutex),
GFP_KERNEL);
proc4430_state.gate_handle =
kmalloc(sizeof(struct mutex), GFP_KERNEL);
mutex_init(proc4430_state.gate_handle);
ducati_setup();
}
/* Copy the user provided values into the state object. */
memcpy(&proc4430_state.cfg, cfg,
sizeof(struct proc4430_config));
/* 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. */
memcpy(&proc4430_state.cfg, cfg,
sizeof(struct proc4430_config));
return retval;
}
EXPORT_SYMBOL(proc4430_setup);
......@@ -218,11 +222,13 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
printk(KERN_WARNING "Processor already exists for specified"
"%d proc_id\n", proc_id);
WARN_ON(1);
handle = proc4430_state.proc_handles[proc_id];
goto func_end;
} else {
handle = (struct processor_object *)
vmalloc(sizeof(struct processor_object));
if (handle == NULL) {
if (WARN_ON(handle == NULL))
goto func_end;
handle->proc_fxn_table.attach = &proc4430_attach;
handle->proc_fxn_table.detach = &proc4430_detach;
handle->proc_fxn_table.start = &proc4430_start;
......@@ -237,25 +243,25 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
handle->state = PROC_MGR_STATE_UNKNOWN;
handle->object = vmalloc
(sizeof(struct proc4430_object));
handle->proc_id = proc_id;
object = (struct proc4430_object *)handle->object;
/* Copy params into instance object. */
memcpy(&(object->params), (void *)params,
sizeof(struct proc4430_object));
if (params->mem_entries != NULL &&
params->num_mem_entries > 0) {
/* Allocate memory for, and copy memEntries table*/
object->params.mem_entries = vmalloc(
sizeof(struct proc4430_mem_entry) *
params->num_mem_entries);
memcpy(object->params.mem_entries,
copy_from_user(object->params.mem_entries,
params->mem_entries,
(sizeof(struct proc4430_mem_entry)
* params->num_mem_entries));
}
/* Set the handle in the state object. */
proc4430_state.proc_handles[proc_id] = handle;
}
}
func_end:
mutex_unlock(proc4430_state.gate_handle);
return handle;
......
......@@ -59,7 +59,7 @@ struct proc4430_mem_entry {
Configuration parameters specific to this processor.
*/
struct proc4430_params {
u32 num_mem_entries;
int num_mem_entries;
/* Number of memory regions to be configured. */
struct proc4430_mem_entry *mem_entries;
/* Array of information structures for memory regions
......
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