summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os/linux/sysfs.c
diff options
context:
space:
mode:
authorDivya Singhatwaria <dsinghatwari@nvidia.com>2019-07-23 01:13:35 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2019-08-02 15:57:24 -0400
commitae175e45edc5807131dfb1b63d3e4795e96a3f86 (patch)
treec209caf5a5804f250be83e4a68295daa64d6cfb5 /drivers/gpu/nvgpu/os/linux/sysfs.c
parent47f6bc0c2e85d0a8ff943b88c81108ca1bfc588e (diff)
gpu: nvgpu: Use TPC_PG_MASK to powergate the TPC
- In GV11B, read fuse_status_opt_tpc_gpc register to read which TPCs are floorswept. - The driver will also read sysfs node: tpc_pg_mask - Based on these two values "can_tpc_powergate" will be set to true or false and mask will be used to write to fuse_ctrl_opt_tpc_gpc register to powergate the TPC. - can_tpc_powergate = true indicates that the mask value sent from userspace is valid and can be used to power gate the desired TPC - can_tpc_powergate = false indicates that the mask value sent from userspace is not valid and cannot be used to power gate the desired TPC. Bug 200532639 Change-Id: Ib0806e4c96305a13b3574e8063ad8e16770aa7cd Signed-off-by: Divya Singhatwaria <dsinghatwari@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2159219 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.c28
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,
788static DEVICE_ATTR(force_idle, ROOTRW, force_idle_read, force_idle_store); 788static DEVICE_ATTR(force_idle, ROOTRW, force_idle_read, force_idle_store);
789#endif 789#endif
790 790
791static 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
799static bool is_tpc_mask_valid(struct gk20a *g, u32 tpc_mask) 791static 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
805static 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
811static ssize_t tpc_pg_mask_store(struct device *dev, 813static 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 {