diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 148 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.h | 5 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c | 24 |
3 files changed, 159 insertions, 18 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c index f5947828..6feb6fb7 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.c | |||
@@ -45,7 +45,7 @@ | |||
45 | static const char *gr_gk20a_graphics_preempt_mode_name(u32 graphics_preempt_mode) | 45 | static const char *gr_gk20a_graphics_preempt_mode_name(u32 graphics_preempt_mode) |
46 | { | 46 | { |
47 | switch (graphics_preempt_mode) { | 47 | switch (graphics_preempt_mode) { |
48 | case NVGPU_GRAPHICS_PREEMPTION_MODE_WFI: | 48 | case NVGPU_PREEMPTION_MODE_GRAPHICS_WFI: |
49 | return "WFI"; | 49 | return "WFI"; |
50 | default: | 50 | default: |
51 | return "?"; | 51 | return "?"; |
@@ -55,9 +55,9 @@ static const char *gr_gk20a_graphics_preempt_mode_name(u32 graphics_preempt_mode | |||
55 | static const char *gr_gk20a_compute_preempt_mode_name(u32 compute_preempt_mode) | 55 | static const char *gr_gk20a_compute_preempt_mode_name(u32 compute_preempt_mode) |
56 | { | 56 | { |
57 | switch (compute_preempt_mode) { | 57 | switch (compute_preempt_mode) { |
58 | case NVGPU_COMPUTE_PREEMPTION_MODE_WFI: | 58 | case NVGPU_PREEMPTION_MODE_COMPUTE_WFI: |
59 | return "WFI"; | 59 | return "WFI"; |
60 | case NVGPU_COMPUTE_PREEMPTION_MODE_CTA: | 60 | case NVGPU_PREEMPTION_MODE_COMPUTE_CTA: |
61 | return "CTA"; | 61 | return "CTA"; |
62 | default: | 62 | default: |
63 | return "?"; | 63 | return "?"; |
@@ -991,6 +991,130 @@ static int nvgpu_ioctl_channel_alloc_obj_ctx(struct channel_gk20a *ch, | |||
991 | nvgpu_obj_ctx_user_flags_to_common_flags(user_flags)); | 991 | nvgpu_obj_ctx_user_flags_to_common_flags(user_flags)); |
992 | } | 992 | } |
993 | 993 | ||
994 | /* | ||
995 | * Convert common preemption mode flags of the form NVGPU_PREEMPTION_MODE_GRAPHICS_* | ||
996 | * into linux preemption mode flags of the form NVGPU_GRAPHICS_PREEMPTION_MODE_* | ||
997 | */ | ||
998 | u32 nvgpu_get_ioctl_graphics_preempt_mode_flags(u32 graphics_preempt_mode_flags) | ||
999 | { | ||
1000 | u32 flags = 0; | ||
1001 | |||
1002 | if (graphics_preempt_mode_flags & NVGPU_PREEMPTION_MODE_GRAPHICS_WFI) | ||
1003 | flags |= NVGPU_GRAPHICS_PREEMPTION_MODE_WFI; | ||
1004 | if (graphics_preempt_mode_flags & NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP) | ||
1005 | flags |= NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP; | ||
1006 | |||
1007 | return flags; | ||
1008 | } | ||
1009 | |||
1010 | /* | ||
1011 | * Convert common preemption mode flags of the form NVGPU_PREEMPTION_MODE_COMPUTE_* | ||
1012 | * into linux preemption mode flags of the form NVGPU_COMPUTE_PREEMPTION_MODE_* | ||
1013 | */ | ||
1014 | u32 nvgpu_get_ioctl_compute_preempt_mode_flags(u32 compute_preempt_mode_flags) | ||
1015 | { | ||
1016 | u32 flags = 0; | ||
1017 | |||
1018 | if (compute_preempt_mode_flags & NVGPU_PREEMPTION_MODE_COMPUTE_WFI) | ||
1019 | flags |= NVGPU_COMPUTE_PREEMPTION_MODE_WFI; | ||
1020 | if (compute_preempt_mode_flags & NVGPU_PREEMPTION_MODE_COMPUTE_CTA) | ||
1021 | flags |= NVGPU_COMPUTE_PREEMPTION_MODE_CTA; | ||
1022 | if (compute_preempt_mode_flags & NVGPU_PREEMPTION_MODE_COMPUTE_CILP) | ||
1023 | flags |= NVGPU_COMPUTE_PREEMPTION_MODE_CILP; | ||
1024 | |||
1025 | return flags; | ||
1026 | } | ||
1027 | |||
1028 | /* | ||
1029 | * Convert common preemption modes of the form NVGPU_PREEMPTION_MODE_GRAPHICS_* | ||
1030 | * into linux preemption modes of the form NVGPU_GRAPHICS_PREEMPTION_MODE_* | ||
1031 | */ | ||
1032 | u32 nvgpu_get_ioctl_graphics_preempt_mode(u32 graphics_preempt_mode) | ||
1033 | { | ||
1034 | switch (graphics_preempt_mode) { | ||
1035 | case NVGPU_PREEMPTION_MODE_GRAPHICS_WFI: | ||
1036 | return NVGPU_GRAPHICS_PREEMPTION_MODE_WFI; | ||
1037 | case NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP: | ||
1038 | return NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP; | ||
1039 | } | ||
1040 | |||
1041 | return graphics_preempt_mode; | ||
1042 | } | ||
1043 | |||
1044 | /* | ||
1045 | * Convert common preemption modes of the form NVGPU_PREEMPTION_MODE_COMPUTE_* | ||
1046 | * into linux preemption modes of the form NVGPU_COMPUTE_PREEMPTION_MODE_* | ||
1047 | */ | ||
1048 | u32 nvgpu_get_ioctl_compute_preempt_mode(u32 compute_preempt_mode) | ||
1049 | { | ||
1050 | switch (compute_preempt_mode) { | ||
1051 | case NVGPU_PREEMPTION_MODE_COMPUTE_WFI: | ||
1052 | return NVGPU_COMPUTE_PREEMPTION_MODE_WFI; | ||
1053 | case NVGPU_PREEMPTION_MODE_COMPUTE_CTA: | ||
1054 | return NVGPU_COMPUTE_PREEMPTION_MODE_CTA; | ||
1055 | case NVGPU_PREEMPTION_MODE_COMPUTE_CILP: | ||
1056 | return NVGPU_COMPUTE_PREEMPTION_MODE_CILP; | ||
1057 | } | ||
1058 | |||
1059 | return compute_preempt_mode; | ||
1060 | } | ||
1061 | |||
1062 | /* | ||
1063 | * Convert linux preemption modes of the form NVGPU_GRAPHICS_PREEMPTION_MODE_* | ||
1064 | * into common preemption modes of the form NVGPU_PREEMPTION_MODE_GRAPHICS_* | ||
1065 | */ | ||
1066 | static u32 nvgpu_get_common_graphics_preempt_mode(u32 graphics_preempt_mode) | ||
1067 | { | ||
1068 | switch (graphics_preempt_mode) { | ||
1069 | case NVGPU_GRAPHICS_PREEMPTION_MODE_WFI: | ||
1070 | return NVGPU_PREEMPTION_MODE_GRAPHICS_WFI; | ||
1071 | case NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP: | ||
1072 | return NVGPU_PREEMPTION_MODE_GRAPHICS_GFXP; | ||
1073 | } | ||
1074 | |||
1075 | return graphics_preempt_mode; | ||
1076 | } | ||
1077 | |||
1078 | /* | ||
1079 | * Convert linux preemption modes of the form NVGPU_COMPUTE_PREEMPTION_MODE_* | ||
1080 | * into common preemption modes of the form NVGPU_PREEMPTION_MODE_COMPUTE_* | ||
1081 | */ | ||
1082 | static u32 nvgpu_get_common_compute_preempt_mode(u32 compute_preempt_mode) | ||
1083 | { | ||
1084 | switch (compute_preempt_mode) { | ||
1085 | case NVGPU_COMPUTE_PREEMPTION_MODE_WFI: | ||
1086 | return NVGPU_PREEMPTION_MODE_COMPUTE_WFI; | ||
1087 | case NVGPU_COMPUTE_PREEMPTION_MODE_CTA: | ||
1088 | return NVGPU_PREEMPTION_MODE_COMPUTE_CTA; | ||
1089 | case NVGPU_COMPUTE_PREEMPTION_MODE_CILP: | ||
1090 | return NVGPU_PREEMPTION_MODE_COMPUTE_CILP; | ||
1091 | } | ||
1092 | |||
1093 | return compute_preempt_mode; | ||
1094 | } | ||
1095 | |||
1096 | static int nvgpu_ioctl_channel_set_preemption_mode(struct channel_gk20a *ch, | ||
1097 | u32 graphics_preempt_mode, u32 compute_preempt_mode) | ||
1098 | { | ||
1099 | int err; | ||
1100 | |||
1101 | if (ch->g->ops.gr.set_preemption_mode) { | ||
1102 | err = gk20a_busy(ch->g); | ||
1103 | if (err) { | ||
1104 | nvgpu_err(ch->g, "failed to power on, %d", err); | ||
1105 | return err; | ||
1106 | } | ||
1107 | err = ch->g->ops.gr.set_preemption_mode(ch, | ||
1108 | nvgpu_get_common_graphics_preempt_mode(graphics_preempt_mode), | ||
1109 | nvgpu_get_common_compute_preempt_mode(compute_preempt_mode)); | ||
1110 | gk20a_idle(ch->g); | ||
1111 | } else { | ||
1112 | err = -EINVAL; | ||
1113 | } | ||
1114 | |||
1115 | return err; | ||
1116 | } | ||
1117 | |||
994 | long gk20a_channel_ioctl(struct file *filp, | 1118 | long gk20a_channel_ioctl(struct file *filp, |
995 | unsigned int cmd, unsigned long arg) | 1119 | unsigned int cmd, unsigned long arg) |
996 | { | 1120 | { |
@@ -1302,21 +1426,9 @@ long gk20a_channel_ioctl(struct file *filp, | |||
1302 | gk20a_channel_get_timeslice(ch); | 1426 | gk20a_channel_get_timeslice(ch); |
1303 | break; | 1427 | break; |
1304 | case NVGPU_IOCTL_CHANNEL_SET_PREEMPTION_MODE: | 1428 | case NVGPU_IOCTL_CHANNEL_SET_PREEMPTION_MODE: |
1305 | if (ch->g->ops.gr.set_preemption_mode) { | 1429 | err = nvgpu_ioctl_channel_set_preemption_mode(ch, |
1306 | err = gk20a_busy(ch->g); | 1430 | ((struct nvgpu_preemption_mode_args *)buf)->graphics_preempt_mode, |
1307 | if (err) { | 1431 | ((struct nvgpu_preemption_mode_args *)buf)->compute_preempt_mode); |
1308 | dev_err(dev, | ||
1309 | "%s: failed to host gk20a for ioctl cmd: 0x%x", | ||
1310 | __func__, cmd); | ||
1311 | break; | ||
1312 | } | ||
1313 | err = ch->g->ops.gr.set_preemption_mode(ch, | ||
1314 | ((struct nvgpu_preemption_mode_args *)buf)->graphics_preempt_mode, | ||
1315 | ((struct nvgpu_preemption_mode_args *)buf)->compute_preempt_mode); | ||
1316 | gk20a_idle(ch->g); | ||
1317 | } else { | ||
1318 | err = -EINVAL; | ||
1319 | } | ||
1320 | break; | 1432 | break; |
1321 | case NVGPU_IOCTL_CHANNEL_SET_BOOSTED_CTX: | 1433 | case NVGPU_IOCTL_CHANNEL_SET_BOOSTED_CTX: |
1322 | if (ch->g->ops.gr.set_boosted_ctx) { | 1434 | if (ch->g->ops.gr.set_boosted_ctx) { |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_channel.h b/drivers/gpu/nvgpu/common/linux/ioctl_channel.h index 48caf9df..235d84ef 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_channel.h +++ b/drivers/gpu/nvgpu/common/linux/ioctl_channel.h | |||
@@ -32,4 +32,9 @@ extern const struct file_operations gk20a_channel_ops; | |||
32 | 32 | ||
33 | u32 nvgpu_event_id_to_ioctl_channel_event_id(u32 event_id); | 33 | u32 nvgpu_event_id_to_ioctl_channel_event_id(u32 event_id); |
34 | u32 nvgpu_get_common_runlist_level(u32 level); | 34 | u32 nvgpu_get_common_runlist_level(u32 level); |
35 | |||
36 | u32 nvgpu_get_ioctl_graphics_preempt_mode_flags(u32 graphics_preempt_mode_flags); | ||
37 | u32 nvgpu_get_ioctl_compute_preempt_mode_flags(u32 compute_preempt_mode_flags); | ||
38 | u32 nvgpu_get_ioctl_graphics_preempt_mode(u32 graphics_preempt_mode); | ||
39 | u32 nvgpu_get_ioctl_compute_preempt_mode(u32 compute_preempt_mode); | ||
35 | #endif | 40 | #endif |
diff --git a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c index b77855f4..58178ac3 100644 --- a/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/common/linux/ioctl_ctrl.c | |||
@@ -194,6 +194,28 @@ static u64 nvgpu_ctrl_ioctl_gpu_characteristics_flags(struct gk20a *g) | |||
194 | return ioctl_flags; | 194 | return ioctl_flags; |
195 | } | 195 | } |
196 | 196 | ||
197 | static void nvgpu_set_preemption_mode_flags(struct gk20a *g, | ||
198 | struct nvgpu_gpu_characteristics *gpu) | ||
199 | { | ||
200 | struct nvgpu_preemption_modes_rec preemption_mode_rec; | ||
201 | |||
202 | g->ops.gr.get_preemption_mode_flags(g, &preemption_mode_rec); | ||
203 | |||
204 | gpu->graphics_preemption_mode_flags = | ||
205 | nvgpu_get_ioctl_graphics_preempt_mode_flags( | ||
206 | preemption_mode_rec.graphics_preemption_mode_flags); | ||
207 | gpu->compute_preemption_mode_flags = | ||
208 | nvgpu_get_ioctl_compute_preempt_mode_flags( | ||
209 | preemption_mode_rec.compute_preemption_mode_flags); | ||
210 | |||
211 | gpu->default_graphics_preempt_mode = | ||
212 | nvgpu_get_ioctl_graphics_preempt_mode( | ||
213 | preemption_mode_rec.default_graphics_preempt_mode); | ||
214 | gpu->default_compute_preempt_mode = | ||
215 | nvgpu_get_ioctl_compute_preempt_mode( | ||
216 | preemption_mode_rec.default_compute_preempt_mode); | ||
217 | } | ||
218 | |||
197 | static long | 219 | static long |
198 | gk20a_ctrl_ioctl_gpu_characteristics( | 220 | gk20a_ctrl_ioctl_gpu_characteristics( |
199 | struct gk20a *g, | 221 | struct gk20a *g, |
@@ -235,6 +257,8 @@ gk20a_ctrl_ioctl_gpu_characteristics( | |||
235 | 257 | ||
236 | pgpu->max_css_buffer_size = g->gr.max_css_buffer_size; | 258 | pgpu->max_css_buffer_size = g->gr.max_css_buffer_size; |
237 | 259 | ||
260 | nvgpu_set_preemption_mode_flags(g, pgpu); | ||
261 | |||
238 | if (request->gpu_characteristics_buf_size > 0) { | 262 | if (request->gpu_characteristics_buf_size > 0) { |
239 | size_t write_size = sizeof(*pgpu); | 263 | size_t write_size = sizeof(*pgpu); |
240 | 264 | ||