From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> To: unlisted-recipients:; (no To-header on input) Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, Sakari Ailus <sakari.ailus@linux.intel.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 01/41] media: atomisp: simplify hive_isp_css_mm_hrt wrapper Date: Sat, 30 May 2020 08:55:18 +0200 Message-ID: <fee8b40da7cc0499b64abc705dcd81964d9057f2.1590821410.git.mchehab+huawei@kernel.org> (raw) In-Reply-To: <cover.1590821410.git.mchehab+huawei@kernel.org> The code there is a wrapper for hmm/ wrapper. Simplify it, and get rid of ION-specific code. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> --- drivers/staging/media/atomisp/Makefile | 5 -- .../media/atomisp/include/hmm/hmm_bo.h | 9 --- .../staging/media/atomisp/pci/atomisp_acc.c | 2 +- .../staging/media/atomisp/pci/atomisp_ioctl.c | 35 --------- .../media/atomisp/pci/atomisp_subdev.c | 5 -- .../atomisp/pci/hrt/hive_isp_css_mm_hrt.c | 77 +++---------------- .../atomisp/pci/hrt/hive_isp_css_mm_hrt.h | 12 --- .../media/atomisp/pci/ia_css_memory_access.c | 1 - 8 files changed, 13 insertions(+), 133 deletions(-) diff --git a/drivers/staging/media/atomisp/Makefile b/drivers/staging/media/atomisp/Makefile index c7a55d059425..b48eb7946a58 100644 --- a/drivers/staging/media/atomisp/Makefile +++ b/drivers/staging/media/atomisp/Makefile @@ -327,11 +327,6 @@ INCLUDES_cht += \ # -I$(atomisp)/pci/css_2401_system/hrt/ \ # -I$(atomisp)/pci/css_2401_system/hive_isp_css_2401_system_generated/ \ - -ifeq ($(CONFIG_ION),y) -INCLUDES += -I$(srctree)/drivers/staging/android/ion -endif - DEFINES := -DHRT_HW -DHRT_ISP_CSS_CUSTOM_HOST -DHRT_USE_VIR_ADDRS -D__HOST__ #DEFINES += -DUSE_DYNAMIC_BIN #DEFINES += -DISP_POWER_GATING diff --git a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h index f847d1de860e..7fcb93b6c0f5 100644 --- a/drivers/staging/media/atomisp/include/hmm/hmm_bo.h +++ b/drivers/staging/media/atomisp/include/hmm/hmm_bo.h @@ -77,9 +77,6 @@ enum hmm_bo_type { HMM_BO_PRIVATE, HMM_BO_SHARE, HMM_BO_USER, -#ifdef CONFIG_ION - HMM_BO_ION, -#endif HMM_BO_LAST, }; @@ -111,9 +108,6 @@ struct hmm_bo_device { /* list lock is used to protect the entire_bo_list */ spinlock_t list_lock; -#ifdef CONFIG_ION - struct ion_client *iclient; -#endif int flag; /* linked list for entire buffer object */ @@ -142,9 +136,6 @@ struct hmm_buffer_object { struct hmm_page_object *page_obj; /* physical pages */ int from_highmem; int mmap_count; -#ifdef CONFIG_ION - struct ion_handle *ihandle; -#endif int status; int mem_type; void *vmap_addr; /* kernel virtual address by vmap */ diff --git a/drivers/staging/media/atomisp/pci/atomisp_acc.c b/drivers/staging/media/atomisp/pci/atomisp_acc.c index 21337c23bfa8..bb1f60fab786 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_acc.c +++ b/drivers/staging/media/atomisp/pci/atomisp_acc.c @@ -355,7 +355,7 @@ 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, HRT_USR_PTR, + pgnr, (map->flags & ATOMISP_MAP_FLAG_CACHED)); } else { /* Allocate private buffer. */ diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 39400a8677aa..8aea90ecd508 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1205,41 +1205,6 @@ static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) } attributes.pgnr = pgnr; - attributes.type = HRT_USR_PTR; -#ifdef CONFIG_ION - if (!atomisp_hw_is_isp2401) { - if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_ION) - attributes.type = HRT_USR_ION; - } else { - if (buf->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_ION) { - attributes.type = HRT_USR_ION; - if (asd->ion_dev_fd->val != ION_FD_UNSET) { - dev_dbg(isp->dev, "ION buffer queued, share_fd=%lddev_fd=%d.\n", - buf->m.userptr, asd->ion_dev_fd->val); - /* - * Make sure the shared fd we just got - * from user space isn't larger than - * the space we have for it. - */ - if ((buf->m.userptr & - (ATOMISP_ION_DEVICE_FD_MASK)) != 0) { - dev_err(isp->dev, - "Error: v4l2 buffer fd:0X%0lX > 0XFFFF.\n", - buf->m.userptr); - ret = -EINVAL; - goto error; - } - buf->m.userptr |= asd->ion_dev_fd->val << - ATOMISP_ION_DEVICE_FD_OFFSET; - } else { - dev_err(isp->dev, "v4l2 buffer type is ION, \ - but no dev fd set from userspace.\n"); - ret = -EINVAL; - goto error; - } - } - } -#endif ret = atomisp_css_frame_map(&handle, &frame_info, (void __user *)buf->m.userptr, 0, &attributes); diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index d3206ddf3b65..830aefad9312 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -1223,11 +1223,6 @@ static int isp_subdev_init_entities(struct atomisp_sub_device *asd) asd->select_isp_version = v4l2_ctrl_new_custom(&asd->ctrl_handler, &ctrl_select_isp_version, NULL); -#if 0 /* #ifdef CONFIG_ION */ - asd->ion_dev_fd = v4l2_ctrl_new_custom(&asd->ctrl_handler, - &ctrl_ion_dev_fd, - NULL); -#endif } /* Make controls visible on subdev as well. */ diff --git a/drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.c b/drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.c index 236f27b50386..14e02fd76ddf 100644 --- a/drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.c +++ b/drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.c @@ -24,85 +24,32 @@ #define __page_align(size) (((size) + (PAGE_SIZE - 1)) & (~(PAGE_SIZE - 1))) -static void __user *my_userptr; -static unsigned int my_num_pages; -static enum hrt_userptr_type my_usr_type; - -void hrt_isp_css_mm_set_user_ptr(void __user *userptr, - unsigned int num_pages, - enum hrt_userptr_type type) -{ - my_userptr = userptr; - my_num_pages = num_pages; - my_usr_type = type; -} - -static ia_css_ptr __hrt_isp_css_mm_alloc(size_t bytes, - const void __user *userptr, - unsigned int num_pages, - enum hrt_userptr_type type, - bool cached) -{ -#ifdef CONFIG_ION - if (type == HRT_USR_ION) - return hmm_alloc(bytes, HMM_BO_ION, 0, - userptr, cached); - -#endif - if (type == HRT_USR_PTR) { - if (!userptr) - return hmm_alloc(bytes, HMM_BO_PRIVATE, 0, - NULL, cached); - else { - 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); - } - } else { - dev_err(atomisp_dev, "user ptr type is incorrect.\n"); - return 0; - } -} - ia_css_ptr hrt_isp_css_mm_alloc(size_t bytes) { - return __hrt_isp_css_mm_alloc(bytes, my_userptr, - my_num_pages, my_usr_type, false); + 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, - enum hrt_userptr_type type, bool cached) { - return __hrt_isp_css_mm_alloc(bytes, userptr, num_pages, - type, 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) { - if (!my_userptr) - return hmm_alloc(bytes, HMM_BO_PRIVATE, 0, NULL, + return hmm_alloc(bytes, HMM_BO_PRIVATE, 0, NULL, HMM_CACHED); - else { - if (my_num_pages < ((__page_align(bytes)) >> PAGE_SHIFT)) - dev_err(atomisp_dev, - "user space memory size is less than the expected size..\n"); - else if (my_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, - my_userptr, HMM_CACHED); - } } ia_css_ptr hrt_isp_css_mm_calloc(size_t bytes) diff --git a/drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.h b/drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.h index 818ecf90b1f5..e4c90c268c42 100644 --- a/drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.h +++ b/drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.h @@ -25,27 +25,15 @@ #define HRT_BUF_FLAG_CACHED BIT(0) -enum hrt_userptr_type { - HRT_USR_PTR = 0, -#ifdef CONFIG_ION - HRT_USR_ION, -#endif -}; - struct hrt_userbuffer_attr { - enum hrt_userptr_type type; unsigned int pgnr; }; -void hrt_isp_css_mm_set_user_ptr(void __user *userptr, - unsigned int num_pages, enum hrt_userptr_type); - /* 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, - enum hrt_userptr_type, bool cached); ia_css_ptr hrt_isp_css_mm_alloc_cached(size_t bytes); diff --git a/drivers/staging/media/atomisp/pci/ia_css_memory_access.c b/drivers/staging/media/atomisp/pci/ia_css_memory_access.c index 8d1356047448..6084d54acac3 100644 --- a/drivers/staging/media/atomisp/pci/ia_css_memory_access.c +++ b/drivers/staging/media/atomisp/pci/ia_css_memory_access.c @@ -80,6 +80,5 @@ mmgr_mmap(const void __user *ptr, const size_t size, return hrt_isp_css_mm_alloc_user_ptr( size, ptr, userbuffer_attr->pgnr, - userbuffer_attr->type, attribute & HRT_BUF_FLAG_CACHED); } -- 2.26.2
next prev parent reply other threads:[~2020-05-30 6:59 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-05-30 6:55 [PATCH v2 00/41] More atomisp fixes and cleanups Mauro Carvalho Chehab 2020-05-30 6:55 ` Mauro Carvalho Chehab [this message] 2020-05-30 6:55 ` [PATCH v2 02/41] media: atomisp: get rid of the hrt/hive_isp_css_mm_hrt abstraction layer Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 03/41] media: atomisp: reduce abstraction at ia_css_memory_access Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 04/41] media: atomisp: go one step further to drop ia_css_memory_access.c Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 05/41] media: atomisp: get rid of mmgr_load and mmgr_store Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 06/41] media: atomisp: get rid of unused memory_realloc code Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 07/41] media: atomisp: change the type returned by mmgr alloc Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 08/41] media: atomisp: get rid of memory_access.c Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 09/41] media: atomisp: hmm_bo: untag user pointers Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 10/41] media: atomisp: add debug message to help debugging hmm code Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 11/41] media: atomisp: use Yocto Aero default hmm pool sizes Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 12/41] media: atomisp: get rid of a warning message Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 13/41] media: atomisp: fix driver caps Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 14/41] media: atomisp: use pin_user_pages() for memory allocation Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 15/41] media: atomisp: add debug for hmm alloc Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 16/41] media: atomisp: improve warning for IRQ enable function Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 17/41] media: atomisp: add debug functions for received events Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 18/41] media: atomisp: add more comments about frame allocation Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 19/41] media: atomisp: remove kvmalloc/kvcalloc abstractions Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 20/41] media: atomisp: avoid OOPS due to non-existing ref_frames Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 21/41] media: atomisp: Clean up if block in sh_css_sp_init_stage Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 22/41] media: atomisp: Remove second increment of count in atomisp_subdev_probe Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 23/41] media: atomisp: Remove unnecessary NULL checks in ia_css_pipe_load_extension Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 24/41] media: atomisp: Remove unnecessary NULL check in atomisp_param Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 25/41] media: atomisp: Avoid overflow in compute_blending Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 26/41] media: atomisp: Remove binary_supports_input_format Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 27/41] media: atomisp: avoid an extra memset() when alloc memory Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 28/41] media: atomisp: remove some trivial wrappers from compat css20 Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 29/41] media: atomisp: do another round of coding style cleanup Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 31/41] media: atomisp: get rid of an error abstraction layer Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 32/41] media: atomisp: don't cause a warn if probe failed Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 33/41] media: atomisp: get rid of a bunch of other wrappers Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 34/41] media: atomisp: get rid of system_types.h Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 35/41] media: atomisp: provide more details about the firmware binaries Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 36/41] media: atomisp: print firmware data during load Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 37/41] media: atomisp: allow passing firmware name at modprobe time Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 38/41] media: atomisp: add a debug message at hmm free Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 39/41] media: atomisp: add some debug messages when binaries are used Mauro Carvalho Chehab 2020-05-30 6:55 ` [PATCH v2 40/41] media: atomisp: get rid of set_fs() dirty hacks Mauro Carvalho Chehab
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=fee8b40da7cc0499b64abc705dcd81964d9057f2.1590821410.git.mchehab+huawei@kernel.org \ --to=mchehab+huawei@kernel.org \ --cc=devel@driverdev.osuosl.org \ --cc=gregkh@linuxfoundation.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=sakari.ailus@linux.intel.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
Unnamed repository; edit this file 'description' to name the repository. This inbox may be cloned and mirrored by anyone: git clone --mirror http://archive.lwn.net:8080/linux-media/0 linux-media/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-media linux-media/ http://archive.lwn.net:8080/linux-media \ linux-media@vger.kernel.org lwn-linux-media@archive.lwn.net public-inbox-index linux-media Example config snippet for mirrors. Newsgroup available over NNTP: nntp://archive.lwn.net/lwn.kernel.linux-media AGPL code for this site: git clone https://public-inbox.org/public-inbox.git