#include "hmm/hmm_pool.h"
#include "ia_css_types.h"
-#define HMM_CACHED true
-#define HMM_UNCACHED false
-
int hmm_pool_register(unsigned int pool_size, enum hmm_pool_type pool_type);
void hmm_pool_unregister(enum hmm_pool_type pool_type);
* within the allocation referencable from the
* returned pointer/address.
*/
-#define MMGR_ATTRIBUTE_MASK 0x000f
#define MMGR_ATTRIBUTE_CACHED 0x0001
#define MMGR_ATTRIBUTE_CONTIGUOUS 0x0002
-#define MMGR_ATTRIBUTE_PAGEALIGN 0x0004
#define MMGR_ATTRIBUTE_CLEARED 0x0008
-#define MMGR_ATTRIBUTE_UNUSED 0xfff0
-/* #define MMGR_ATTRIBUTE_DEFAULT (MMGR_ATTRIBUTE_CACHED) */
-#define MMGR_ATTRIBUTE_DEFAULT 0
-
-extern const hrt_vaddress mmgr_NULL;
-extern const hrt_vaddress mmgr_EXCEPTION;
-
-/*! Return the address of an allocation in memory
-
- \param size[in] Size in bytes of the allocation
- \param caller_func[in] Caller function name
- \param caller_line[in] Caller function line number
-
- \return vaddress
- */
-hrt_vaddress mmgr_malloc(const size_t size);
-
-/*! Return the address of a zero initialised allocation in memory
-
- \param N[in] Horizontal dimension of array
- \param size[in] Vertical dimension of array Total size is N*size
-
- \return vaddress
- */
-hrt_vaddress mmgr_calloc(const size_t N, const size_t size);
+#define mmgr_NULL ((hrt_vaddress)0)
+#define mmgr_EXCEPTION ((hrt_vaddress)-1)
/*! Return the address of an allocation in memory
hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attribute);
-/*! Return the address of a mapped existing allocation in memory
-
- \param ptr[in] Pointer to an allocation in a different
- virtual memory page table, but the same
- physical memory
- \param size[in] Size of the memory of the pointer
- \param attribute[in] Bit vector specifying the properties
- of the allocation
- \param context Pointer of a context provided by
- client/driver for additional parameters
- needed by the implementation
- \Note
- This interface is tentative, limited to the desired function
- the actual interface may require furhter parameters
-
- \return vaddress
- */
-hrt_vaddress mmgr_mmap(
- const void __user *ptr,
- const size_t size,
- u16 attribute,
- unsigned int pgnr);
-
-/*! Zero initialise an allocation in memory
-
- \param vaddr[in] Address of an allocation
- \param size[in] Size in bytes of the area to be cleared
-
- \return none
- */
-void mmgr_clear(hrt_vaddress vaddr, const size_t size);
-
/*! Read an array of bytes from a virtual memory address
\param vaddr[in] Address of an allocation
* at the beginning, to avoid hmm_alloc return 0 in the
* further allocation.
*/
- dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, HMM_UNCACHED);
+ dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, false);
if (!ret) {
ret = sysfs_create_group(&atomisp_dev->kobj,
#include "atomisp_internal.h"
-const hrt_vaddress mmgr_NULL = (hrt_vaddress)0;
-const hrt_vaddress mmgr_EXCEPTION = (hrt_vaddress)-1;
-
-hrt_vaddress
-mmgr_malloc(const size_t size)
-{
- return mmgr_alloc_attr(size, 0);
-}
-
hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attrs)
{
- u16 masked_attrs = attrs & MMGR_ATTRIBUTE_MASK;
ia_css_ptr data;
WARN_ON(attrs & MMGR_ATTRIBUTE_CONTIGUOUS);
data = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL,
- masked_attrs & MMGR_ATTRIBUTE_CACHED);
+ attrs & MMGR_ATTRIBUTE_CACHED);
if (!data)
return 0;
- if (masked_attrs & MMGR_ATTRIBUTE_CLEARED)
+ if (attrs & MMGR_ATTRIBUTE_CLEARED)
hmm_set(data, 0, size);
return (ia_css_ptr)data;
}
-hrt_vaddress
-mmgr_calloc(const size_t N, const size_t size)
-{
- return mmgr_alloc_attr(size * N, MMGR_ATTRIBUTE_CLEARED);
-}
-
-void mmgr_clear(hrt_vaddress vaddr, const size_t size)
-{
- if (vaddr)
- hmm_set(vaddr, 0, size);
-}
-
void mmgr_load(const hrt_vaddress vaddr, void *data, const size_t size)
{
if (vaddr && data)
if (vaddr && data)
hmm_store(vaddr, data, size);
}
-
-hrt_vaddress
-mmgr_mmap(const void __user *ptr, const size_t size,
- u16 attribute, unsigned int pgnr)
-{
- if (pgnr < ((PAGE_ALIGN(size)) >> PAGE_SHIFT)) {
- dev_err(atomisp_dev,
- "user space memory size is less than the expected size..\n");
- return -ENOMEM;
- } else if (pgnr > ((PAGE_ALIGN(size)) >> PAGE_SHIFT)) {
- dev_err(atomisp_dev,
- "user space memory size is large than the expected size..\n");
- return -ENOMEM;
- }
-
- return hmm_alloc(size, HMM_BO_USER, 0, ptr,
- attribute & MMGR_ATTRIBUTE_CACHED);
-
-}
HIVE_ISP_DDR_WORD_BYTES);
me->size = hor_size + ver_size;
- me->data_ptr = mmgr_malloc(me->size);
+ me->data_ptr = mmgr_alloc_attr(me->size, 0);
if (me->data_ptr == mmgr_NULL)
goto err;
me->hor_size = hor_size;
* grid->aligned_height * IA_CSS_DVS2_NUM_COEF_TYPES;
me->size = 2 * size;
- me->data_ptr = mmgr_malloc(me->size);
+ me->data_ptr = mmgr_alloc_attr(me->size, 0);
if (me->data_ptr == mmgr_NULL)
goto err;
me->hor_proj = me->data_ptr;
enum ia_css_err *err)
{
bool ret;
- u16 mmgr_attribute = MMGR_ATTRIBUTE_DEFAULT;
IA_CSS_ENTER_PRIVATE("void");
ret = realloc_isp_css_mm_buf(curr_buf,
- curr_size, needed_size, force, err, mmgr_attribute);
+ curr_size, needed_size, force, err, 0);
IA_CSS_LEAVE_PRIVATE("ret=%d", ret);
return ret;
void sh_css_init_ddr_debug_queue(void)
{
hrt_vaddress ddr_debug_queue_addr =
- mmgr_malloc(sizeof(debug_data_ddr_t));
+ mmgr_alloc_attr(sizeof(debug_data_ddr_t), 0);
const struct ia_css_fw_info *fw;
unsigned int HIVE_ADDR_debug_buffer_ddr_address;
#include "isp.h"
#include "sh_css_internal.h"
#include "memory_access.h"
+#include "atomisp_internal.h"
#define NV12_TILEY_TILE_WIDTH 128
#define NV12_TILEY_TILE_HEIGHT 32
void ia_css_frame_zero(struct ia_css_frame *frame)
{
assert(frame);
- mmgr_clear(frame->data, frame->data_bytes);
+ hmm_set(frame->data, 0, frame->data_bytes);
}
enum ia_css_err ia_css_frame_allocate_from_info(struct ia_css_frame **frame,
return err;
if (err == IA_CSS_SUCCESS) {
- /* use mmgr_mmap to map */
- me->data = (ia_css_ptr) mmgr_mmap(data,
- me->data_bytes,
- attribute, pgnr);
+ if (pgnr < ((PAGE_ALIGN(me->data_bytes)) >> PAGE_SHIFT)) {
+ dev_err(atomisp_dev,
+ "user space memory size is less than the expected size..\n");
+ return -ENOMEM;
+ } else if (pgnr > ((PAGE_ALIGN(me->data_bytes)) >> PAGE_SHIFT)) {
+ dev_err(atomisp_dev,
+ "user space memory size is large than the expected size..\n");
+ return -ENOMEM;
+ }
+
+ return hmm_alloc(me->data_bytes, HMM_BO_USER, 0, data,
+ attribute & MMGR_ATTRIBUTE_CACHED);
+
if (me->data == mmgr_NULL)
err = IA_CSS_ERR_INVALID_ARGUMENTS;
}
#endif
frame->data = mmgr_alloc_attr(frame->data_bytes,
frame->contiguous ?
- MMGR_ATTRIBUTE_CONTIGUOUS :
- MMGR_ATTRIBUTE_DEFAULT);
+ MMGR_ATTRIBUTE_CONTIGUOUS : 0);
if (frame->data == mmgr_NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
goto cleanup;
}
if (pclass != IA_CSS_PARAM_CLASS_PARAM) {
- css_params->params[pclass][mem].address = mmgr_malloc(size);
+ css_params->params[pclass][mem].address = mmgr_alloc_attr(size, 0);
if (!css_params->params[pclass][mem].address) {
err = IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
goto cleanup;
#include <type_support.h>
#include <assert_support.h>
#include <platform_support.h> /* memset */
-#include <memory_access.h> /* mmmgr_malloc, mhmm_free */
+#include <memory_access.h> /* mmmgr_alloc_attr */
#include <ia_css_debug.h>
/*
}
if ((*handle)->vptr == 0x0) {
/* we need to allocate */
- (*handle)->vptr = mmgr_malloc((*handle)->size);
+ (*handle)->vptr = mmgr_alloc_attr((*handle)->size, 0);
} else {
/* we popped a buffer */
return;
* Data used to be stored separately, because of access alignment constraints,
* fix the FW generation instead
*/
- code_addr = mmgr_malloc(spctrl_cfg->code_size);
+ code_addr = mmgr_alloc_attr(spctrl_cfg->code_size, 0);
if (code_addr == mmgr_NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
mmgr_store(code_addr, spctrl_cfg->code, spctrl_cfg->code_size);
hrt_vaddress
sh_css_load_blob(const unsigned char *blob, unsigned int size)
{
- hrt_vaddress target_addr = mmgr_malloc(size);
+ hrt_vaddress target_addr = mmgr_alloc_attr(size, 0);
/* this will allocate memory aligned to a DDR word boundary which
is required for the CSS DMA to read the instructions. */
enum ia_css_err *err)
{
bool ret;
- u16 mmgr_attribute = MMGR_ATTRIBUTE_DEFAULT;
IA_CSS_ENTER_PRIVATE("void");
ret = realloc_isp_css_mm_buf(curr_buf,
- curr_size, needed_size, force, err, mmgr_attribute);
+ curr_size, needed_size, force, err, 0);
IA_CSS_LEAVE_PRIVATE("ret=%d", ret);
return ret;
me->hmem_size = CEIL_MUL(me->hmem_size, HIVE_ISP_DDR_WORD_BYTES);
me->size = me->dmem_size + me->vmem_size * 2 + me->hmem_size;
- me->data_ptr = mmgr_malloc(me->size);
+ me->data_ptr = mmgr_alloc_attr(me->size, 0);
if (me->data_ptr == mmgr_NULL) {
sh_css_free(me);
me = NULL;
md->info = *metadata_info;
md->exp_id = 0;
- md->address = mmgr_malloc(metadata_info->size);
+ md->address = mmgr_alloc_attr(metadata_info->size, 0);
if (md->address == mmgr_NULL)
goto error;
ddr_ptrs_size->isp_param = params_size;
ddr_ptrs->isp_param =
ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER,
- mmgr_malloc(params_size));
+ mmgr_alloc_attr(params_size, 0));
succ &= (ddr_ptrs->isp_param != mmgr_NULL);
ddr_ptrs_size->macc_tbl = sizeof(struct ia_css_macc_table);
ddr_ptrs->macc_tbl =
ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_BUFFER,
- mmgr_malloc(sizeof(struct ia_css_macc_table)));
+ mmgr_alloc_attr(sizeof(struct ia_css_macc_table), 0));
succ &= (ddr_ptrs->macc_tbl != mmgr_NULL);
*isp_params_out = params;
for (i = 0; i < SH_CSS_MAX_STAGES; i++) {
xmem_sp_stage_ptrs[p][i] =
ia_css_refcount_increment(-1,
- mmgr_calloc(1,
- sizeof(struct sh_css_sp_stage)));
+ mmgr_alloc_attr(sizeof(struct sh_css_sp_stage),
+ MMGR_ATTRIBUTE_CLEARED));
xmem_isp_stage_ptrs[p][i] =
ia_css_refcount_increment(-1,
- mmgr_calloc(1,
- sizeof(struct sh_css_isp_stage)));
+ mmgr_alloc_attr(sizeof(struct sh_css_sp_stage),
+ MMGR_ATTRIBUTE_CLEARED));
if ((xmem_sp_stage_ptrs[p][i] == mmgr_NULL) ||
(xmem_isp_stage_ptrs[p][i] == mmgr_NULL)) {
ia_css_config_rgb_gamma_tables();
ia_css_config_xnr_table();
- sp_ddr_ptrs = ia_css_refcount_increment(-1, mmgr_calloc(1,
- CEIL_MUL(sizeof(struct sh_css_ddr_address_map),
- HIVE_ISP_DDR_WORD_BYTES)));
- xmem_sp_group_ptrs = ia_css_refcount_increment(-1, mmgr_calloc(1,
- sizeof(struct sh_css_sp_group)));
+ sp_ddr_ptrs = ia_css_refcount_increment(-1,
+ mmgr_alloc_attr(CEIL_MUL(sizeof(struct sh_css_ddr_address_map),
+ HIVE_ISP_DDR_WORD_BYTES),
+ MMGR_ATTRIBUTE_CLEARED));
+ xmem_sp_group_ptrs = ia_css_refcount_increment(-1,
+ mmgr_alloc_attr(sizeof(struct sh_css_sp_group),
+ MMGR_ATTRIBUTE_CLEARED));
if ((sp_ddr_ptrs == mmgr_NULL) ||
(xmem_sp_group_ptrs == mmgr_NULL))
/* Note that allocation is in ipu address space. */
inline hrt_vaddress sh_css_params_alloc_gdc_lut(void)
{
- return mmgr_malloc(sizeof(zoom_table));
+ return mmgr_alloc_attr(sizeof(zoom_table), 0);
}
inline void sh_css_params_free_gdc_lut(hrt_vaddress addr)
if (!stream_started) {
if (!atomisp_hw_is_isp2401)
- pipe->scaler_pp_lut = mmgr_malloc(sizeof(zoom_table));
+ pipe->scaler_pp_lut = mmgr_alloc_attr(sizeof(zoom_table), 0);
else
pipe->scaler_pp_lut = sh_css_params_alloc_gdc_lut();
host_lut_store((void *)zoom_table);
if (!atomisp_hw_is_isp2401)
- default_gdc_lut = mmgr_malloc(sizeof(zoom_table));
+ default_gdc_lut = mmgr_alloc_attr(sizeof(zoom_table), 0);
else
default_gdc_lut = sh_css_params_alloc_gdc_lut();
assert(me);
assert(out);
- *out = ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_SET_POOL, mmgr_malloc(
- sizeof(struct ia_css_isp_parameter_set_info)));
+ *out = ia_css_refcount_increment(IA_CSS_REFCOUNT_PARAM_SET_POOL,
+ mmgr_alloc_attr(sizeof(struct ia_css_isp_parameter_set_info), 0));
succ = (*out != mmgr_NULL);
if (succ)
mmgr_store(*out,