1 1.4 riastrad /* $NetBSD: i915_getparam.c,v 1.4 2021/12/19 11:32:01 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * SPDX-License-Identifier: MIT 5 1.1 riastrad */ 6 1.1 riastrad 7 1.1 riastrad #include <sys/cdefs.h> 8 1.4 riastrad __KERNEL_RCSID(0, "$NetBSD: i915_getparam.c,v 1.4 2021/12/19 11:32:01 riastradh Exp $"); 9 1.1 riastrad 10 1.1 riastrad #include "gem/i915_gem_mman.h" 11 1.1 riastrad #include "gt/intel_engine_user.h" 12 1.1 riastrad 13 1.1 riastrad #include "i915_drv.h" 14 1.1 riastrad #include "i915_perf.h" 15 1.1 riastrad 16 1.1 riastrad int i915_getparam_ioctl(struct drm_device *dev, void *data, 17 1.1 riastrad struct drm_file *file_priv) 18 1.1 riastrad { 19 1.1 riastrad struct drm_i915_private *i915 = to_i915(dev); 20 1.1 riastrad const struct sseu_dev_info *sseu = &RUNTIME_INFO(i915)->sseu; 21 1.1 riastrad drm_i915_getparam_t *param = data; 22 1.1 riastrad int value; 23 1.1 riastrad 24 1.1 riastrad switch (param->param) { 25 1.1 riastrad case I915_PARAM_IRQ_ACTIVE: 26 1.1 riastrad case I915_PARAM_ALLOW_BATCHBUFFER: 27 1.1 riastrad case I915_PARAM_LAST_DISPATCH: 28 1.1 riastrad case I915_PARAM_HAS_EXEC_CONSTANTS: 29 1.1 riastrad /* Reject all old ums/dri params. */ 30 1.1 riastrad return -ENODEV; 31 1.1 riastrad case I915_PARAM_CHIPSET_ID: 32 1.1 riastrad value = i915->drm.pdev->device; 33 1.1 riastrad break; 34 1.1 riastrad case I915_PARAM_REVISION: 35 1.1 riastrad value = i915->drm.pdev->revision; 36 1.1 riastrad break; 37 1.1 riastrad case I915_PARAM_NUM_FENCES_AVAIL: 38 1.1 riastrad value = i915->ggtt.num_fences; 39 1.1 riastrad break; 40 1.1 riastrad case I915_PARAM_HAS_OVERLAY: 41 1.1 riastrad value = !!i915->overlay; 42 1.1 riastrad break; 43 1.1 riastrad case I915_PARAM_HAS_BSD: 44 1.1 riastrad value = !!intel_engine_lookup_user(i915, 45 1.1 riastrad I915_ENGINE_CLASS_VIDEO, 0); 46 1.1 riastrad break; 47 1.1 riastrad case I915_PARAM_HAS_BLT: 48 1.1 riastrad value = !!intel_engine_lookup_user(i915, 49 1.1 riastrad I915_ENGINE_CLASS_COPY, 0); 50 1.1 riastrad break; 51 1.1 riastrad case I915_PARAM_HAS_VEBOX: 52 1.1 riastrad value = !!intel_engine_lookup_user(i915, 53 1.1 riastrad I915_ENGINE_CLASS_VIDEO_ENHANCE, 0); 54 1.1 riastrad break; 55 1.1 riastrad case I915_PARAM_HAS_BSD2: 56 1.1 riastrad value = !!intel_engine_lookup_user(i915, 57 1.1 riastrad I915_ENGINE_CLASS_VIDEO, 1); 58 1.1 riastrad break; 59 1.1 riastrad case I915_PARAM_HAS_LLC: 60 1.1 riastrad value = HAS_LLC(i915); 61 1.1 riastrad break; 62 1.1 riastrad case I915_PARAM_HAS_WT: 63 1.1 riastrad value = HAS_WT(i915); 64 1.1 riastrad break; 65 1.1 riastrad case I915_PARAM_HAS_ALIASING_PPGTT: 66 1.1 riastrad value = INTEL_PPGTT(i915); 67 1.1 riastrad break; 68 1.1 riastrad case I915_PARAM_HAS_SEMAPHORES: 69 1.1 riastrad value = !!(i915->caps.scheduler & I915_SCHEDULER_CAP_SEMAPHORES); 70 1.1 riastrad break; 71 1.1 riastrad case I915_PARAM_HAS_SECURE_BATCHES: 72 1.1 riastrad value = HAS_SECURE_BATCHES(i915) && capable(CAP_SYS_ADMIN); 73 1.1 riastrad break; 74 1.1 riastrad case I915_PARAM_CMD_PARSER_VERSION: 75 1.1 riastrad value = i915_cmd_parser_get_version(i915); 76 1.1 riastrad break; 77 1.1 riastrad case I915_PARAM_SUBSLICE_TOTAL: 78 1.1 riastrad value = intel_sseu_subslice_total(sseu); 79 1.1 riastrad if (!value) 80 1.1 riastrad return -ENODEV; 81 1.1 riastrad break; 82 1.1 riastrad case I915_PARAM_EU_TOTAL: 83 1.1 riastrad value = sseu->eu_total; 84 1.1 riastrad if (!value) 85 1.1 riastrad return -ENODEV; 86 1.1 riastrad break; 87 1.1 riastrad case I915_PARAM_HAS_GPU_RESET: 88 1.1 riastrad value = i915_modparams.enable_hangcheck && 89 1.1 riastrad intel_has_gpu_reset(&i915->gt); 90 1.1 riastrad if (value && intel_has_reset_engine(&i915->gt)) 91 1.1 riastrad value = 2; 92 1.1 riastrad break; 93 1.1 riastrad case I915_PARAM_HAS_RESOURCE_STREAMER: 94 1.1 riastrad value = 0; 95 1.1 riastrad break; 96 1.1 riastrad case I915_PARAM_HAS_POOLED_EU: 97 1.1 riastrad value = HAS_POOLED_EU(i915); 98 1.1 riastrad break; 99 1.1 riastrad case I915_PARAM_MIN_EU_IN_POOL: 100 1.1 riastrad value = sseu->min_eu_in_pool; 101 1.1 riastrad break; 102 1.1 riastrad case I915_PARAM_HUC_STATUS: 103 1.1 riastrad value = intel_huc_check_status(&i915->gt.uc.huc); 104 1.1 riastrad if (value < 0) 105 1.1 riastrad return value; 106 1.1 riastrad break; 107 1.1 riastrad case I915_PARAM_MMAP_GTT_VERSION: 108 1.1 riastrad /* Though we've started our numbering from 1, and so class all 109 1.1 riastrad * earlier versions as 0, in effect their value is undefined as 110 1.1 riastrad * the ioctl will report EINVAL for the unknown param! 111 1.1 riastrad */ 112 1.1 riastrad value = i915_gem_mmap_gtt_version(); 113 1.1 riastrad break; 114 1.1 riastrad case I915_PARAM_HAS_SCHEDULER: 115 1.1 riastrad value = i915->caps.scheduler; 116 1.1 riastrad break; 117 1.1 riastrad 118 1.1 riastrad case I915_PARAM_MMAP_VERSION: 119 1.4 riastrad /* Remember to bump this if the version changes! */ 120 1.3 riastrad #ifdef __NetBSD__ 121 1.4 riastrad i915->quirks |= QUIRK_NETBSD_VERSION_CALLED; 122 1.3 riastrad #endif 123 1.4 riastrad /* FALLTHROUGH */ 124 1.1 riastrad case I915_PARAM_HAS_GEM: 125 1.1 riastrad case I915_PARAM_HAS_PAGEFLIPPING: 126 1.1 riastrad case I915_PARAM_HAS_EXECBUF2: /* depends on GEM */ 127 1.1 riastrad case I915_PARAM_HAS_RELAXED_FENCING: 128 1.1 riastrad case I915_PARAM_HAS_COHERENT_RINGS: 129 1.1 riastrad case I915_PARAM_HAS_RELAXED_DELTA: 130 1.1 riastrad case I915_PARAM_HAS_GEN7_SOL_RESET: 131 1.1 riastrad case I915_PARAM_HAS_WAIT_TIMEOUT: 132 1.1 riastrad case I915_PARAM_HAS_PRIME_VMAP_FLUSH: 133 1.1 riastrad case I915_PARAM_HAS_PINNED_BATCHES: 134 1.1 riastrad case I915_PARAM_HAS_EXEC_NO_RELOC: 135 1.1 riastrad case I915_PARAM_HAS_EXEC_HANDLE_LUT: 136 1.1 riastrad case I915_PARAM_HAS_COHERENT_PHYS_GTT: 137 1.1 riastrad case I915_PARAM_HAS_EXEC_SOFTPIN: 138 1.1 riastrad case I915_PARAM_HAS_EXEC_ASYNC: 139 1.1 riastrad case I915_PARAM_HAS_EXEC_FENCE: 140 1.1 riastrad case I915_PARAM_HAS_EXEC_CAPTURE: 141 1.1 riastrad case I915_PARAM_HAS_EXEC_BATCH_FIRST: 142 1.1 riastrad case I915_PARAM_HAS_EXEC_FENCE_ARRAY: 143 1.1 riastrad case I915_PARAM_HAS_EXEC_SUBMIT_FENCE: 144 1.1 riastrad /* For the time being all of these are always true; 145 1.1 riastrad * if some supported hardware does not have one of these 146 1.1 riastrad * features this value needs to be provided from 147 1.1 riastrad * INTEL_INFO(), a feature macro, or similar. 148 1.1 riastrad */ 149 1.1 riastrad value = 1; 150 1.1 riastrad break; 151 1.1 riastrad case I915_PARAM_HAS_CONTEXT_ISOLATION: 152 1.1 riastrad value = intel_engines_has_context_isolation(i915); 153 1.1 riastrad break; 154 1.1 riastrad case I915_PARAM_SLICE_MASK: 155 1.1 riastrad value = sseu->slice_mask; 156 1.1 riastrad if (!value) 157 1.1 riastrad return -ENODEV; 158 1.1 riastrad break; 159 1.1 riastrad case I915_PARAM_SUBSLICE_MASK: 160 1.1 riastrad value = sseu->subslice_mask[0]; 161 1.1 riastrad if (!value) 162 1.1 riastrad return -ENODEV; 163 1.1 riastrad break; 164 1.1 riastrad case I915_PARAM_CS_TIMESTAMP_FREQUENCY: 165 1.1 riastrad value = 1000 * RUNTIME_INFO(i915)->cs_timestamp_frequency_khz; 166 1.1 riastrad break; 167 1.1 riastrad case I915_PARAM_MMAP_GTT_COHERENT: 168 1.1 riastrad value = INTEL_INFO(i915)->has_coherent_ggtt; 169 1.1 riastrad break; 170 1.1 riastrad case I915_PARAM_PERF_REVISION: 171 1.1 riastrad value = i915_perf_ioctl_version(); 172 1.1 riastrad break; 173 1.1 riastrad default: 174 1.1 riastrad DRM_DEBUG("Unknown parameter %d\n", param->param); 175 1.1 riastrad return -EINVAL; 176 1.1 riastrad } 177 1.1 riastrad 178 1.1 riastrad if (put_user(value, param->value)) 179 1.1 riastrad return -EFAULT; 180 1.1 riastrad 181 1.1 riastrad return 0; 182 1.1 riastrad } 183