mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
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:
committed by
mobile promotions
parent
4021d42cbb
commit
3ccf5c85fb
@@ -86,7 +86,7 @@ int gk20a_ctrl_dev_open(struct inode *inode, struct file *filp)
|
||||
*/
|
||||
priv->g = g;
|
||||
|
||||
if (!g->gr.sw_ready) {
|
||||
if (!g->sw_ready) {
|
||||
err = gk20a_busy(g);
|
||||
if (err)
|
||||
goto free_ref;
|
||||
@@ -1556,7 +1556,7 @@ long gk20a_ctrl_dev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (!g->gr.sw_ready) {
|
||||
if (!g->sw_ready) {
|
||||
err = gk20a_busy(g);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -1835,7 +1835,7 @@ long gk20a_dbg_gpu_dev_ioctl(struct file *filp, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (!g->gr.sw_ready) {
|
||||
if (!g->sw_ready) {
|
||||
err = gk20a_busy(g);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -458,7 +458,7 @@ long nvgpu_ioctl_tsg_dev_ioctl(struct file *filp, unsigned int cmd,
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
if (!g->gr.sw_ready) {
|
||||
if (!g->sw_ready) {
|
||||
err = gk20a_busy(g);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -815,6 +815,7 @@ static ssize_t tpc_fs_mask_store(struct device *dev,
|
||||
g->gr.ctx_vars.local_golden_image = NULL;
|
||||
g->gr.ctx_vars.golden_image_initialized = false;
|
||||
g->gr.ctx_vars.golden_image_size = 0;
|
||||
/* Cause next poweron to reinit just gr */
|
||||
g->gr.sw_ready = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -505,6 +505,8 @@ int vgpu_pm_finalize_poweron(struct device *dev)
|
||||
gk20a_sched_ctrl_init(g);
|
||||
gk20a_channel_resume(g);
|
||||
|
||||
g->sw_ready = true;
|
||||
|
||||
done:
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -1133,6 +1133,7 @@ struct gk20a {
|
||||
bool gpu_reset_done;
|
||||
bool power_on;
|
||||
bool suspended;
|
||||
bool sw_ready;
|
||||
|
||||
u32 log_mask;
|
||||
u32 log_trace;
|
||||
|
||||
Reference in New Issue
Block a user