mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: set preemption mode for specific GR instance
Pass gr_instance_id to function nvgpu_gr_setup_set_preemption_mode() which picks up correct nvgpu_gr struct pointer based on instance id. nvgpu_gr_get_cur_instance_ptr() is not needed in this special case since there is no PGRAPH register programming required to set preemption mode. All writes/updates are done on context image. Also fix unit tests accordingly to always select 0th GR instance. Jira NVGPU-5648 Change-Id: I46eff816d5a4afe784bf75b64ee9d698c77eb64a Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2435468 Reviewed-by: automaticguardword <automaticguardword@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: svc-mobile-misra <svc-mobile-misra@nvidia.com> Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com> Reviewed-by: Lakshmanan M <lm@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
4478cb6b2f
commit
d584294545
@@ -295,8 +295,8 @@ static bool nvgpu_gr_setup_validate_preemption_mode(u32 *graphics_preempt_mode,
|
||||
|
||||
|
||||
int nvgpu_gr_setup_set_preemption_mode(struct nvgpu_channel *ch,
|
||||
u32 graphics_preempt_mode,
|
||||
u32 compute_preempt_mode)
|
||||
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||
u32 gr_instance_id)
|
||||
{
|
||||
struct nvgpu_gr_ctx *gr_ctx;
|
||||
struct gk20a *g = ch->g;
|
||||
@@ -306,7 +306,7 @@ int nvgpu_gr_setup_set_preemption_mode(struct nvgpu_channel *ch,
|
||||
u32 class_num;
|
||||
int err = 0;
|
||||
|
||||
gr = nvgpu_gr_get_cur_instance_ptr(g);
|
||||
gr = &g->gr[gr_instance_id];
|
||||
|
||||
class_num = ch->obj_class;
|
||||
if (class_num == 0U) {
|
||||
|
||||
@@ -1470,8 +1470,8 @@ fail:
|
||||
}
|
||||
|
||||
int vgpu_gr_set_preemption_mode(struct nvgpu_channel *ch,
|
||||
u32 graphics_preempt_mode,
|
||||
u32 compute_preempt_mode)
|
||||
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||
u32 gr_instance_id)
|
||||
{
|
||||
struct nvgpu_gr_ctx *gr_ctx;
|
||||
struct gk20a *g = ch->g;
|
||||
|
||||
@@ -86,8 +86,8 @@ int vgpu_gr_init_sm_id_table(struct gk20a *g,
|
||||
int vgpu_gr_update_pc_sampling(struct nvgpu_channel *ch, bool enable);
|
||||
void vgpu_gr_init_cyclestats(struct gk20a *g);
|
||||
int vgpu_gr_set_preemption_mode(struct nvgpu_channel *ch,
|
||||
u32 graphics_preempt_mode,
|
||||
u32 compute_preempt_mode);
|
||||
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||
u32 gr_instance_id);
|
||||
int vgpu_gr_isr(struct gk20a *g, struct tegra_vgpu_gr_intr_info *info);
|
||||
void vgpu_gr_handle_sm_esr_event(struct gk20a *g,
|
||||
struct tegra_vgpu_sm_esr_info *info);
|
||||
|
||||
@@ -204,6 +204,8 @@ struct gops_gr_setup {
|
||||
* preemption mode.
|
||||
* @param compute_preempt_mode [in] Requested compute
|
||||
* preemption mode.
|
||||
* @param gr_instance_id[in] Instance ID of
|
||||
* graphics engine.
|
||||
*
|
||||
* This function will program newly requested preemption modes
|
||||
* into GR engine context image.
|
||||
@@ -223,7 +225,8 @@ struct gops_gr_setup {
|
||||
*/
|
||||
int (*set_preemption_mode)(struct nvgpu_channel *ch,
|
||||
u32 graphics_preempt_mode,
|
||||
u32 compute_preempt_mode);
|
||||
u32 compute_preempt_mode,
|
||||
u32 gr_instance_id);
|
||||
|
||||
/** @cond DOXYGEN_SHOULD_SKIP_THIS */
|
||||
#ifdef CONFIG_NVGPU_GRAPHICS
|
||||
|
||||
@@ -108,6 +108,7 @@ void nvgpu_gr_setup_free_subctx(struct nvgpu_channel *c);
|
||||
* @param ch [in] Pointer to GPU channel.
|
||||
* @param graphics_preempt_mode [in] Requested graphics preemption mode.
|
||||
* @param compute_preempt_mode [in] Requested compute preemption mode.
|
||||
* @param gr_instance_id [in] Instance ID of the graphics engine.
|
||||
*
|
||||
* This function will program newly requested preemption modes into
|
||||
* GR engine context image. This function is typically needed if user
|
||||
@@ -122,8 +123,8 @@ void nvgpu_gr_setup_free_subctx(struct nvgpu_channel *c);
|
||||
* @retval -EINVAL if invalid GPU channel pointer is provided.
|
||||
*/
|
||||
int nvgpu_gr_setup_set_preemption_mode(struct nvgpu_channel *ch,
|
||||
u32 graphics_preempt_mode,
|
||||
u32 compute_preempt_mode);
|
||||
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||
u32 gr_instance_id);
|
||||
|
||||
#ifdef CONFIG_NVGPU_GRAPHICS
|
||||
int nvgpu_gr_setup_bind_ctxsw_zcull(struct gk20a *g, struct nvgpu_channel *c,
|
||||
|
||||
@@ -1086,7 +1086,8 @@ static u32 nvgpu_get_common_compute_preempt_mode(u32 compute_preempt_mode)
|
||||
}
|
||||
|
||||
static int nvgpu_ioctl_channel_set_preemption_mode(struct nvgpu_channel *ch,
|
||||
u32 graphics_preempt_mode, u32 compute_preempt_mode)
|
||||
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||
u32 gr_instance_id)
|
||||
{
|
||||
int err;
|
||||
|
||||
@@ -1098,7 +1099,8 @@ static int nvgpu_ioctl_channel_set_preemption_mode(struct nvgpu_channel *ch,
|
||||
}
|
||||
err = ch->g->ops.gr.setup.set_preemption_mode(ch,
|
||||
nvgpu_get_common_graphics_preempt_mode(graphics_preempt_mode),
|
||||
nvgpu_get_common_compute_preempt_mode(compute_preempt_mode));
|
||||
nvgpu_get_common_compute_preempt_mode(compute_preempt_mode),
|
||||
gr_instance_id);
|
||||
gk20a_idle(ch->g);
|
||||
} else {
|
||||
err = -EINVAL;
|
||||
@@ -1468,7 +1470,8 @@ long gk20a_channel_ioctl(struct file *filp,
|
||||
case NVGPU_IOCTL_CHANNEL_SET_PREEMPTION_MODE:
|
||||
err = nvgpu_ioctl_channel_set_preemption_mode(ch,
|
||||
((struct nvgpu_preemption_mode_args *)buf)->graphics_preempt_mode,
|
||||
((struct nvgpu_preemption_mode_args *)buf)->compute_preempt_mode);
|
||||
((struct nvgpu_preemption_mode_args *)buf)->compute_preempt_mode,
|
||||
gr_instance_id);
|
||||
break;
|
||||
case NVGPU_IOCTL_CHANNEL_SET_BOOSTED_CTX:
|
||||
if (ch->g->ops.gr.set_boosted_ctx) {
|
||||
|
||||
@@ -288,7 +288,7 @@ int test_gr_setup_preemption_mode_errors(struct unit_module *m,
|
||||
for (i = 0; i < arry_cnt; i++) {
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch,
|
||||
preemp_mode_types[i].graphics_mode,
|
||||
preemp_mode_types[i].compute_mode);
|
||||
preemp_mode_types[i].compute_mode, 0);
|
||||
if (err != preemp_mode_types[i].result) {
|
||||
unit_return_fail(m, "Fail Preemp_mode Error Test-1\n");
|
||||
}
|
||||
@@ -299,7 +299,7 @@ int test_gr_setup_preemption_mode_errors(struct unit_module *m,
|
||||
NVGPU_PREEMPTION_MODE_COMPUTE_WFI;
|
||||
g->ops.fifo.preempt_tsg = stub_gr_fifo_preempt_tsg;
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0,
|
||||
NVGPU_PREEMPTION_MODE_COMPUTE_CTA);
|
||||
NVGPU_PREEMPTION_MODE_COMPUTE_CTA, 0);
|
||||
if (err == 0) {
|
||||
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
||||
}
|
||||
@@ -308,7 +308,7 @@ int test_gr_setup_preemption_mode_errors(struct unit_module *m,
|
||||
tsgid = gr_setup_ch->tsgid;
|
||||
/* Unset the tsgid */
|
||||
gr_setup_ch->tsgid = NVGPU_INVALID_TSG_ID;
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0, 0);
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0, 0, 0);
|
||||
if (err == 0) {
|
||||
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
||||
}
|
||||
@@ -316,14 +316,14 @@ int test_gr_setup_preemption_mode_errors(struct unit_module *m,
|
||||
gr_setup_ch->tsgid = tsgid;
|
||||
/* Unset the valid Class*/
|
||||
gr_setup_ch->obj_class = 0;
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0, 0);
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0, 0, 0);
|
||||
if (err == 0) {
|
||||
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
||||
}
|
||||
|
||||
/* Set invalid Class*/
|
||||
gr_setup_ch->obj_class = 0x1234;
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0, 0);
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0, 0, 0);
|
||||
if (err == 0) {
|
||||
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
||||
}
|
||||
@@ -606,7 +606,7 @@ int test_gr_setup_set_preemption_mode(struct unit_module *m,
|
||||
&compute_mode);
|
||||
|
||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0,
|
||||
(compute_mode & NVGPU_PREEMPTION_MODE_COMPUTE_CTA));
|
||||
(compute_mode & NVGPU_PREEMPTION_MODE_COMPUTE_CTA), 0);
|
||||
if (err != 0) {
|
||||
unit_return_fail(m, "setup preemption_mode failed\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user