Commit f5cb5ada authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: atomisp: Drop userptr support from hmm

After the conversion to videobuf2 userptr support is no longer needed,
drop it.
Reviewed-by: default avatarAndy Shevchenko <andy@kernel.org>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 86c9abf8
...@@ -37,7 +37,6 @@ int hmm_init(void); ...@@ -37,7 +37,6 @@ int hmm_init(void);
void hmm_cleanup(void); void hmm_cleanup(void);
ia_css_ptr hmm_alloc(size_t bytes); ia_css_ptr hmm_alloc(size_t bytes);
ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr);
ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr); ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr);
void hmm_free(ia_css_ptr ptr); void hmm_free(ia_css_ptr ptr);
......
...@@ -74,7 +74,6 @@ ...@@ -74,7 +74,6 @@
enum hmm_bo_type { enum hmm_bo_type {
HMM_BO_PRIVATE, HMM_BO_PRIVATE,
HMM_BO_VMALLOC, HMM_BO_VMALLOC,
HMM_BO_USER,
HMM_BO_LAST, HMM_BO_LAST,
}; };
...@@ -208,7 +207,6 @@ int hmm_bo_allocated(struct hmm_buffer_object *bo); ...@@ -208,7 +207,6 @@ int hmm_bo_allocated(struct hmm_buffer_object *bo);
*/ */
int hmm_bo_alloc_pages(struct hmm_buffer_object *bo, int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,
enum hmm_bo_type type, enum hmm_bo_type type,
const void __user *userptr,
void *vmalloc_addr); void *vmalloc_addr);
void hmm_bo_free_pages(struct hmm_buffer_object *bo); void hmm_bo_free_pages(struct hmm_buffer_object *bo);
int hmm_bo_page_allocated(struct hmm_buffer_object *bo); int hmm_bo_page_allocated(struct hmm_buffer_object *bo);
......
...@@ -42,9 +42,8 @@ static bool hmm_initialized; ...@@ -42,9 +42,8 @@ static bool hmm_initialized;
/* /*
* p: private * p: private
* v: vmalloc * v: vmalloc
* u: user
*/ */
static const char hmm_bo_type_string[] = "pvu"; static const char hmm_bo_type_string[] = "pv";
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)
...@@ -168,7 +167,6 @@ void hmm_cleanup(void) ...@@ -168,7 +167,6 @@ void hmm_cleanup(void)
} }
static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
const void __user *userptr,
void *vmalloc_addr) void *vmalloc_addr)
{ {
unsigned int pgnr; unsigned int pgnr;
...@@ -193,7 +191,7 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, ...@@ -193,7 +191,7 @@ static 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, userptr, vmalloc_addr); ret = hmm_bo_alloc_pages(bo, type, vmalloc_addr);
if (ret) { if (ret) {
dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n"); dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n");
goto alloc_page_err; goto alloc_page_err;
...@@ -206,9 +204,8 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, ...@@ -206,9 +204,8 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
goto bind_err; goto bind_err;
} }
dev_dbg(atomisp_dev, dev_dbg(atomisp_dev, "pages: 0x%08x (%zu bytes), type: %d, vmalloc %p\n",
"%s: pages: 0x%08x (%zu bytes), type: %d, user ptr %p\n", bo->start, bytes, type, vmalloc);
__func__, bo->start, bytes, type, userptr);
return bo->start; return bo->start;
...@@ -222,17 +219,12 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, ...@@ -222,17 +219,12 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
ia_css_ptr hmm_alloc(size_t bytes) ia_css_ptr hmm_alloc(size_t bytes)
{ {
return __hmm_alloc(bytes, HMM_BO_PRIVATE, NULL, NULL); return __hmm_alloc(bytes, HMM_BO_PRIVATE, NULL);
} }
ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr) ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr)
{ {
return __hmm_alloc(bytes, HMM_BO_VMALLOC, NULL, vmalloc_addr); return __hmm_alloc(bytes, HMM_BO_VMALLOC, vmalloc_addr);
}
ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr)
{
return __hmm_alloc(bytes, HMM_BO_USER, userptr, NULL);
} }
void hmm_free(ia_css_ptr virt) void hmm_free(ia_css_ptr virt)
......
...@@ -652,49 +652,6 @@ static int alloc_private_pages(struct hmm_buffer_object *bo) ...@@ -652,49 +652,6 @@ static int alloc_private_pages(struct hmm_buffer_object *bo)
return 0; return 0;
} }
static void free_user_pages(struct hmm_buffer_object *bo,
unsigned int page_nr)
{
int i;
for (i = 0; i < page_nr; i++)
put_page(bo->pages[i]);
}
/*
* Convert user space virtual address into pages list
*/
static int alloc_user_pages(struct hmm_buffer_object *bo,
const void __user *userptr)
{
int page_nr;
userptr = untagged_addr(userptr);
/* Handle frame buffer allocated in user space */
mutex_unlock(&bo->mutex);
page_nr = get_user_pages_fast((unsigned long)userptr, bo->pgnr, 1, bo->pages);
mutex_lock(&bo->mutex);
/* can be written by caller, not forced */
if (page_nr != bo->pgnr) {
dev_err(atomisp_dev,
"get_user_pages err: bo->pgnr = %d, pgnr actually pinned = %d.\n",
bo->pgnr, page_nr);
if (page_nr < 0)
page_nr = 0;
goto out_of_mem;
}
return 0;
out_of_mem:
free_user_pages(bo, page_nr);
return -ENOMEM;
}
static int alloc_vmalloc_pages(struct hmm_buffer_object *bo, void *vmalloc_addr) static int alloc_vmalloc_pages(struct hmm_buffer_object *bo, void *vmalloc_addr)
{ {
void *vaddr = vmalloc_addr; void *vaddr = vmalloc_addr;
...@@ -716,16 +673,12 @@ static int alloc_vmalloc_pages(struct hmm_buffer_object *bo, void *vmalloc_addr) ...@@ -716,16 +673,12 @@ static int alloc_vmalloc_pages(struct hmm_buffer_object *bo, void *vmalloc_addr)
* allocate/free physical pages for the bo. * allocate/free physical pages for the bo.
* *
* type indicate where are the pages from. currently we have 3 types * type indicate where are the pages from. currently we have 3 types
* of memory: HMM_BO_PRIVATE, HMM_BO_VMALLOC, HMM_BO_USER. * of memory: HMM_BO_PRIVATE, HMM_BO_VMALLOC.
* *
* vmalloc_addr is only valid when type is HMM_BO_VMALLOC. * vmalloc_addr is only valid when type is HMM_BO_VMALLOC.
*
* userptr is only valid when type is HMM_BO_USER, it indicates
* the start address from user space task.
*/ */
int hmm_bo_alloc_pages(struct hmm_buffer_object *bo, int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,
enum hmm_bo_type type, enum hmm_bo_type type,
const void __user *userptr,
void *vmalloc_addr) void *vmalloc_addr)
{ {
int ret = -EINVAL; int ret = -EINVAL;
...@@ -745,8 +698,6 @@ int hmm_bo_alloc_pages(struct hmm_buffer_object *bo, ...@@ -745,8 +698,6 @@ int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,
ret = alloc_private_pages(bo); ret = alloc_private_pages(bo);
} else if (type == HMM_BO_VMALLOC) { } else if (type == HMM_BO_VMALLOC) {
ret = alloc_vmalloc_pages(bo, vmalloc_addr); ret = alloc_vmalloc_pages(bo, vmalloc_addr);
} else if (type == HMM_BO_USER) {
ret = alloc_user_pages(bo, userptr);
} else { } else {
dev_err(atomisp_dev, "invalid buffer type.\n"); dev_err(atomisp_dev, "invalid buffer type.\n");
ret = -EINVAL; ret = -EINVAL;
...@@ -792,8 +743,6 @@ void hmm_bo_free_pages(struct hmm_buffer_object *bo) ...@@ -792,8 +743,6 @@ void hmm_bo_free_pages(struct hmm_buffer_object *bo)
free_private_bo_pages(bo); free_private_bo_pages(bo);
else if (bo->type == HMM_BO_VMALLOC) else if (bo->type == HMM_BO_VMALLOC)
; /* No-op, nothing to do */ ; /* No-op, nothing to do */
else if (bo->type == HMM_BO_USER)
free_user_pages(bo, bo->pgnr);
else else
dev_err(atomisp_dev, "invalid buffer type.\n"); dev_err(atomisp_dev, "invalid buffer type.\n");
......
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