mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
video: tegra: nvmap: Allow CPU read on VPR buffers
This patch allows CPU to read and mmap VPR buffers by restricting CPU VPR read restrictions for pre-si platforms. The knob for controlling the access is /sys/kernel/debug/nvmap/vpr/vpr_cpu_acces and by default VPR CPU read is disallowed. This change is necessary to support pre-si VPR validation for platforms where there may not be a HW engine that supports CRC computation for VPR buffers. Bug 4670086 Change-Id: Ic0d575abbda3cdda10f075a2c7092ced09723333 Signed-off-by: Ashish Mhetre <amhetre@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3145680 Reviewed-by: Sachin Nikam <snikam@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
6fea0b4122
commit
acc19f5003
@@ -1,14 +1,18 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2011-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2011-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* Interface with nvmap carveouts
|
||||
*/
|
||||
|
||||
#include <linux/debugfs.h>
|
||||
|
||||
#include <soc/tegra/fuse-helper.h>
|
||||
|
||||
#include "nvmap_priv.h"
|
||||
|
||||
bool vpr_cpu_access;
|
||||
|
||||
extern struct nvmap_device *nvmap_dev;
|
||||
|
||||
extern const struct file_operations debug_clients_fops;
|
||||
@@ -125,6 +129,10 @@ int nvmap_create_carveout(const struct nvmap_platform_carveout *co)
|
||||
#endif /* NVMAP_CONFIG_DEBUG_MAPS */
|
||||
nvmap_heap_debugfs_init(heap_root,
|
||||
node->carveout);
|
||||
if (!tegra_platform_is_silicon() && node->heap_bit == NVMAP_HEAP_CARVEOUT_VPR)
|
||||
debugfs_create_bool("allow_cpu_access", S_IRUGO | S_IWUGO,
|
||||
heap_root, (bool *)&vpr_cpu_access);
|
||||
|
||||
}
|
||||
}
|
||||
out:
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#define NVMAP_DMABUF_ATTACH nvmap_dmabuf_attach
|
||||
|
||||
extern bool vpr_cpu_access;
|
||||
|
||||
struct nvmap_handle_sgt {
|
||||
enum dma_data_direction dir;
|
||||
struct sg_table *sgt;
|
||||
@@ -380,12 +382,14 @@ int __nvmap_map(struct nvmap_handle *h, struct vm_area_struct *vma)
|
||||
nvmap_handle_put(h);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't allow mmap on VPR memory as it would be mapped
|
||||
* as device memory. User space shouldn't be accessing
|
||||
* device memory.
|
||||
* VPR memory would be mapped as device memory.
|
||||
* User space shouldn't be accessing device memory.
|
||||
* NvGPU require to access VPR from user-space for validation on pre-sil.
|
||||
* So, allow VPR CPU access only if vpr_cpu_access flag is set else don't allow.
|
||||
*/
|
||||
if (h->heap_type == NVMAP_HEAP_CARVEOUT_VPR) {
|
||||
if (!vpr_cpu_access && h->heap_type == NVMAP_HEAP_CARVEOUT_VPR) {
|
||||
nvmap_handle_put(h);
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
MODULE_IMPORT_NS(VFS_internal_I_am_really_a_filesystem_and_am_NOT_a_driver);
|
||||
#endif
|
||||
|
||||
extern bool vpr_cpu_access;
|
||||
|
||||
static ssize_t rw_handle(struct nvmap_client *client, struct nvmap_handle *h,
|
||||
int is_read, unsigned long h_offs,
|
||||
@@ -549,7 +550,8 @@ int nvmap_ioctl_rw_handle(struct file *filp, int is_read, void __user *arg,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (is_read && h->heap_type == NVMAP_HEAP_CARVEOUT_VPR) {
|
||||
if (!vpr_cpu_access && is_read &&
|
||||
h->heap_type == NVMAP_HEAP_CARVEOUT_VPR) {
|
||||
pr_err("CPU read operation is not allowed on VPR carveout\n");
|
||||
err = -EPERM;
|
||||
goto fail;
|
||||
|
||||
Reference in New Issue
Block a user