From ef69bbc92bc49af226e76358bad9e54ed910e1e4 Mon Sep 17 00:00:00 2001 From: Aaron Tian Date: Tue, 18 Feb 2020 14:54:57 +0800 Subject: [PATCH] gpu: nvgpu: add unified path of GPU devfreq dev Add a symbolic link: /sys/devices/gpu.0/devfreq_dev which pointed to GPU devfreq device: /sys/devices/gpu.0/devfreq/ devfreq. The unified path won't be changed when the number devfreq is changed. Bug 200588449 Change-Id: If00c9f9517a13a952d54a2963f31db81fd52e6fb Signed-off-by: Aaron Tian Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2298606 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Leon Yu Reviewed-by: Seshendra Gadagottu Reviewed-by: Alex Waterman Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/scale.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/scale.c b/drivers/gpu/nvgpu/os/linux/scale.c index 2b6d6e77c..e6599d305 100644 --- a/drivers/gpu/nvgpu/os/linux/scale.c +++ b/drivers/gpu/nvgpu/os/linux/scale.c @@ -361,6 +361,7 @@ void gk20a_scale_init(struct device *dev) if (platform->devfreq_governor) { struct devfreq *devfreq; + int error = 0; profile->devfreq_profile.initial_freq = profile->devfreq_profile.freq_table[0]; @@ -378,6 +379,18 @@ void gk20a_scale_init(struct device *dev) devfreq = NULL; l->devfreq = devfreq; + + /* create symlink /sys/devices/gpu.0/devfreq_dev */ + if (devfreq != NULL) { + error = sysfs_create_link(&dev->kobj, + &devfreq->dev.kobj, "devfreq_dev"); + + if (error) { + nvgpu_err(g, + "Failed to create devfreq_dev: %d", + error); + } + } } #ifdef CONFIG_GK20A_PM_QOS @@ -416,6 +429,8 @@ void gk20a_scale_exit(struct device *dev) #endif if (platform->devfreq_governor) { + sysfs_remove_link(&dev->kobj, "devfreq_dev"); + err = devfreq_remove_device(l->devfreq); l->devfreq = NULL; }