gpu: nvgpu: add g->sw_ready flag

Fix a race condition where we'd still be booting up the gpu and/or
initializing the driver but elsewhere assume that all is done already.

Some userspace APIs to make sure that we're ready by testing
g->gr.sw_ready, but this flag is set in the middle of bootup; there are
other things after gr initialization. Add a new flag that is enabled
after bootup is fully complete at the end of finalize_poweron, and
change the checks in user API paths to test the new flag only.

These checks are only in the ioctl paths for ctrl, dbg and tsg, and in
the ctrl device's opening path.

The gr.sw_ready flag is still left there to signify whether just gr has
had its bookkeeping initialized.

Bug 200370011

Change-Id: I2995500e06de46430d9b835de1e9d60b3f01744e
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1640124
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Konsta Holtta
2018-01-16 15:38:13 +02:00
committed by mobile promotions
parent 4021d42cbb
commit 3ccf5c85fb
7 changed files with 11 additions and 4 deletions

View File

@@ -290,6 +290,8 @@ int gk20a_pm_finalize_poweron(struct device *dev)
return err;
}
g->sw_ready = true;
done:
if (err)
g->power_on = false;
@@ -1041,6 +1043,7 @@ void gk20a_driver_start_unload(struct gk20a *g)
/* GR SW ready needs to be invalidated at this time with the busy lock
* held to prevent a racing condition on the gr/mm code */
g->gr.sw_ready = false;
g->sw_ready = false;
up_write(&l->busy_lock);
if (g->is_virtual)