From 2e0770fecce3eb3d921722238dd14f00617c81e2 Mon Sep 17 00:00:00 2001 From: Seshendra Gadagottu Date: Thu, 12 Nov 2015 09:25:19 -0800 Subject: gpu: nvgpu: create generic name for sysfs module Make gpu sysfs name same across different chips. If gpu device name is different from "gpu.0", then create symlink with generic name under same parent. Generic gpu syfs module path: /sys/devices/gpu.0 Bug 200161014 Change-Id: I9a7d5971c069d5a33f8e5c811d4578231f710878 Signed-off-by: Seshendra Gadagottu Reviewed-on: http://git-master/r/840742 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c index aabe572b..ca8b8bea 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_sysfs.c @@ -30,7 +30,6 @@ #include "fifo_gk20a.h" #include "pmu_gk20a.h" - #define PTIMER_FP_FACTOR 1000000 #define ROOTRW (S_IRWXU|S_IRGRP|S_IROTH) @@ -787,8 +786,15 @@ void gk20a_remove_sysfs(struct device *dev) device_remove_file(dev, &dev_attr_allow_all); device_remove_file(dev, &dev_attr_tpc_fs_mask); - if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) + if (g->host1x_dev && (dev->parent != &g->host1x_dev->dev)) { sysfs_remove_link(&g->host1x_dev->dev.kobj, dev_name(dev)); + if (strcmp(dev_name(dev), "gpu.0")) { + struct kobject *kobj = &dev->kobj; + struct device *parent = container_of((kobj->parent), + struct device, kobj); + sysfs_remove_link(&parent->kobj, "gpu.0"); + } + } } void gk20a_create_sysfs(struct platform_device *dev) @@ -820,10 +826,19 @@ void gk20a_create_sysfs(struct platform_device *dev) error |= device_create_file(&dev->dev, &dev_attr_allow_all); error |= device_create_file(&dev->dev, &dev_attr_tpc_fs_mask); - if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev)) + if (g->host1x_dev && (dev->dev.parent != &g->host1x_dev->dev)) { error |= sysfs_create_link(&g->host1x_dev->dev.kobj, &dev->dev.kobj, dev_name(&dev->dev)); + if (strcmp(dev_name(&dev->dev), "gpu.0")) { + struct kobject *kobj = &dev->dev.kobj; + struct device *parent = container_of((kobj->parent), + struct device, kobj); + error |= sysfs_create_link(&parent->kobj, + &dev->dev.kobj, "gpu.0"); + } + + } if (error) dev_err(&dev->dev, "Failed to create sysfs attributes!\n"); -- cgit v1.2.2