Commit 8d21af81 authored by Philipp Guendisch's avatar Philipp Guendisch Committed by Mauro Carvalho Chehab

media: staging: atomisp: hmm: Alignment code (rebased)

This patch fixed code alignment to open paranthesis.
Semantic should not be affected by this patch.

It has been rebased on top of media_tree atomisp branch
Signed-off-by: default avatarPhilipp Guendisch <philipp.guendisch@fau.de>
Signed-off-by: default avatarChris Baller <chris.baller@gmx.de>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent cd31dae7
...@@ -55,7 +55,7 @@ struct _hmm_mem_stat hmm_mem_stat; ...@@ -55,7 +55,7 @@ struct _hmm_mem_stat hmm_mem_stat;
static const char hmm_bo_type_string[] = "psui"; static const char hmm_bo_type_string[] = "psui";
static ssize_t bo_show(struct device *dev, struct device_attribute *attr, static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
char *buf, struct list_head *bo_list, bool active) char *buf, struct list_head *bo_list, bool active)
{ {
ssize_t ret = 0; ssize_t ret = 0;
struct hmm_buffer_object *bo; struct hmm_buffer_object *bo;
...@@ -75,10 +75,10 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr, ...@@ -75,10 +75,10 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
spin_lock_irqsave(&bo_device.list_lock, flags); spin_lock_irqsave(&bo_device.list_lock, flags);
list_for_each_entry(bo, bo_list, list) { list_for_each_entry(bo, bo_list, list) {
if ((active && (bo->status & HMM_BO_ALLOCED)) || if ((active && (bo->status & HMM_BO_ALLOCED)) ||
(!active && !(bo->status & HMM_BO_ALLOCED))) { (!active && !(bo->status & HMM_BO_ALLOCED))) {
ret = scnprintf(buf + index1, PAGE_SIZE - index1, ret = scnprintf(buf + index1, PAGE_SIZE - index1,
"%c %d\n", "%c %d\n",
hmm_bo_type_string[bo->type], bo->pgnr); hmm_bo_type_string[bo->type], bo->pgnr);
total[bo->type] += bo->pgnr; total[bo->type] += bo->pgnr;
count[bo->type]++; count[bo->type]++;
...@@ -91,9 +91,10 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr, ...@@ -91,9 +91,10 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
for (i = 0; i < HMM_BO_LAST; i++) { for (i = 0; i < HMM_BO_LAST; i++) {
if (count[i]) { if (count[i]) {
ret = scnprintf(buf + index1 + index2, ret = scnprintf(buf + index1 + index2,
PAGE_SIZE - index1 - index2, PAGE_SIZE - index1 - index2,
"%ld %c buffer objects: %ld KB\n", "%ld %c buffer objects: %ld KB\n",
count[i], hmm_bo_type_string[i], total[i] * 4); count[i], hmm_bo_type_string[i],
total[i] * 4);
if (ret > 0) if (ret > 0)
index2 += ret; index2 += ret;
} }
...@@ -103,23 +104,21 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr, ...@@ -103,23 +104,21 @@ static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
return index1 + index2 + 1; return index1 + index2 + 1;
} }
static ssize_t active_bo_show(struct device *dev, static ssize_t active_bo_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr, char *buf)
char *buf)
{ {
return bo_show(dev, attr, buf, &bo_device.entire_bo_list, true); return bo_show(dev, attr, buf, &bo_device.entire_bo_list, true);
} }
static ssize_t free_bo_show(struct device *dev, static ssize_t free_bo_show(struct device *dev, struct device_attribute *attr,
struct device_attribute *attr, char *buf)
char *buf)
{ {
return bo_show(dev, attr, buf, &bo_device.entire_bo_list, false); return bo_show(dev, attr, buf, &bo_device.entire_bo_list, false);
} }
static ssize_t reserved_pool_show(struct device *dev, static ssize_t reserved_pool_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
ssize_t ret = 0; ssize_t ret = 0;
...@@ -131,7 +130,7 @@ static ssize_t reserved_pool_show(struct device *dev, ...@@ -131,7 +130,7 @@ static ssize_t reserved_pool_show(struct device *dev,
spin_lock_irqsave(&pinfo->list_lock, flags); spin_lock_irqsave(&pinfo->list_lock, flags);
ret = scnprintf(buf, PAGE_SIZE, "%d out of %d pages available\n", ret = scnprintf(buf, PAGE_SIZE, "%d out of %d pages available\n",
pinfo->index, pinfo->pgnr); pinfo->index, pinfo->pgnr);
spin_unlock_irqrestore(&pinfo->list_lock, flags); spin_unlock_irqrestore(&pinfo->list_lock, flags);
if (ret > 0) if (ret > 0)
...@@ -141,8 +140,8 @@ static ssize_t reserved_pool_show(struct device *dev, ...@@ -141,8 +140,8 @@ static ssize_t reserved_pool_show(struct device *dev,
}; };
static ssize_t dynamic_pool_show(struct device *dev, static ssize_t dynamic_pool_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
ssize_t ret = 0; ssize_t ret = 0;
...@@ -154,7 +153,7 @@ static ssize_t dynamic_pool_show(struct device *dev, ...@@ -154,7 +153,7 @@ static ssize_t dynamic_pool_show(struct device *dev,
spin_lock_irqsave(&pinfo->list_lock, flags); spin_lock_irqsave(&pinfo->list_lock, flags);
ret = scnprintf(buf, PAGE_SIZE, "%d (max %d) pages available\n", ret = scnprintf(buf, PAGE_SIZE, "%d (max %d) pages available\n",
pinfo->pgnr, pinfo->pool_size); pinfo->pgnr, pinfo->pool_size);
spin_unlock_irqrestore(&pinfo->list_lock, flags); spin_unlock_irqrestore(&pinfo->list_lock, flags);
if (ret > 0) if (ret > 0)
...@@ -202,7 +201,7 @@ int hmm_init(void) ...@@ -202,7 +201,7 @@ int hmm_init(void)
if (!ret) { if (!ret) {
ret = sysfs_create_group(&atomisp_dev->kobj, ret = sysfs_create_group(&atomisp_dev->kobj,
atomisp_attribute_group); atomisp_attribute_group);
if (ret) if (ret)
dev_err(atomisp_dev, dev_err(atomisp_dev,
"%s Failed to create sysfs\n", __func__); "%s Failed to create sysfs\n", __func__);
...@@ -224,7 +223,7 @@ void hmm_cleanup(void) ...@@ -224,7 +223,7 @@ 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, void *userptr, bool cached) int from_highmem, void *userptr, bool cached)
{ {
unsigned int pgnr; unsigned int pgnr;
struct hmm_buffer_object *bo; struct hmm_buffer_object *bo;
...@@ -250,8 +249,7 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, ...@@ -250,8 +249,7 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type,
/* Allocate pages for memory */ /* Allocate pages for memory */
ret = hmm_bo_alloc_pages(bo, type, from_highmem, userptr, cached); ret = hmm_bo_alloc_pages(bo, type, from_highmem, userptr, cached);
if (ret) { if (ret) {
dev_err(atomisp_dev, dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n");
"hmm_bo_alloc_pages failed.\n");
goto alloc_page_err; goto alloc_page_err;
} }
...@@ -284,8 +282,8 @@ void hmm_free(ia_css_ptr virt) ...@@ -284,8 +282,8 @@ void hmm_free(ia_css_ptr virt)
if (!bo) { if (!bo) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
"can not find buffer object start with " "can not find buffer object start with address 0x%x\n",
"address 0x%x\n", (unsigned int)virt); (unsigned int)virt);
return; return;
} }
...@@ -300,21 +298,20 @@ static inline int hmm_check_bo(struct hmm_buffer_object *bo, unsigned int ptr) ...@@ -300,21 +298,20 @@ static inline int hmm_check_bo(struct hmm_buffer_object *bo, unsigned int ptr)
{ {
if (!bo) { if (!bo) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
"can not find buffer object contains " "can not find buffer object contains address 0x%x\n",
"address 0x%x\n", ptr); ptr);
return -EINVAL; return -EINVAL;
} }
if (!hmm_bo_page_allocated(bo)) { if (!hmm_bo_page_allocated(bo)) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
"buffer object has no page allocated.\n"); "buffer object has no page allocated.\n");
return -EINVAL; return -EINVAL;
} }
if (!hmm_bo_allocated(bo)) { if (!hmm_bo_allocated(bo)) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
"buffer object has no virtual address" "buffer object has no virtual address space allocated.\n");
" space allocated.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -322,7 +319,8 @@ static inline int hmm_check_bo(struct hmm_buffer_object *bo, unsigned int ptr) ...@@ -322,7 +319,8 @@ static inline int hmm_check_bo(struct hmm_buffer_object *bo, unsigned int ptr)
} }
/* Read function in ISP memory management */ /* Read function in ISP memory management */
static int load_and_flush_by_kmap(ia_css_ptr virt, void *data, unsigned int bytes) static int load_and_flush_by_kmap(ia_css_ptr virt, void *data,
unsigned int bytes)
{ {
struct hmm_buffer_object *bo; struct hmm_buffer_object *bo;
unsigned int idx, offset, len; unsigned int idx, offset, len;
...@@ -404,7 +402,7 @@ int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes) ...@@ -404,7 +402,7 @@ int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes)
{ {
if (!data) { if (!data) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
"hmm_load NULL argument\n"); "hmm_load NULL argument\n");
return -EINVAL; return -EINVAL;
} }
return load_and_flush(virt, data, bytes); return load_and_flush(virt, data, bytes);
...@@ -462,8 +460,8 @@ int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes) ...@@ -462,8 +460,8 @@ int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes)
if (!des) { if (!des) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
"kmap buffer object page failed: " "kmap buffer object page failed: pg_idx = %d\n",
"pg_idx = %d\n", idx); idx);
return -EINVAL; return -EINVAL;
} }
...@@ -602,8 +600,8 @@ void *hmm_vmap(ia_css_ptr virt, bool cached) ...@@ -602,8 +600,8 @@ void *hmm_vmap(ia_css_ptr virt, bool cached)
bo = hmm_bo_device_search_in_range(&bo_device, virt); bo = hmm_bo_device_search_in_range(&bo_device, virt);
if (!bo) { if (!bo) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
"can not find buffer object contains address 0x%x\n", "can not find buffer object contains address 0x%x\n",
virt); virt);
return NULL; return NULL;
} }
...@@ -622,8 +620,8 @@ void hmm_flush_vmap(ia_css_ptr virt) ...@@ -622,8 +620,8 @@ void hmm_flush_vmap(ia_css_ptr virt)
bo = hmm_bo_device_search_in_range(&bo_device, virt); bo = hmm_bo_device_search_in_range(&bo_device, virt);
if (!bo) { if (!bo) {
dev_warn(atomisp_dev, dev_warn(atomisp_dev,
"can not find buffer object contains address 0x%x\n", "can not find buffer object contains address 0x%x\n",
virt); virt);
return; return;
} }
...@@ -637,26 +635,25 @@ void hmm_vunmap(ia_css_ptr virt) ...@@ -637,26 +635,25 @@ void hmm_vunmap(ia_css_ptr virt)
bo = hmm_bo_device_search_in_range(&bo_device, virt); bo = hmm_bo_device_search_in_range(&bo_device, virt);
if (!bo) { if (!bo) {
dev_warn(atomisp_dev, dev_warn(atomisp_dev,
"can not find buffer object contains address 0x%x\n", "can not find buffer object contains address 0x%x\n",
virt); virt);
return; return;
} }
hmm_bo_vunmap(bo); hmm_bo_vunmap(bo);
} }
int hmm_pool_register(unsigned int pool_size, int hmm_pool_register(unsigned int pool_size, enum hmm_pool_type pool_type)
enum hmm_pool_type pool_type)
{ {
switch (pool_type) { switch (pool_type) {
case HMM_POOL_TYPE_RESERVED: case HMM_POOL_TYPE_RESERVED:
reserved_pool.pops = &reserved_pops; reserved_pool.pops = &reserved_pops;
return reserved_pool.pops->pool_init(&reserved_pool.pool_info, return reserved_pool.pops->pool_init(&reserved_pool.pool_info,
pool_size); pool_size);
case HMM_POOL_TYPE_DYNAMIC: case HMM_POOL_TYPE_DYNAMIC:
dynamic_pool.pops = &dynamic_pops; dynamic_pool.pops = &dynamic_pops;
return dynamic_pool.pops->pool_init(&dynamic_pool.pool_info, return dynamic_pool.pops->pool_init(&dynamic_pool.pool_info,
pool_size); pool_size);
default: default:
dev_err(atomisp_dev, "invalid pool type.\n"); dev_err(atomisp_dev, "invalid pool type.\n");
return -EINVAL; return -EINVAL;
...@@ -705,10 +702,10 @@ ia_css_ptr hmm_host_vaddr_to_hrt_vaddr(const void *ptr) ...@@ -705,10 +702,10 @@ ia_css_ptr hmm_host_vaddr_to_hrt_vaddr(const void *ptr)
void hmm_show_mem_stat(const char *func, const int line) void hmm_show_mem_stat(const char *func, const int line)
{ {
trace_printk("tol_cnt=%d usr_size=%d res_size=%d res_cnt=%d sys_size=%d dyc_thr=%d dyc_size=%d.\n", trace_printk("tol_cnt=%d usr_size=%d res_size=%d res_cnt=%d sys_size=%d dyc_thr=%d dyc_size=%d.\n",
hmm_mem_stat.tol_cnt, hmm_mem_stat.tol_cnt,
hmm_mem_stat.usr_size, hmm_mem_stat.res_size, hmm_mem_stat.usr_size, hmm_mem_stat.res_size,
hmm_mem_stat.res_cnt, hmm_mem_stat.sys_size, hmm_mem_stat.res_cnt, hmm_mem_stat.sys_size,
hmm_mem_stat.dyc_thr, hmm_mem_stat.dyc_size); hmm_mem_stat.dyc_thr, hmm_mem_stat.dyc_size);
} }
void hmm_init_mem_stat(int res_pgnr, int dyc_en, int dyc_pgnr) void hmm_init_mem_stat(int res_pgnr, int dyc_en, int dyc_pgnr)
......
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