From f6a634ff24194ee83579f90ab399a08d91df233a Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Mon, 9 Jan 2017 10:54:36 -0800 Subject: gpu: nvgpu: use HAL to set TSG timeslice Setting timeslice for virtualized case was not effective, because both ioctls NVGPU_TSG_IOCTL_SET_TIMESLICE and NVGPU_SCHED_IOCTL_TSG_SET_TIMESLICE were calling the native function to set TSG timeslice. - Fixed wrapper function to call HAL - Defined HAL function for "native" set TSG timeslice - Also, properly update timeout_us in TSG context, in virtualized case. This change also moves the min/max bounds checking for tsg timeslice into the native function implementation. There is no sysfs node for these parameters for vgpu, as RM server is ultimately responsible for this check. Bug 200263575 Change-Id: Ibceab9427561ad58ec28abfff0c96ca8f592bdb9 Signed-off-by: Thomas Fleury Reviewed-on: http://git-master/r/1283180 Reviewed-by: svccoveritychecker GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/tsg_gk20a.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/tsg_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c index 81a4b78e..96d6873d 100644 --- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c @@ -177,27 +177,24 @@ int gk20a_init_tsg_support(struct gk20a *g, u32 tsgid) static int gk20a_tsg_set_priority(struct gk20a *g, struct tsg_gk20a *tsg, u32 priority) { + u32 timeslice_us; + switch (priority) { case NVGPU_PRIORITY_LOW: - tsg->timeslice_us = g->timeslice_low_priority_us; + timeslice_us = g->timeslice_low_priority_us; break; case NVGPU_PRIORITY_MEDIUM: - tsg->timeslice_us = g->timeslice_medium_priority_us; + timeslice_us = g->timeslice_medium_priority_us; break; case NVGPU_PRIORITY_HIGH: - tsg->timeslice_us = g->timeslice_high_priority_us; + timeslice_us = g->timeslice_high_priority_us; break; default: pr_err("Unsupported priority"); return -EINVAL; } - gk20a_channel_get_timescale_from_timeslice(g, tsg->timeslice_us, - &tsg->timeslice_timeout, &tsg->timeslice_scale); - - g->ops.fifo.update_runlist(g, tsg->runlist_id, ~0, true, true); - - return 0; + return gk20a_tsg_set_timeslice(tsg, timeslice_us); } static int gk20a_tsg_get_event_data_from_id(struct tsg_gk20a *tsg, @@ -343,6 +340,8 @@ int gk20a_tsg_set_runlist_interleave(struct tsg_gk20a *tsg, u32 level) struct gk20a *g = tsg->g; int ret; + gk20a_dbg(gpu_dbg_sched, "tsgid=%u interleave=%u", tsg->tsgid, level); + switch (level) { case NVGPU_RUNLIST_INTERLEAVE_LEVEL_LOW: case NVGPU_RUNLIST_INTERLEAVE_LEVEL_MEDIUM: @@ -364,16 +363,9 @@ int gk20a_tsg_set_timeslice(struct tsg_gk20a *tsg, u32 timeslice) { struct gk20a *g = tsg->g; - if (timeslice < g->min_timeslice_us || - timeslice > g->max_timeslice_us) - return -EINVAL; - - gk20a_channel_get_timescale_from_timeslice(g, timeslice, - &tsg->timeslice_timeout, &tsg->timeslice_scale); - - tsg->timeslice_us = timeslice; + gk20a_dbg(gpu_dbg_sched, "tsgid=%u timeslice=%u us", tsg->tsgid, timeslice); - return g->ops.fifo.update_runlist(g, tsg->runlist_id, ~0, true, true); + return g->ops.fifo.tsg_set_timeslice(tsg, timeslice); } static void release_used_tsg(struct fifo_gk20a *f, struct tsg_gk20a *tsg) @@ -551,6 +543,8 @@ static int gk20a_tsg_ioctl_set_runlist_interleave(struct gk20a *g, struct gk20a_sched_ctrl *sched = &g->sched_ctrl; int err; + gk20a_dbg(gpu_dbg_fn | gpu_dbg_sched, "tsgid=%u", tsg->tsgid); + mutex_lock(&sched->control_lock); if (sched->control_locked) { err = -EPERM; @@ -576,6 +570,8 @@ static int gk20a_tsg_ioctl_set_timeslice(struct gk20a *g, struct gk20a_sched_ctrl *sched = &g->sched_ctrl; int err; + gk20a_dbg(gpu_dbg_fn | gpu_dbg_sched, "tsgid=%u", tsg->tsgid); + mutex_lock(&sched->control_lock); if (sched->control_locked) { err = -EPERM; @@ -728,5 +724,4 @@ void gk20a_init_tsg_ops(struct gpu_ops *gops) { gops->fifo.tsg_bind_channel = gk20a_tsg_bind_channel; gops->fifo.tsg_unbind_channel = gk20a_tsg_unbind_channel; - gops->fifo.tsg_set_timeslice = gk20a_tsg_set_timeslice; } -- cgit v1.2.2