Lines Matching full:i915
29 * DOC: i915 Perf Overview
35 * This i915 perf interface enables userspace to configure and open a file
45 * privileges by default, unless changed via the dev.i915.perf_event_paranoid
51 * DOC: i915 Perf History and Comparison with Core Perf
56 * i915 perf file descriptors represent a "stream" instead of an "event"; where
61 * of related counters. Samples for an i915 perf stream capturing OA metrics
68 * i915 perf stream configurations are provided as an array of u64 (key,value)
72 * i915 perf doesn't support exposing metrics via an mmap'd circular buffer.
95 * how userspace will sometimes need to combine i915 perf OA metrics with
103 * better suited to exposing i915 metrics these were the main pain points we
191 * with the rest of the i915 driver.
272 /* for sysctl proc_dointvec_minmax of dev.i915.perf_stream_paranoid */
295 #define HAS_MI_SET_PREDICATE(i915) (GRAPHICS_VER_FULL(i915) >= IP_VER(12, 55)) argument
470 (GRAPHICS_VER(stream->perf->i915) == 12 ? in oa_report_reason()
521 * @stream: i915 stream instance
598 drm_notice(&stream->uncore->i915->drm, in oa_buffer_check_unlocked()
614 * @stream: An i915-perf stream opened for OA metrics
648 * @stream: An i915-perf stream opened for OA metrics
709 * @stream: An i915-perf stream opened for OA metrics
742 if (drm_WARN_ON(&uncore->i915->drm, !stream->enabled)) in gen8_append_oa_reports()
758 if (drm_WARN_ONCE(&uncore->i915->drm, in gen8_append_oa_reports()
823 GRAPHICS_VER_FULL(stream->engine->i915) < IP_VER(12, 55)) { in gen8_append_oa_reports()
906 oaheadptr = GRAPHICS_VER(stream->perf->i915) == 12 ? in gen8_append_oa_reports()
928 * @stream: An i915-perf stream opened for OA metrics
956 if (drm_WARN_ON(&uncore->i915->drm, !stream->oa_buffer.vaddr)) in gen8_oa_read()
959 oastatus_reg = GRAPHICS_VER(stream->perf->i915) == 12 ? in gen8_oa_read()
985 drm_dbg(&stream->perf->i915->drm, in gen8_oa_read()
1008 IS_GRAPHICS_VER(uncore->i915, 8, 11) ? in gen8_oa_read()
1019 * @stream: An i915-perf stream opened for OA metrics
1052 if (drm_WARN_ON(&uncore->i915->drm, !stream->enabled)) in gen7_append_oa_reports()
1068 if (drm_WARN_ONCE(&uncore->i915->drm, in gen7_append_oa_reports()
1090 if (drm_WARN_ON(&uncore->i915->drm, in gen7_append_oa_reports()
1092 drm_err(&uncore->i915->drm, in gen7_append_oa_reports()
1105 drm_notice(&uncore->i915->drm, in gen7_append_oa_reports()
1137 * @stream: An i915-perf stream opened for OA metrics
1160 if (drm_WARN_ON(&uncore->i915->drm, !stream->oa_buffer.vaddr)) in gen7_oa_read()
1198 drm_dbg(&stream->perf->i915->drm, in gen7_oa_read()
1222 * @stream: An i915-perf stream opened for OA metrics
1246 * @stream: An i915-perf stream opened for OA metrics
1247 * @file: An i915 perf stream file
1250 * For handling userspace polling on an i915 perf stream opened for OA metrics,
1263 * @stream: An i915-perf stream opened for OA metrics
1328 if (GRAPHICS_VER(rq->i915) >= 8) in __store_reg_to_mem()
1425 } else if (GRAPHICS_VER_FULL(stream->engine->i915) >= IP_VER(12, 55)) { in gen12_get_render_context_id()
1467 if (drm_WARN_ON(&ce->engine->i915->drm, !state)) in oa_context_image_offset()
1476 drm_WARN_ON(&ce->engine->i915->drm, in oa_context_image_offset()
1492 struct i915_perf *perf = &ce->engine->i915->perf; in set_oa_ctx_ctrl_offset()
1502 drm_dbg(&ce->engine->i915->drm, in set_oa_ctx_ctrl_offset()
1517 * @stream: An i915-perf stream opened for OA metrics
1535 HAS_LOGICAL_RING_CONTEXTS(stream->perf->i915)) { in oa_get_render_ctx_id()
1543 drm_err(&stream->perf->i915->drm, in oa_get_render_ctx_id()
1550 switch (GRAPHICS_VER(ce->engine->i915)) { in oa_get_render_ctx_id()
1566 * i915 is read by GuC and rewritten before it's in oa_get_render_ctx_id()
1595 MISSING_CASE(GRAPHICS_VER(ce->engine->i915)); in oa_get_render_ctx_id()
1600 drm_dbg(&stream->perf->i915->drm, in oa_get_render_ctx_id()
1610 * @stream: An i915-perf stream opened for OA metrics
1853 struct drm_i915_private *i915 = stream->perf->i915; in alloc_oa_buffer() local
1859 if (drm_WARN_ON(&i915->drm, stream->oa_buffer.vma)) in alloc_oa_buffer()
1865 bo = i915_gem_object_create_shmem(stream->perf->i915, OA_BUFFER_SIZE); in alloc_oa_buffer()
1867 drm_err(&i915->drm, "Failed to allocate OA buffer\n"); in alloc_oa_buffer()
1922 if (GRAPHICS_VER(stream->perf->i915) >= 8) in save_restore_register()
1937 struct drm_i915_private *i915 = stream->perf->i915; in alloc_noa_wait() local
1942 intel_gt_ns_to_clock_interval(to_gt(stream->perf->i915), in alloc_noa_wait()
1957 i915_reg_t mi_predicate_result = HAS_MI_SET_PREDICATE(i915) ? in alloc_noa_wait()
1967 bo = i915_gem_object_create_internal(i915, 8192); in alloc_noa_wait()
1969 drm_err(&i915->drm, in alloc_noa_wait()
1983 * needs to be fixed during the lifetime of the i915/perf stream. in alloc_noa_wait()
2068 if (HAS_MI_SET_PREDICATE(i915)) in alloc_noa_wait()
2072 *cs++ = (GRAPHICS_VER(i915) < 8 ? in alloc_noa_wait()
2079 if (HAS_MI_SET_PREDICATE(i915)) in alloc_noa_wait()
2111 if (HAS_MI_SET_PREDICATE(i915)) in alloc_noa_wait()
2115 *cs++ = (GRAPHICS_VER(i915) < 8 ? in alloc_noa_wait()
2122 if (HAS_MI_SET_PREDICATE(i915)) in alloc_noa_wait()
2212 obj = i915_gem_object_create_shmem(stream->perf->i915, config_length); in alloc_oa_config_buffer()
2241 *cs++ = (GRAPHICS_VER(stream->perf->i915) < 8 ? in alloc_oa_config_buffer()
2690 struct drm_i915_private *i915 = stream->perf->i915; in oa_configure_all_contexts() local
2714 spin_lock(&i915->gem.contexts.lock); in oa_configure_all_contexts()
2715 list_for_each_entry_safe(ctx, cn, &i915->gem.contexts.list, link) { in oa_configure_all_contexts()
2719 spin_unlock(&i915->gem.contexts.lock); in oa_configure_all_contexts()
2727 spin_lock(&i915->gem.contexts.lock); in oa_configure_all_contexts()
2731 spin_unlock(&i915->gem.contexts.lock); in oa_configure_all_contexts()
2738 for_each_uabi_engine(engine, i915) { in oa_configure_all_contexts()
2827 if (IS_GRAPHICS_VER(stream->perf->i915, 9, 11)) { in gen8_enable_metric_set()
2858 struct drm_i915_private *i915 = stream->perf->i915; in gen12_enable_metric_set() local
2870 if (IS_DG2(i915)) { in gen12_enable_metric_set()
2899 (HAS_OA_BPC_REPORTING(i915) ? GEN12_SQCNT1_OABPC : 0); in gen12_enable_metric_set()
2943 struct drm_i915_private *i915 = stream->perf->i915; in gen12_disable_metric_set() local
2949 if (IS_DG2(i915)) { in gen12_disable_metric_set()
2964 (HAS_OA_BPC_REPORTING(i915) ? GEN12_SQCNT1_OABPC : 0); in gen12_disable_metric_set()
3049 * @stream: An i915 perf stream opened for OA metrics
3076 drm_err(&stream->perf->i915->drm, in gen7_oa_disable()
3088 drm_err(&stream->perf->i915->drm, in gen8_oa_disable()
3101 drm_err(&stream->perf->i915->drm, in gen12_oa_disable()
3109 drm_err(&stream->perf->i915->drm, in gen12_oa_disable()
3115 * @stream: An i915 perf stream opened for OA metrics
3163 if (GRAPHICS_VER(engine->i915) == 11) { in get_default_sseu_config()
3192 u32 i915_perf_oa_timestamp_frequency(struct drm_i915_private *i915) in i915_perf_oa_timestamp_frequency() argument
3194 struct intel_gt *gt = to_gt(i915); in i915_perf_oa_timestamp_frequency()
3197 if (IS_DG2(i915) || IS_GFX_GT_IP_RANGE(gt, IP_VER(12, 70), IP_VER(12, 74))) { in i915_perf_oa_timestamp_frequency()
3201 with_intel_runtime_pm(to_gt(i915)->uncore->rpm, wakeref) in i915_perf_oa_timestamp_frequency()
3202 reg = intel_uncore_read(to_gt(i915)->uncore, RPM_CONFIG0); in i915_perf_oa_timestamp_frequency()
3207 return to_gt(i915)->clock_frequency << (3 - shift); in i915_perf_oa_timestamp_frequency()
3210 return to_gt(i915)->clock_frequency; in i915_perf_oa_timestamp_frequency()
3215 * @stream: An i915 perf stream
3235 struct drm_i915_private *i915 = stream->perf->i915; in i915_oa_stream_init() local
3241 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3253 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3259 (GRAPHICS_VER(perf->i915) < 12 || !stream->ctx)) { in i915_oa_stream_init()
3260 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3266 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3277 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3283 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3294 if (drm_WARN_ON(&i915->drm, stream->oa_buffer.format->size == 0)) in i915_oa_stream_init()
3309 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3317 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3324 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3356 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3361 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3405 if (stream && GRAPHICS_VER(stream->perf->i915) < 12) in i915_oa_init_reg_state()
3410 * i915_perf_read - handles read() FOP for i915 perf stream FDs
3411 * @file: An i915 perf stream file
3502 * @stream: An i915 perf stream
3503 * @file: An i915 perf stream file
3506 * For handling userspace polling on an i915 perf stream, this calls through to
3534 * @file: An i915 perf stream file
3537 * For handling userspace polling on an i915 perf stream, this ensures
3559 * @stream: A disabled i915 perf stream
3584 * @stream: An enabled i915 perf stream
3646 * i915_perf_ioctl_locked - support ioctl() usage with i915 perf stream FDs
3647 * @stream: An i915 perf stream
3673 * i915_perf_ioctl - support ioctl() usage with i915 perf stream FDs
3674 * @file: An i915 perf stream file
3698 * i915_perf_destroy_locked - destroy an i915 perf stream
3699 * @stream: An i915 perf stream
3701 * Frees all resources associated with the given i915 perf @stream, disabling
3724 * @file: An i915 perf stream file
3726 * Cleans up any resources associated with an open i915 perf stream file.
3748 drm_dev_put(&perf->i915->drm); in i915_perf_release()
3769 * @perf: i915 perf instance
3810 drm_dbg(&perf->i915->drm, in i915_perf_open_ioctl_locked()
3837 if (IS_HASWELL(perf->i915) && specific_ctx) in i915_perf_open_ioctl_locked()
3839 else if (GRAPHICS_VER(perf->i915) == 12 && specific_ctx && in i915_perf_open_ioctl_locked()
3845 drm_dbg(&perf->i915->drm, in i915_perf_open_ioctl_locked()
3862 * we check a dev.i915.perf_stream_paranoid sysctl option in i915_perf_open_ioctl_locked()
3868 drm_dbg(&perf->i915->drm, in i915_perf_open_ioctl_locked()
3869 "Insufficient privileges to open i915 perf stream\n"); in i915_perf_open_ioctl_locked()
3914 drm_dev_get(&perf->i915->drm); in i915_perf_open_ioctl_locked()
3933 u32 den = i915_perf_oa_timestamp_frequency(perf->i915); in oa_exponent_to_ns()
3952 * @perf: i915 perf instance
3990 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
3991 "Invalid number of i915 perf properties given\n"); in read_properties_unlocked()
4012 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4013 "Unknown i915 perf property ID\n"); in read_properties_unlocked()
4028 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4036 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4042 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4051 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4080 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4081 …"OA exponent would exceed the max sampling frequency (sysctl dev.i915.oa_max_sample_rate) %uHz wit… in read_properties_unlocked()
4093 if (GRAPHICS_VER_FULL(perf->i915) >= IP_VER(12, 55)) { in read_properties_unlocked()
4094 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4096 GRAPHICS_VER_FULL(perf->i915)); in read_properties_unlocked()
4103 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4112 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4137 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4142 props->engine = intel_engine_lookup_user(perf->i915, class, instance); in read_properties_unlocked()
4144 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4151 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4165 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4173 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4182 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4203 * i915-perf stream is expected to be a suitable interface for other forms of
4206 * Note we copy the properties from userspace outside of the i915 perf
4213 * Return: A newly opened i915 Perf stream file descriptor or negative
4226 if (!perf->i915) in i915_perf_open_ioctl()
4233 drm_dbg(&perf->i915->drm, in i915_perf_open_ioctl()
4255 * i915_perf_register - exposes i915-perf to userspace
4256 * @i915: i915 device instance
4260 * used to open an i915-perf stream.
4262 void i915_perf_register(struct drm_i915_private *i915) in i915_perf_register() argument
4264 struct i915_perf *perf = &i915->perf; in i915_perf_register()
4265 struct intel_gt *gt = to_gt(i915); in i915_perf_register()
4267 if (!perf->i915) in i915_perf_register()
4278 &i915->drm.primary->kdev->kobj); in i915_perf_register()
4284 * i915_perf_unregister - hide i915-perf from userspace
4285 * @i915: i915 device instance
4287 * i915-perf state cleanup is split up into an 'unregister' and
4292 void i915_perf_unregister(struct drm_i915_private *i915) in i915_perf_unregister() argument
4294 struct i915_perf *perf = &i915->perf; in i915_perf_unregister()
4459 if (HAS_OAM(perf->i915) && in mtl_is_valid_oam_b_counter_addr()
4460 GRAPHICS_VER_FULL(perf->i915) >= IP_VER(12, 70)) in mtl_is_valid_oam_b_counter_addr()
4475 if (GRAPHICS_VER_FULL(perf->i915) >= IP_VER(12, 70)) in gen12_is_valid_mux_addr()
4531 drm_dbg(&perf->i915->drm, in alloc_oa_regs()
4605 if (!perf->i915) in i915_perf_add_config_ioctl()
4609 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4615 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4616 "Insufficient privileges to add i915 OA config\n"); in i915_perf_add_config_ioctl()
4623 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4630 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4639 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4657 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4671 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4678 if (GRAPHICS_VER(perf->i915) < 8) { in i915_perf_add_config_ioctl()
4691 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4708 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4717 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4727 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4734 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4744 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4768 if (!perf->i915) in i915_perf_remove_config_ioctl()
4772 drm_dbg(&perf->i915->drm, in i915_perf_remove_config_ioctl()
4773 "Insufficient privileges to remove i915 OA config\n"); in i915_perf_remove_config_ioctl()
4783 drm_dbg(&perf->i915->drm, in i915_perf_remove_config_ioctl()
4797 drm_dbg(&perf->i915->drm, in i915_perf_remove_config_ioctl()
4837 if (GRAPHICS_VER_FULL(engine->i915) >= IP_VER(12, 70)) { in __oam_engine_group()
4842 drm_WARN_ON(&engine->i915->drm, in __oam_engine_group()
4910 } else if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70)) { in oa_init_groups()
4951 for_each_gt(gt, perf->i915, i) { in oa_init_engine_groups()
4962 struct drm_i915_private *i915 = perf->i915; in oa_init_supported_formats() local
4963 enum intel_platform platform = INTEL_INFO(i915)->platform; in oa_init_supported_formats()
5016 static void i915_perf_init_info(struct drm_i915_private *i915) in i915_perf_init_info() argument
5018 struct i915_perf *perf = &i915->perf; in i915_perf_init_info()
5020 switch (GRAPHICS_VER(i915)) { in i915_perf_init_info()
5044 MISSING_CASE(GRAPHICS_VER(i915)); in i915_perf_init_info()
5049 * i915_perf_init - initialize i915-perf state on module bind
5050 * @i915: i915 device instance
5052 * Initializes i915-perf state without exposing anything to userspace.
5054 * Note: i915-perf initialization is split into an 'init' and 'register'
5057 int i915_perf_init(struct drm_i915_private *i915) in i915_perf_init() argument
5059 struct i915_perf *perf = &i915->perf; in i915_perf_init()
5062 if (IS_HASWELL(i915)) { in i915_perf_init()
5072 } else if (HAS_LOGICAL_RING_CONTEXTS(i915)) { in i915_perf_init()
5080 i915_perf_init_info(i915); in i915_perf_init()
5082 if (IS_GRAPHICS_VER(i915, 8, 9)) { in i915_perf_init()
5090 if (IS_CHERRYVIEW(i915)) { in i915_perf_init()
5100 } else if (GRAPHICS_VER(i915) == 11) { in i915_perf_init()
5113 } else if (GRAPHICS_VER(i915) == 12) { in i915_perf_init()
5115 HAS_OA_SLICE_CONTRIB_LIMITS(i915) ? in i915_perf_init()
5135 for_each_gt(gt, i915, i) in i915_perf_init()
5139 oa_sample_rate_hard_limit = to_gt(i915)->clock_frequency / 2; in i915_perf_init()
5170 perf->i915 = i915; in i915_perf_init()
5174 drm_err(&i915->drm, in i915_perf_init()
5193 sysctl_header = register_sysctl("dev/i915", oa_table); in i915_perf_sysctl_register()
5204 * @i915: i915 device instance
5206 void i915_perf_fini(struct drm_i915_private *i915) in i915_perf_fini() argument
5208 struct i915_perf *perf = &i915->perf; in i915_perf_fini()
5212 if (!perf->i915) in i915_perf_fini()
5215 for_each_gt(gt, perf->i915, i) in i915_perf_fini()
5222 perf->i915 = NULL; in i915_perf_fini()
5226 * i915_perf_ioctl_version - Version of the i915-perf subsystem
5227 * @i915: The i915 device
5231 int i915_perf_ioctl_version(struct drm_i915_private *i915) in i915_perf_ioctl_version() argument
5264 if (IS_MEDIA_GT_IP_STEP(i915->media_gt, IP_VER(13, 0), STEP_A0, STEP_C0) && in i915_perf_ioctl_version()
5265 intel_check_bios_c6_setup(&i915->media_gt->rc6)) in i915_perf_ioctl_version()