18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * SPDX-License-Identifier: MIT 38c2ecf20Sopenharmony_ci */ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include "gem/i915_gem_mman.h" 68c2ecf20Sopenharmony_ci#include "gt/intel_engine_user.h" 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include "i915_drv.h" 98c2ecf20Sopenharmony_ci#include "i915_perf.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciint i915_getparam_ioctl(struct drm_device *dev, void *data, 128c2ecf20Sopenharmony_ci struct drm_file *file_priv) 138c2ecf20Sopenharmony_ci{ 148c2ecf20Sopenharmony_ci struct drm_i915_private *i915 = to_i915(dev); 158c2ecf20Sopenharmony_ci const struct sseu_dev_info *sseu = &i915->gt.info.sseu; 168c2ecf20Sopenharmony_ci drm_i915_getparam_t *param = data; 178c2ecf20Sopenharmony_ci int value; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci switch (param->param) { 208c2ecf20Sopenharmony_ci case I915_PARAM_IRQ_ACTIVE: 218c2ecf20Sopenharmony_ci case I915_PARAM_ALLOW_BATCHBUFFER: 228c2ecf20Sopenharmony_ci case I915_PARAM_LAST_DISPATCH: 238c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_CONSTANTS: 248c2ecf20Sopenharmony_ci /* Reject all old ums/dri params. */ 258c2ecf20Sopenharmony_ci return -ENODEV; 268c2ecf20Sopenharmony_ci case I915_PARAM_CHIPSET_ID: 278c2ecf20Sopenharmony_ci value = i915->drm.pdev->device; 288c2ecf20Sopenharmony_ci break; 298c2ecf20Sopenharmony_ci case I915_PARAM_REVISION: 308c2ecf20Sopenharmony_ci value = i915->drm.pdev->revision; 318c2ecf20Sopenharmony_ci break; 328c2ecf20Sopenharmony_ci case I915_PARAM_NUM_FENCES_AVAIL: 338c2ecf20Sopenharmony_ci value = i915->ggtt.num_fences; 348c2ecf20Sopenharmony_ci break; 358c2ecf20Sopenharmony_ci case I915_PARAM_HAS_OVERLAY: 368c2ecf20Sopenharmony_ci value = !!i915->overlay; 378c2ecf20Sopenharmony_ci break; 388c2ecf20Sopenharmony_ci case I915_PARAM_HAS_BSD: 398c2ecf20Sopenharmony_ci value = !!intel_engine_lookup_user(i915, 408c2ecf20Sopenharmony_ci I915_ENGINE_CLASS_VIDEO, 0); 418c2ecf20Sopenharmony_ci break; 428c2ecf20Sopenharmony_ci case I915_PARAM_HAS_BLT: 438c2ecf20Sopenharmony_ci value = !!intel_engine_lookup_user(i915, 448c2ecf20Sopenharmony_ci I915_ENGINE_CLASS_COPY, 0); 458c2ecf20Sopenharmony_ci break; 468c2ecf20Sopenharmony_ci case I915_PARAM_HAS_VEBOX: 478c2ecf20Sopenharmony_ci value = !!intel_engine_lookup_user(i915, 488c2ecf20Sopenharmony_ci I915_ENGINE_CLASS_VIDEO_ENHANCE, 0); 498c2ecf20Sopenharmony_ci break; 508c2ecf20Sopenharmony_ci case I915_PARAM_HAS_BSD2: 518c2ecf20Sopenharmony_ci value = !!intel_engine_lookup_user(i915, 528c2ecf20Sopenharmony_ci I915_ENGINE_CLASS_VIDEO, 1); 538c2ecf20Sopenharmony_ci break; 548c2ecf20Sopenharmony_ci case I915_PARAM_HAS_LLC: 558c2ecf20Sopenharmony_ci value = HAS_LLC(i915); 568c2ecf20Sopenharmony_ci break; 578c2ecf20Sopenharmony_ci case I915_PARAM_HAS_WT: 588c2ecf20Sopenharmony_ci value = HAS_WT(i915); 598c2ecf20Sopenharmony_ci break; 608c2ecf20Sopenharmony_ci case I915_PARAM_HAS_ALIASING_PPGTT: 618c2ecf20Sopenharmony_ci value = INTEL_PPGTT(i915); 628c2ecf20Sopenharmony_ci break; 638c2ecf20Sopenharmony_ci case I915_PARAM_HAS_SEMAPHORES: 648c2ecf20Sopenharmony_ci value = !!(i915->caps.scheduler & I915_SCHEDULER_CAP_SEMAPHORES); 658c2ecf20Sopenharmony_ci break; 668c2ecf20Sopenharmony_ci case I915_PARAM_HAS_SECURE_BATCHES: 678c2ecf20Sopenharmony_ci value = HAS_SECURE_BATCHES(i915) && capable(CAP_SYS_ADMIN); 688c2ecf20Sopenharmony_ci break; 698c2ecf20Sopenharmony_ci case I915_PARAM_CMD_PARSER_VERSION: 708c2ecf20Sopenharmony_ci value = i915_cmd_parser_get_version(i915); 718c2ecf20Sopenharmony_ci break; 728c2ecf20Sopenharmony_ci case I915_PARAM_SUBSLICE_TOTAL: 738c2ecf20Sopenharmony_ci value = intel_sseu_subslice_total(sseu); 748c2ecf20Sopenharmony_ci if (!value) 758c2ecf20Sopenharmony_ci return -ENODEV; 768c2ecf20Sopenharmony_ci break; 778c2ecf20Sopenharmony_ci case I915_PARAM_EU_TOTAL: 788c2ecf20Sopenharmony_ci value = sseu->eu_total; 798c2ecf20Sopenharmony_ci if (!value) 808c2ecf20Sopenharmony_ci return -ENODEV; 818c2ecf20Sopenharmony_ci break; 828c2ecf20Sopenharmony_ci case I915_PARAM_HAS_GPU_RESET: 838c2ecf20Sopenharmony_ci value = i915->params.enable_hangcheck && 848c2ecf20Sopenharmony_ci intel_has_gpu_reset(&i915->gt); 858c2ecf20Sopenharmony_ci if (value && intel_has_reset_engine(&i915->gt)) 868c2ecf20Sopenharmony_ci value = 2; 878c2ecf20Sopenharmony_ci break; 888c2ecf20Sopenharmony_ci case I915_PARAM_HAS_RESOURCE_STREAMER: 898c2ecf20Sopenharmony_ci value = 0; 908c2ecf20Sopenharmony_ci break; 918c2ecf20Sopenharmony_ci case I915_PARAM_HAS_POOLED_EU: 928c2ecf20Sopenharmony_ci value = HAS_POOLED_EU(i915); 938c2ecf20Sopenharmony_ci break; 948c2ecf20Sopenharmony_ci case I915_PARAM_MIN_EU_IN_POOL: 958c2ecf20Sopenharmony_ci value = sseu->min_eu_in_pool; 968c2ecf20Sopenharmony_ci break; 978c2ecf20Sopenharmony_ci case I915_PARAM_HUC_STATUS: 988c2ecf20Sopenharmony_ci value = intel_huc_check_status(&i915->gt.uc.huc); 998c2ecf20Sopenharmony_ci if (value < 0) 1008c2ecf20Sopenharmony_ci return value; 1018c2ecf20Sopenharmony_ci break; 1028c2ecf20Sopenharmony_ci case I915_PARAM_MMAP_GTT_VERSION: 1038c2ecf20Sopenharmony_ci /* Though we've started our numbering from 1, and so class all 1048c2ecf20Sopenharmony_ci * earlier versions as 0, in effect their value is undefined as 1058c2ecf20Sopenharmony_ci * the ioctl will report EINVAL for the unknown param! 1068c2ecf20Sopenharmony_ci */ 1078c2ecf20Sopenharmony_ci value = i915_gem_mmap_gtt_version(); 1088c2ecf20Sopenharmony_ci break; 1098c2ecf20Sopenharmony_ci case I915_PARAM_HAS_SCHEDULER: 1108c2ecf20Sopenharmony_ci value = i915->caps.scheduler; 1118c2ecf20Sopenharmony_ci break; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci case I915_PARAM_MMAP_VERSION: 1148c2ecf20Sopenharmony_ci /* Remember to bump this if the version changes! */ 1158c2ecf20Sopenharmony_ci case I915_PARAM_HAS_GEM: 1168c2ecf20Sopenharmony_ci case I915_PARAM_HAS_PAGEFLIPPING: 1178c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXECBUF2: /* depends on GEM */ 1188c2ecf20Sopenharmony_ci case I915_PARAM_HAS_RELAXED_FENCING: 1198c2ecf20Sopenharmony_ci case I915_PARAM_HAS_COHERENT_RINGS: 1208c2ecf20Sopenharmony_ci case I915_PARAM_HAS_RELAXED_DELTA: 1218c2ecf20Sopenharmony_ci case I915_PARAM_HAS_GEN7_SOL_RESET: 1228c2ecf20Sopenharmony_ci case I915_PARAM_HAS_WAIT_TIMEOUT: 1238c2ecf20Sopenharmony_ci case I915_PARAM_HAS_PRIME_VMAP_FLUSH: 1248c2ecf20Sopenharmony_ci case I915_PARAM_HAS_PINNED_BATCHES: 1258c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_NO_RELOC: 1268c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_HANDLE_LUT: 1278c2ecf20Sopenharmony_ci case I915_PARAM_HAS_COHERENT_PHYS_GTT: 1288c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_SOFTPIN: 1298c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_ASYNC: 1308c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_FENCE: 1318c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_CAPTURE: 1328c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_BATCH_FIRST: 1338c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_FENCE_ARRAY: 1348c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_SUBMIT_FENCE: 1358c2ecf20Sopenharmony_ci case I915_PARAM_HAS_EXEC_TIMELINE_FENCES: 1368c2ecf20Sopenharmony_ci /* For the time being all of these are always true; 1378c2ecf20Sopenharmony_ci * if some supported hardware does not have one of these 1388c2ecf20Sopenharmony_ci * features this value needs to be provided from 1398c2ecf20Sopenharmony_ci * INTEL_INFO(), a feature macro, or similar. 1408c2ecf20Sopenharmony_ci */ 1418c2ecf20Sopenharmony_ci value = 1; 1428c2ecf20Sopenharmony_ci break; 1438c2ecf20Sopenharmony_ci case I915_PARAM_HAS_CONTEXT_ISOLATION: 1448c2ecf20Sopenharmony_ci value = intel_engines_has_context_isolation(i915); 1458c2ecf20Sopenharmony_ci break; 1468c2ecf20Sopenharmony_ci case I915_PARAM_SLICE_MASK: 1478c2ecf20Sopenharmony_ci value = sseu->slice_mask; 1488c2ecf20Sopenharmony_ci if (!value) 1498c2ecf20Sopenharmony_ci return -ENODEV; 1508c2ecf20Sopenharmony_ci break; 1518c2ecf20Sopenharmony_ci case I915_PARAM_SUBSLICE_MASK: 1528c2ecf20Sopenharmony_ci value = sseu->subslice_mask[0]; 1538c2ecf20Sopenharmony_ci if (!value) 1548c2ecf20Sopenharmony_ci return -ENODEV; 1558c2ecf20Sopenharmony_ci break; 1568c2ecf20Sopenharmony_ci case I915_PARAM_CS_TIMESTAMP_FREQUENCY: 1578c2ecf20Sopenharmony_ci value = RUNTIME_INFO(i915)->cs_timestamp_frequency_hz; 1588c2ecf20Sopenharmony_ci break; 1598c2ecf20Sopenharmony_ci case I915_PARAM_MMAP_GTT_COHERENT: 1608c2ecf20Sopenharmony_ci value = INTEL_INFO(i915)->has_coherent_ggtt; 1618c2ecf20Sopenharmony_ci break; 1628c2ecf20Sopenharmony_ci case I915_PARAM_PERF_REVISION: 1638c2ecf20Sopenharmony_ci value = i915_perf_ioctl_version(); 1648c2ecf20Sopenharmony_ci break; 1658c2ecf20Sopenharmony_ci default: 1668c2ecf20Sopenharmony_ci DRM_DEBUG("Unknown parameter %d\n", param->param); 1678c2ecf20Sopenharmony_ci return -EINVAL; 1688c2ecf20Sopenharmony_ci } 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci if (put_user(value, param->value)) 1718c2ecf20Sopenharmony_ci return -EFAULT; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci return 0; 1748c2ecf20Sopenharmony_ci} 175