From 4ab8c87974f1d44fc69751a58b0da1ff8a627bb0 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Tue, 10 Nov 2020 13:05:57 +0530 Subject: [PATCH] gpu: nvgpu: expose V2 device node hierarchy Nvgpu will move to new V2 device node hierarchy by default to be consistent with MIG mode hierarchy. As part of this, expose V2 device node hierarchy with this patch. Both legacy and V2 hierarchies will co-exist for some duration until V2 hierarchy is well tested out, and then legacy hierarchy will be removed. With V2 hierarchy, below is the directory structure for dev nodes : igpu: /dev/nvgpu/igpu0/ dgpu: /dev/nvgpu/dgpu-0001\:01\:00.0/ Jira NVGPU-5648 Change-Id: I1c7a1c41e6d59fb248bc98a145c5ecebd06e8bad Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2443712 GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions Reviewed-by: Alex Waterman Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/ioctl.c | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/ioctl.c b/drivers/gpu/nvgpu/os/linux/ioctl.c index 3dd0e5a34..e024970b9 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl.c @@ -201,6 +201,25 @@ static char *nvgpu_pci_devnode(struct device *dev, umode_t *mode) dev_name(dev->parent), dev_name(dev)); } +static char *nvgpu_devnode_v2(struct device *dev, umode_t *mode) +{ + if (mode) { + *mode = S_IRUSR | S_IWUSR; + } + + return kasprintf(GFP_KERNEL, "nvgpu/igpu0/%s", dev_name(dev)); +} + +static char *nvgpu_pci_devnode_v2(struct device *dev, umode_t *mode) +{ + if (mode) { + *mode = S_IRUSR | S_IWUSR; + } + + return kasprintf(GFP_KERNEL, "nvgpu/dgpu-%s/%s", dev_name(dev->parent), + dev_name(dev)); +} + static char *nvgpu_mig_phys_devnode(struct device *dev, umode_t *mode) { struct nvgpu_cdev_class_priv_data *priv_data; @@ -465,6 +484,27 @@ static int nvgpu_prepare_default_dev_node_class_list(struct gk20a *g, u32 *num_c count++; } + /* + * V2 device node names hierarchy. + * This hierarchy will replace above hierarchy in second phase. + * Both legacy and V2 device node hierarchies will co-exist until then. + */ + if (g->pci_class != 0U) { + class = nvgpu_create_class(g, "nvidia-pci-gpu-v2"); + if (class == NULL) { + return -ENOMEM; + } + class->class->devnode = nvgpu_pci_devnode_v2; + count++; + } else { + class = nvgpu_create_class(g, "nvidia-gpu-v2"); + if (class == NULL) { + return -ENOMEM; + } + class->class->devnode = nvgpu_devnode_v2; + count++; + } + *num_classes = count; return 0; }