diff options
Diffstat (limited to 'drivers/gpu/nvgpu/os/linux/module.c')
-rw-r--r-- | drivers/gpu/nvgpu/os/linux/module.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index 0d4cd7f1..9d84cc2f 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c | |||
@@ -129,18 +129,13 @@ int gk20a_busy(struct gk20a *g) | |||
129 | goto fail; | 129 | goto fail; |
130 | } | 130 | } |
131 | } else { | 131 | } else { |
132 | nvgpu_mutex_acquire(&g->poweron_lock); | 132 | ret = gk20a_gpu_is_virtual(dev) ? |
133 | if (!g->power_on) { | 133 | vgpu_pm_finalize_poweron(dev) : |
134 | ret = gk20a_gpu_is_virtual(dev) ? | 134 | gk20a_pm_finalize_poweron(dev); |
135 | vgpu_pm_finalize_poweron(dev) | 135 | if (ret) { |
136 | : gk20a_pm_finalize_poweron(dev); | 136 | atomic_dec(&g->usage_count.atomic_var); |
137 | if (ret) { | 137 | goto fail; |
138 | atomic_dec(&g->usage_count.atomic_var); | ||
139 | nvgpu_mutex_release(&g->poweron_lock); | ||
140 | goto fail; | ||
141 | } | ||
142 | } | 138 | } |
143 | nvgpu_mutex_release(&g->poweron_lock); | ||
144 | } | 139 | } |
145 | 140 | ||
146 | fail: | 141 | fail: |
@@ -240,12 +235,14 @@ int gk20a_pm_finalize_poweron(struct device *dev) | |||
240 | struct gk20a *g = get_gk20a(dev); | 235 | struct gk20a *g = get_gk20a(dev); |
241 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | 236 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); |
242 | struct gk20a_platform *platform = gk20a_get_platform(dev); | 237 | struct gk20a_platform *platform = gk20a_get_platform(dev); |
243 | int err; | 238 | int err = 0; |
244 | 239 | ||
245 | nvgpu_log_fn(g, " "); | 240 | nvgpu_log_fn(g, " "); |
246 | 241 | ||
242 | nvgpu_mutex_acquire(&g->power_lock); | ||
243 | |||
247 | if (g->power_on) | 244 | if (g->power_on) |
248 | return 0; | 245 | goto done; |
249 | 246 | ||
250 | trace_gk20a_finalize_poweron(dev_name(dev)); | 247 | trace_gk20a_finalize_poweron(dev_name(dev)); |
251 | 248 | ||
@@ -254,13 +251,13 @@ int gk20a_pm_finalize_poweron(struct device *dev) | |||
254 | err = platform->busy(dev); | 251 | err = platform->busy(dev); |
255 | if (err < 0) { | 252 | if (err < 0) { |
256 | nvgpu_err(g, "failed to poweron platform dependency"); | 253 | nvgpu_err(g, "failed to poweron platform dependency"); |
257 | return err; | 254 | goto done; |
258 | } | 255 | } |
259 | } | 256 | } |
260 | 257 | ||
261 | err = gk20a_restore_registers(g); | 258 | err = gk20a_restore_registers(g); |
262 | if (err) | 259 | if (err) |
263 | return err; | 260 | goto done; |
264 | 261 | ||
265 | /* Enable interrupt workqueue */ | 262 | /* Enable interrupt workqueue */ |
266 | if (!l->nonstall_work_queue) { | 263 | if (!l->nonstall_work_queue) { |
@@ -271,7 +268,7 @@ int gk20a_pm_finalize_poweron(struct device *dev) | |||
271 | 268 | ||
272 | err = gk20a_detect_chip(g); | 269 | err = gk20a_detect_chip(g); |
273 | if (err) | 270 | if (err) |
274 | return err; | 271 | goto done; |
275 | 272 | ||
276 | if (g->sim) { | 273 | if (g->sim) { |
277 | if (g->sim->sim_init_late) | 274 | if (g->sim->sim_init_late) |
@@ -319,7 +316,7 @@ int gk20a_pm_finalize_poweron(struct device *dev) | |||
319 | err = gk20a_sched_ctrl_init(g); | 316 | err = gk20a_sched_ctrl_init(g); |
320 | if (err) { | 317 | if (err) { |
321 | nvgpu_err(g, "failed to init sched control"); | 318 | nvgpu_err(g, "failed to init sched control"); |
322 | return err; | 319 | goto done; |
323 | } | 320 | } |
324 | 321 | ||
325 | g->sw_ready = true; | 322 | g->sw_ready = true; |
@@ -328,6 +325,7 @@ done: | |||
328 | if (err) | 325 | if (err) |
329 | g->power_on = false; | 326 | g->power_on = false; |
330 | 327 | ||
328 | nvgpu_mutex_release(&g->power_lock); | ||
331 | return err; | 329 | return err; |
332 | } | 330 | } |
333 | 331 | ||
@@ -356,13 +354,13 @@ static int gk20a_pm_prepare_poweroff(struct device *dev) | |||
356 | #ifdef CONFIG_NVGPU_SUPPORT_CDE | 354 | #ifdef CONFIG_NVGPU_SUPPORT_CDE |
357 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); | 355 | struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); |
358 | #endif | 356 | #endif |
359 | int ret = 0; | ||
360 | struct gk20a_platform *platform = gk20a_get_platform(dev); | 357 | struct gk20a_platform *platform = gk20a_get_platform(dev); |
361 | bool irqs_enabled; | 358 | bool irqs_enabled; |
359 | int ret = 0; | ||
362 | 360 | ||
363 | nvgpu_log_fn(g, " "); | 361 | nvgpu_log_fn(g, " "); |
364 | 362 | ||
365 | nvgpu_mutex_acquire(&g->poweroff_lock); | 363 | nvgpu_mutex_acquire(&g->power_lock); |
366 | 364 | ||
367 | if (!g->power_on) | 365 | if (!g->power_on) |
368 | goto done; | 366 | goto done; |
@@ -393,7 +391,7 @@ static int gk20a_pm_prepare_poweroff(struct device *dev) | |||
393 | /* Stop CPU from accessing the GPU registers. */ | 391 | /* Stop CPU from accessing the GPU registers. */ |
394 | gk20a_lockout_registers(g); | 392 | gk20a_lockout_registers(g); |
395 | 393 | ||
396 | nvgpu_mutex_release(&g->poweroff_lock); | 394 | nvgpu_mutex_release(&g->power_lock); |
397 | return 0; | 395 | return 0; |
398 | 396 | ||
399 | error: | 397 | error: |
@@ -407,7 +405,7 @@ error: | |||
407 | 405 | ||
408 | gk20a_scale_resume(dev); | 406 | gk20a_scale_resume(dev); |
409 | done: | 407 | done: |
410 | nvgpu_mutex_release(&g->poweroff_lock); | 408 | nvgpu_mutex_release(&g->power_lock); |
411 | 409 | ||
412 | return ret; | 410 | return ret; |
413 | } | 411 | } |