mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
gpu: nvgpu: track gr_ctx init state
On successful obj_ctx allocation, set ctx_initialized member in gr_ctx to true and when it is true then only invoke free_gr_ctx. With this we can get rid of tsg->vm check while calling free_gr_ctx. tsg->vm will go away with multiple address spaces support in TSG. Bug 3677982 Change-Id: I4a64842411ce4ab157010808e4e8e4d5cd254a7f Signed-off-by: Sagar Kamble <skamble@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2746803 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: Scott Long <scottl@nvidia.com> Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
mobile promotions
parent
b1802085f2
commit
3fb2a2e209
@@ -968,6 +968,7 @@ static struct nvgpu_tsg *tsg_gk20a_from_ref(struct nvgpu_ref *ref)
|
|||||||
void nvgpu_tsg_release(struct nvgpu_ref *ref)
|
void nvgpu_tsg_release(struct nvgpu_ref *ref)
|
||||||
{
|
{
|
||||||
struct nvgpu_tsg *tsg = tsg_gk20a_from_ref(ref);
|
struct nvgpu_tsg *tsg = tsg_gk20a_from_ref(ref);
|
||||||
|
struct nvgpu_gr_ctx *gr_ctx = tsg->gr_ctx;
|
||||||
struct gk20a *g = tsg->g;
|
struct gk20a *g = tsg->g;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -977,8 +978,8 @@ void nvgpu_tsg_release(struct nvgpu_ref *ref)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tsg->gr_ctx != NULL) && (tsg->vm != NULL)) {
|
if ((gr_ctx != NULL) && nvgpu_gr_ctx_get_ctx_initialized(gr_ctx)) {
|
||||||
g->ops.gr.setup.free_gr_ctx(g, tsg->gr_ctx);
|
g->ops.gr.setup.free_gr_ctx(g, gr_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NVGPU_CHANNEL_TSG_CONTROL
|
#ifdef CONFIG_NVGPU_CHANNEL_TSG_CONTROL
|
||||||
|
|||||||
@@ -563,6 +563,16 @@ u32 nvgpu_gr_ctx_get_tsgid(struct nvgpu_gr_ctx *gr_ctx)
|
|||||||
return gr_ctx->tsgid;
|
return gr_ctx->tsgid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nvgpu_gr_ctx_mark_ctx_initialized(struct nvgpu_gr_ctx *gr_ctx)
|
||||||
|
{
|
||||||
|
gr_ctx->ctx_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool nvgpu_gr_ctx_get_ctx_initialized(struct nvgpu_gr_ctx *gr_ctx)
|
||||||
|
{
|
||||||
|
return gr_ctx->ctx_initialized;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NVGPU_GRAPHICS
|
#ifdef CONFIG_NVGPU_GRAPHICS
|
||||||
void nvgpu_gr_ctx_init_graphics_preemption_mode(struct nvgpu_gr_ctx *gr_ctx,
|
void nvgpu_gr_ctx_init_graphics_preemption_mode(struct nvgpu_gr_ctx *gr_ctx,
|
||||||
u32 graphics_preempt_mode)
|
u32 graphics_preempt_mode)
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ struct nvgpu_gr_ctx {
|
|||||||
*/
|
*/
|
||||||
u32 tsgid;
|
u32 tsgid;
|
||||||
|
|
||||||
|
bool ctx_initialized;
|
||||||
|
|
||||||
#ifdef CONFIG_NVGPU_SM_DIVERSITY
|
#ifdef CONFIG_NVGPU_SM_DIVERSITY
|
||||||
/** SM diversity configuration offset.
|
/** SM diversity configuration offset.
|
||||||
* It is valid only if NVGPU_SUPPORT_SM_DIVERSITY support is true.
|
* It is valid only if NVGPU_SUPPORT_SM_DIVERSITY support is true.
|
||||||
|
|||||||
@@ -267,6 +267,8 @@ int nvgpu_gr_setup_alloc_obj_ctx(struct nvgpu_channel *c, u32 class_num,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nvgpu_gr_ctx_mark_ctx_initialized(gr_ctx);
|
||||||
|
|
||||||
nvgpu_mutex_release(&tsg->ctx_init_lock);
|
nvgpu_mutex_release(&tsg->ctx_init_lock);
|
||||||
|
|
||||||
nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gr, "done");
|
nvgpu_log(g, gpu_dbg_fn | gpu_dbg_gr, "done");
|
||||||
|
|||||||
@@ -233,7 +233,9 @@ int vgpu_gr_alloc_obj_ctx(struct nvgpu_channel *c, u32 class_num, u32 flags)
|
|||||||
|
|
||||||
err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
|
err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
|
||||||
err = err ? err : msg.ret;
|
err = err ? err : msg.ret;
|
||||||
if (err) {
|
if (err == 0) {
|
||||||
|
nvgpu_gr_ctx_mark_ctx_initialized(gr_ctx);
|
||||||
|
} else {
|
||||||
nvgpu_err(g, "alloc obj ctx failed err %d", err);
|
nvgpu_err(g, "alloc obj ctx failed err %d", err);
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
@@ -530,6 +530,28 @@ void nvgpu_gr_ctx_set_tsgid(struct nvgpu_gr_ctx *gr_ctx, u32 tsgid);
|
|||||||
*/
|
*/
|
||||||
u32 nvgpu_gr_ctx_get_tsgid(struct nvgpu_gr_ctx *gr_ctx);
|
u32 nvgpu_gr_ctx_get_tsgid(struct nvgpu_gr_ctx *gr_ctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Mark graphics context initialized.
|
||||||
|
*
|
||||||
|
* @param gr_ctx [in] Pointer to graphics context struct.
|
||||||
|
*
|
||||||
|
* This function will mark obj_ctx initialized for the gr_ctx by
|
||||||
|
* setting ctx_initialized to true.
|
||||||
|
*/
|
||||||
|
void nvgpu_gr_ctx_mark_ctx_initialized(struct nvgpu_gr_ctx *gr_ctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get ctx_initialized stored in graphics context structure.
|
||||||
|
*
|
||||||
|
* @param gr_ctx [in] Pointer to graphics context struct.
|
||||||
|
*
|
||||||
|
* This function will return ctx_initialized stored in #nvgpu_gr_ctx
|
||||||
|
* structure.
|
||||||
|
*
|
||||||
|
* @return ctx initialization status.
|
||||||
|
*/
|
||||||
|
bool nvgpu_gr_ctx_get_ctx_initialized(struct nvgpu_gr_ctx *gr_ctx);
|
||||||
|
|
||||||
#ifdef CONFIG_NVGPU_CILP
|
#ifdef CONFIG_NVGPU_CILP
|
||||||
bool nvgpu_gr_ctx_get_cilp_preempt_pending(struct nvgpu_gr_ctx *gr_ctx);
|
bool nvgpu_gr_ctx_get_cilp_preempt_pending(struct nvgpu_gr_ctx *gr_ctx);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user