summaryrefslogtreecommitdiff
path: root/drivers/staging/media/atomisp/pci/hmm/hmm.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2022-09-26 18:45:46 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-11-25 08:12:15 +0000
commit931d87d204aa17d1ee853c1c327d025ec9f7f4f7 (patch)
tree17ecb8fa5729a3ade3070ecb47e6fa59329d6e78 /drivers/staging/media/atomisp/pci/hmm/hmm.c
parent813ceef062b53d68f296aa3cb944b21a091fabdb (diff)
downloadlinux-931d87d204aa17d1ee853c1c327d025ec9f7f4f7.tar.gz
media: atomisp: Add hmm_create_from_vmalloc_buf() function
Add a new hmm creating function to create a vmm object from a vmalloc-ed kernel buffer. This is a preparation patch for adding videobuf2 (and working MMAP mode) support. Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/staging/media/atomisp/pci/hmm/hmm.c')
-rw-r--r--drivers/staging/media/atomisp/pci/hmm/hmm.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index fc6cfe9f7744..a262477104fc 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -41,11 +41,10 @@ static bool hmm_initialized;
/*
* p: private
- * s: shared
+ * v: vmalloc
* u: user
- * i: ion
*/
-static const char hmm_bo_type_string[] = "psui";
+static const char hmm_bo_type_string[] = "pvu";
static ssize_t bo_show(struct device *dev, struct device_attribute *attr,
char *buf, struct list_head *bo_list, bool active)
@@ -168,7 +167,9 @@ void hmm_cleanup(void)
hmm_initialized = false;
}
-static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, const void __user *userptr)
+static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
+ const void __user *userptr,
+ void *vmalloc_addr)
{
unsigned int pgnr;
struct hmm_buffer_object *bo;
@@ -192,7 +193,7 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type, const void __
}
/* Allocate pages for memory */
- ret = hmm_bo_alloc_pages(bo, type, userptr);
+ ret = hmm_bo_alloc_pages(bo, type, userptr, vmalloc_addr);
if (ret) {
dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n");
goto alloc_page_err;
@@ -221,12 +222,17 @@ create_bo_err:
ia_css_ptr hmm_alloc(size_t bytes)
{
- return __hmm_alloc(bytes, HMM_BO_PRIVATE, NULL);
+ return __hmm_alloc(bytes, HMM_BO_PRIVATE, NULL, NULL);
+}
+
+ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr)
+{
+ return __hmm_alloc(bytes, HMM_BO_VMALLOC, NULL, vmalloc_addr);
}
ia_css_ptr hmm_create_from_userdata(size_t bytes, const void __user *userptr)
{
- return __hmm_alloc(bytes, HMM_BO_USER, userptr);
+ return __hmm_alloc(bytes, HMM_BO_USER, userptr, NULL);
}
void hmm_free(ia_css_ptr virt)