From 7a28547892bfa73d31c1423b33e98030840a4f6d Mon Sep 17 00:00:00 2001 From: Alex Frid Date: Tue, 8 May 2018 18:58:22 -0700 Subject: gpu: nvgpu: Fix Gpu sysfs access to Fmax@Vmin Currently gpu sysfs retrieves Fmax@Vmin by direct call into Tegra DVFS driver that introduces compile time dependencies on CONFIG_TEGRA_DVFS. In addition incorrect clock is used for DVFS information access. Re-factored sysfs node to use generic GPU clock operation for Fmax@Vmin read. This would fix a bug in target clock selection, and allows to remove dependency of sysfs on CONFIG_TEGRA_DVFS. Updated nvgpu_linux_get_fmax_at_vmin_safe operation itself so it can be called on platforms that does not support Tegra DVFS, although 0 will still be returned as Fmax@Vmin on such platforms. Bug 2045903 Change-Id: I32cce25320df026288c82458c913b0cde9ad4f72 Signed-off-by: Alex Frid Reviewed-on: https://git-master.nvidia.com/r/1710924 Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/sysfs.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux/sysfs.c') diff --git a/drivers/gpu/nvgpu/common/linux/sysfs.c b/drivers/gpu/nvgpu/common/linux/sysfs.c index 1f6da803..e425e153 100644 --- a/drivers/gpu/nvgpu/common/linux/sysfs.c +++ b/drivers/gpu/nvgpu/common/linux/sysfs.c @@ -17,9 +17,6 @@ #include #include #include -#ifdef CONFIG_TEGRA_DVFS -#include -#endif #include #include @@ -781,21 +778,19 @@ static ssize_t emc3d_ratio_read(struct device *dev, static DEVICE_ATTR(emc3d_ratio, ROOTRW, emc3d_ratio_read, emc3d_ratio_store); -#ifdef CONFIG_TEGRA_DVFS static ssize_t fmax_at_vmin_safe_read(struct device *dev, struct device_attribute *attr, char *buf) { struct gk20a *g = get_gk20a(dev); unsigned long gpu_fmax_at_vmin_hz = 0; - struct clk *clk = g->clk.tegra_clk; - gpu_fmax_at_vmin_hz = tegra_dvfs_get_fmax_at_vmin_safe_t(clk); + if (g->ops.clk.get_fmax_at_vmin_safe) + gpu_fmax_at_vmin_hz = g->ops.clk.get_fmax_at_vmin_safe(g); return snprintf(buf, PAGE_SIZE, "%d\n", (int)(gpu_fmax_at_vmin_hz)); } static DEVICE_ATTR(fmax_at_vmin_safe, S_IRUGO, fmax_at_vmin_safe_read, NULL); -#endif #ifdef CONFIG_PM static ssize_t force_idle_store(struct device *dev, @@ -1116,9 +1111,9 @@ void nvgpu_remove_sysfs(struct device *dev) device_remove_file(dev, &dev_attr_elpg_enable); device_remove_file(dev, &dev_attr_mscg_enable); device_remove_file(dev, &dev_attr_emc3d_ratio); -#ifdef CONFIG_TEGRA_DVFS + device_remove_file(dev, &dev_attr_fmax_at_vmin_safe); -#endif + device_remove_file(dev, &dev_attr_counters); device_remove_file(dev, &dev_attr_counters_reset); device_remove_file(dev, &dev_attr_load); @@ -1167,9 +1162,9 @@ int nvgpu_create_sysfs(struct device *dev) error |= device_create_file(dev, &dev_attr_mscg_enable); error |= device_create_file(dev, &dev_attr_emc3d_ratio); error |= device_create_file(dev, &dev_attr_ldiv_slowdown_factor); -#ifdef CONFIG_TEGRA_DVFS + error |= device_create_file(dev, &dev_attr_fmax_at_vmin_safe); -#endif + error |= device_create_file(dev, &dev_attr_counters); error |= device_create_file(dev, &dev_attr_counters_reset); error |= device_create_file(dev, &dev_attr_load); -- cgit v1.2.2