gpu: nvgpu: protect nvgpu power state access using spinlock

IRQs can get triggered during nvgpu power-on due to MMU fault, invalid
PRIV ring or bus access etc. Handlers for those IRQs can't access the
full state related to the IRQ unless nvgpu is fully powered on.

In order to let the IRQ handlers know about the nvgpu power-on state
gk20a.power_on_state variable has to be protected through spinlock
to avoid the deadlock due to usage of earlier power_lock mutex.

Further the IRQs need to be disabled on local CPU while updating the
power state variable hence use spin_lock_irqsave and spin_unlock_-
irqrestore APIs for protecting the access.

JIRA NVGPU-1592

Change-Id: If5d1b5e2617ad90a68faa56ff47f62bb3f0b232b
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2203860
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sagar Kamble
2019-09-20 16:19:44 +05:30
committed by Alex Waterman
parent 1cd6ae945c
commit 6c3c360462
20 changed files with 235 additions and 68 deletions

View File

@@ -260,7 +260,7 @@ static ssize_t gpu_powered_on_show(struct device *dev,
{
struct gk20a *g = get_gk20a(dev);
return snprintf(buf, PAGE_SIZE, "%u\n", g->power_on);
return snprintf(buf, PAGE_SIZE, "%s\n", nvgpu_get_power_state(g));
}
static DEVICE_ATTR(gpu_powered_on, S_IRUGO, gpu_powered_on_show, NULL);
@@ -406,7 +406,7 @@ static ssize_t gk20a_load_show(struct device *dev,
ssize_t res;
int err;
if (!g->power_on) {
if (nvgpu_is_powered_off(g)) {
busy_time = 0;
} else {
err = gk20a_busy(g);
@@ -435,7 +435,7 @@ static ssize_t elpg_enable_store(struct device *dev,
if (kstrtoul(buf, 10, &val) < 0)
return -EINVAL;
if (!g->power_on) {
if (nvgpu_is_powered_off(g)) {
return -EAGAIN;
} else {
err = gk20a_busy(g);
@@ -487,7 +487,7 @@ static ssize_t ldiv_slowdown_factor_store(struct device *dev,
if (val == g->ldiv_slowdown_factor)
return count;
if (!g->power_on) {
if (nvgpu_is_powered_off(g)) {
g->ldiv_slowdown_factor = val;
} else {
err = gk20a_busy(g);
@@ -530,7 +530,7 @@ static ssize_t mscg_enable_store(struct device *dev,
if (kstrtoul(buf, 10, &val) < 0)
return -EINVAL;
if (!g->power_on) {
if (nvgpu_is_powered_off(g)) {
g->mscg_enabled = val ? true : false;
} else {
err = gk20a_busy(g);