summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/sysfs.c
diff options
context:
space:
mode:
authorDeepak Goyal <dgoyal@nvidia.com>2018-05-07 02:12:33 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-05-09 07:40:28 -0400
commitf9e55fbaf66c024125a19e1a773a1a4f0e9648f4 (patch)
tree9df8d81c214e5208b5a9b3e4ddc45e345a2128d0 /drivers/gpu/nvgpu/common/linux/sysfs.c
parenta1a8ceca0c5cdc8484e4da66019c066be716f9c8 (diff)
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 <dgoyal@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1674208 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/sysfs.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/sysfs.c55
1 files changed, 54 insertions, 1 deletions
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 @@
1/* 1/*
2 * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. 2 * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License, 5 * under the terms and conditions of the GNU General Public License,
@@ -504,6 +504,58 @@ static ssize_t elpg_enable_read(struct device *dev,
504 504
505static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store); 505static DEVICE_ATTR(elpg_enable, ROOTRW, elpg_enable_read, elpg_enable_store);
506 506
507static ssize_t ldiv_slowdown_factor_store(struct device *dev,
508 struct device_attribute *attr, const char *buf, size_t count)
509{
510 struct gk20a *g = get_gk20a(dev);
511 unsigned long val = 0;
512 int err;
513
514 if (kstrtoul(buf, 10, &val) < 0) {
515 nvgpu_err(g, "parse error for input SLOWDOWN factor\n");
516 return -EINVAL;
517 }
518
519 if (val >= SLOWDOWN_FACTOR_FPDIV_BYMAX) {
520 nvgpu_err(g, "Invalid SLOWDOWN factor\n");
521 return -EINVAL;
522 }
523
524 if (val == g->ldiv_slowdown_factor)
525 return count;
526
527 if (!g->power_on) {
528 g->ldiv_slowdown_factor = val;
529 } else {
530 err = gk20a_busy(g);
531 if (err)
532 return -EAGAIN;
533
534 g->ldiv_slowdown_factor = val;
535
536 if (g->ops.pmu.pmu_pg_init_param)
537 g->ops.pmu.pmu_pg_init_param(g,
538 PMU_PG_ELPG_ENGINE_ID_GRAPHICS);
539
540 gk20a_idle(g);
541 }
542
543 nvgpu_info(g, "ldiv_slowdown_factor is %x\n", g->ldiv_slowdown_factor);
544
545 return count;
546}
547
548static ssize_t ldiv_slowdown_factor_read(struct device *dev,
549 struct device_attribute *attr, char *buf)
550{
551 struct gk20a *g = get_gk20a(dev);
552
553 return snprintf(buf, PAGE_SIZE, "%d\n", g->ldiv_slowdown_factor);
554}
555
556static DEVICE_ATTR(ldiv_slowdown_factor, ROOTRW,
557 ldiv_slowdown_factor_read, ldiv_slowdown_factor_store);
558
507static ssize_t mscg_enable_store(struct device *dev, 559static ssize_t mscg_enable_store(struct device *dev,
508 struct device_attribute *attr, const char *buf, size_t count) 560 struct device_attribute *attr, const char *buf, size_t count)
509{ 561{
@@ -1114,6 +1166,7 @@ int nvgpu_create_sysfs(struct device *dev)
1114 error |= device_create_file(dev, &dev_attr_elpg_enable); 1166 error |= device_create_file(dev, &dev_attr_elpg_enable);
1115 error |= device_create_file(dev, &dev_attr_mscg_enable); 1167 error |= device_create_file(dev, &dev_attr_mscg_enable);
1116 error |= device_create_file(dev, &dev_attr_emc3d_ratio); 1168 error |= device_create_file(dev, &dev_attr_emc3d_ratio);
1169 error |= device_create_file(dev, &dev_attr_ldiv_slowdown_factor);
1117#ifdef CONFIG_TEGRA_DVFS 1170#ifdef CONFIG_TEGRA_DVFS
1118 error |= device_create_file(dev, &dev_attr_fmax_at_vmin_safe); 1171 error |= device_create_file(dev, &dev_attr_fmax_at_vmin_safe);
1119#endif 1172#endif