diff options
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/sysfs.c')
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/sysfs.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index 759c12e8..2ab29649 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c | |||
@@ -788,26 +788,28 @@ static ssize_t force_idle_read(struct device *dev, | |||
788 | static DEVICE_ATTR(force_idle, ROOTRW, force_idle_read, force_idle_store); | 788 | static DEVICE_ATTR(force_idle, ROOTRW, force_idle_read, force_idle_store); |
789 | #endif | 789 | #endif |
790 | 790 | ||
791 | static ssize_t tpc_pg_mask_read(struct device *dev, | ||
792 | struct device_attribute *attr, char *buf) | ||
793 | { | ||
794 | struct gk20a *g = get_gk20a(dev); | ||
795 | |||
796 | return snprintf(buf, PAGE_SIZE, "%d\n", g->tpc_pg_mask); | ||
797 | } | ||
798 | |||
799 | static bool is_tpc_mask_valid(struct gk20a *g, u32 tpc_mask) | 791 | static bool is_tpc_mask_valid(struct gk20a *g, u32 tpc_mask) |
800 | { | 792 | { |
801 | u32 i; | 793 | u32 i; |
802 | bool valid = false; | 794 | bool valid = false; |
803 | 795 | ||
804 | for (i = 0; i < MAX_TPC_PG_CONFIGS; i++) { | 796 | for (i = 0; i < MAX_TPC_PG_CONFIGS; i++) { |
805 | if (tpc_mask == g->valid_tpc_mask[i]) | 797 | if (tpc_mask == g->valid_tpc_mask[i]) { |
806 | valid = true; | 798 | valid = true; |
799 | break; | ||
800 | } | ||
807 | } | 801 | } |
808 | return valid; | 802 | return valid; |
809 | } | 803 | } |
810 | 804 | ||
805 | static ssize_t tpc_pg_mask_read(struct device *dev, | ||
806 | struct device_attribute *attr, char *buf) | ||
807 | { | ||
808 | struct gk20a *g = get_gk20a(dev); | ||
809 | |||
810 | return snprintf(buf, PAGE_SIZE, "%d\n", g->tpc_pg_mask); | ||
811 | } | ||
812 | |||
811 | static ssize_t tpc_pg_mask_store(struct device *dev, | 813 | static ssize_t tpc_pg_mask_store(struct device *dev, |
812 | struct device_attribute *attr, const char *buf, size_t count) | 814 | struct device_attribute *attr, const char *buf, size_t count) |
813 | { | 815 | { |
@@ -817,11 +819,6 @@ static ssize_t tpc_pg_mask_store(struct device *dev, | |||
817 | 819 | ||
818 | nvgpu_mutex_acquire(&g->tpc_pg_lock); | 820 | nvgpu_mutex_acquire(&g->tpc_pg_lock); |
819 | 821 | ||
820 | if (!g->can_tpc_powergate) { | ||
821 | nvgpu_info(g, "TPC-PG not enabled for the platform"); | ||
822 | goto exit; | ||
823 | } | ||
824 | |||
825 | if (kstrtoul(buf, 10, &val) < 0) { | 822 | if (kstrtoul(buf, 10, &val) < 0) { |
826 | nvgpu_err(g, "invalid value"); | 823 | nvgpu_err(g, "invalid value"); |
827 | nvgpu_mutex_release(&g->tpc_pg_lock); | 824 | nvgpu_mutex_release(&g->tpc_pg_lock); |
@@ -839,6 +836,9 @@ static ssize_t tpc_pg_mask_store(struct device *dev, | |||
839 | return -ENODEV; | 836 | return -ENODEV; |
840 | } | 837 | } |
841 | 838 | ||
839 | /* checking that the value from userspace is within | ||
840 | * the possible valid TPC configurations. | ||
841 | */ | ||
842 | if (is_tpc_mask_valid(g, (u32)val)) { | 842 | if (is_tpc_mask_valid(g, (u32)val)) { |
843 | g->tpc_pg_mask = val; | 843 | g->tpc_pg_mask = val; |
844 | } else { | 844 | } else { |