gpu: nvgpu: use single lock for gpu power on-off

Using two separate locks (poweron_lock and poweroff_lock)
allows concurrent gpu power-on and power-off. This shall
not happen as driver won't be able to maintain correct
gpu state.

Use a single power_lock to manage gpu power state. This
lock will be used to manage gpu power state from multiple
triggers like gpu idle, gpu gc-off, etc.

JIRA NVGPU-1100

Change-Id: Ia9b4aeda024a5844ae9f182d453cd6341876680a
Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1827812
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: svc-misra-checker <svc-misra-checker@nvidia.com>
Reviewed-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Nitin Kumbhar
2018-09-17 15:18:28 +05:30
committed by mobile promotions
parent 1982d050cc
commit fbc5296e7d
4 changed files with 36 additions and 32 deletions

View File

@@ -72,8 +72,7 @@ static void vgpu_init_vars(struct gk20a *g, struct gk20a_platform *platform)
{
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
nvgpu_mutex_init(&g->poweron_lock);
nvgpu_mutex_init(&g->poweroff_lock);
nvgpu_mutex_init(&g->power_lock);
nvgpu_mutex_init(&g->ctxsw_disable_lock);
l->regs_saved = l->regs;
l->bar1_saved = l->bar1;
@@ -142,16 +141,19 @@ int vgpu_pm_prepare_poweroff(struct device *dev)
nvgpu_log_fn(g, " ");
nvgpu_mutex_acquire(&g->power_lock);
if (!g->power_on)
return 0;
goto done;
if (g->ops.fifo.channel_suspend)
ret = g->ops.fifo.channel_suspend(g);
if (ret)
return ret;
goto done;
g->power_on = false;
done:
nvgpu_mutex_release(&g->power_lock);
return ret;
}
@@ -160,12 +162,14 @@ int vgpu_pm_finalize_poweron(struct device *dev)
{
struct gk20a *g = get_gk20a(dev);
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
int err;
int err = 0;
nvgpu_log_fn(g, " ");
nvgpu_mutex_acquire(&g->power_lock);
if (g->power_on)
return 0;
goto done;
g->power_on = true;
@@ -220,6 +224,10 @@ int vgpu_pm_finalize_poweron(struct device *dev)
g->sw_ready = true;
done:
if (err)
g->power_on = false;
nvgpu_mutex_release(&g->power_lock);
return err;
}