summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/sysfs.c
diff options
context:
space:
mode:
authorNicolin Chen <nicolinc@nvidia.com>2018-08-30 17:52:16 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-04 19:17:04 -0400
commit9e4bbd2c9b4d5d9712921a7db058061e4f8cd389 (patch)
treec1c569d83a99429fc71559a516f6ddab74a3c011 /drivers/gpu/nvgpu/os/linux/sysfs.c
parentbd47d00ce736a421a3b4376ad996fdc877ccf0ca (diff)
gpu: nvgpu: Add configurable comptag_mem_deduct sysfs node per device
Adding a comptag_mem_deduct in the platform_gk20a has certain problems: 1) It's not really convenient for platform users to configure it. 2) All products using the same GPU have to share the same configuration. So this patch moves this comptag_mem_deduct from struct platform_gk20a to struct gr_gk20a (per device). And it adds an sysfs node for products or platform users to easily configure from user space. Note: The comptag memory will not be allocated until the GPU driver goes through the final poweron routine. So the user space has a small window to configure this sysfs node. Bug 2327574 Bug 2284925 Change-Id: Ie7d00b082704e422645c0ea254b59e22f9fc3b7f Signed-off-by: Nicolin Chen <nicolinc@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1810334 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/sysfs.c')
-rw-r--r--drivers/gpu/nvgpu/os/linux/sysfs.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c
index a42070d4..5eef8bfa 100644
--- a/drivers/gpu/nvgpu/os/linux/sysfs.c
+++ b/drivers/gpu/nvgpu/os/linux/sysfs.c
@@ -22,6 +22,7 @@
22#include <nvgpu/nvhost.h> 22#include <nvgpu/nvhost.h>
23#include <nvgpu/ptimer.h> 23#include <nvgpu/ptimer.h>
24 24
25#include "os_linux.h"
25#include "sysfs.h" 26#include "sysfs.h"
26#include "platform_gk20a.h" 27#include "platform_gk20a.h"
27#include "gk20a/gr_gk20a.h" 28#include "gk20a/gr_gk20a.h"
@@ -1159,6 +1160,40 @@ static DEVICE_ATTR(gfxp_wfi_timeout_count, (S_IRWXU|S_IRGRP|S_IROTH),
1159static DEVICE_ATTR(gfxp_wfi_timeout_unit, (S_IRWXU|S_IRGRP|S_IROTH), 1160static DEVICE_ATTR(gfxp_wfi_timeout_unit, (S_IRWXU|S_IRGRP|S_IROTH),
1160 gfxp_wfi_timeout_unit_read, gfxp_wfi_timeout_unit_store); 1161 gfxp_wfi_timeout_unit_read, gfxp_wfi_timeout_unit_store);
1161 1162
1163static ssize_t comptag_mem_deduct_store(struct device *dev,
1164 struct device_attribute *attr,
1165 const char *buf, size_t count)
1166{
1167 struct gk20a *g = get_gk20a(dev);
1168 unsigned long val;
1169
1170 if (kstrtoul(buf, 10, &val) < 0)
1171 return -EINVAL;
1172
1173 if (val >= totalram_size_in_mb) {
1174 dev_err(dev, "comptag_mem_deduct can not be set above %lu",
1175 totalram_size_in_mb);
1176 return -EINVAL;
1177 }
1178
1179 g->gr.comptag_mem_deduct = val;
1180 /* Deduct the part taken by the running system */
1181 g->gr.max_comptag_mem -= val;
1182
1183 return count;
1184}
1185
1186static ssize_t comptag_mem_deduct_show(struct device *dev,
1187 struct device_attribute *attr, char *buf)
1188{
1189 struct gk20a *g = get_gk20a(dev);
1190
1191 return sprintf(buf, "%d\n", g->gr.comptag_mem_deduct);
1192}
1193
1194static DEVICE_ATTR(comptag_mem_deduct, ROOTRW,
1195 comptag_mem_deduct_show, comptag_mem_deduct_store);
1196
1162void nvgpu_remove_sysfs(struct device *dev) 1197void nvgpu_remove_sysfs(struct device *dev)
1163{ 1198{
1164 device_remove_file(dev, &dev_attr_elcg_enable); 1199 device_remove_file(dev, &dev_attr_elcg_enable);
@@ -1200,6 +1235,8 @@ void nvgpu_remove_sysfs(struct device *dev)
1200 device_remove_file(dev, &dev_attr_gfxp_wfi_timeout_count); 1235 device_remove_file(dev, &dev_attr_gfxp_wfi_timeout_count);
1201 device_remove_file(dev, &dev_attr_gfxp_wfi_timeout_unit); 1236 device_remove_file(dev, &dev_attr_gfxp_wfi_timeout_unit);
1202 1237
1238 device_remove_file(dev, &dev_attr_comptag_mem_deduct);
1239
1203 if (strcmp(dev_name(dev), "gpu.0")) { 1240 if (strcmp(dev_name(dev), "gpu.0")) {
1204 struct kobject *kobj = &dev->kobj; 1241 struct kobject *kobj = &dev->kobj;
1205 struct device *parent = container_of((kobj->parent), 1242 struct device *parent = container_of((kobj->parent),
@@ -1252,6 +1289,8 @@ int nvgpu_create_sysfs(struct device *dev)
1252 error |= device_create_file(dev, &dev_attr_gfxp_wfi_timeout_count); 1289 error |= device_create_file(dev, &dev_attr_gfxp_wfi_timeout_count);
1253 error |= device_create_file(dev, &dev_attr_gfxp_wfi_timeout_unit); 1290 error |= device_create_file(dev, &dev_attr_gfxp_wfi_timeout_unit);
1254 1291
1292 error |= device_create_file(dev, &dev_attr_comptag_mem_deduct);
1293
1255 if (strcmp(dev_name(dev), "gpu.0")) { 1294 if (strcmp(dev_name(dev), "gpu.0")) {
1256 struct kobject *kobj = &dev->kobj; 1295 struct kobject *kobj = &dev->kobj;
1257 struct device *parent = container_of((kobj->parent), 1296 struct device *parent = container_of((kobj->parent),