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/<dev_node>
dgpu: /dev/nvgpu/dgpu-0001\:01\:00.0/<dev_node>

Jira NVGPU-5648

Change-Id: I1c7a1c41e6d59fb248bc98a145c5ecebd06e8bad
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2443712
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Deepak Nibade
2020-11-10 13:05:57 +05:30
committed by mobile promotions
parent ca636eaeb7
commit 4ab8c87974

View File

@@ -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;
}