summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/sysfs.c
diff options
context:
space:
mode:
authorDeepak Goyal <dgoyal@nvidia.com>2018-07-16 01:40:23 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-07-24 02:52:39 -0400
commitd3b8415948de8c9ffe2f2fa66340dd7e71a894e6 (patch)
tree328970819ace31fae3bf3bc27376121330064db9 /drivers/gpu/nvgpu/os/linux/sysfs.c
parent2df33e32e40eb2c8e025f8d27396d9b5cdb3ac11 (diff)
gpu: nvgpu: tpc powergating through sysfs
- adds static tpc-powergating through sysfs. - active tpc count will remain till the GPU/systems is not booted again. - tpc_pg_mask can be written only after GPU probe finishes and GPU boot is triggered. Note: To be able to use this feature, we need to change boot/init scripts of the OS(used with nvgpu driver) to write to sysfs nodes before posting discover image size query to FECS. Bug 200406784 Change-Id: Id749c7a617422c625f77d0c1a9aada2eb960c4d0 Signed-off-by: Deepak Goyal <dgoyal@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1742422 Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> 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.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c
index 1b84e2e2..b607768a 100644
--- a/drivers/gpu/nvgpu/os/linux/sysfs.c
+++ b/drivers/gpu/nvgpu/os/linux/sysfs.c
@@ -31,6 +31,8 @@
31 31
32#define ROOTRW (S_IRWXU|S_IRGRP|S_IROTH) 32#define ROOTRW (S_IRWXU|S_IRGRP|S_IROTH)
33 33
34#define TPC_MASK_FOR_ALL_ACTIVE_TPCs (u32) 0x0
35
34static ssize_t elcg_enable_store(struct device *dev, 36static ssize_t elcg_enable_store(struct device *dev,
35 struct device_attribute *attr, const char *buf, size_t count) 37 struct device_attribute *attr, const char *buf, size_t count)
36{ 38{
@@ -843,6 +845,61 @@ static ssize_t force_idle_read(struct device *dev,
843static DEVICE_ATTR(force_idle, ROOTRW, force_idle_read, force_idle_store); 845static DEVICE_ATTR(force_idle, ROOTRW, force_idle_read, force_idle_store);
844#endif 846#endif
845 847
848static ssize_t tpc_pg_mask_read(struct device *dev,
849 struct device_attribute *attr, char *buf)
850{
851 struct gk20a *g = get_gk20a(dev);
852
853 return snprintf(buf, PAGE_SIZE, "%d\n", g->tpc_pg_mask);
854}
855
856static ssize_t tpc_pg_mask_store(struct device *dev,
857 struct device_attribute *attr, const char *buf, size_t count)
858{
859 struct gk20a *g = get_gk20a(dev);
860 struct gr_gk20a *gr = &g->gr;
861 unsigned long val = 0;
862
863 nvgpu_mutex_acquire(&g->tpc_pg_lock);
864
865 if (!g->can_tpc_powergate) {
866 nvgpu_info(g, "TPC-PG not enabled for the platform");
867 goto exit;
868 }
869
870 if (kstrtoul(buf, 10, &val) < 0) {
871 nvgpu_err(g, "invalid value");
872 nvgpu_mutex_release(&g->tpc_pg_lock);
873 return -EINVAL;
874 }
875
876 if (val == g->tpc_pg_mask) {
877 nvgpu_info(g, "no value change, same mask already set");
878 goto exit;
879 }
880
881 if (gr->ctx_vars.golden_image_size) {
882 nvgpu_err(g, "golden image size already initialized");
883 nvgpu_mutex_release(&g->tpc_pg_lock);
884 return -ENODEV;
885 }
886
887 if (val == TPC_MASK_FOR_ALL_ACTIVE_TPCs || val == g->valid_tpc_mask) {
888 g->tpc_pg_mask = val;
889 } else {
890
891 nvgpu_err(g, "TPC-PG mask is invalid");
892 nvgpu_mutex_release(&g->tpc_pg_lock);
893 return -EINVAL;
894 }
895exit:
896 nvgpu_mutex_release(&g->tpc_pg_lock);
897
898 return count;
899}
900
901static DEVICE_ATTR(tpc_pg_mask, ROOTRW, tpc_pg_mask_read, tpc_pg_mask_store);
902
846static ssize_t tpc_fs_mask_store(struct device *dev, 903static ssize_t tpc_fs_mask_store(struct device *dev,
847 struct device_attribute *attr, const char *buf, size_t count) 904 struct device_attribute *attr, const char *buf, size_t count)
848{ 905{
@@ -1130,6 +1187,7 @@ void nvgpu_remove_sysfs(struct device *dev)
1130 device_remove_file(dev, &dev_attr_aelpg_enable); 1187 device_remove_file(dev, &dev_attr_aelpg_enable);
1131 device_remove_file(dev, &dev_attr_allow_all); 1188 device_remove_file(dev, &dev_attr_allow_all);
1132 device_remove_file(dev, &dev_attr_tpc_fs_mask); 1189 device_remove_file(dev, &dev_attr_tpc_fs_mask);
1190 device_remove_file(dev, &dev_attr_tpc_pg_mask);
1133 device_remove_file(dev, &dev_attr_min_timeslice_us); 1191 device_remove_file(dev, &dev_attr_min_timeslice_us);
1134 device_remove_file(dev, &dev_attr_max_timeslice_us); 1192 device_remove_file(dev, &dev_attr_max_timeslice_us);
1135 1193
@@ -1181,6 +1239,7 @@ int nvgpu_create_sysfs(struct device *dev)
1181 error |= device_create_file(dev, &dev_attr_aelpg_enable); 1239 error |= device_create_file(dev, &dev_attr_aelpg_enable);
1182 error |= device_create_file(dev, &dev_attr_allow_all); 1240 error |= device_create_file(dev, &dev_attr_allow_all);
1183 error |= device_create_file(dev, &dev_attr_tpc_fs_mask); 1241 error |= device_create_file(dev, &dev_attr_tpc_fs_mask);
1242 error |= device_create_file(dev, &dev_attr_tpc_pg_mask);
1184 error |= device_create_file(dev, &dev_attr_min_timeslice_us); 1243 error |= device_create_file(dev, &dev_attr_min_timeslice_us);
1185 error |= device_create_file(dev, &dev_attr_max_timeslice_us); 1244 error |= device_create_file(dev, &dev_attr_max_timeslice_us);
1186 1245