gpu: nvgpu: fix gk20a_busy_noresume and gk20a_idle_nosuspend

gk20a_idle can still race with gk20a_busy_noresume as the following
pm_runtime's functions can run concurrently. i.e. pm_runtime_suspend and
pm_runtime_get_noresume. pm_runtime_get_noresume simply increments the
refcount without first acquiring the pm_runtime's power_lock. This can
be resolved by the use of pm_runtime_get_if_in_use which acquires a
the power lock of PM runtime. This prevents a potential use of register
after power_off in the l2_ops ioctl path.

We still call pm_runtime_get_noresume even if pm_runtime_get_if_in_use
returns <= 0. This helps in the following ways.

1) The signature of the function gk20a_busy_noresume remains same w.r.t
QNX code

2) Any calls to gk20a_busy_noresume() in the driver is followed by a
check to g->power_on. When pm_runtime_get_if_in_use() returns <=0, 
g->power_on is false and would immediately call gk20a_suspend_noidle()
thus keeping the original 'intent' of the gk20a_busy_noresume intact.

Bug 200507468

Change-Id: Id46bf2124047bb0e9a299fda57441e425195468f
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2180787
Reviewed-by: Bibek Basu <bbasu@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Debarshi Dutta
2019-09-05 16:44:29 +05:30
committed by mobile promotions
parent 0bdffbed34
commit dd70aa47db

View File

@@ -107,6 +107,9 @@ struct device_node *nvgpu_get_node(struct gk20a *g)
void gk20a_busy_noresume(struct gk20a *g)
{
int ret = pm_runtime_get_if_in_use(dev_from_gk20a(g));
if (ret <= 0)
pm_runtime_get_noresume(dev_from_gk20a(g));
}