summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/tsg_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/tsg_gk20a.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
index 0eaa23ab..40c871ce 100644
--- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
@@ -25,6 +25,9 @@
25#include "gk20a.h" 25#include "gk20a.h"
26#include "hw_ccsr_gk20a.h" 26#include "hw_ccsr_gk20a.h"
27 27
28#define NVGPU_TSG_MIN_TIMESLICE_US 1000
29#define NVGPU_TSG_MAX_TIMESLICE_US 50000
30
28static void gk20a_tsg_release(struct kref *ref); 31static void gk20a_tsg_release(struct kref *ref);
29 32
30bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch) 33bool gk20a_is_channel_marked_as_tsg(struct channel_gk20a *ch)
@@ -345,6 +348,20 @@ static int gk20a_tsg_set_runlist_interleave(struct tsg_gk20a *tsg, u32 level)
345 return ret ? ret : g->ops.fifo.update_runlist(g, 0, ~0, true, true); 348 return ret ? ret : g->ops.fifo.update_runlist(g, 0, ~0, true, true);
346} 349}
347 350
351static int gk20a_tsg_set_timeslice(struct tsg_gk20a *tsg, u32 timeslice)
352{
353 struct gk20a *g = tsg->g;
354
355 if (timeslice < NVGPU_TSG_MIN_TIMESLICE_US ||
356 timeslice > NVGPU_TSG_MAX_TIMESLICE_US)
357 return -EINVAL;
358
359 gk20a_channel_get_timescale_from_timeslice(g, timeslice,
360 &tsg->timeslice_timeout, &tsg->timeslice_scale);
361
362 return g->ops.fifo.update_runlist(g, 0, ~0, true, true);
363}
364
348static void release_used_tsg(struct fifo_gk20a *f, struct tsg_gk20a *tsg) 365static void release_used_tsg(struct fifo_gk20a *f, struct tsg_gk20a *tsg)
349{ 366{
350 mutex_lock(&f->tsg_inuse_mutex); 367 mutex_lock(&f->tsg_inuse_mutex);
@@ -554,6 +571,20 @@ long gk20a_tsg_dev_ioctl(struct file *filp, unsigned int cmd,
554 break; 571 break;
555 } 572 }
556 573
574 case NVGPU_IOCTL_TSG_SET_TIMESLICE:
575 {
576 err = gk20a_busy(g->dev);
577 if (err) {
578 gk20a_err(dev_from_gk20a(g),
579 "failed to host gk20a for ioctl cmd: 0x%x", cmd);
580 return err;
581 }
582 err = gk20a_tsg_set_timeslice(tsg,
583 ((struct nvgpu_timeslice_args *)buf)->timeslice_us);
584 gk20a_idle(g->dev);
585 break;
586 }
587
557 default: 588 default:
558 gk20a_err(dev_from_gk20a(g), 589 gk20a_err(dev_from_gk20a(g),
559 "unrecognized tsg gpu ioctl cmd: 0x%x", 590 "unrecognized tsg gpu ioctl cmd: 0x%x",