public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Tsuchiya Yuto <kitakar@gmail.com>,
	Andy Shevchenko <andy@kernel.org>,
	Yury Luneff <yury.lunev@gmail.com>,
	Nable <nable.maininbox@googlemail.com>,
	andrey.i.trufanov@gmail.com, Fabio Aiuto <fabioaiuto83@gmail.com>,
	linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: [PATCH 10/20] media: atomisp: Drop userptr support from hmm
Date: Sun, 20 Nov 2022 23:40:51 +0100	[thread overview]
Message-ID: <20221120224101.746199-11-hdegoede@redhat.com> (raw)
In-Reply-To: <20221120224101.746199-1-hdegoede@redhat.com>

After the conversion to videobuf2 userptr support is no longer needed,
drop it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../staging/media/atomisp/include/hmm/hmm.h   |  1 -
 .../media/atomisp/include/hmm/hmm_bo.h        |  2 -
 drivers/staging/media/atomisp/pci/hmm/hmm.c   | 19 +++----
 .../staging/media/atomisp/pci/hmm/hmm_bo.c    | 53 +------------------
 4 files changed, 7 insertions(+), 68 deletions(-)

diff --git a/drivers/staging/media/atomisp/include/hmm/hmm.h b/drivers/staging/media/atomisp/include/hmm/hmm.h
index b81b8580d405..2bc323b34f89 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm.h
@@ -37,7 +37,6 @@ int hmm_init(void);
 void hmm_cleanup(void);
 
 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);
 
 void hmm_free(ia_css_ptr ptr);
diff --git a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
index a51d89f0b5cc..b4c03e0ca9c0 100644
--- a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
+++ b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h
@@ -74,7 +74,6 @@
 enum hmm_bo_type {
 	HMM_BO_PRIVATE,
 	HMM_BO_VMALLOC,
-	HMM_BO_USER,
 	HMM_BO_LAST,
 };
 
@@ -208,7 +207,6 @@ int hmm_bo_allocated(struct hmm_buffer_object *bo);
  */
 int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,
 		       enum hmm_bo_type type,
-		       const void __user *userptr,
 		       void *vmalloc_addr);
 void hmm_bo_free_pages(struct hmm_buffer_object *bo);
 int hmm_bo_page_allocated(struct hmm_buffer_object *bo);
diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c b/drivers/staging/media/atomisp/pci/hmm/hmm.c
index a262477104fc..e266628be332 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c
@@ -42,9 +42,8 @@ static bool hmm_initialized;
 /*
  * p: private
  * 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,
 		       char *buf, struct list_head *bo_list, bool active)
@@ -168,7 +167,6 @@ void hmm_cleanup(void)
 }
 
 static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
-			      const void __user *userptr,
 			      void *vmalloc_addr)
 {
 	unsigned int pgnr;
@@ -193,7 +191,7 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
 	}
 
 	/* 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) {
 		dev_err(atomisp_dev, "hmm_bo_alloc_pages failed.\n");
 		goto alloc_page_err;
@@ -207,8 +205,8 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
 	}
 
 	dev_dbg(atomisp_dev,
-		"%s: pages: 0x%08x (%zu bytes), type: %d, user ptr %p\n",
-		__func__, bo->start, bytes, type, userptr);
+		"%s: pages: 0x%08x (%zu bytes), type: %d, vmalloc %p\n",
+		__func__, bo->start, bytes, type, vmalloc);
 
 	return bo->start;
 
@@ -222,17 +220,12 @@ static ia_css_ptr __hmm_alloc(size_t bytes, enum hmm_bo_type type,
 
 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)
 {
-	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, NULL);
+	return __hmm_alloc(bytes, HMM_BO_VMALLOC, vmalloc_addr);
 }
 
 void hmm_free(ia_css_ptr virt)
diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
index 3c150268db51..11c43e296de1 100644
--- a/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
+++ b/drivers/staging/media/atomisp/pci/hmm/hmm_bo.c
@@ -652,49 +652,6 @@ static int alloc_private_pages(struct hmm_buffer_object *bo)
 	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)
 {
 	void *vaddr = 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.
  *
  * 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.
- *
- * 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,
 		       enum hmm_bo_type type,
-		       const void __user *userptr,
 		       void *vmalloc_addr)
 {
 	int ret = -EINVAL;
@@ -745,8 +698,6 @@ int hmm_bo_alloc_pages(struct hmm_buffer_object *bo,
 		ret = alloc_private_pages(bo);
 	} else if (type == HMM_BO_VMALLOC) {
 		ret = alloc_vmalloc_pages(bo, vmalloc_addr);
-	} else if (type == HMM_BO_USER) {
-		ret = alloc_user_pages(bo, userptr);
 	} else {
 		dev_err(atomisp_dev, "invalid buffer type.\n");
 		ret = -EINVAL;
@@ -792,8 +743,6 @@ void hmm_bo_free_pages(struct hmm_buffer_object *bo)
 		free_private_bo_pages(bo);
 	else if (bo->type == HMM_BO_VMALLOC)
 		; /* No-op, nothing to do */
-	else if (bo->type == HMM_BO_USER)
-		free_user_pages(bo, bo->pgnr);
 	else
 		dev_err(atomisp_dev, "invalid buffer type.\n");
 
-- 
2.38.1


  parent reply	other threads:[~2022-11-20 22:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-20 22:40 [PATCH 00/20] media: atomisp: Misc. cleanups / fixes Hans de Goede
2022-11-20 22:40 ` [PATCH 01/20] media: atomisp: Silence: 'atomisp_q_one_s3a_buffer: drop one s3a stat which has exp_id xx' log messages Hans de Goede
2022-11-21  8:54   ` Andy Shevchenko
2022-11-21 12:27     ` Hans de Goede
2022-11-20 22:40 ` [PATCH 02/20] media: atomisp: Remove accelerator pipe creation code Hans de Goede
2022-11-20 22:40 ` [PATCH 03/20] media: atomisp: Remove unused QOS defines / structure member Hans de Goede
2022-11-20 22:40 ` [PATCH 04/20] media: atomisp: Flush queue on atomisp_css_start() error Hans de Goede
2022-11-20 22:40 ` [PATCH 05/20] media: atomisp: Log an error on failing to alloc private-mem Hans de Goede
2022-11-21  8:58   ` Andy Shevchenko
2022-11-21 12:29     ` Hans de Goede
2022-11-20 22:40 ` [PATCH 06/20] media: atomisp: Fix deadlock when the /dev/video# node is closed while still streaming Hans de Goede
2022-11-20 22:40 ` [PATCH 07/20] media: atomisp: Remove 2 unused accelerator mode related functions Hans de Goede
2022-11-20 22:40 ` [PATCH 08/20] media: atomisp: Remove atomisp_css_yuvpp_configure_viewfinder() function Hans de Goede
2022-11-20 22:40 ` [PATCH 09/20] media: atomisp: Remove unused ia_css_frame_*() functions Hans de Goede
2022-11-20 22:40 ` Hans de Goede [this message]
2022-11-21  9:01   ` [PATCH 10/20] media: atomisp: Drop userptr support from hmm Andy Shevchenko
2022-11-21 12:31     ` Hans de Goede
2022-11-20 22:40 ` [PATCH 11/20] media: atomisp: Remove double atomisp_mrfld_power_down()/_up() calls from atomisp_reset() Hans de Goede
2022-11-20 22:40 ` [PATCH 12/20] media: atomisp: Remove atomisp_mrfld_power_down()/_up() Hans de Goede
2022-11-20 22:40 ` [PATCH 13/20] media: atomisp: Remove clearing of config from atomisp_css_uninit() Hans de Goede
2022-11-20 22:40 ` [PATCH 14/20] media: atomisp: Remove atomisp_css_suspend()/_resume() Hans de Goede
2022-11-20 22:40 ` [PATCH 15/20] media: atomisp: Remove sw_contex.power_state checks Hans de Goede
2022-11-21  9:09   ` Andy Shevchenko
2022-11-21  9:16     ` Andy Shevchenko
2022-11-20 22:40 ` [PATCH 16/20] media: atomisp: Remove duplication between runtime-pm and normal-pm code Hans de Goede
2022-11-20 22:40 ` [PATCH 17/20] media: atomisp: Move calling of css_[un]init() to power_on()/_off() Hans de Goede
2022-11-21  9:14   ` Andy Shevchenko
2022-11-21 12:33     ` Hans de Goede
2022-11-20 22:40 ` [PATCH 18/20] media: atomisp: Remove atomisp_ospm_dphy_down() call from probe error path Hans de Goede
2022-11-20 22:41 ` [PATCH 19/20] media: atomisp: Remove atomisp_ospm_dphy_up()/_down() functions Hans de Goede
2022-11-20 22:41 ` [PATCH 20/20] media: atomisp_ov2680: Fix 1280x720 -> 1296x736 resolution Hans de Goede
2022-11-21  9:20 ` [PATCH 00/20] media: atomisp: Misc. cleanups / fixes Andy Shevchenko
2022-11-21 12:40   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221120224101.746199-11-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andrey.i.trufanov@gmail.com \
    --cc=andy@kernel.org \
    --cc=fabioaiuto83@gmail.com \
    --cc=kitakar@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=nable.maininbox@googlemail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yury.lunev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox