diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/ioctl_channel.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/ioctl_channel.c | 148 |
1 files changed, 130 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) { |