diff options
author | Nicolin Chen <nicolinc@nvidia.com> | 2018-08-30 17:52:16 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-09-04 19:17:04 -0400 |
commit | 9e4bbd2c9b4d5d9712921a7db058061e4f8cd389 (patch) | |
tree | c1c569d83a99429fc71559a516f6ddab74a3c011 /drivers | |
parent | bd47d00ce736a421a3b4376ad996fdc877ccf0ca (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')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gr_gk20a.h | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/driver_common.c | 9 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/platform_gk20a.h | 6 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/sysfs.c | 39 |
4 files changed, 45 insertions, 15 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h index 303e1f53..44b6de8d 100644 --- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.h | |||
@@ -373,6 +373,12 @@ struct gr_gk20a { | |||
373 | u32 gfxp_wfi_timeout_count; | 373 | u32 gfxp_wfi_timeout_count; |
374 | u32 gfxp_wfi_timeout_unit; | 374 | u32 gfxp_wfi_timeout_unit; |
375 | 375 | ||
376 | /* | ||
377 | * The deductible memory size for max_comptag_mem (in MBytes) | ||
378 | * Usually close to memory size that running system is taking | ||
379 | */ | ||
380 | u32 comptag_mem_deduct; | ||
381 | |||
376 | struct gr_ctx_buffer_desc global_ctx_buffer[NR_GLOBAL_CTX_BUF]; | 382 | struct gr_ctx_buffer_desc global_ctx_buffer[NR_GLOBAL_CTX_BUF]; |
377 | 383 | ||
378 | struct nvgpu_mem mmu_wr_mem; | 384 | struct nvgpu_mem mmu_wr_mem; |
diff --git a/drivers/gpu/nvgpu/os/linux/driver_common.c b/drivers/gpu/nvgpu/os/linux/driver_common.c index 4d345aaa..6375030b 100644 --- a/drivers/gpu/nvgpu/os/linux/driver_common.c +++ b/drivers/gpu/nvgpu/os/linux/driver_common.c | |||
@@ -94,19 +94,10 @@ static void nvgpu_init_vars(struct gk20a *g) | |||
94 | 94 | ||
95 | static void nvgpu_init_gr_vars(struct gk20a *g) | 95 | static void nvgpu_init_gr_vars(struct gk20a *g) |
96 | { | 96 | { |
97 | struct gk20a_platform *platform = dev_get_drvdata(dev_from_gk20a(g)); | ||
98 | gk20a_init_gr(g); | 97 | gk20a_init_gr(g); |
99 | 98 | ||
100 | nvgpu_log_info(g, "total ram pages : %lu", totalram_pages); | 99 | nvgpu_log_info(g, "total ram pages : %lu", totalram_pages); |
101 | g->gr.max_comptag_mem = totalram_size_in_mb; | 100 | g->gr.max_comptag_mem = totalram_size_in_mb; |
102 | |||
103 | /* Deduct the part taken by the running system */ | ||
104 | if (platform->comptag_mem_deduct && | ||
105 | g->gr.max_comptag_mem > platform->comptag_mem_deduct) { | ||
106 | g->gr.max_comptag_mem -= platform->comptag_mem_deduct; | ||
107 | nvgpu_log_info(g, "deducted max memory for comptag: %u", | ||
108 | g->gr.max_comptag_mem); | ||
109 | } | ||
110 | } | 101 | } |
111 | 102 | ||
112 | static void nvgpu_init_timeout(struct gk20a *g) | 103 | static void nvgpu_init_timeout(struct gk20a *g) |
diff --git a/drivers/gpu/nvgpu/os/linux/platform_gk20a.h b/drivers/gpu/nvgpu/os/linux/platform_gk20a.h index 5848a5ef..f3e80b8c 100644 --- a/drivers/gpu/nvgpu/os/linux/platform_gk20a.h +++ b/drivers/gpu/nvgpu/os/linux/platform_gk20a.h | |||
@@ -272,12 +272,6 @@ struct gk20a_platform { | |||
272 | /* stream id to use */ | 272 | /* stream id to use */ |
273 | u32 ltc_streamid; | 273 | u32 ltc_streamid; |
274 | 274 | ||
275 | /* | ||
276 | * The deductible memory size for max_comptag_mem (in MBytes) | ||
277 | * Usually close to memory size that running system is taking | ||
278 | */ | ||
279 | u32 comptag_mem_deduct; | ||
280 | |||
281 | /* scaling rate */ | 275 | /* scaling rate */ |
282 | unsigned long cached_rate; | 276 | unsigned long cached_rate; |
283 | }; | 277 | }; |
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), | |||
1159 | static DEVICE_ATTR(gfxp_wfi_timeout_unit, (S_IRWXU|S_IRGRP|S_IROTH), | 1160 | static 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 | ||
1163 | static 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 | |||
1186 | static 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 | |||
1194 | static DEVICE_ATTR(comptag_mem_deduct, ROOTRW, | ||
1195 | comptag_mem_deduct_show, comptag_mem_deduct_store); | ||
1196 | |||
1162 | void nvgpu_remove_sysfs(struct device *dev) | 1197 | void 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), |