summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu
diff options
context:
space:
mode:
authorThomas Fleury <tfleury@nvidia.com>2017-04-19 19:47:13 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-05-24 07:55:36 -0400
commitb03afb6d5c4bbca5a26cc95027491c816e5e1f6d (patch)
treeb59ae1b881877cf52ca921a5bf9d884f78fac648 /drivers/gpu/nvgpu
parenta823c72219d3bb96bc9489e84b64e0038e7119d7 (diff)
gpu: nvgpu: add ioctls to get current timeslice
Add the following ioctls - NVGPU_CHANNEL_IOCTL_GET_TIMESLICE for channel timeslice in us - NVGPU_TSG_IOCTL_GET_TIMESLICE for TSG timeslice in us If timeslice has not been set explicitly, ioctl returns the default timeslice that will be used when programming the runlist entry. Bug 1883271 Change-Id: Ib18fdd836323b1a2d4efceb1e27d07713bd6fca5 Signed-off-by: Thomas Fleury <tfleury@nvidia.com> Reviewed-on: http://git-master/r/1469040 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_channel.c4
-rw-r--r--drivers/gpu/nvgpu/common/linux/ioctl_tsg.c12
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.c10
-rw-r--r--drivers/gpu/nvgpu/gk20a/channel_gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/gk20a/fifo_gk20a.c14
-rw-r--r--drivers/gpu/nvgpu/gk20a/fifo_gk20a.h5
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/gk20a/tsg_gk20a.c10
-rw-r--r--drivers/gpu/nvgpu/gk20a/tsg_gk20a.h1
-rw-r--r--drivers/gpu/nvgpu/gm20b/fifo_gm20b.c1
-rw-r--r--drivers/gpu/nvgpu/vgpu/fifo_vgpu.c15
11 files changed, 70 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
index 8a87e4cb..4d4d1690 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c
@@ -1125,6 +1125,10 @@ long gk20a_channel_ioctl(struct file *filp,
1125 gk20a_channel_trace_sched_param( 1125 gk20a_channel_trace_sched_param(
1126 trace_gk20a_channel_set_timeslice, ch); 1126 trace_gk20a_channel_set_timeslice, ch);
1127 break; 1127 break;
1128 case NVGPU_IOCTL_CHANNEL_GET_TIMESLICE:
1129 ((struct nvgpu_timeslice_args *)buf)->timeslice_us =
1130 gk20a_channel_get_timeslice(ch);
1131 break;
1128 case NVGPU_IOCTL_CHANNEL_SET_PREEMPTION_MODE: 1132 case NVGPU_IOCTL_CHANNEL_SET_PREEMPTION_MODE:
1129 if (ch->g->ops.gr.set_preemption_mode) { 1133 if (ch->g->ops.gr.set_preemption_mode) {
1130 err = gk20a_busy(ch->g); 1134 err = gk20a_busy(ch->g);
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c
index e67965e1..25805ea0 100644
--- a/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c
+++ b/drivers/gpu/nvgpu/common/linux/ioctl_tsg.c
@@ -340,6 +340,12 @@ done:
340 return err; 340 return err;
341} 341}
342 342
343static int gk20a_tsg_ioctl_get_timeslice(struct gk20a *g,
344 struct tsg_gk20a *tsg, struct nvgpu_timeslice_args *arg)
345{
346 arg->timeslice_us = gk20a_tsg_get_timeslice(tsg);
347 return 0;
348}
343 349
344long nvgpu_ioctl_tsg_dev_ioctl(struct file *filp, unsigned int cmd, 350long nvgpu_ioctl_tsg_dev_ioctl(struct file *filp, unsigned int cmd,
345 unsigned long arg) 351 unsigned long arg)
@@ -455,6 +461,12 @@ long nvgpu_ioctl_tsg_dev_ioctl(struct file *filp, unsigned int cmd,
455 (struct nvgpu_timeslice_args *)buf); 461 (struct nvgpu_timeslice_args *)buf);
456 break; 462 break;
457 } 463 }
464 case NVGPU_IOCTL_TSG_GET_TIMESLICE:
465 {
466 err = gk20a_tsg_ioctl_get_timeslice(g, tsg,
467 (struct nvgpu_timeslice_args *)buf);
468 break;
469 }
458 470
459 default: 471 default:
460 nvgpu_err(g, "unrecognized tsg gpu ioctl cmd: 0x%x", 472 nvgpu_err(g, "unrecognized tsg gpu ioctl cmd: 0x%x",
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
index 9e3bc05e..6cb77d67 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.c
@@ -146,6 +146,16 @@ int channel_gk20a_commit_va(struct channel_gk20a *c)
146 return 0; 146 return 0;
147} 147}
148 148
149u32 gk20a_channel_get_timeslice(struct channel_gk20a *ch)
150{
151 struct gk20a *g = ch->g;
152
153 if (!ch->timeslice_us)
154 return g->ops.fifo.default_timeslice_us(g);
155
156 return ch->timeslice_us;
157}
158
149int gk20a_channel_get_timescale_from_timeslice(struct gk20a *g, 159int gk20a_channel_get_timescale_from_timeslice(struct gk20a *g,
150 int timeslice_period, 160 int timeslice_period,
151 int *__timeslice_timeout, int *__timeslice_scale) 161 int *__timeslice_timeout, int *__timeslice_scale)
diff --git a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h
index bbc1a72a..d3ab9b27 100644
--- a/drivers/gpu/nvgpu/gk20a/channel_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/channel_gk20a.h
@@ -388,6 +388,7 @@ void channel_gk20a_joblist_lock(struct channel_gk20a *c);
388void channel_gk20a_joblist_unlock(struct channel_gk20a *c); 388void channel_gk20a_joblist_unlock(struct channel_gk20a *c);
389bool channel_gk20a_joblist_is_empty(struct channel_gk20a *c); 389bool channel_gk20a_joblist_is_empty(struct channel_gk20a *c);
390 390
391u32 gk20a_channel_get_timeslice(struct channel_gk20a *ch);
391int gk20a_channel_get_timescale_from_timeslice(struct gk20a *g, 392int gk20a_channel_get_timescale_from_timeslice(struct gk20a *g,
392 int timeslice_period, 393 int timeslice_period,
393 int *__timeslice_timeout, int *__timeslice_scale); 394 int *__timeslice_timeout, int *__timeslice_scale);
diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
index 8085318d..f536b374 100644
--- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c
@@ -2920,14 +2920,24 @@ void gk20a_get_tsg_runlist_entry(struct tsg_gk20a *tsg, u32 *runlist)
2920 ram_rl_entry_timeslice_timeout_f(tsg->timeslice_timeout); 2920 ram_rl_entry_timeslice_timeout_f(tsg->timeslice_timeout);
2921 else 2921 else
2922 runlist_entry_0 |= 2922 runlist_entry_0 |=
2923 ram_rl_entry_timeslice_scale_3_f() | 2923 ram_rl_entry_timeslice_scale_f(
2924 ram_rl_entry_timeslice_timeout_128_f(); 2924 NVGPU_FIFO_DEFAULT_TIMESLICE_SCALE) |
2925 ram_rl_entry_timeslice_timeout_f(
2926 NVGPU_FIFO_DEFAULT_TIMESLICE_TIMEOUT);
2925 2927
2926 runlist[0] = runlist_entry_0; 2928 runlist[0] = runlist_entry_0;
2927 runlist[1] = 0; 2929 runlist[1] = 0;
2928 2930
2929} 2931}
2930 2932
2933u32 gk20a_fifo_default_timeslice_us(struct gk20a *g)
2934{
2935 return (((u64)(NVGPU_FIFO_DEFAULT_TIMESLICE_TIMEOUT <<
2936 NVGPU_FIFO_DEFAULT_TIMESLICE_SCALE) *
2937 (u64)g->ptimer_src_freq) /
2938 (u64)PTIMER_REF_FREQ_HZ);
2939}
2940
2931void gk20a_get_ch_runlist_entry(struct channel_gk20a *ch, u32 *runlist) 2941void gk20a_get_ch_runlist_entry(struct channel_gk20a *ch, u32 *runlist)
2932{ 2942{
2933 runlist[0] = ram_rl_entry_chid_f(ch->hw_chid); 2943 runlist[0] = ram_rl_entry_chid_f(ch->hw_chid);
diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
index 0bec9e82..b09fde65 100644
--- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.h
@@ -47,6 +47,9 @@
47#define RC_TYPE_PBDMA_FAULT 2 47#define RC_TYPE_PBDMA_FAULT 2
48#define RC_TYPE_NO_RC 0xff 48#define RC_TYPE_NO_RC 0xff
49 49
50#define NVGPU_FIFO_DEFAULT_TIMESLICE_TIMEOUT 128UL
51#define NVGPU_FIFO_DEFAULT_TIMESLICE_SCALE 3UL
52
50/* 53/*
51 * Number of entries in the kickoff latency buffer, used to calculate 54 * Number of entries in the kickoff latency buffer, used to calculate
52 * the profiling and histogram. This number is calculated to be statistically 55 * the profiling and histogram. This number is calculated to be statistically
@@ -399,4 +402,6 @@ void gk20a_fifo_reset_pbdma_method(struct gk20a *g, int pbdma_id,
399 int pbdma_method_index); 402 int pbdma_method_index);
400unsigned int gk20a_fifo_handle_pbdma_intr_0(struct gk20a *g, u32 pbdma_id, 403unsigned int gk20a_fifo_handle_pbdma_intr_0(struct gk20a *g, u32 pbdma_id,
401 u32 pbdma_intr_0, u32 *handled, u32 *error_notifier); 404 u32 pbdma_intr_0, u32 *handled, u32 *error_notifier);
405
406u32 gk20a_fifo_default_timeslice_us(struct gk20a *g);
402#endif /*__GR_GK20A_H__*/ 407#endif /*__GR_GK20A_H__*/
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 9ab0d202..b3292ac4 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -445,6 +445,7 @@ struct gpu_ops {
445 int (*channel_set_timeslice)(struct channel_gk20a *ch, 445 int (*channel_set_timeslice)(struct channel_gk20a *ch,
446 u32 timeslice); 446 u32 timeslice);
447 int (*tsg_set_timeslice)(struct tsg_gk20a *tsg, u32 timeslice); 447 int (*tsg_set_timeslice)(struct tsg_gk20a *tsg, u32 timeslice);
448 u32 (*default_timeslice_us)(struct gk20a *);
448 int (*force_reset_ch)(struct channel_gk20a *ch, 449 int (*force_reset_ch)(struct channel_gk20a *ch,
449 u32 err_code, bool verbose); 450 u32 err_code, bool verbose);
450 int (*engine_enum_from_type)(struct gk20a *g, u32 engine_type, 451 int (*engine_enum_from_type)(struct gk20a *g, u32 engine_type,
diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
index f9884cfb..9cb5b262 100644
--- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.c
@@ -211,6 +211,16 @@ int gk20a_tsg_set_timeslice(struct tsg_gk20a *tsg, u32 timeslice)
211 return g->ops.fifo.tsg_set_timeslice(tsg, timeslice); 211 return g->ops.fifo.tsg_set_timeslice(tsg, timeslice);
212} 212}
213 213
214u32 gk20a_tsg_get_timeslice(struct tsg_gk20a *tsg)
215{
216 struct gk20a *g = tsg->g;
217
218 if (!tsg->timeslice_us)
219 return g->ops.fifo.default_timeslice_us(g);
220
221 return tsg->timeslice_us;
222}
223
214static void release_used_tsg(struct fifo_gk20a *f, struct tsg_gk20a *tsg) 224static void release_used_tsg(struct fifo_gk20a *f, struct tsg_gk20a *tsg)
215{ 225{
216 nvgpu_mutex_acquire(&f->tsg_inuse_mutex); 226 nvgpu_mutex_acquire(&f->tsg_inuse_mutex);
diff --git a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h
index 945058a2..5a13c912 100644
--- a/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/tsg_gk20a.h
@@ -70,6 +70,7 @@ void gk20a_tsg_event_id_post_event(struct tsg_gk20a *tsg,
70 int event_id); 70 int event_id);
71int gk20a_tsg_set_runlist_interleave(struct tsg_gk20a *tsg, u32 level); 71int gk20a_tsg_set_runlist_interleave(struct tsg_gk20a *tsg, u32 level);
72int gk20a_tsg_set_timeslice(struct tsg_gk20a *tsg, u32 timeslice); 72int gk20a_tsg_set_timeslice(struct tsg_gk20a *tsg, u32 timeslice);
73u32 gk20a_tsg_get_timeslice(struct tsg_gk20a *tsg);
73int gk20a_tsg_set_priority(struct gk20a *g, struct tsg_gk20a *tsg, 74int gk20a_tsg_set_priority(struct gk20a *g, struct tsg_gk20a *tsg,
74 u32 priority); 75 u32 priority);
75 76
diff --git a/drivers/gpu/nvgpu/gm20b/fifo_gm20b.c b/drivers/gpu/nvgpu/gm20b/fifo_gm20b.c
index ed3a4b98..513f250d 100644
--- a/drivers/gpu/nvgpu/gm20b/fifo_gm20b.c
+++ b/drivers/gpu/nvgpu/gm20b/fifo_gm20b.c
@@ -195,6 +195,7 @@ void gm20b_init_fifo(struct gpu_ops *gops)
195 gops->fifo.setup_ramfc = gk20a_fifo_setup_ramfc; 195 gops->fifo.setup_ramfc = gk20a_fifo_setup_ramfc;
196 gops->fifo.channel_set_priority = gk20a_fifo_set_priority; 196 gops->fifo.channel_set_priority = gk20a_fifo_set_priority;
197 gops->fifo.channel_set_timeslice = gk20a_fifo_set_timeslice; 197 gops->fifo.channel_set_timeslice = gk20a_fifo_set_timeslice;
198 gops->fifo.default_timeslice_us = gk20a_fifo_default_timeslice_us;
198 gops->fifo.setup_userd = gk20a_fifo_setup_userd; 199 gops->fifo.setup_userd = gk20a_fifo_setup_userd;
199 gops->fifo.userd_gp_get = gk20a_fifo_userd_gp_get; 200 gops->fifo.userd_gp_get = gk20a_fifo_userd_gp_get;
200 gops->fifo.userd_gp_put = gk20a_fifo_userd_gp_put; 201 gops->fifo.userd_gp_put = gk20a_fifo_userd_gp_put;
diff --git a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c
index 309a395a..28514386 100644
--- a/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c
+++ b/drivers/gpu/nvgpu/vgpu/fifo_vgpu.c
@@ -655,8 +655,11 @@ static int vgpu_channel_set_timeslice(struct channel_gk20a *ch, u32 timeslice)
655 p->handle = ch->virt_ctx; 655 p->handle = ch->virt_ctx;
656 p->timeslice_us = timeslice; 656 p->timeslice_us = timeslice;
657 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); 657 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
658 WARN_ON(err || msg.ret); 658 err = err ? err : msg.ret;
659 return err ? err : msg.ret; 659 WARN_ON(err);
660 if (!err)
661 ch->timeslice_us = p->timeslice_us;
662 return err;
660} 663}
661 664
662static int vgpu_fifo_force_reset_ch(struct channel_gk20a *ch, 665static int vgpu_fifo_force_reset_ch(struct channel_gk20a *ch,
@@ -776,6 +779,13 @@ int vgpu_fifo_nonstall_isr(struct gk20a *g,
776 return 0; 779 return 0;
777} 780}
778 781
782u32 vgpu_fifo_default_timeslice_us(struct gk20a *g)
783{
784 struct vgpu_priv_data *priv = vgpu_get_priv_data(g);
785
786 return priv->constants.default_timeslice_us;
787}
788
779void vgpu_init_fifo_ops(struct gpu_ops *gops) 789void vgpu_init_fifo_ops(struct gpu_ops *gops)
780{ 790{
781 gops->fifo.bind_channel = vgpu_channel_bind; 791 gops->fifo.bind_channel = vgpu_channel_bind;
@@ -794,4 +804,5 @@ void vgpu_init_fifo_ops(struct gpu_ops *gops)
794 gops->fifo.channel_set_timeslice = vgpu_channel_set_timeslice; 804 gops->fifo.channel_set_timeslice = vgpu_channel_set_timeslice;
795 gops->fifo.force_reset_ch = vgpu_fifo_force_reset_ch; 805 gops->fifo.force_reset_ch = vgpu_fifo_force_reset_ch;
796 gops->fifo.init_engine_info = vgpu_fifo_init_engine_info; 806 gops->fifo.init_engine_info = vgpu_fifo_init_engine_info;
807 gops->fifo.default_timeslice_us = vgpu_fifo_default_timeslice_us;
797} 808}