mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +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,
|
int nvgpu_gr_setup_set_preemption_mode(struct nvgpu_channel *ch,
|
||||||
u32 graphics_preempt_mode,
|
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||||
u32 compute_preempt_mode)
|
u32 gr_instance_id)
|
||||||
{
|
{
|
||||||
struct nvgpu_gr_ctx *gr_ctx;
|
struct nvgpu_gr_ctx *gr_ctx;
|
||||||
struct gk20a *g = ch->g;
|
struct gk20a *g = ch->g;
|
||||||
@@ -306,7 +306,7 @@ int nvgpu_gr_setup_set_preemption_mode(struct nvgpu_channel *ch,
|
|||||||
u32 class_num;
|
u32 class_num;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
gr = nvgpu_gr_get_cur_instance_ptr(g);
|
gr = &g->gr[gr_instance_id];
|
||||||
|
|
||||||
class_num = ch->obj_class;
|
class_num = ch->obj_class;
|
||||||
if (class_num == 0U) {
|
if (class_num == 0U) {
|
||||||
|
|||||||
@@ -1470,8 +1470,8 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int vgpu_gr_set_preemption_mode(struct nvgpu_channel *ch,
|
int vgpu_gr_set_preemption_mode(struct nvgpu_channel *ch,
|
||||||
u32 graphics_preempt_mode,
|
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||||
u32 compute_preempt_mode)
|
u32 gr_instance_id)
|
||||||
{
|
{
|
||||||
struct nvgpu_gr_ctx *gr_ctx;
|
struct nvgpu_gr_ctx *gr_ctx;
|
||||||
struct gk20a *g = ch->g;
|
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);
|
int vgpu_gr_update_pc_sampling(struct nvgpu_channel *ch, bool enable);
|
||||||
void vgpu_gr_init_cyclestats(struct gk20a *g);
|
void vgpu_gr_init_cyclestats(struct gk20a *g);
|
||||||
int vgpu_gr_set_preemption_mode(struct nvgpu_channel *ch,
|
int vgpu_gr_set_preemption_mode(struct nvgpu_channel *ch,
|
||||||
u32 graphics_preempt_mode,
|
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||||
u32 compute_preempt_mode);
|
u32 gr_instance_id);
|
||||||
int vgpu_gr_isr(struct gk20a *g, struct tegra_vgpu_gr_intr_info *info);
|
int vgpu_gr_isr(struct gk20a *g, struct tegra_vgpu_gr_intr_info *info);
|
||||||
void vgpu_gr_handle_sm_esr_event(struct gk20a *g,
|
void vgpu_gr_handle_sm_esr_event(struct gk20a *g,
|
||||||
struct tegra_vgpu_sm_esr_info *info);
|
struct tegra_vgpu_sm_esr_info *info);
|
||||||
|
|||||||
@@ -204,6 +204,8 @@ struct gops_gr_setup {
|
|||||||
* preemption mode.
|
* preemption mode.
|
||||||
* @param compute_preempt_mode [in] Requested compute
|
* @param compute_preempt_mode [in] Requested compute
|
||||||
* preemption mode.
|
* preemption mode.
|
||||||
|
* @param gr_instance_id[in] Instance ID of
|
||||||
|
* graphics engine.
|
||||||
*
|
*
|
||||||
* This function will program newly requested preemption modes
|
* This function will program newly requested preemption modes
|
||||||
* into GR engine context image.
|
* into GR engine context image.
|
||||||
@@ -223,7 +225,8 @@ struct gops_gr_setup {
|
|||||||
*/
|
*/
|
||||||
int (*set_preemption_mode)(struct nvgpu_channel *ch,
|
int (*set_preemption_mode)(struct nvgpu_channel *ch,
|
||||||
u32 graphics_preempt_mode,
|
u32 graphics_preempt_mode,
|
||||||
u32 compute_preempt_mode);
|
u32 compute_preempt_mode,
|
||||||
|
u32 gr_instance_id);
|
||||||
|
|
||||||
/** @cond DOXYGEN_SHOULD_SKIP_THIS */
|
/** @cond DOXYGEN_SHOULD_SKIP_THIS */
|
||||||
#ifdef CONFIG_NVGPU_GRAPHICS
|
#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 ch [in] Pointer to GPU channel.
|
||||||
* @param graphics_preempt_mode [in] Requested graphics preemption mode.
|
* @param graphics_preempt_mode [in] Requested graphics preemption mode.
|
||||||
* @param compute_preempt_mode [in] Requested compute 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
|
* This function will program newly requested preemption modes into
|
||||||
* GR engine context image. This function is typically needed if user
|
* 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.
|
* @retval -EINVAL if invalid GPU channel pointer is provided.
|
||||||
*/
|
*/
|
||||||
int nvgpu_gr_setup_set_preemption_mode(struct nvgpu_channel *ch,
|
int nvgpu_gr_setup_set_preemption_mode(struct nvgpu_channel *ch,
|
||||||
u32 graphics_preempt_mode,
|
u32 graphics_preempt_mode, u32 compute_preempt_mode,
|
||||||
u32 compute_preempt_mode);
|
u32 gr_instance_id);
|
||||||
|
|
||||||
#ifdef CONFIG_NVGPU_GRAPHICS
|
#ifdef CONFIG_NVGPU_GRAPHICS
|
||||||
int nvgpu_gr_setup_bind_ctxsw_zcull(struct gk20a *g, struct nvgpu_channel *c,
|
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,
|
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;
|
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,
|
err = ch->g->ops.gr.setup.set_preemption_mode(ch,
|
||||||
nvgpu_get_common_graphics_preempt_mode(graphics_preempt_mode),
|
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);
|
gk20a_idle(ch->g);
|
||||||
} else {
|
} else {
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
@@ -1468,7 +1470,8 @@ long gk20a_channel_ioctl(struct file *filp,
|
|||||||
case NVGPU_IOCTL_CHANNEL_SET_PREEMPTION_MODE:
|
case NVGPU_IOCTL_CHANNEL_SET_PREEMPTION_MODE:
|
||||||
err = nvgpu_ioctl_channel_set_preemption_mode(ch,
|
err = nvgpu_ioctl_channel_set_preemption_mode(ch,
|
||||||
((struct nvgpu_preemption_mode_args *)buf)->graphics_preempt_mode,
|
((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;
|
break;
|
||||||
case NVGPU_IOCTL_CHANNEL_SET_BOOSTED_CTX:
|
case NVGPU_IOCTL_CHANNEL_SET_BOOSTED_CTX:
|
||||||
if (ch->g->ops.gr.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++) {
|
for (i = 0; i < arry_cnt; i++) {
|
||||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch,
|
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch,
|
||||||
preemp_mode_types[i].graphics_mode,
|
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) {
|
if (err != preemp_mode_types[i].result) {
|
||||||
unit_return_fail(m, "Fail Preemp_mode Error Test-1\n");
|
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;
|
NVGPU_PREEMPTION_MODE_COMPUTE_WFI;
|
||||||
g->ops.fifo.preempt_tsg = stub_gr_fifo_preempt_tsg;
|
g->ops.fifo.preempt_tsg = stub_gr_fifo_preempt_tsg;
|
||||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0,
|
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) {
|
if (err == 0) {
|
||||||
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
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;
|
tsgid = gr_setup_ch->tsgid;
|
||||||
/* Unset the tsgid */
|
/* Unset the tsgid */
|
||||||
gr_setup_ch->tsgid = NVGPU_INVALID_TSG_ID;
|
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) {
|
if (err == 0) {
|
||||||
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
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;
|
gr_setup_ch->tsgid = tsgid;
|
||||||
/* Unset the valid Class*/
|
/* Unset the valid Class*/
|
||||||
gr_setup_ch->obj_class = 0;
|
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) {
|
if (err == 0) {
|
||||||
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set invalid Class*/
|
/* Set invalid Class*/
|
||||||
gr_setup_ch->obj_class = 0x1234;
|
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) {
|
if (err == 0) {
|
||||||
unit_return_fail(m, "Fail Preemp_mode Error Test-2\n");
|
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);
|
&compute_mode);
|
||||||
|
|
||||||
err = g->ops.gr.setup.set_preemption_mode(gr_setup_ch, 0,
|
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) {
|
if (err != 0) {
|
||||||
unit_return_fail(m, "setup preemption_mode failed\n");
|
unit_return_fail(m, "setup preemption_mode failed\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user