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/driver_common.c | 1 + drivers/gpu/nvgpu/common/linux/platform_gk20a.h | 3 ++ .../gpu/nvgpu/common/linux/platform_gp10b_tegra.c | 3 ++ drivers/gpu/nvgpu/common/linux/sysfs.c | 55 +++++++++++++++++++++- drivers/gpu/nvgpu/common/pmu/pmu_fw.c | 2 +- 5 files changed, 62 insertions(+), 2 deletions(-) (limited to 'drivers/gpu/nvgpu/common') diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c index c3663117..53789423 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c @@ -159,6 +159,7 @@ static void nvgpu_init_pm_vars(struct gk20a *g) g->support_pmu = support_gk20a_pmu(dev_from_gk20a(g)); g->can_railgate = platform->can_railgate_init; g->railgate_delay = platform->railgate_delay_init; + g->ldiv_slowdown_factor = platform->ldiv_slowdown_factor_init; __nvgpu_set_enabled(g, NVGPU_PMU_PERFMON, platform->enable_perfmon); /* set default values to aelpg parameters */ diff --git a/drivers/gpu/nvgpu/common/linux/platform_gk20a.h b/drivers/gpu/nvgpu/common/linux/platform_gk20a.h index 43afbbf9..dec79b87 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gk20a.h +++ b/drivers/gpu/nvgpu/common/linux/platform_gk20a.h @@ -74,6 +74,9 @@ struct gk20a_platform { /* Delay before rail gated */ int railgate_delay_init; + /* init value for slowdown factor */ + u8 ldiv_slowdown_factor_init; + /* Second Level Clock Gating: true = enable false = disable */ bool enable_slcg; diff --git a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c index 96acf24b..6e54d00b 100644 --- a/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c +++ b/drivers/gpu/nvgpu/common/linux/platform_gp10b_tegra.c @@ -370,6 +370,9 @@ struct gk20a_platform gp10b_tegra_platform = { /* power management configuration */ .railgate_delay_init = 500, + /* ldiv slowdown factor */ + .ldiv_slowdown_factor_init = SLOWDOWN_FACTOR_FPDIV_BY16, + /* power management configuration */ .can_railgate_init = true, .enable_elpg = true, 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 diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_fw.c b/drivers/gpu/nvgpu/common/pmu/pmu_fw.c index ed4e6c20..c610c391 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_fw.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_fw.c @@ -39,7 +39,7 @@ #define APP_VERSION_GV11B 23416738 #define APP_VERSION_GV10X 23616379 #define APP_VERSION_GP10X 24008084 -#define APP_VERSION_GP10B 20429989 +#define APP_VERSION_GP10B 23782727 #define APP_VERSION_GM20B 20490253 /* PMU version specific functions */ -- cgit v1.2.2