From cd0e863f0712edcab4b1b7816ac3773f51632950 Mon Sep 17 00:00:00 2001 From: Ketan Patil Date: Wed, 22 Jan 2025 12:56:20 +0000 Subject: [PATCH] video: tegra: nvmap: Cleanup NVMAP_IOC_SET_TAG_LABEL ioctl NvRmMemSetAllocationTagLabel is not being used by any of clients. Also, this API does not have any SHR or JAMA requirement. Hence we are removing support for this API on linux to have a cleaner and uniform ICD. Remove the corresponding ioctl code from nvmap. Bug 4980808 Change-Id: I74676e07b2c617ad6554b4538ce27ab52176e5b9 Signed-off-by: Ketan Patil Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3288404 Reviewed-by: N V S Abhishek Reviewed-by: Pritesh Raithatha GVS: buildbot_gerritrpt --- drivers/video/tegra/nvmap/nvmap_dev.c | 6 +- drivers/video/tegra/nvmap/nvmap_dev_int.h | 11 +--- drivers/video/tegra/nvmap/nvmap_ioctl.c | 25 +------- drivers/video/tegra/nvmap/nvmap_tag.c | 76 ----------------------- include/uapi/linux/nvmap.h | 12 +--- 5 files changed, 4 insertions(+), 126 deletions(-) diff --git a/drivers/video/tegra/nvmap/nvmap_dev.c b/drivers/video/tegra/nvmap/nvmap_dev.c index eee25a28..da511c18 100644 --- a/drivers/video/tegra/nvmap/nvmap_dev.c +++ b/drivers/video/tegra/nvmap/nvmap_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * SPDX-FileCopyrightText: Copyright (c) 2011-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2011-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * * User-space interface to nvmap */ @@ -443,10 +443,6 @@ static long nvmap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) "Use the pair NVMAP_IOC_GET_FD/FROM_FD.\n"); break; - case NVMAP_IOC_SET_TAG_LABEL: - err = nvmap_ioctl_set_tag_label(filp, uarg); - break; - case NVMAP_IOC_GET_AVAILABLE_HEAPS: err = nvmap_ioctl_get_available_heaps(filp, uarg); break; diff --git a/drivers/video/tegra/nvmap/nvmap_dev_int.h b/drivers/video/tegra/nvmap/nvmap_dev_int.h index 330860af..01df0c17 100644 --- a/drivers/video/tegra/nvmap/nvmap_dev_int.h +++ b/drivers/video/tegra/nvmap/nvmap_dev_int.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -/* SPDX-FileCopyrightText: Copyright (c) 2010-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ +/* SPDX-FileCopyrightText: Copyright (c) 2010-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #ifndef __NVMAP_DEV_INT_H #define __NVMAP_DEV_INT_H @@ -37,8 +37,6 @@ int nvmap_ioctl_rw_handle(struct file *filp, int is_read, void __user *arg, int nvmap_ioctl_gup_test(struct file *filp, void __user *arg); -int nvmap_ioctl_set_tag_label(struct file *filp, void __user *arg); - int nvmap_ioctl_get_available_heaps(struct file *filp, void __user *arg); int nvmap_ioctl_get_handle_parameters(struct file *filp, void __user *arg); @@ -54,11 +52,4 @@ int nvmap_ioctl_query_heap_params_numa(struct file *filp, void __user *arg); int nvmap_ioctl_dup_handle(struct file *filp, void __user *arg); int nvmap_ioctl_get_fd_from_list(struct file *filp, void __user *arg); - -int nvmap_define_tag(struct nvmap_device *dev, u32 tag, - const char __user *name, u32 len); - -int nvmap_remove_tag(struct nvmap_device *dev, u32 tag); - -unsigned int nvmap_get_tag_maxlen(void); #endif /* __NVMAP_DEV_INT_H */ diff --git a/drivers/video/tegra/nvmap/nvmap_ioctl.c b/drivers/video/tegra/nvmap/nvmap_ioctl.c index 3a7d70e1..fa69818c 100644 --- a/drivers/video/tegra/nvmap/nvmap_ioctl.c +++ b/drivers/video/tegra/nvmap/nvmap_ioctl.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * SPDX-FileCopyrightText: Copyright (c) 2011-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2011-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * * User-space interface to nvmap */ @@ -865,29 +865,6 @@ exit: return err; } -int nvmap_ioctl_set_tag_label(struct file *filp, void __user *arg) -{ - struct nvmap_set_tag_label op; - struct nvmap_device *dev = nvmap_dev; - int err; - unsigned int nvmap_tag_label_maxlen = 0; - - if (copy_from_user(&op, arg, sizeof(op))) - return -EFAULT; - - nvmap_tag_label_maxlen = nvmap_get_tag_maxlen(); - if (op.len > nvmap_tag_label_maxlen) - op.len = nvmap_tag_label_maxlen; - - if (op.len) - err = nvmap_define_tag(dev, op.tag, - (const char __user *)op.addr, op.len); - else - err = nvmap_remove_tag(dev, op.tag); - - return err; -} - int nvmap_ioctl_get_available_heaps(struct file *filp, void __user *arg) { struct nvmap_available_heaps op; diff --git a/drivers/video/tegra/nvmap/nvmap_tag.c b/drivers/video/tegra/nvmap/nvmap_tag.c index 11fbd99b..26fca367 100644 --- a/drivers/video/tegra/nvmap/nvmap_tag.c +++ b/drivers/video/tegra/nvmap/nvmap_tag.c @@ -21,11 +21,6 @@ struct nvmap_tag_entry { u32 tag; }; -unsigned int nvmap_get_tag_maxlen(void) -{ - return 63 - sizeof(struct nvmap_tag_entry); -} - static struct nvmap_tag_entry *nvmap_search_tag_entry(struct rb_root *root, u32 tag) { struct rb_node *node = root->rb_node; /* top of the tree */ @@ -44,77 +39,6 @@ static struct nvmap_tag_entry *nvmap_search_tag_entry(struct rb_root *root, u32 return NULL; } - -static void nvmap_insert_tag_entry(struct rb_root *root, - struct nvmap_tag_entry *new) -{ - struct rb_node **link = &root->rb_node; - struct rb_node *parent = NULL; - struct nvmap_tag_entry *entry; - u32 tag = new->tag; - - /* Go to the bottom of the tree */ - while (*link) { - parent = *link; - entry = rb_entry(parent, struct nvmap_tag_entry, node); - - if (entry->tag > tag) - link = &parent->rb_left; - else - link = &parent->rb_right; - } - - /* Put the new node there */ - rb_link_node(&new->node, parent, link); - rb_insert_color(&new->node, root); -} - - -int nvmap_define_tag(struct nvmap_device *dev, u32 tag, - const char __user *name, u32 len) -{ - struct nvmap_tag_entry *new; - struct nvmap_tag_entry *old; - - new = kzalloc(sizeof(struct nvmap_tag_entry) + len + 1, GFP_KERNEL); - if (new == NULL) - return -ENOMEM; - - if (copy_from_user(new + 1, name, len)) { - kfree(new); - return -EFAULT; - } - - new->tag = tag; - - mutex_lock(&dev->tags_lock); - old = nvmap_search_tag_entry(&dev->tags, tag); - if (old) { - rb_replace_node(&old->node, &new->node, &dev->tags); - kfree(old); - } else { - nvmap_insert_tag_entry(&dev->tags, new); - } - mutex_unlock(&dev->tags_lock); - - return 0; -} - -int nvmap_remove_tag(struct nvmap_device *dev, u32 tag) -{ - struct nvmap_tag_entry *old; - - mutex_lock(&dev->tags_lock); - old = nvmap_search_tag_entry(&dev->tags, tag); - if (old){ - rb_erase(&old->node, &dev->tags); - kfree(old); - } - mutex_unlock(&dev->tags_lock); - - return 0; -} - /* must hold tag_lock */ char *__nvmap_tag_name(struct nvmap_device *dev, u32 tag) { diff --git a/include/uapi/linux/nvmap.h b/include/uapi/linux/nvmap.h index 19ee6416..f5c6c151 100644 --- a/include/uapi/linux/nvmap.h +++ b/include/uapi/linux/nvmap.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2009-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2009-2025, NVIDIA CORPORATION. All rights reserved. * * structure declarations for nvmem and nvmap user-space ioctls */ @@ -194,13 +194,6 @@ struct nvmap_debugfs_handles_entry { __u64 mapped_size; }; -struct nvmap_set_tag_label { - __u32 tag; - __u32 len; /* in: label length - out: number of characters copied */ - __u64 addr; /* in: pointer to label or NULL to remove */ -}; - struct nvmap_available_heaps { __u64 heaps; /* heaps bitmask */ }; @@ -327,9 +320,6 @@ struct nvmap_fd_for_range_from_list { #define NVMAP_IOC_GUP_TEST _IOWR(NVMAP_IOC_MAGIC, 23, struct nvmap_gup_test) -/* Define a label for allocation tag */ -#define NVMAP_IOC_SET_TAG_LABEL _IOW(NVMAP_IOC_MAGIC, 24, struct nvmap_set_tag_label) - #define NVMAP_IOC_GET_AVAILABLE_HEAPS \ _IOR(NVMAP_IOC_MAGIC, 25, struct nvmap_available_heaps)