diff options
author | skadamati <skadamati@nvidia.com> | 2017-06-30 04:47:25 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-07-05 12:36:03 -0400 |
commit | e768e74df8be8abe8442d958bde7a4a2886694ba (patch) | |
tree | 9dc9b2adb04e9b2b674cd29267752ed4d3e3807f /drivers | |
parent | 8b36c45b39d06e273d00cd76180b589727dcde45 (diff) |
gpu: nvgpu: Fix race condition during poweron
When two or more apps ran simultaneously
First app context sets power_on flag & starts init
Other app context check the power_on flag
and try to use GPU without init completed
Which makes aother apps to assert
Added mutex to synchronize poweron access
Bug 200297265
Change-Id: Ie138f7f43bb0dd3304ed91ae3649a6a4947bee91
Signed-off-by: skadamati <skadamati@nvidia.com>
Reviewed-on: https://git-master/r/1511436
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/driver_common.c | 1 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/module.c | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a.h | 1 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/vgpu.c | 1 |
4 files changed, 6 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c index c2bd9d78..b12917d6 100644 --- a/drivers/gpu/nvgpu/common/linux/driver_common.c +++ b/drivers/gpu/nvgpu/common/linux/driver_common.c | |||
@@ -50,6 +50,7 @@ static void nvgpu_init_vars(struct gk20a *g) | |||
50 | nvgpu_mutex_init(&platform->railgate_lock); | 50 | nvgpu_mutex_init(&platform->railgate_lock); |
51 | nvgpu_mutex_init(&g->dbg_sessions_lock); | 51 | nvgpu_mutex_init(&g->dbg_sessions_lock); |
52 | nvgpu_mutex_init(&g->client_lock); | 52 | nvgpu_mutex_init(&g->client_lock); |
53 | nvgpu_mutex_init(&g->poweron_lock); | ||
53 | nvgpu_mutex_init(&g->poweroff_lock); | 54 | nvgpu_mutex_init(&g->poweroff_lock); |
54 | 55 | ||
55 | g->regs_saved = g->regs; | 56 | g->regs_saved = g->regs; |
diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index b107a721..0b5dfec8 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c | |||
@@ -88,15 +88,18 @@ int gk20a_busy(struct gk20a *g) | |||
88 | goto fail; | 88 | goto fail; |
89 | } | 89 | } |
90 | } else { | 90 | } else { |
91 | nvgpu_mutex_acquire(&g->poweron_lock); | ||
91 | if (!g->power_on) { | 92 | if (!g->power_on) { |
92 | ret = gk20a_gpu_is_virtual(dev) ? | 93 | ret = gk20a_gpu_is_virtual(dev) ? |
93 | vgpu_pm_finalize_poweron(dev) | 94 | vgpu_pm_finalize_poweron(dev) |
94 | : gk20a_pm_finalize_poweron(dev); | 95 | : gk20a_pm_finalize_poweron(dev); |
95 | if (ret) { | 96 | if (ret) { |
96 | atomic_dec(&g->usage_count); | 97 | atomic_dec(&g->usage_count); |
98 | nvgpu_mutex_release(&g->poweron_lock); | ||
97 | goto fail; | 99 | goto fail; |
98 | } | 100 | } |
99 | } | 101 | } |
102 | nvgpu_mutex_release(&g->poweron_lock); | ||
100 | } | 103 | } |
101 | 104 | ||
102 | fail: | 105 | fail: |
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 9203882c..d45477fc 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h | |||
@@ -1075,6 +1075,7 @@ struct gk20a { | |||
1075 | #endif | 1075 | #endif |
1076 | unsigned int ch_wdt_timeout_ms; | 1076 | unsigned int ch_wdt_timeout_ms; |
1077 | 1077 | ||
1078 | struct nvgpu_mutex poweron_lock; | ||
1078 | struct nvgpu_mutex poweroff_lock; | 1079 | struct nvgpu_mutex poweroff_lock; |
1079 | 1080 | ||
1080 | /* Channel priorities */ | 1081 | /* Channel priorities */ |
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index f02acad0..bd52dc0a 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c | |||
@@ -243,6 +243,7 @@ static void vgpu_remove_support(struct gk20a *g) | |||
243 | 243 | ||
244 | static void vgpu_init_vars(struct gk20a *g, struct gk20a_platform *platform) | 244 | static void vgpu_init_vars(struct gk20a *g, struct gk20a_platform *platform) |
245 | { | 245 | { |
246 | nvgpu_mutex_init(&g->poweron_lock); | ||
246 | nvgpu_mutex_init(&g->poweroff_lock); | 247 | nvgpu_mutex_init(&g->poweroff_lock); |
247 | g->regs_saved = g->regs; | 248 | g->regs_saved = g->regs; |
248 | g->bar1_saved = g->bar1; | 249 | g->bar1_saved = g->bar1; |