Commit 44620a65 authored by Hari Kanigeri's avatar Hari Kanigeri

plug dmm with proc module

this patch plugs the dmm module with Proc4430 driver
and procmgr module. This provides both Map and Unmap
functionality.
Signed-off-by: default avatarHari Kanigeri <h-kanigeri2@ti.com>
parent 2a1b3fca
......@@ -116,6 +116,11 @@
#define DSP_MAPVMALLOCADDR 0x00000080
#define PG_MASK(pg_size) (~((pg_size)-1))
#define PG_ALIGN_LOW(addr, pg_size) ((addr) & PG_MASK(pg_size))
#define PG_ALIGN_HIGH(addr, pg_size) (((addr)+(pg_size)-1) & PG_MASK(pg_size))
struct mmu_entry {
u32 ul_phy_addr ;
u32 ul_virt_addr ;
......@@ -153,5 +158,6 @@ void dbg_print_ptes(bool ashow_inv_entries, bool ashow_repeat_entries);
int ducati_setup(void);
void ducati_destroy(void);
u32 get_ducati_virt_mem();
int ducati_mem_map(u32 va, u32 da, u32 num_bytes, u32 map_attr);
int ducati_mem_unmap(u32 da, u32 num_bytes);
#endif /* _DDUCATIMMU_ENABLER_H_*/
......@@ -112,7 +112,7 @@ extern hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
u32 page_size,
struct hw_mmu_map_attrs_t *map_attrs);
extern hw_status hw_mmu_pt_clear(const u32 pg_tbl_va,
extern hw_status hw_mmu_pte_clear(const u32 pg_tbl_va,
u32 pg_size,
u32 virtual_addr);
......
......@@ -225,7 +225,7 @@ func_exit:
* Purpose:
*Free a chunk of reserved DSP/IVA address space.
*/
int dmm_unreserve_memory(u32 rsv_addr)
int dmm_unreserve_memory(u32 rsv_addr, u32 *psize)
{
struct map_page *chunk;
int status = 0;
......@@ -239,6 +239,7 @@ int dmm_unreserve_memory(u32 rsv_addr)
WARN_ON(status < 0);
if (status == 0) {
chunk->b_reserved = false;
*psize = chunk->region_size * PAGE_SIZE;
/* NOTE: We do NOT coalesce free regions here.
* Free regions are coalesced in get_region(), as it traverses
*the whole mapping table
......
......@@ -32,7 +32,7 @@
int dmm_reserve_memory(u32 size, u32 *p_rsv_addr);
int dmm_unreserve_memory(u32 rsv_addr);
int dmm_unreserve_memory(u32 rsv_addr, u32 *psize);
void dmm_destroy(void);
......
......@@ -26,7 +26,7 @@
#include "../procmgr.h"
#include "../procmgr_drvdefs.h"
#include "proc4430.h"
#include "dmm4430.h"
#include <syslink/multiproc.h>
#include <syslink/ducatienabler.h>
......@@ -229,6 +229,7 @@ void *proc4430_create(u16 proc_id, const struct proc4430_params *params)
handle->proc_fxn_table.translateAddr =
&proc4430_translate_addr;
handle->proc_fxn_table.map = &proc4430_map;
handle->proc_fxn_table.unmap = &proc4430_unmap;
handle->state = PROC_MGR_STATE_UNKNOWN;
handle->object = vmalloc
(sizeof(struct proc4430_object));
......@@ -475,9 +476,48 @@ int proc4430_translate_addr(void *handle,
* function also maps the specified address to slave MMU space.
*/
int proc4430_map(void *handle, u32 proc_addr,
u32 size, u32 *mapped_addr, u32 *mapped_size)
u32 size, u32 *mapped_addr, u32 *mapped_size, u32 map_attribs)
{
int retval = 0;
/* TODO */
u32 da_align;
u32 da;
u32 va_align;
u32 size_align;
dmm_reserve_memory(size, &da);
/* Calculate the page-aligned PA, VA and size */
da_align = PG_ALIGN_LOW((u32)da, PAGE_SIZE);
va_align = PG_ALIGN_LOW(proc_addr, PAGE_SIZE);
size_align = PG_ALIGN_HIGH(size + (u32)proc_addr - va_align, PAGE_SIZE);
retval = ducati_mem_map(va_align, da_align, size_align, map_attribs);
/* Mapped address = MSB of DA | LSB of VA */
*mapped_addr = (da_align | (proc_addr & (PAGE_SIZE - 1)));
return retval;
}
/*=================================================
* Function to unmap slave address to host address space
*
* UnMap the provided slave address to master address space. This
* function also unmaps the specified address to slave MMU space.
*/
int proc4430_unmap(void *handle, u32 mapped_addr)
{
int da_align;
int ret_val = 0;
int size_align;
da_align = PG_ALIGN_LOW((u32)mapped_addr, PAGE_SIZE);
ret_val = dmm_unreserve_memory(da_align, &size_align);
if (WARN_ON(ret_val < 0))
goto error_exit;
ret_val = ducati_mem_unmap(da_align, size_align);
if (WARN_ON(ret_val < 0))
goto error_exit;
return 0;
error_exit:
printk(KERN_WARNING "proc4430_unmap failed !!!!\n");
return ret_val;
}
......@@ -101,7 +101,10 @@ int proc4430_translate_addr(void *handle, void **dst_addr,
/* Function to map slave address to host address space */
int proc4430_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
u32 *mapped_size);
u32 *mapped_size, u32 map_attribs);
/* Function to unmap the slave address to host address space */
int proc4430_unmap(void *handle, u32 mapped_addr);
/* =================================================
* APIs
......
This diff is collapsed.
......@@ -315,7 +315,7 @@ inline int processor_translate_addr(void *handle, void **dst_addr,
* and returns the mapped address and size.
*/
inline int processor_map(void *handle, u32 proc_addr, u32 size,
u32 *mapped_addr, u32 *mapped_size)
u32 *mapped_addr, u32 *mapped_size, u32 map_attribs)
{
int retval = 0;
struct processor_object *proc_handle =
......@@ -329,10 +329,24 @@ inline int processor_map(void *handle, u32 proc_addr, u32 size,
BUG_ON(proc_handle->proc_fxn_table.map == NULL);
retval = proc_handle->proc_fxn_table.map(handle, proc_addr,
size, mapped_addr, mapped_size);
size, mapped_addr, mapped_size, map_attribs);
return retval;
}
/*
* Function to unmap address to slave address space.
*
* This function unmap the provided slave address
*/
inline int processor_unmap(void *handle, u32 mapped_addr)
{
int retval = 0;
struct processor_object *proc_handle =
(struct processor_object *)handle;
retval = proc_handle->proc_fxn_table.unmap(handle, mapped_addr);
return retval;
}
/*
* Function that registers for notification when the slave
......
/*
* processor.h
*
* Syslink driver support functions for TI OMAP processors.
*
* Copyright (C) 2009-2010 Texas Instruments, Inc.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef SYSLINK_PROCESSOR_H_
#define SYSLINK_PROCESSOR_H_
#include <linux/types.h>
/* Module level headers */
#include "procdefs.h"
/* ===================================
* APIs
* ===================================
*/
/* Function to attach to the Processor. */
int processor_attach(void *handle, struct processor_attach_params *params);
/* Function to detach from the Processor. */
int processor_detach(void *handle);
/* Function to start the processor. */
int processor_start(void *handle, u32 entry_pt,
struct processor_start_params *params);
/* Function to stop the processor. */
int processor_stop(void *handle);
/* Function to read from the slave processor's memory. */
int processor_read(void *handle, u32 proc_addr, u32 *num_bytes, void *buffer);
/* Function to read write into the slave processor's memory. */
int processor_write(void *handle, u32 proc_addr, u32 *num_bytes, void *buffer);
/* Function to get the current state of the slave Processor as maintained on
* the master Processor state machine.
*/
enum proc_mgr_state processor_get_state(void *handle);
/* Function to set the current state of the slave Processor to specified value.
*/
void processor_set_state(void *handle, enum proc_mgr_state state);
/* Function to perform device-dependent operations. */
int processor_control(void *handle, int cmd, void *arg);
/* Function to translate between two types of address spaces. */
int processor_translate_addr(void *handle, void **dst_addr,
enum proc_mgr_addr_type dst_addr_type, void *src_addr,
enum proc_mgr_addr_type src_addr_type);
/* Function to map address to slave address space */
int processor_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
u32 *mapped_size);
/* Function that registers for notification when the slave processor
* transitions to any of the states specified.
*/
int processor_register_notify(void *handle, proc_mgr_callback_fxn fxn,
void *args, enum proc_mgr_state state[]);
#endif
/*
* processor.h
*
* Syslink driver support functions for TI OMAP processors.
*
* Copyright (C) 2009-2010 Texas Instruments, Inc.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef SYSLINK_PROCESSOR_H_
#define SYSLINK_PROCESSOR_H_
#include <linux/types.h>
/* Module level headers */
#include "procdefs.h"
/* ===================================
* APIs
* ===================================
*/
/* Function to attach to the Processor. */
int processor_attach(void *handle, struct processor_attach_params *params);
/* Function to detach from the Processor. */
int processor_detach(void *handle);
/* Function to start the processor. */
int processor_start(void *handle, u32 entry_pt,
struct processor_start_params *params);
/* Function to stop the processor. */
int processor_stop(void *handle);
/* Function to read from the slave processor's memory. */
int processor_read(void *handle, u32 proc_addr, u32 *num_bytes, void *buffer);
/* Function to read write into the slave processor's memory. */
int processor_write(void *handle, u32 proc_addr, u32 *num_bytes, void *buffer);
/* Function to get the current state of the slave Processor as maintained on
* the master Processor state machine.
*/
enum proc_mgr_state processor_get_state(void *handle);
/* Function to set the current state of the slave Processor to specified value.
*/
void processor_set_state(void *handle, enum proc_mgr_state state);
/* Function to perform device-dependent operations. */
int processor_control(void *handle, int cmd, void *arg);
/* Function to translate between two types of address spaces. */
int processor_translate_addr(void *handle, void **dst_addr,
enum proc_mgr_addr_type dst_addr_type, void *src_addr,
enum proc_mgr_addr_type src_addr_type);
/* Function to map address to slave address space */
int processor_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
u32 *mapped_size, u32 map_attribs);
/* Function to unmap address to slave address space */
int processor_unmap(void *handle, u32 mapped_addr);
/* Function that registers for notification when the slave processor
* transitions to any of the states specified.
*/
int processor_register_notify(void *handle, proc_mgr_callback_fxn fxn,
void *args, enum proc_mgr_state state[]);
#endif
......@@ -650,7 +650,7 @@ EXPORT_SYMBOL(proc_mgr_translate_addr);
*
*/
int proc_mgr_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
u32 *mapped_size, enum proc_mgr_map_type type)
u32 *mapped_size, u32 map_attribs)
{
int retval = 0;
struct proc_mgr_object *proc_mgr_handle =
......@@ -664,13 +664,35 @@ int proc_mgr_map(void *handle, u32 proc_addr, u32 size, u32 *mapped_addr,
/* Map to host address space. */
retval = processor_map(proc_mgr_handle->proc_handle, proc_addr,
size, mapped_addr, mapped_size);
size, mapped_addr, mapped_size, map_attribs);
WARN_ON(retval < 0);
mutex_unlock(proc_mgr_obj_state.gate_handle);
return retval;;
}
EXPORT_SYMBOL(proc_mgr_map);
/*============================================
* Function to unmap address to slave address space.
*
* This function unmaps the provided slave address to a host address
*
*/
int proc_mgr_unmap(void *handle, u32 mapped_addr)
{
int retval = 0;
struct proc_mgr_object *proc_mgr_handle =
(struct proc_mgr_object *)handle;
WARN_ON(mutex_lock_interruptible(proc_mgr_obj_state.gate_handle));
/* Map to host address space. */
retval = processor_unmap(proc_mgr_handle->proc_handle, mapped_addr);
WARN_ON(retval < 0);
mutex_unlock(proc_mgr_obj_state.gate_handle);
return retval;;
}
EXPORT_SYMBOL(proc_mgr_unmap);
/*=================================
* Function that registers for notification when the slave
* processor transitions to any of the states specified.
......
......@@ -165,10 +165,10 @@ typedef int (*proc_mgr_callback_fxn)(u16 proc_id, void *handle,
enum proc_mgr_state from_state, enum proc_mgr_state to_state);
/* Function to get the default configuration for the ProcMgr module. */
void proc_mgr_get_config(struct proc_mgr_config*cfg);
void proc_mgr_get_config(struct proc_mgr_config *cfg);
/* Function to setup the ProcMgr module. */
int proc_mgr_setup(struct proc_mgr_config*cfg);
int proc_mgr_setup(struct proc_mgr_config *cfg);
/* Function to destroy the ProcMgr module. */
int proc_mgr_destroy(void);
......@@ -240,7 +240,10 @@ int proc_mgr_translate_addr(void *handle, void **dst_addr,
/* Function that maps the specified slave address to master address space. */
int proc_mgr_map(void *handle, u32 proc_addr, u32 size,
u32 *mappedAddr, u32 *mapped_size, enum proc_mgr_map_type type);
u32 *mappedAddr, u32 *mapped_size, u32 map_attribs);
/* Function that unmaps the specified slave address to master address space. */
int proc_mgr_unmap(void *handle, u32 mapped_addr);
/* Function that registers for notification when the slave processor
* transitions to any of the states specified.
......
......@@ -74,10 +74,10 @@ static void __exit proc_mgr_drv_finalize_module(void);
/*
* name DriverOps
*
* desc Function to invoke the APIs through ioctl.
* desc Function to invoke the APIs through ioctl
*
*/
static struct file_operations procmgr_fops = {
static const struct file_operations procmgr_fops = {
.open = proc_mgr_drv_open,
.ioctl = proc_mgr_drv_ioctl,
.release = proc_mgr_drv_release,
......@@ -498,7 +498,7 @@ static int proc_mgr_drv_ioctl(struct inode *inode, struct file *filp,
src_args.proc_addr, src_args.size,
&(src_args.mapped_addr),
&(src_args.mapped_size),
src_args.type);
src_args.map_attribs);
if (WARN_ON(retval < 0))
goto func_exit;
retval = copy_to_user((void *)(args),
......@@ -508,6 +508,21 @@ static int proc_mgr_drv_ioctl(struct inode *inode, struct file *filp,
}
break;
case CMD_PROCMGR_UNMAP:
{
struct proc_mgr_cmd_args_unmap src_args;
/* Copy the full args from user-side. */
retval = copy_from_user((void *)&src_args,
(const void *)(args),
sizeof(struct proc_mgr_cmd_args_unmap));
if (WARN_ON(retval < 0))
goto func_exit;
retval = proc_mgr_unmap(src_args.handle,
(src_args.mapped_addr));
WARN_ON(retval < 0);
}
case CMD_PROCMGR_REGISTERNOTIFY:
{
struct proc_mgr_cmd_args_register_notify src_args;
......@@ -555,8 +570,7 @@ func_exit:
/* Set the retval and copy the common args to user-side. */
command_args.api_status = retval;
retval = copy_to_user((void *)cmd_args,
(const void *) &command_args,
sizeof(struct proc_mgr_cmd_args));
(const void *)&command_args, sizeof(struct proc_mgr_cmd_args));
WARN_ON(retval < 0);
return retval;
......
......@@ -154,12 +154,12 @@ struct proc_mgr_cmd_args {
/*
* Command for ProcMgr_getSymbolAddress
*/
#define CMD_PROCMGR_GETSYMBOLADDRESS (PROCMGR_BASE_CMD + 23)
#define CMD_PROCMGR_GETSYMBOLADDRESS (PROCMGR_BASE_CMD + 23)
/*
* Command for ProcMgr_map
*/
#define CMD_PROCMGR_MAP (PROCMGR_BASE_CMD + 24)
#define CMD_PROCMGR_MAP (PROCMGR_BASE_CMD + 24)
/*
* Command for ProcMgr_registerNotify
......@@ -169,7 +169,13 @@ struct proc_mgr_cmd_args {
/*
* Command for ProcMgr_getProcInfo
*/
#define CMD_PROCMGR_GETPROCINFO (PROCMGR_BASE_CMD + 26)
#define CMD_PROCMGR_GETPROCINFO (PROCMGR_BASE_CMD + 26)
/*
* Command for ProcMgr_unmap
*/
#define CMD_PROCMGR_UNMAP (PROCMGR_BASE_CMD + 27)
/* ----------------------------------------------------------------------------
......@@ -460,10 +466,22 @@ struct proc_mgr_cmd_args_map {
/*Return parameter: Mapped address in host address space */
u32 mapped_size;
/*Return parameter: Mapped size */
enum proc_mgr_map_type type;
u32 map_attribs;
/*Type of mapping. */
};
/*
* Command arguments for ProcMgr_map
*/
struct proc_mgr_cmd_args_unmap {
struct proc_mgr_cmd_args commond_args;
/*Common command args */
void *handle;
/*Handle to the ProcMgr object */
u32 mapped_addr;
/* Mapped address in host address space */
};
/*
* Command arguments for ProcMgr_registerNotify
*/
......
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