media: atomisp: simplify hive_isp_css_mm_hrt wrapper
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 25 May 2020 08:11:49 +0000 (10:11 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 11 Jun 2020 16:03:15 +0000 (18:03 +0200)
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
drivers/staging/media/atomisp/include/hmm/hmm_bo.h
drivers/staging/media/atomisp/pci/atomisp_acc.c
drivers/staging/media/atomisp/pci/atomisp_ioctl.c
drivers/staging/media/atomisp/pci/atomisp_subdev.c
drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.c
drivers/staging/media/atomisp/pci/hrt/hive_isp_css_mm_hrt.h
drivers/staging/media/atomisp/pci/ia_css_memory_access.c

index c7a55d05942535c0d6f55847c2b281168c748f61..b48eb7946a58646fbfd502e3b9993dcea07f8795 100644 (file)
@@ -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
index f847d1de860ef45d0c7835330e5a86dc2a14b2b0..7fcb93b6c0f5e509299e896ea6293f0e7612d52f 100644 (file)
@@ -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 */
index 21337c23bfa8e32ef25b81537640b173e9659e22..bb1f60fab786edf0507c47ec1fd40357e23ce577 100644 (file)
@@ -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. */
index 39400a8677aa5211b740791f7c8abb2e1d2d27f8..8aea90ecd50850671cb86a03f874f11ec7c717ee 100644 (file)
@@ -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);
index d3206ddf3b656ca5ae0fba9db46efb0105cf0404..830aefad9312e045cedbcd7bace527e2a4370911 100644 (file)
@@ -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. */
index 236f27b503862de915c62d88419f0c9264eace9e..14e02fd76ddf3f3ff8034be08730d08c43a041b7 100644 (file)
 
 #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)
index 818ecf90b1f5aecc149fbbecfd2513ef8acfc5cc..e4c90c268c42ce557878b209b45de07fd7980465 100644 (file)
 
 #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);
 
index 8d1356047448b01ac0f033105bb0822a6df3cd73..6084d54acac3e034f11d7e9e4087d1764f2721c4 100644 (file)
@@ -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);
 }