Commit b92d99ae authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: atomisp: go one step further to drop ia_css_memory_access.c

Move the attrs handling into hmm, simplifying even further
what the ia_css_memory_access.c file does.

Yet, the returned type for ia_css_memory_access.c is an
integer, instead of a pointer.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 86df6ff2
...@@ -35,7 +35,8 @@ int hmm_init(void); ...@@ -35,7 +35,8 @@ int hmm_init(void);
void hmm_cleanup(void); void hmm_cleanup(void);
ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
int from_highmem, const void __user *userptr, bool cached); int from_highmem, const void __user *userptr,
const uint16_t attrs);
void hmm_free(ia_css_ptr ptr); void hmm_free(ia_css_ptr ptr);
int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes); int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes);
int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes); int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes);
......
...@@ -917,6 +917,8 @@ struct atomisp_acc_map { ...@@ -917,6 +917,8 @@ struct atomisp_acc_map {
#define ATOMISP_MAP_FLAG_NOFLUSH 0x0001 /* Do not flush cache */ #define ATOMISP_MAP_FLAG_NOFLUSH 0x0001 /* Do not flush cache */
#define ATOMISP_MAP_FLAG_CACHED 0x0002 /* Enable cache */ #define ATOMISP_MAP_FLAG_CACHED 0x0002 /* Enable cache */
#define ATOMISP_MAP_FLAG_CONTIGUOUS 0x0004
#define ATOMISP_MAP_FLAG_CLEARED 0x0008
struct atomisp_acc_state { struct atomisp_acc_state {
__u32 flags; /* Flags, see list below */ __u32 flags; /* Flags, see list below */
......
...@@ -76,9 +76,6 @@ ...@@ -76,9 +76,6 @@
* within the allocation referencable from the * within the allocation referencable from the
* returned pointer/address. * returned pointer/address.
*/ */
#define MMGR_ATTRIBUTE_CACHED 0x0001
#define MMGR_ATTRIBUTE_CONTIGUOUS 0x0002
#define MMGR_ATTRIBUTE_CLEARED 0x0008
#define mmgr_NULL ((hrt_vaddress)0) #define mmgr_NULL ((hrt_vaddress)0)
#define mmgr_EXCEPTION ((hrt_vaddress)-1) #define mmgr_EXCEPTION ((hrt_vaddress)-1)
......
...@@ -193,7 +193,7 @@ int hmm_init(void) ...@@ -193,7 +193,7 @@ int hmm_init(void)
* at the beginning, to avoid hmm_alloc return 0 in the * at the beginning, to avoid hmm_alloc return 0 in the
* further allocation. * further allocation.
*/ */
dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, false); dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, 0);
if (!ret) { if (!ret) {
ret = sysfs_create_group(&atomisp_dev->kobj, ret = sysfs_create_group(&atomisp_dev->kobj,
...@@ -219,12 +219,16 @@ void hmm_cleanup(void) ...@@ -219,12 +219,16 @@ void hmm_cleanup(void)
} }
ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
int from_highmem, const void __user *userptr, bool cached) int from_highmem, const void __user *userptr,
const uint16_t attrs)
{ {
unsigned int pgnr; unsigned int pgnr;
struct hmm_buffer_object *bo; struct hmm_buffer_object *bo;
bool cached = attrs & ATOMISP_MAP_FLAG_CACHED;
int ret; int ret;
WARN_ON(attrs & ATOMISP_MAP_FLAG_CONTIGUOUS);
/* /*
* Check if we are initialized. In the ideal world we wouldn't need * Check if we are initialized. In the ideal world we wouldn't need
* this but we can tackle it once the driver is a lot cleaner * this but we can tackle it once the driver is a lot cleaner
...@@ -258,6 +262,9 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, ...@@ -258,6 +262,9 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
hmm_mem_stat.tol_cnt += pgnr; hmm_mem_stat.tol_cnt += pgnr;
if (attrs & ATOMISP_MAP_FLAG_CLEARED)
hmm_set(bo->start, 0, bytes);
return bo->start; return bo->start;
bind_err: bind_err:
......
...@@ -12,30 +12,11 @@ ...@@ -12,30 +12,11 @@
* more details. * more details.
*/ */
#include <type_support.h>
#include <system_types.h>
#include <assert_support.h>
#include <memory_access.h> #include <memory_access.h>
#include <ia_css_env.h>
#include "atomisp_internal.h"
hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attrs) hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attrs)
{ {
ia_css_ptr data; return hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL, attrs);
WARN_ON(attrs & MMGR_ATTRIBUTE_CONTIGUOUS);
data = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL,
attrs & MMGR_ATTRIBUTE_CACHED);
if (!data)
return 0;
if (attrs & MMGR_ATTRIBUTE_CLEARED)
hmm_set(data, 0, size);
return (ia_css_ptr)data;
} }
void mmgr_load(const hrt_vaddress vaddr, void *data, const size_t size) void mmgr_load(const hrt_vaddress vaddr, void *data, const size_t size)
......
...@@ -178,7 +178,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame, ...@@ -178,7 +178,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame,
} }
return hmm_alloc(me->data_bytes, HMM_BO_USER, 0, data, return hmm_alloc(me->data_bytes, HMM_BO_USER, 0, data,
attribute & MMGR_ATTRIBUTE_CACHED); attribute & ATOMISP_MAP_FLAG_CACHED);
if (me->data == mmgr_NULL) if (me->data == mmgr_NULL)
err = IA_CSS_ERR_INVALID_ARGUMENTS; err = IA_CSS_ERR_INVALID_ARGUMENTS;
...@@ -799,7 +799,7 @@ static enum ia_css_err frame_allocate_buffer_data(struct ia_css_frame *frame) ...@@ -799,7 +799,7 @@ static enum ia_css_err frame_allocate_buffer_data(struct ia_css_frame *frame)
#endif #endif
frame->data = mmgr_alloc_attr(frame->data_bytes, frame->data = mmgr_alloc_attr(frame->data_bytes,
frame->contiguous ? frame->contiguous ?
MMGR_ATTRIBUTE_CONTIGUOUS : 0); ATOMISP_MAP_FLAG_CONTIGUOUS : 0);
if (frame->data == mmgr_NULL) if (frame->data == mmgr_NULL)
return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY;
......
...@@ -3267,11 +3267,11 @@ sh_css_params_init(void) { ...@@ -3267,11 +3267,11 @@ sh_css_params_init(void) {
xmem_sp_stage_ptrs[p][i] = xmem_sp_stage_ptrs[p][i] =
ia_css_refcount_increment(-1, ia_css_refcount_increment(-1,
mmgr_alloc_attr(sizeof(struct sh_css_sp_stage), mmgr_alloc_attr(sizeof(struct sh_css_sp_stage),
MMGR_ATTRIBUTE_CLEARED)); ATOMISP_MAP_FLAG_CLEARED));
xmem_isp_stage_ptrs[p][i] = xmem_isp_stage_ptrs[p][i] =
ia_css_refcount_increment(-1, ia_css_refcount_increment(-1,
mmgr_alloc_attr(sizeof(struct sh_css_sp_stage), mmgr_alloc_attr(sizeof(struct sh_css_sp_stage),
MMGR_ATTRIBUTE_CLEARED)); ATOMISP_MAP_FLAG_CLEARED));
if ((xmem_sp_stage_ptrs[p][i] == mmgr_NULL) || if ((xmem_sp_stage_ptrs[p][i] == mmgr_NULL) ||
(xmem_isp_stage_ptrs[p][i] == mmgr_NULL)) { (xmem_isp_stage_ptrs[p][i] == mmgr_NULL)) {
...@@ -3290,10 +3290,10 @@ sh_css_params_init(void) { ...@@ -3290,10 +3290,10 @@ sh_css_params_init(void) {
sp_ddr_ptrs = ia_css_refcount_increment(-1, sp_ddr_ptrs = ia_css_refcount_increment(-1,
mmgr_alloc_attr(CEIL_MUL(sizeof(struct sh_css_ddr_address_map), mmgr_alloc_attr(CEIL_MUL(sizeof(struct sh_css_ddr_address_map),
HIVE_ISP_DDR_WORD_BYTES), HIVE_ISP_DDR_WORD_BYTES),
MMGR_ATTRIBUTE_CLEARED)); ATOMISP_MAP_FLAG_CLEARED));
xmem_sp_group_ptrs = ia_css_refcount_increment(-1, xmem_sp_group_ptrs = ia_css_refcount_increment(-1,
mmgr_alloc_attr(sizeof(struct sh_css_sp_group), mmgr_alloc_attr(sizeof(struct sh_css_sp_group),
MMGR_ATTRIBUTE_CLEARED)); ATOMISP_MAP_FLAG_CLEARED));
if ((sp_ddr_ptrs == mmgr_NULL) || if ((sp_ddr_ptrs == mmgr_NULL) ||
(xmem_sp_group_ptrs == mmgr_NULL)) (xmem_sp_group_ptrs == mmgr_NULL))
......
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