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 04/41] media: atomisp: go one step further to drop ia_css_memory_access.c Date: Sat, 30 May 2020 08:55:21 +0200 Message-ID: <dad0d48d7c31c157cf5354c3fda9bc00214f650b.1590821410.git.mchehab+huawei@kernel.org> (raw) In-Reply-To: <cover.1590821410.git.mchehab+huawei@kernel.org> Move the attrs handling into hmm, simplifying even further what the ia_css_memory_access.c file does. Yet, the returned type for ia_css_memory_access.c is an integer, instead of a pointer. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> --- .../staging/media/atomisp/include/hmm/hmm.h | 3 ++- .../media/atomisp/include/linux/atomisp.h | 2 ++ .../memory_access/memory_access.h | 3 --- drivers/staging/media/atomisp/pci/hmm/hmm.c | 11 ++++++++-- .../media/atomisp/pci/ia_css_memory_access.c | 21 +------------------ .../atomisp/pci/runtime/frame/src/frame.c | 4 ++-- .../staging/media/atomisp/pci/sh_css_params.c | 8 +++---- 7 files changed, 20 insertions(+), 32 deletions(-) diff --git a/drivers/staging/media/atomisp/include/hmm/hmm.h b/drivers/staging/media/atomisp/include/hmm/hmm.h index e2149b16c9fd..a661c039a2cc 100644 --- a/drivers/staging/media/atomisp/include/hmm/hmm.h +++ b/drivers/staging/media/atomisp/include/hmm/hmm.h @@ -35,7 +35,8 @@ int hmm_init(void); void hmm_cleanup(void); ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, - int from_highmem, const void __user *userptr, bool cached); + int from_highmem, const void __user *userptr, + const uint16_t attrs); void hmm_free(ia_css_ptr ptr); int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes); int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes); diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h b/drivers/staging/media/atomisp/include/linux/atomisp.h index e9670749bae0..fc2e76694613 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp.h @@ -917,6 +917,8 @@ struct atomisp_acc_map { #define ATOMISP_MAP_FLAG_NOFLUSH 0x0001 /* Do not flush cache */ #define ATOMISP_MAP_FLAG_CACHED 0x0002 /* Enable cache */ +#define ATOMISP_MAP_FLAG_CONTIGUOUS 0x0004 +#define ATOMISP_MAP_FLAG_CLEARED 0x0008 struct atomisp_acc_state { __u32 flags; /* Flags, see list below */ diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h index c8a41e5d8dab..19b9083995a4 100644 --- a/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h +++ b/drivers/staging/media/atomisp/pci/hive_isp_css_include/memory_access/memory_access.h @@ -76,9 +76,6 @@ * within the allocation referencable from the * returned pointer/address. */ -#define MMGR_ATTRIBUTE_CACHED 0x0001 -#define MMGR_ATTRIBUTE_CONTIGUOUS 0x0002 -#define MMGR_ATTRIBUTE_CLEARED 0x0008 #define mmgr_NULL ((hrt_vaddress)0) #define mmgr_EXCEPTION ((hrt_vaddress)-1) diff --git a/drivers/staging/media/atomisp/pci/hmm/hmm.c b/drivers/staging/media/atomisp/pci/hmm/hmm.c index 975749d67131..68dab2393767 100644 --- a/drivers/staging/media/atomisp/pci/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/hmm/hmm.c @@ -193,7 +193,7 @@ int hmm_init(void) * at the beginning, to avoid hmm_alloc return 0 in the * further allocation. */ - dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, false); + dummy_ptr = hmm_alloc(1, HMM_BO_PRIVATE, 0, NULL, 0); if (!ret) { ret = sysfs_create_group(&atomisp_dev->kobj, @@ -219,12 +219,16 @@ void hmm_cleanup(void) } ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, - int from_highmem, const void __user *userptr, bool cached) + int from_highmem, const void __user *userptr, + const uint16_t attrs) { unsigned int pgnr; struct hmm_buffer_object *bo; + bool cached = attrs & ATOMISP_MAP_FLAG_CACHED; int ret; + WARN_ON(attrs & ATOMISP_MAP_FLAG_CONTIGUOUS); + /* * Check if we are initialized. In the ideal world we wouldn't need * this but we can tackle it once the driver is a lot cleaner @@ -258,6 +262,9 @@ ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, hmm_mem_stat.tol_cnt += pgnr; + if (attrs & ATOMISP_MAP_FLAG_CLEARED) + hmm_set(bo->start, 0, bytes); + return bo->start; bind_err: 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 d11843a717e0..e19b98fe7201 100644 --- a/drivers/staging/media/atomisp/pci/ia_css_memory_access.c +++ b/drivers/staging/media/atomisp/pci/ia_css_memory_access.c @@ -12,30 +12,11 @@ * more details. */ -#include <type_support.h> -#include <system_types.h> -#include <assert_support.h> #include <memory_access.h> -#include <ia_css_env.h> - -#include "atomisp_internal.h" hrt_vaddress mmgr_alloc_attr(const size_t size, const uint16_t attrs) { - ia_css_ptr data; - - WARN_ON(attrs & MMGR_ATTRIBUTE_CONTIGUOUS); - - data = hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL, - attrs & MMGR_ATTRIBUTE_CACHED); - - if (!data) - return 0; - - if (attrs & MMGR_ATTRIBUTE_CLEARED) - hmm_set(data, 0, size); - - return (ia_css_ptr)data; + return hmm_alloc(size, HMM_BO_PRIVATE, 0, NULL, attrs); } void mmgr_load(const hrt_vaddress vaddr, void *data, const size_t size) diff --git a/drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c b/drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c index 75edd79b7968..9a9c1fffd3d9 100644 --- a/drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c +++ b/drivers/staging/media/atomisp/pci/runtime/frame/src/frame.c @@ -178,7 +178,7 @@ enum ia_css_err ia_css_frame_map(struct ia_css_frame **frame, } return hmm_alloc(me->data_bytes, HMM_BO_USER, 0, data, - attribute & MMGR_ATTRIBUTE_CACHED); + attribute & ATOMISP_MAP_FLAG_CACHED); if (me->data == mmgr_NULL) err = IA_CSS_ERR_INVALID_ARGUMENTS; @@ -799,7 +799,7 @@ static enum ia_css_err frame_allocate_buffer_data(struct ia_css_frame *frame) #endif frame->data = mmgr_alloc_attr(frame->data_bytes, frame->contiguous ? - MMGR_ATTRIBUTE_CONTIGUOUS : 0); + ATOMISP_MAP_FLAG_CONTIGUOUS : 0); if (frame->data == mmgr_NULL) return IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY; diff --git a/drivers/staging/media/atomisp/pci/sh_css_params.c b/drivers/staging/media/atomisp/pci/sh_css_params.c index 0a59ef0d4bce..00388e563668 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_params.c +++ b/drivers/staging/media/atomisp/pci/sh_css_params.c @@ -3267,11 +3267,11 @@ sh_css_params_init(void) { xmem_sp_stage_ptrs[p][i] = ia_css_refcount_increment(-1, mmgr_alloc_attr(sizeof(struct sh_css_sp_stage), - MMGR_ATTRIBUTE_CLEARED)); + ATOMISP_MAP_FLAG_CLEARED)); xmem_isp_stage_ptrs[p][i] = ia_css_refcount_increment(-1, mmgr_alloc_attr(sizeof(struct sh_css_sp_stage), - MMGR_ATTRIBUTE_CLEARED)); + ATOMISP_MAP_FLAG_CLEARED)); if ((xmem_sp_stage_ptrs[p][i] == mmgr_NULL) || (xmem_isp_stage_ptrs[p][i] == mmgr_NULL)) { @@ -3290,10 +3290,10 @@ sh_css_params_init(void) { sp_ddr_ptrs = ia_css_refcount_increment(-1, mmgr_alloc_attr(CEIL_MUL(sizeof(struct sh_css_ddr_address_map), HIVE_ISP_DDR_WORD_BYTES), - MMGR_ATTRIBUTE_CLEARED)); + ATOMISP_MAP_FLAG_CLEARED)); xmem_sp_group_ptrs = ia_css_refcount_increment(-1, mmgr_alloc_attr(sizeof(struct sh_css_sp_group), - MMGR_ATTRIBUTE_CLEARED)); + ATOMISP_MAP_FLAG_CLEARED)); if ((sp_ddr_ptrs == mmgr_NULL) || (xmem_sp_group_ptrs == mmgr_NULL)) -- 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 ` [PATCH v2 01/41] media: atomisp: simplify hive_isp_css_mm_hrt wrapper Mauro Carvalho Chehab 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 ` Mauro Carvalho Chehab [this message] 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=dad0d48d7c31c157cf5354c3fda9bc00214f650b.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