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 += \
pci/hmm/hmm_dynamic_pool.o \
pci/hmm/hmm.o \
pci/hmm/hmm_reserved_pool.o \
pci/hrt/hive_isp_css_mm_hrt.o \
pci/ia_css_device_access.o \
pci/ia_css_memory_access.o \
pci/isp/kernels/aa/aa_2/ia_css_aa2.host.o \
......
......@@ -28,7 +28,6 @@
#include "atomisp_compat.h"
#include "atomisp_cmd.h"
#include "hrt/hive_isp_css_mm_hrt.h"
#include "memory_access/memory_access.h"
#include "ia_css.h"
......@@ -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);
cssptr = hrt_isp_css_mm_alloc_user_ptr(map->length,
map->user_ptr,
pgnr,
(map->flags & ATOMISP_MAP_FLAG_CACHED));
if (pgnr < ((PAGE_ALIGN(map->length)) >> PAGE_SHIFT)) {
dev_err(atomisp_dev,
"user space memory size is less than the expected size..\n");
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 {
/* Allocate private buffer. */
if (map->flags & ATOMISP_MAP_FLAG_CACHED)
cssptr = hrt_isp_css_mm_calloc_cached(map->length);
else
cssptr = hrt_isp_css_mm_calloc(map->length);
cssptr = hmm_alloc(map->length, HMM_BO_PRIVATE, 0, NULL,
map->flags & ATOMISP_MAP_FLAG_CACHED);
}
if (!cssptr)
......
......@@ -44,7 +44,7 @@
#include "atomisp_subdev.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_defs.h"
......
......@@ -261,7 +261,7 @@ void atomisp_css_frame_free(struct ia_css_frame *frame);
int atomisp_css_frame_map(struct ia_css_frame **frame,
const struct ia_css_frame_info *info,
const void __user *data, uint16_t attribute,
void *context);
unsigned int pgnr);
int atomisp_css_set_black_frame(struct atomisp_sub_device *asd,
const struct ia_css_frame *raw_black_frame);
......
......@@ -32,8 +32,6 @@
#include "atomisp_ioctl.h"
#include "atomisp_acc.h"
#include "hrt/hive_isp_css_mm_hrt.h"
#include <asm/intel-mid.h>
#include "ia_css_debug.h"
......@@ -2187,9 +2185,9 @@ void atomisp_css_frame_free(struct ia_css_frame *frame)
int atomisp_css_frame_map(struct ia_css_frame **frame,
const struct ia_css_frame_info *info,
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)
return -ENOMEM;
......
......@@ -34,8 +34,6 @@
#include "atomisp-regs.h"
#include "hmm/hmm.h"
#include "hrt/hive_isp_css_mm_hrt.h"
#include "type_support.h"
#include "device_access/device_access.h"
#include "memory_access/memory_access.h"
......
......@@ -39,8 +39,6 @@
#include "device_access.h"
#include "irq.h"
#include "hrt/hive_isp_css_mm_hrt.h"
static const char *DRIVER = "atomisp"; /* max size 15 */
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)
* address and reprograme out page table properly
*/
if (buf->memory == V4L2_MEMORY_USERPTR) {
struct hrt_userbuffer_attr attributes;
vb = pipe->capq.bufs[buf->index];
vm_mem = vb->priv;
if (!vm_mem) {
......@@ -1204,10 +1200,9 @@ static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
goto error;
}
attributes.pgnr = pgnr;
ret = atomisp_css_frame_map(&handle, &frame_info,
(void __user *)buf->m.userptr,
0, &attributes);
0, pgnr);
if (ret) {
dev_err(isp->dev, "Failed to map user buffer\n");
goto error;
......
......@@ -42,8 +42,6 @@
#include "hmm/hmm.h"
#include "atomisp_trace_event.h"
#include "hrt/hive_isp_css_mm_hrt.h"
#include "device_access.h"
/* Timeouts to wait for all subdevs to be registered */
......
......@@ -140,7 +140,7 @@ hrt_vaddress mmgr_mmap(
const void __user *ptr,
const size_t size,
u16 attribute,
void *context);
unsigned int pgnr);
/*! 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,
const struct ia_css_frame_info *info,
const void __user *data,
u16 attribute,
void *context);
unsigned int pgnr);
/* @brief Unmap a CSS frame structure.
*
......
......@@ -17,7 +17,8 @@
#include <assert_support.h>
#include <memory_access.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_EXCEPTION = (hrt_vaddress)-1;
......@@ -31,20 +32,20 @@ mmgr_malloc(const size_t size)
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);
if (masked_attrs & MMGR_ATTRIBUTE_CLEARED) {
if (masked_attrs & MMGR_ATTRIBUTE_CACHED)
return (ia_css_ptr) hrt_isp_css_mm_calloc_cached(size);
else
return (ia_css_ptr) hrt_isp_css_mm_calloc(size);
} else {
if (masked_attrs & MMGR_ATTRIBUTE_CACHED)
return (ia_css_ptr) hrt_isp_css_mm_alloc_cached(size);
else
return (ia_css_ptr) hrt_isp_css_mm_alloc(size);
}
data = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL,
masked_attrs & MMGR_ATTRIBUTE_CACHED);
if (!data)
return 0;
if (masked_attrs & MMGR_ATTRIBUTE_CLEARED)
hmm_set(data, 0, size);
return (ia_css_ptr)data;
}
hrt_vaddress
......@@ -74,11 +75,19 @@ mmgr_store(const hrt_vaddress vaddr, const void *data, const size_t size)
hrt_vaddress
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,
const struct ia_css_frame_info *info,
const void __user *data,
u16 attribute,
void *context)
unsigned int pgnr)
{
enum ia_css_err err = IA_CSS_SUCCESS;
struct ia_css_frame *me;
......@@ -169,7 +169,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame,
/* use mmgr_mmap to map */
me->data = (ia_css_ptr) mmgr_mmap(data,
me->data_bytes,
attribute, context);
attribute, pgnr);
if (me->data == mmgr_NULL)
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