Commit 4fba2916 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: atomisp: get rid of the hrt/hive_isp_css_mm_hrt abstraction layer

Simplify the code by removing this extra memory management
abstraction layer.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 23239943
...@@ -53,7 +53,6 @@ atomisp-objs += \ ...@@ -53,7 +53,6 @@ atomisp-objs += \
pci/hmm/hmm_dynamic_pool.o \ pci/hmm/hmm_dynamic_pool.o \
pci/hmm/hmm.o \ pci/hmm/hmm.o \
pci/hmm/hmm_reserved_pool.o \ pci/hmm/hmm_reserved_pool.o \
pci/hrt/hive_isp_css_mm_hrt.o \
pci/ia_css_device_access.o \ pci/ia_css_device_access.o \
pci/ia_css_memory_access.o \ pci/ia_css_memory_access.o \
pci/isp/kernels/aa/aa_2/ia_css_aa2.host.o \ pci/isp/kernels/aa/aa_2/ia_css_aa2.host.o \
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "atomisp_compat.h" #include "atomisp_compat.h"
#include "atomisp_cmd.h" #include "atomisp_cmd.h"
#include "hrt/hive_isp_css_mm_hrt.h"
#include "memory_access/memory_access.h" #include "memory_access/memory_access.h"
#include "ia_css.h" #include "ia_css.h"
...@@ -353,16 +352,23 @@ int atomisp_acc_map(struct atomisp_sub_device *asd, struct atomisp_acc_map *map) ...@@ -353,16 +352,23 @@ int atomisp_acc_map(struct atomisp_sub_device *asd, struct atomisp_acc_map *map)
} }
pgnr = DIV_ROUND_UP(map->length, PAGE_SIZE); pgnr = DIV_ROUND_UP(map->length, PAGE_SIZE);
cssptr = hrt_isp_css_mm_alloc_user_ptr(map->length, if (pgnr < ((PAGE_ALIGN(map->length)) >> PAGE_SHIFT)) {
map->user_ptr, dev_err(atomisp_dev,
pgnr, "user space memory size is less than the expected size..\n");
(map->flags & ATOMISP_MAP_FLAG_CACHED)); return -ENOMEM;
} else if (pgnr > ((PAGE_ALIGN(map->length)) >> PAGE_SHIFT)) {
dev_err(atomisp_dev,
"user space memory size is large than the expected size..\n");
return -ENOMEM;
}
cssptr = hmm_alloc(map->length, HMM_BO_USER, 0, map->user_ptr,
map->flags & ATOMISP_MAP_FLAG_CACHED);
} else { } else {
/* Allocate private buffer. */ /* Allocate private buffer. */
if (map->flags & ATOMISP_MAP_FLAG_CACHED) cssptr = hmm_alloc(map->length, HMM_BO_PRIVATE, 0, NULL,
cssptr = hrt_isp_css_mm_calloc_cached(map->length); map->flags & ATOMISP_MAP_FLAG_CACHED);
else
cssptr = hrt_isp_css_mm_calloc(map->length);
} }
if (!cssptr) if (!cssptr)
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#include "atomisp_subdev.h" #include "atomisp_subdev.h"
#include "atomisp_dfs_tables.h" #include "atomisp_dfs_tables.h"
#include "hrt/hive_isp_css_mm_hrt.h" #include <hmm/hmm.h>
#include "sh_css_hrt.h" #include "sh_css_hrt.h"
#include "sh_css_defs.h" #include "sh_css_defs.h"
......
...@@ -261,7 +261,7 @@ void atomisp_css_frame_free(struct ia_css_frame *frame); ...@@ -261,7 +261,7 @@ void atomisp_css_frame_free(struct ia_css_frame *frame);
int atomisp_css_frame_map(struct ia_css_frame **frame, int atomisp_css_frame_map(struct ia_css_frame **frame,
const struct ia_css_frame_info *info, const struct ia_css_frame_info *info,
const void __user *data, uint16_t attribute, const void __user *data, uint16_t attribute,
void *context); unsigned int pgnr);
int atomisp_css_set_black_frame(struct atomisp_sub_device *asd, int atomisp_css_set_black_frame(struct atomisp_sub_device *asd,
const struct ia_css_frame *raw_black_frame); const struct ia_css_frame *raw_black_frame);
......
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
#include "atomisp_ioctl.h" #include "atomisp_ioctl.h"
#include "atomisp_acc.h" #include "atomisp_acc.h"
#include "hrt/hive_isp_css_mm_hrt.h"
#include <asm/intel-mid.h> #include <asm/intel-mid.h>
#include "ia_css_debug.h" #include "ia_css_debug.h"
...@@ -2187,9 +2185,9 @@ void atomisp_css_frame_free(struct ia_css_frame *frame) ...@@ -2187,9 +2185,9 @@ void atomisp_css_frame_free(struct ia_css_frame *frame)
int atomisp_css_frame_map(struct ia_css_frame **frame, int atomisp_css_frame_map(struct ia_css_frame **frame,
const struct ia_css_frame_info *info, const struct ia_css_frame_info *info,
const void __user *data, uint16_t attribute, const void __user *data, uint16_t attribute,
void *context) unsigned int pgnr)
{ {
if (ia_css_frame_map(frame, info, data, attribute, context) if (ia_css_frame_map(frame, info, data, attribute, pgnr)
!= IA_CSS_SUCCESS) != IA_CSS_SUCCESS)
return -ENOMEM; return -ENOMEM;
......
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include "atomisp-regs.h" #include "atomisp-regs.h"
#include "hmm/hmm.h" #include "hmm/hmm.h"
#include "hrt/hive_isp_css_mm_hrt.h"
#include "type_support.h" #include "type_support.h"
#include "device_access/device_access.h" #include "device_access/device_access.h"
#include "memory_access/memory_access.h" #include "memory_access/memory_access.h"
......
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
#include "device_access.h" #include "device_access.h"
#include "irq.h" #include "irq.h"
#include "hrt/hive_isp_css_mm_hrt.h"
static const char *DRIVER = "atomisp"; /* max size 15 */ static const char *DRIVER = "atomisp"; /* max size 15 */
static const char *CARD = "ATOM ISP"; /* max size 31 */ static const char *CARD = "ATOM ISP"; /* max size 31 */
...@@ -1183,8 +1181,6 @@ static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) ...@@ -1183,8 +1181,6 @@ static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
* address and reprograme out page table properly * address and reprograme out page table properly
*/ */
if (buf->memory == V4L2_MEMORY_USERPTR) { if (buf->memory == V4L2_MEMORY_USERPTR) {
struct hrt_userbuffer_attr attributes;
vb = pipe->capq.bufs[buf->index]; vb = pipe->capq.bufs[buf->index];
vm_mem = vb->priv; vm_mem = vb->priv;
if (!vm_mem) { if (!vm_mem) {
...@@ -1204,10 +1200,9 @@ static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) ...@@ -1204,10 +1200,9 @@ static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
goto error; goto error;
} }
attributes.pgnr = pgnr;
ret = atomisp_css_frame_map(&handle, &frame_info, ret = atomisp_css_frame_map(&handle, &frame_info,
(void __user *)buf->m.userptr, (void __user *)buf->m.userptr,
0, &attributes); 0, pgnr);
if (ret) { if (ret) {
dev_err(isp->dev, "Failed to map user buffer\n"); dev_err(isp->dev, "Failed to map user buffer\n");
goto error; goto error;
......
...@@ -42,8 +42,6 @@ ...@@ -42,8 +42,6 @@
#include "hmm/hmm.h" #include "hmm/hmm.h"
#include "atomisp_trace_event.h" #include "atomisp_trace_event.h"
#include "hrt/hive_isp_css_mm_hrt.h"
#include "device_access.h" #include "device_access.h"
/* Timeouts to wait for all subdevs to be registered */ /* Timeouts to wait for all subdevs to be registered */
......
...@@ -140,7 +140,7 @@ hrt_vaddress mmgr_mmap( ...@@ -140,7 +140,7 @@ hrt_vaddress mmgr_mmap(
const void __user *ptr, const void __user *ptr,
const size_t size, const size_t size,
u16 attribute, u16 attribute,
void *context); unsigned int pgnr);
/*! Zero initialise an allocation in memory /*! Zero initialise an allocation in memory
......
/*
* Support for Medifield PNW Camera Imaging ISP subsystem.
*
* Copyright (c) 2010 Intel Corporation. All Rights Reserved.
*
* Copyright (c) 2010 Silicon Hive www.siliconhive.com.
*
* This program 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 program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*/
#include "atomisp_internal.h"
#include "hive_isp_css_mm_hrt.h"
#include "hmm/hmm.h"
#define __page_align(size) (((size) + (PAGE_SIZE - 1)) & (~(PAGE_SIZE - 1)))
ia_css_ptr hrt_isp_css_mm_alloc(size_t bytes)
{
return hmm_alloc(bytes, HMM_BO_PRIVATE, 0, NULL, false);
}
ia_css_ptr hrt_isp_css_mm_alloc_user_ptr(size_t bytes,
const void __user *userptr,
unsigned int num_pages,
bool cached)
{
if (num_pages < ((__page_align(bytes)) >> PAGE_SHIFT))
dev_err(atomisp_dev,
"user space memory size is less than the expected size..\n");
else if (num_pages > ((__page_align(bytes))
>> PAGE_SHIFT))
dev_err(atomisp_dev,
"user space memory size is large than the expected size..\n");
return hmm_alloc(bytes, HMM_BO_USER, 0,
userptr, cached);
}
ia_css_ptr hrt_isp_css_mm_alloc_cached(size_t bytes)
{
return hmm_alloc(bytes, HMM_BO_PRIVATE, 0, NULL,
HMM_CACHED);
}
ia_css_ptr hrt_isp_css_mm_calloc(size_t bytes)
{
ia_css_ptr ptr = hrt_isp_css_mm_alloc(bytes);
if (ptr)
hmm_set(ptr, 0, bytes);
return ptr;
}
ia_css_ptr hrt_isp_css_mm_calloc_cached(size_t bytes)
{
ia_css_ptr ptr = hrt_isp_css_mm_alloc_cached(bytes);
if (ptr)
hmm_set(ptr, 0, bytes);
return ptr;
}
/*
* Support for Medfield PNW Camera Imaging ISP subsystem.
*
* Copyright (c) 2010 Intel Corporation. All Rights Reserved.
*
* Copyright (c) 2010 Silicon Hive www.siliconhive.com.
*
* This program 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 program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
*/
#ifndef _hive_isp_css_mm_hrt_h_
#define _hive_isp_css_mm_hrt_h_
#include <hmm/hmm.h>
#include <hrt/hive_isp_css_custom_host_hrt.h>
#define HRT_BUF_FLAG_CACHED BIT(0)
struct hrt_userbuffer_attr {
unsigned int pgnr;
};
/* Allocate memory, returns a virtual address */
ia_css_ptr hrt_isp_css_mm_alloc(size_t bytes);
ia_css_ptr hrt_isp_css_mm_alloc_user_ptr(size_t bytes,
const void __user *userptr,
unsigned int num_pages,
bool cached);
ia_css_ptr hrt_isp_css_mm_alloc_cached(size_t bytes);
/* allocate memory and initialize with zeros,
returns a virtual address */
ia_css_ptr hrt_isp_css_mm_calloc(size_t bytes);
ia_css_ptr hrt_isp_css_mm_calloc_cached(size_t bytes);
#endif /* _hive_isp_css_mm_hrt_h_ */
...@@ -336,7 +336,7 @@ ia_css_frame_map(struct ia_css_frame **frame, ...@@ -336,7 +336,7 @@ ia_css_frame_map(struct ia_css_frame **frame,
const struct ia_css_frame_info *info, const struct ia_css_frame_info *info,
const void __user *data, const void __user *data,
u16 attribute, u16 attribute,
void *context); unsigned int pgnr);
/* @brief Unmap a CSS frame structure. /* @brief Unmap a CSS frame structure.
* *
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
#include <assert_support.h> #include <assert_support.h>
#include <memory_access.h> #include <memory_access.h>
#include <ia_css_env.h> #include <ia_css_env.h>
#include <hrt/hive_isp_css_mm_hrt.h>
#include "atomisp_internal.h"
const hrt_vaddress mmgr_NULL = (hrt_vaddress)0; const hrt_vaddress mmgr_NULL = (hrt_vaddress)0;
const hrt_vaddress mmgr_EXCEPTION = (hrt_vaddress)-1; const hrt_vaddress mmgr_EXCEPTION = (hrt_vaddress)-1;
...@@ -31,20 +32,20 @@ mmgr_malloc(const size_t size) ...@@ -31,20 +32,20 @@ mmgr_malloc(const size_t size)
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)
{ {
u16 masked_attrs = attrs & MMGR_ATTRIBUTE_MASK; u16 masked_attrs = attrs & MMGR_ATTRIBUTE_MASK;
ia_css_ptr data;
WARN_ON(attrs & MMGR_ATTRIBUTE_CONTIGUOUS); WARN_ON(attrs & MMGR_ATTRIBUTE_CONTIGUOUS);
if (masked_attrs & MMGR_ATTRIBUTE_CLEARED) { data = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL,
if (masked_attrs & MMGR_ATTRIBUTE_CACHED) masked_attrs & MMGR_ATTRIBUTE_CACHED);
return (ia_css_ptr) hrt_isp_css_mm_calloc_cached(size);
else if (!data)
return (ia_css_ptr) hrt_isp_css_mm_calloc(size); return 0;
} else {
if (masked_attrs & MMGR_ATTRIBUTE_CACHED) if (masked_attrs & MMGR_ATTRIBUTE_CLEARED)
return (ia_css_ptr) hrt_isp_css_mm_alloc_cached(size); hmm_set(data, 0, size);
else
return (ia_css_ptr) hrt_isp_css_mm_alloc(size); return (ia_css_ptr)data;
}
} }
hrt_vaddress hrt_vaddress
...@@ -74,11 +75,19 @@ mmgr_store(const hrt_vaddress vaddr, const void *data, const size_t size) ...@@ -74,11 +75,19 @@ mmgr_store(const hrt_vaddress vaddr, const void *data, const size_t size)
hrt_vaddress hrt_vaddress
mmgr_mmap(const void __user *ptr, const size_t size, mmgr_mmap(const void __user *ptr, const size_t size,
u16 attribute, void *context) u16 attribute, unsigned int pgnr)
{ {
struct hrt_userbuffer_attr *userbuffer_attr = context; 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);
return hrt_isp_css_mm_alloc_user_ptr(
size, ptr, userbuffer_attr->pgnr,
attribute & HRT_BUF_FLAG_CACHED);
} }
...@@ -152,7 +152,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame, ...@@ -152,7 +152,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame,
const struct ia_css_frame_info *info, const struct ia_css_frame_info *info,
const void __user *data, const void __user *data,
u16 attribute, u16 attribute,
void *context) unsigned int pgnr)
{ {
enum ia_css_err err = IA_CSS_SUCCESS; enum ia_css_err err = IA_CSS_SUCCESS;
struct ia_css_frame *me; struct ia_css_frame *me;
...@@ -169,7 +169,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame, ...@@ -169,7 +169,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame,
/* use mmgr_mmap to map */ /* use mmgr_mmap to map */
me->data = (ia_css_ptr) mmgr_mmap(data, me->data = (ia_css_ptr) mmgr_mmap(data,
me->data_bytes, me->data_bytes,
attribute, context); attribute, pgnr);
if (me->data == mmgr_NULL) if (me->data == mmgr_NULL)
err = IA_CSS_ERR_INVALID_ARGUMENTS; err = IA_CSS_ERR_INVALID_ARGUMENTS;
} }
......
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