From f9e55fbaf66c024125a19e1a773a1a4f0e9648f4 Mon Sep 17 00:00:00 2001 From: Deepak Goyal Date: Mon, 7 May 2018 11:42:33 +0530 Subject: gpu: nvgpu: Add LDIV slowdown factor in INIT cmd. PMU ucode is updated to include LDIV slowdown factor in gr_init_param command. - Defined a new version gr_init_param_v2. - Updated the PMU FW version code. - Set the LDIV slowdown factor to 0x1e by default. - Added sysfs entry to program ldiv_slowdown factor at runtime. Bug 200391931 Change-Id: Ic66049588c3b20e934faff3f29283f66c30303e4 Signed-off-by: Deepak Goyal Reviewed-on: https://git-master.nvidia.com/r/1674208 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/sysfs.c | 55 +++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (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 6709285d..1f6da803 100644 --- a/drivers/gpu/nvgpu/common/linux/sysfs.c +++ b/drivers/gpu/nvgpu/common/linux/sysfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -504,6 +504,58 @@ static ssize_t elpg_enable_read(struct device *dev, static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store); +static ssize_t ldiv_slowdown_factor_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct gk20a *g = get_gk20a(dev); + unsigned long val = 0; + int err; + + if (kstrtoul(buf, 10, &val) < 0) { + nvgpu_err(g, "parse error for input SLOWDOWN factor\n"); + return -EINVAL; + } + + if (val >= SLOWDOWN_FACTOR_FPDIV_BYMAX) { + nvgpu_err(g, "Invalid SLOWDOWN factor\n"); + return -EINVAL; + } + + if (val == g->ldiv_slowdown_factor) + return count; + + if (!g->power_on) { + g->ldiv_slowdown_factor = val; + } else { + err = gk20a_busy(g); + if (err) + return -EAGAIN; + + g->ldiv_slowdown_factor = val; + + if (g->ops.pmu.pmu_pg_init_param) + g->ops.pmu.pmu_pg_init_param(g, + PMU_PG_ELPG_ENGINE_ID_GRAPHICS); + + gk20a_idle(g); + } + + nvgpu_info(g, "ldiv_slowdown_factor is %x\n", g->ldiv_slowdown_factor); + + return count; +} + +static ssize_t ldiv_slowdown_factor_read(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct gk20a *g = get_gk20a(dev); + + return snprintf(buf, PAGE_SIZE, "%d\n", g->ldiv_slowdown_factor); +} + +static DEVICE_ATTR(ldiv_slowdown_factor, ROOTRW, + ldiv_slowdown_factor_read, ldiv_slowdown_factor_store); + static ssize_t mscg_enable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -1114,6 +1166,7 @@ int nvgpu_create_sysfs(struct device *dev) error |= device_create_file(dev, &dev_attr_elpg_enable); 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 -- cgit v1.2.2