summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/sysfs.c')
-rw-r--r--drivers/gpu/nvgpu/os/linux/sysfs.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c
index 9e48e45d..1ffb6539 100644
--- a/drivers/gpu/nvgpu/os/linux/sysfs.c
+++ b/drivers/gpu/nvgpu/os/linux/sysfs.c
@@ -865,6 +865,18 @@ static ssize_t tpc_pg_mask_read(struct device *dev,
865 return snprintf(buf, PAGE_SIZE, "%d\n", g->tpc_pg_mask); 865 return snprintf(buf, PAGE_SIZE, "%d\n", g->tpc_pg_mask);
866} 866}
867 867
868static bool is_tpc_mask_valid(struct gk20a *g, u32 tpc_mask)
869{
870 u32 i;
871 bool valid = false;
872
873 for (i = 0; i < MAX_TPC_PG_CONFIGS; i++) {
874 if (tpc_mask == g->valid_tpc_mask[i])
875 valid = true;
876 }
877 return valid;
878}
879
868static ssize_t tpc_pg_mask_store(struct device *dev, 880static ssize_t tpc_pg_mask_store(struct device *dev,
869 struct device_attribute *attr, const char *buf, size_t count) 881 struct device_attribute *attr, const char *buf, size_t count)
870{ 882{
@@ -896,10 +908,9 @@ static ssize_t tpc_pg_mask_store(struct device *dev,
896 return -ENODEV; 908 return -ENODEV;
897 } 909 }
898 910
899 if (val == TPC_MASK_FOR_ALL_ACTIVE_TPCs || val == g->valid_tpc_mask) { 911 if (is_tpc_mask_valid(g, (u32)val)) {
900 g->tpc_pg_mask = val; 912 g->tpc_pg_mask = val;
901 } else { 913 } else {
902
903 nvgpu_err(g, "TPC-PG mask is invalid"); 914 nvgpu_err(g, "TPC-PG mask is invalid");
904 nvgpu_mutex_release(&g->tpc_pg_lock); 915 nvgpu_mutex_release(&g->tpc_pg_lock);
905 return -EINVAL; 916 return -EINVAL;