From b3060acfe7d3777892c02f69832f356f52d0dbbc Mon Sep 17 00:00:00 2001 From: Kirill Artamonov Date: Tue, 15 Jun 2021 17:13:46 +0300 Subject: capture-isp: use separate ringbuffer to pass iovas to rtcpu Passing iova pointers using capture descriptor is not safe since usermode application can access them. Use additional ringbuffers shared between kernel and rtcpu to pass iova pointers securely. Related changes and bugfixes: Use permanent vmap mapping for ISP capture and program descriptors This should also improve performance and reduce fragmentation of kernel address space. Don't use relocs. Access descriptor like normal C structure. Remove unused reloc API. Fix map error reporting capture_common_pin_and_get_iova(). Allocate fixed size unpin buffer at setup time istead of relying on kzalloc/kfree during each request. This is to simplify critical runtime codepath and remove flexible array struct member which is prohibited by MISRA C conventions. Add unpin check to prevent submission of requests which are still in progress bug 2768992 bug 3231670 bug 200688288 bug 200690078 CAMASIL-7472 CAMASIL-7474 Signed-off-by: Kirill Artamonov Change-Id: Ie2c556cc61334ae478c7edc7e062e16e8b142031 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2487425 (cherry picked from commit 23186dfdd7b090e6b93c3a6daed60860225b9663) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2545380 Reviewed-by: Semi Malinen Reviewed-by: Pekka Pessi Reviewed-by: Mika Liljeberg Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- include/media/capture_common.h | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'include') diff --git a/include/media/capture_common.h b/include/media/capture_common.h index ccee4df06..7042ba5fa 100644 --- a/include/media/capture_common.h +++ b/include/media/capture_common.h @@ -1,13 +1,14 @@ /* - * Tegra capture common operations + * Copyright (c) 2017-2021 NVIDIA Corporation. All rights reserved. * - * Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved. + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. * - * Author: Sudhir Vyas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. */ #include @@ -63,19 +64,6 @@ struct capture_common_unpins { struct capture_mapping *data[MAX_PIN_BUFFER_PER_REQUEST]; /**< Surface buffers to unpin */ }; -struct capture_common_pin_req { - struct device *dev; - struct device *rtcpu_dev; - struct capture_buffer_table *table; - struct capture_common_unpins *unpins; - struct capture_common_buf *requests; - uint32_t request_size; - uint32_t request_offset; - struct dma_buf *requests_mem; - uint32_t num_relocs; - uint32_t __user *reloc_user; -}; - struct capture_common_status_notifier { struct dma_buf *buf; void *va; @@ -101,8 +89,6 @@ int capture_common_pin_memory(struct device *dev, void capture_common_unpin_memory(struct capture_common_buf *unpin_data); -int capture_common_request_pin_and_reloc(struct capture_common_pin_req *req); - /** * @brief Pins (maps) the physical address for provided capture surface address * and updates the iova pointer. -- cgit v1.2.2