From 68a92468e296e751253655e2a9949d68d26e8959 Mon Sep 17 00:00:00 2001 From: Ninad Malwade Date: Tue, 14 Dec 2021 18:30:25 +0800 Subject: [PATCH] nvgpu: set tpc_pg_mask only if it's changed Set tpc_pg_mask only if it's different from the one which is set earlier. Bug 3463659 Change-Id: I8388e10ac0adcd56cf310c491c870614419bd18d Signed-off-by: Ninad Malwade Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2641763 (cherry picked from commit 54adf26042148519b003cad551fd301005dfb6af) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2650592 Reviewed-by: Amulya Yarlagadda GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/sysfs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index a0f75ccc8..18e7e02a9 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -1006,6 +1006,9 @@ static ssize_t tpc_pg_mask_store(struct device *dev, struct gk20a_platform *platform = dev_get_drvdata(dev); unsigned long val = 0; int err = 0; + u32 i; + /* hold the combined tpc pg mask */ + u32 combined_tpc_pg_mask = 0x0U; nvgpu_mutex_acquire(&g->static_pg_lock); @@ -1015,6 +1018,16 @@ static ssize_t tpc_pg_mask_store(struct device *dev, return -EINVAL; } + for (i = 0U; i < MAX_PG_GPC; i++) { + combined_tpc_pg_mask = combined_tpc_pg_mask | + (g->tpc_pg_mask[i] << 4*i); + } + + if (val == combined_tpc_pg_mask) { + nvgpu_info(g, "no value change, same mask already set"); + goto exit; + } + if (nvgpu_is_powered_on(g)) { nvgpu_err(g, "gpu is already powered on"); nvgpu_mutex_release(&g->static_pg_lock); @@ -1029,6 +1042,8 @@ static ssize_t tpc_pg_mask_store(struct device *dev, return -EINVAL; } } + +exit: nvgpu_mutex_release(&g->static_pg_lock); return count; }