From ffb7e1f5ec032cdababb31b4ea8a073c6a53f162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konsta=20H=C3=B6ltt=C3=A4?= Date: Thu, 2 Dec 2021 11:36:44 +0200 Subject: [PATCH] gpu: nvgpu: fix power races in gsp test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The GSP stress test debug node only checks for gpu poweron and continues to trigger the stress test if power is on. This results in a small window where the GPU might get railgated, so call gk20a_busy() to hold a power ref while loading or starting the stress test (which touches HW). Change-Id: I2ced45472cd0602da36f1801e56b486097ece83d Signed-off-by: Konsta Hölttä Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2635604 Reviewed-by: svcacv Reviewed-by: Dinesh T Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/debug_gsp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/nvgpu/os/linux/debug_gsp.c b/drivers/gpu/nvgpu/os/linux/debug_gsp.c index 955a45e6d..2f02f13f2 100644 --- a/drivers/gpu/nvgpu/os/linux/debug_gsp.c +++ b/drivers/gpu/nvgpu/os/linux/debug_gsp.c @@ -199,11 +199,16 @@ static ssize_t gsp_start_test_write(struct file *file, if (strtobool(buf, &bv) == 0) { if (nvgpu_is_powered_on(g) && nvgpu_gsp_get_stress_test_load(g)) { + err = gk20a_busy(g); + if (err) + return err; err = nvgpu_gsp_set_stress_test_start(g, bv); if (err != 0) { nvgpu_err(g, "failed to start GSP stress test"); + gk20a_idle(g); return -EFAULT; } + gk20a_idle(g); } else { nvgpu_err(g, "Unable to start GSP stress test, check GPU state"); @@ -255,11 +260,16 @@ static ssize_t gsp_load_test_write(struct file *file, if (strtobool(buf, &bv) == 0) { if (nvgpu_is_powered_on(g)) { + err = gk20a_busy(g); + if (err) + return err; err = nvgpu_gsp_set_stress_test_load(g, bv); if (err != 0) { nvgpu_err(g, "failed to load GSP stress test"); + gk20a_idle(g); return -EFAULT; } + gk20a_idle(g); } else { nvgpu_err(g, "Unable to load GSP stress test, check GPU state");