Lines Matching full:perf
29 * DOC: i915 Perf Overview
35 * This i915 perf interface enables userspace to configure and open a file
51 * DOC: i915 Perf History and Comparison with Core Perf
53 * The interface was initially inspired by the core Perf infrastructure but
56 * i915 perf file descriptors represent a "stream" instead of an "event"; where
57 * a perf event primarily corresponds to a single 64bit value, while a stream
61 * of related counters. Samples for an i915 perf stream capturing OA metrics
64 * selected by the user opening the stream. Perf has support for grouping
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.
82 * Issues hit with first prototype based on Core Perf
85 * The first prototype of this driver was based on the core perf
87 * perf, we found we were breaking or working around too many assumptions baked
88 * into perf's currently cpu centric design.
90 * In the end we didn't see a clear benefit to making perf's implementation and
92 * wouldn't be able to use any existing perf based userspace tools.
95 * how userspace will sometimes need to combine i915 perf OA metrics with
99 * a standard vendor/architecture agnostic interface by not using perf.
102 * For posterity, in case we might re-visit trying to adapt core perf to be
106 * - The perf based OA PMU driver broke some significant design assumptions:
108 * Existing perf pmus are used for profiling work on a cpu and we were
111 * registers) to fit with perf's current design, and adding _DEVICE records
118 * buffer to perf's buffer, those bursts of sample writes looked to perf like
121 * Perf supports groups of counters and allows those to be read via
128 * set while perf generally expects counter configurations to be orthogonal.
133 * GPU context to filter metrics on). We avoided using perf's grouping
134 * feature and forwarded OA reports to userspace via perf's 'raw' sample
142 * - As a side note on perf's grouping feature; there was also some concern
156 * event scheduling is a central design idea within perf for allowing
178 * - It felt like our perf based PMU was making some technical compromises
179 * just for the sake of using perf:
185 * cpu id, perf ensures pmu methods will be invoked via an inter process
187 * perf events for a specific cpu. This was workable but it meant the
309 * The default threshold of 100000Hz is based on perf's similar
410 i915_perf_get_oa_config(struct i915_perf *perf, int metrics_set) in i915_perf_get_oa_config() argument
415 oa_config = idr_find(&perf->metrics_idr, metrics_set); in i915_perf_get_oa_config()
470 (GRAPHICS_VER(stream->perf->i915) == 12 ? in oa_report_reason()
486 stream->perf->gen8_valid_ctx_bit); in oa_report_ctx_invalid()
558 hw_tail = stream->perf->ops.oa_hw_tail_read(stream); in oa_buffer_check_unlocked()
597 __ratelimit(&stream->perf->tail_pointer_race)) 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
906 oaheadptr = GRAPHICS_VER(stream->perf->i915) == 12 ? in gen8_append_oa_reports()
928 * @stream: An i915-perf stream opened for OA metrics
959 oastatus_reg = GRAPHICS_VER(stream->perf->i915) == 12 ? in gen8_oa_read()
985 drm_dbg(&stream->perf->i915->drm, in gen8_oa_read()
989 stream->perf->ops.oa_disable(stream); in gen8_oa_read()
990 stream->perf->ops.oa_enable(stream); in gen8_oa_read()
1019 * @stream: An i915-perf stream opened for OA metrics
1104 if (__ratelimit(&stream->perf->spurious_report_rs)) in gen7_append_oa_reports()
1137 * @stream: An i915-perf stream opened for OA metrics
1170 oastatus1 &= ~stream->perf->gen7_latched_oastatus1; in gen7_oa_read()
1198 drm_dbg(&stream->perf->i915->drm, in gen7_oa_read()
1202 stream->perf->ops.oa_disable(stream); in gen7_oa_read()
1203 stream->perf->ops.oa_enable(stream); in gen7_oa_read()
1213 stream->perf->gen7_latched_oastatus1 |= 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
1278 return stream->perf->ops.read(stream, buf, count, offset); in i915_oa_read()
1492 struct i915_perf *perf = &ce->engine->i915->perf; in set_oa_ctx_ctrl_offset() local
1493 u32 offset = perf->ctx_oactxctrl_offset; in set_oa_ctx_ctrl_offset()
1500 perf->ctx_oactxctrl_offset = offset; 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()
1537 * We are enabling perf query here. If we don't find the context in oa_get_render_ctx_id()
1543 drm_err(&stream->perf->i915->drm, in oa_get_render_ctx_id()
1544 "Enabling perf query failed for %s\n", 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
1666 struct i915_perf *perf = stream->perf; in i915_oa_stream_destroy() local
1681 perf->ops.disable_metric_set(stream); in i915_oa_stream_destroy()
1694 m = ratelimit_state_get_miss(&perf->spurious_report_rs); in i915_oa_stream_destroy()
1728 stream->perf->gen7_latched_oastatus1 = 0; in gen7_init_oa_buffer()
1853 struct drm_i915_private *i915 = stream->perf->i915; in alloc_oa_buffer()
1865 bo = i915_gem_object_create_shmem(stream->perf->i915, OA_BUFFER_SIZE); 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()
1942 intel_gt_ns_to_clock_interval(to_gt(stream->perf->i915), in alloc_noa_wait()
1943 atomic64_read(&stream->perf->noa_programming_delay)); in alloc_noa_wait()
1983 * needs to be fixed during the lifetime of the i915/perf stream. 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()
2450 u32 ctx_oactxctrl = stream->perf->ctx_oactxctrl_offset; in gen8_update_reg_state_unlocked()
2451 u32 ctx_flexeu0 = stream->perf->ctx_flexeu0_offset; in gen8_update_reg_state_unlocked()
2615 u32 offset = stream->perf->ctx_oactxctrl_offset; in gen12_configure_oar_context()
2690 struct drm_i915_private *i915 = stream->perf->i915; in oa_configure_all_contexts()
2696 lockdep_assert_held(>->perf.lock); in oa_configure_all_contexts()
2759 u32 ctx_oactxctrl = stream->perf->ctx_oactxctrl_offset; in lrc_configure_all_contexts()
2761 const u32 ctx_flexeu0 = stream->perf->ctx_flexeu0_offset; in lrc_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()
2943 struct drm_i915_private *i915 = stream->perf->i915; in gen12_disable_metric_set()
3049 * @stream: An i915 perf stream opened for OA metrics
3060 stream->perf->ops.oa_enable(stream); in i915_oa_stream_enable()
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
3123 stream->perf->ops.oa_disable(stream); in i915_oa_stream_disable()
3147 err = stream->perf->ops.enable_metric_set(stream, active); in i915_perf_stream_enable_sync()
3215 * @stream: An i915 perf stream
3235 struct drm_i915_private *i915 = stream->perf->i915; in i915_oa_stream_init()
3236 struct i915_perf *perf = stream->perf; in i915_oa_stream_init() local
3241 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3252 if (!perf->metrics_kobj) { 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()
3265 if (!perf->ops.enable_metric_set) { 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()
3293 stream->oa_buffer.format = &perf->oa_formats[props->oa_format]; 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()
3322 stream->oa_config = i915_perf_get_oa_config(perf, props->metrics_set); in i915_oa_stream_init()
3324 drm_dbg(&stream->perf->i915->drm, in i915_oa_stream_init()
3351 stream->engine->gt->perf.sseu = props->sseu; 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()
3375 perf->ops.disable_metric_set(stream); in i915_oa_stream_init()
3403 /* perf.exclusive_stream serialised by lrc_configure_all_contexts() */ in i915_oa_init_reg_state()
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
3617 config = i915_perf_get_oa_config(stream->perf, metrics_set); in i915_perf_config_locked()
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
3704 * Note: The >->perf.lock mutex has been taken to serialize
3724 * @file: An i915 perf stream file
3726 * Cleans up any resources associated with an open i915 perf stream file.
3735 struct i915_perf *perf = stream->perf; in i915_perf_release() local
3740 * other user of stream->lock. Use the perf lock to destroy the stream in i915_perf_release()
3743 mutex_lock(>->perf.lock); in i915_perf_release()
3745 mutex_unlock(>->perf.lock); in i915_perf_release()
3747 /* Release the reference the perf stream kept on the driver. */ in i915_perf_release()
3748 drm_dev_put(&perf->i915->drm); in i915_perf_release()
3769 * @perf: i915 perf instance
3777 * behalf of i915_perf_open_ioctl() with the >->perf.lock mutex
3792 i915_perf_open_ioctl_locked(struct i915_perf *perf, in i915_perf_open_ioctl_locked() argument
3810 drm_dbg(&perf->i915->drm, in i915_perf_open_ioctl_locked()
3811 "Failed to look up context with ID %u for opening perf stream\n", 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()
3861 /* Similar to perf's kernel.perf_paranoid_cpu 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()
3880 stream->perf = perf; in i915_perf_open_ioctl_locked()
3914 drm_dev_get(&perf->i915->drm); in i915_perf_open_ioctl_locked()
3930 static u64 oa_exponent_to_ns(struct i915_perf *perf, int exponent) in oa_exponent_to_ns() argument
3933 u32 den = i915_perf_oa_timestamp_frequency(perf->i915); in oa_exponent_to_ns()
3939 oa_format_valid(struct i915_perf *perf, enum drm_i915_oa_format format) in oa_format_valid() argument
3941 return test_bit(format, perf->format_mask); in oa_format_valid()
3945 oa_format_add(struct i915_perf *perf, enum drm_i915_oa_format format) in oa_format_add() argument
3947 __set_bit(format, perf->format_mask); in oa_format_add()
3952 * @perf: i915 perf instance
3965 static int read_properties_unlocked(struct i915_perf *perf, in read_properties_unlocked() argument
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()
4041 if (!oa_format_valid(perf, value)) { in read_properties_unlocked()
4042 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4051 drm_dbg(&perf->i915->drm, in read_properties_unlocked()
4064 oa_period = oa_exponent_to_ns(perf, value); in read_properties_unlocked()
4080 drm_dbg(&perf->i915->drm, 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()
4171 f = &perf->oa_formats[i]; 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
4210 * i915_perf_open_ioctl_locked() after taking the >->perf.lock
4213 * Return: A newly opened i915 Perf stream file descriptor or negative
4219 struct i915_perf *perf = &to_i915(dev)->perf; in i915_perf_open_ioctl() local
4226 if (!perf->i915) in i915_perf_open_ioctl()
4233 drm_dbg(&perf->i915->drm, in i915_perf_open_ioctl()
4238 ret = read_properties_unlocked(perf, in i915_perf_open_ioctl()
4247 mutex_lock(>->perf.lock); in i915_perf_open_ioctl()
4248 ret = i915_perf_open_ioctl_locked(perf, param, &props, file); in i915_perf_open_ioctl()
4249 mutex_unlock(>->perf.lock); in i915_perf_open_ioctl()
4255 * i915_perf_register - exposes i915-perf to userspace
4260 * used to open an i915-perf stream.
4264 struct i915_perf *perf = &i915->perf; in i915_perf_register() local
4267 if (!perf->i915) in i915_perf_register()
4274 mutex_lock(>->perf.lock); in i915_perf_register()
4276 perf->metrics_kobj = in i915_perf_register()
4280 mutex_unlock(>->perf.lock); in i915_perf_register()
4284 * i915_perf_unregister - hide i915-perf from userspace
4287 * i915-perf state cleanup is split up into an 'unregister' and
4294 struct i915_perf *perf = &i915->perf; in i915_perf_unregister() local
4296 if (!perf->metrics_kobj) in i915_perf_unregister()
4299 kobject_put(perf->metrics_kobj); in i915_perf_unregister()
4300 perf->metrics_kobj = NULL; in i915_perf_unregister()
4303 static bool gen8_is_valid_flex_addr(struct i915_perf *perf, u32 addr) in gen8_is_valid_flex_addr() argument
4422 static bool gen7_is_valid_b_counter_addr(struct i915_perf *perf, u32 addr) in gen7_is_valid_b_counter_addr() argument
4427 static bool gen8_is_valid_mux_addr(struct i915_perf *perf, u32 addr) in gen8_is_valid_mux_addr() argument
4433 static bool gen11_is_valid_mux_addr(struct i915_perf *perf, u32 addr) in gen11_is_valid_mux_addr() argument
4440 static bool hsw_is_valid_mux_addr(struct i915_perf *perf, u32 addr) in hsw_is_valid_mux_addr() argument
4446 static bool chv_is_valid_mux_addr(struct i915_perf *perf, u32 addr) in chv_is_valid_mux_addr() argument
4452 static bool gen12_is_valid_b_counter_addr(struct i915_perf *perf, u32 addr) in gen12_is_valid_b_counter_addr() argument
4457 static bool mtl_is_valid_oam_b_counter_addr(struct i915_perf *perf, u32 addr) in mtl_is_valid_oam_b_counter_addr() argument
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()
4466 static bool xehp_is_valid_b_counter_addr(struct i915_perf *perf, u32 addr) in xehp_is_valid_b_counter_addr() argument
4470 mtl_is_valid_oam_b_counter_addr(perf, addr); in xehp_is_valid_b_counter_addr()
4473 static bool gen12_is_valid_mux_addr(struct i915_perf *perf, u32 addr) in gen12_is_valid_mux_addr() argument
4475 if (GRAPHICS_VER_FULL(perf->i915) >= IP_VER(12, 70)) in gen12_is_valid_mux_addr()
4502 static struct i915_oa_reg *alloc_oa_regs(struct i915_perf *perf, in alloc_oa_regs() argument
4503 bool (*is_valid)(struct i915_perf *perf, u32 addr), in alloc_oa_regs() argument
4530 if (!is_valid(perf, addr)) { in alloc_oa_regs()
4531 drm_dbg(&perf->i915->drm, in alloc_oa_regs()
4564 static int create_dynamic_oa_sysfs_entry(struct i915_perf *perf, in create_dynamic_oa_sysfs_entry() argument
4579 return sysfs_create_group(perf->metrics_kobj, in create_dynamic_oa_sysfs_entry()
4593 * Returns: A new allocated config number to be used with the perf open ioctl
4599 struct i915_perf *perf = &to_i915(dev)->perf; in i915_perf_add_config_ioctl() local
4605 if (!perf->i915) in i915_perf_add_config_ioctl()
4608 if (!perf->metrics_kobj) { 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()
4623 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4630 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4635 oa_config->perf = perf; in i915_perf_add_config_ioctl()
4639 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4651 regs = alloc_oa_regs(perf, in i915_perf_add_config_ioctl()
4652 perf->ops.is_valid_mux_reg, in i915_perf_add_config_ioctl()
4657 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4665 regs = alloc_oa_regs(perf, in i915_perf_add_config_ioctl()
4666 perf->ops.is_valid_b_counter_reg, 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()
4685 regs = alloc_oa_regs(perf, in i915_perf_add_config_ioctl()
4686 perf->ops.is_valid_flex_reg, in i915_perf_add_config_ioctl()
4691 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4699 err = mutex_lock_interruptible(&perf->metrics_lock); in i915_perf_add_config_ioctl()
4706 idr_for_each_entry(&perf->metrics_idr, tmp, id) { in i915_perf_add_config_ioctl()
4708 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4715 err = create_dynamic_oa_sysfs_entry(perf, oa_config); in i915_perf_add_config_ioctl()
4717 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4723 oa_config->id = idr_alloc(&perf->metrics_idr, 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()
4736 mutex_unlock(&perf->metrics_lock); in i915_perf_add_config_ioctl()
4741 mutex_unlock(&perf->metrics_lock); in i915_perf_add_config_ioctl()
4744 drm_dbg(&perf->i915->drm, in i915_perf_add_config_ioctl()
4763 struct i915_perf *perf = &to_i915(dev)->perf; in i915_perf_remove_config_ioctl() local
4768 if (!perf->i915) in i915_perf_remove_config_ioctl()
4772 drm_dbg(&perf->i915->drm, in i915_perf_remove_config_ioctl()
4777 ret = mutex_lock_interruptible(&perf->metrics_lock); in i915_perf_remove_config_ioctl()
4781 oa_config = idr_find(&perf->metrics_idr, *arg); in i915_perf_remove_config_ioctl()
4783 drm_dbg(&perf->i915->drm, in i915_perf_remove_config_ioctl()
4791 sysfs_remove_group(perf->metrics_kobj, &oa_config->sysfs_metric); in i915_perf_remove_config_ioctl()
4793 idr_remove(&perf->metrics_idr, *arg); in i915_perf_remove_config_ioctl()
4795 mutex_unlock(&perf->metrics_lock); in i915_perf_remove_config_ioctl()
4797 drm_dbg(&perf->i915->drm, in i915_perf_remove_config_ioctl()
4805 mutex_unlock(&perf->metrics_lock); in i915_perf_remove_config_ioctl()
4898 int i, num_groups = gt->perf.num_perf_groups; in oa_init_groups()
4901 struct i915_perf_group *g = >->perf.group[i]; in oa_init_groups()
4938 gt->perf.num_perf_groups = num_groups; in oa_init_gt()
4939 gt->perf.group = g; in oa_init_gt()
4946 static int oa_init_engine_groups(struct i915_perf *perf) in oa_init_engine_groups() argument
4951 for_each_gt(gt, perf->i915, i) { in oa_init_engine_groups()
4960 static void oa_init_supported_formats(struct i915_perf *perf) in oa_init_supported_formats() argument
4962 struct drm_i915_private *i915 = perf->i915; in oa_init_supported_formats()
4967 oa_format_add(perf, I915_OA_FORMAT_A13); in oa_init_supported_formats()
4968 oa_format_add(perf, I915_OA_FORMAT_A13); in oa_init_supported_formats()
4969 oa_format_add(perf, I915_OA_FORMAT_A29); in oa_init_supported_formats()
4970 oa_format_add(perf, I915_OA_FORMAT_A13_B8_C8); in oa_init_supported_formats()
4971 oa_format_add(perf, I915_OA_FORMAT_B4_C8); in oa_init_supported_formats()
4972 oa_format_add(perf, I915_OA_FORMAT_A45_B8_C8); in oa_init_supported_formats()
4973 oa_format_add(perf, I915_OA_FORMAT_B4_C8_A16); in oa_init_supported_formats()
4974 oa_format_add(perf, I915_OA_FORMAT_C4_B8); in oa_init_supported_formats()
4993 oa_format_add(perf, I915_OA_FORMAT_A12); in oa_init_supported_formats()
4994 oa_format_add(perf, I915_OA_FORMAT_A12_B8_C8); in oa_init_supported_formats()
4995 oa_format_add(perf, I915_OA_FORMAT_A32u40_A4u32_B8_C8); in oa_init_supported_formats()
4996 oa_format_add(perf, I915_OA_FORMAT_C4_B8); in oa_init_supported_formats()
5000 oa_format_add(perf, I915_OAR_FORMAT_A32u40_A4u32_B8_C8); in oa_init_supported_formats()
5001 oa_format_add(perf, I915_OA_FORMAT_A24u40_A14u32_B8_C8); in oa_init_supported_formats()
5005 oa_format_add(perf, I915_OAR_FORMAT_A32u40_A4u32_B8_C8); in oa_init_supported_formats()
5006 oa_format_add(perf, I915_OA_FORMAT_A24u40_A14u32_B8_C8); in oa_init_supported_formats()
5007 oa_format_add(perf, I915_OAM_FORMAT_MPEC8u64_B8_C8); in oa_init_supported_formats()
5008 oa_format_add(perf, I915_OAM_FORMAT_MPEC8u32_B8_C8); in oa_init_supported_formats()
5018 struct i915_perf *perf = &i915->perf; in i915_perf_init_info() local
5022 perf->ctx_oactxctrl_offset = 0x120; in i915_perf_init_info()
5023 perf->ctx_flexeu0_offset = 0x2ce; in i915_perf_init_info()
5024 perf->gen8_valid_ctx_bit = BIT(25); in i915_perf_init_info()
5027 perf->ctx_oactxctrl_offset = 0x128; in i915_perf_init_info()
5028 perf->ctx_flexeu0_offset = 0x3de; in i915_perf_init_info()
5029 perf->gen8_valid_ctx_bit = BIT(16); in i915_perf_init_info()
5032 perf->ctx_oactxctrl_offset = 0x124; in i915_perf_init_info()
5033 perf->ctx_flexeu0_offset = 0x78e; in i915_perf_init_info()
5034 perf->gen8_valid_ctx_bit = BIT(16); in i915_perf_init_info()
5037 perf->gen8_valid_ctx_bit = BIT(16); in i915_perf_init_info()
5040 * cache the value in perf->ctx_oactxctrl_offset. in i915_perf_init_info()
5049 * i915_perf_init - initialize i915-perf state on module bind
5052 * Initializes i915-perf state without exposing anything to userspace.
5054 * Note: i915-perf initialization is split into an 'init' and 'register'
5059 struct i915_perf *perf = &i915->perf; in i915_perf_init() local
5061 perf->oa_formats = oa_formats; in i915_perf_init()
5063 perf->ops.is_valid_b_counter_reg = gen7_is_valid_b_counter_addr; in i915_perf_init()
5064 perf->ops.is_valid_mux_reg = hsw_is_valid_mux_addr; in i915_perf_init()
5065 perf->ops.is_valid_flex_reg = NULL; in i915_perf_init()
5066 perf->ops.enable_metric_set = hsw_enable_metric_set; in i915_perf_init()
5067 perf->ops.disable_metric_set = hsw_disable_metric_set; in i915_perf_init()
5068 perf->ops.oa_enable = gen7_oa_enable; in i915_perf_init()
5069 perf->ops.oa_disable = gen7_oa_disable; in i915_perf_init()
5070 perf->ops.read = gen7_oa_read; in i915_perf_init()
5071 perf->ops.oa_hw_tail_read = gen7_oa_hw_tail_read; in i915_perf_init()
5079 perf->ops.read = gen8_oa_read; in i915_perf_init()
5083 perf->ops.is_valid_b_counter_reg = in i915_perf_init()
5085 perf->ops.is_valid_mux_reg = in i915_perf_init()
5087 perf->ops.is_valid_flex_reg = in i915_perf_init()
5091 perf->ops.is_valid_mux_reg = in i915_perf_init()
5095 perf->ops.oa_enable = gen8_oa_enable; in i915_perf_init()
5096 perf->ops.oa_disable = gen8_oa_disable; in i915_perf_init()
5097 perf->ops.enable_metric_set = gen8_enable_metric_set; in i915_perf_init()
5098 perf->ops.disable_metric_set = gen8_disable_metric_set; in i915_perf_init()
5099 perf->ops.oa_hw_tail_read = gen8_oa_hw_tail_read; in i915_perf_init()
5101 perf->ops.is_valid_b_counter_reg = in i915_perf_init()
5103 perf->ops.is_valid_mux_reg = in i915_perf_init()
5105 perf->ops.is_valid_flex_reg = in i915_perf_init()
5108 perf->ops.oa_enable = gen8_oa_enable; in i915_perf_init()
5109 perf->ops.oa_disable = gen8_oa_disable; in i915_perf_init()
5110 perf->ops.enable_metric_set = gen8_enable_metric_set; in i915_perf_init()
5111 perf->ops.disable_metric_set = gen11_disable_metric_set; in i915_perf_init()
5112 perf->ops.oa_hw_tail_read = gen8_oa_hw_tail_read; in i915_perf_init()
5114 perf->ops.is_valid_b_counter_reg = in i915_perf_init()
5118 perf->ops.is_valid_mux_reg = in i915_perf_init()
5120 perf->ops.is_valid_flex_reg = in i915_perf_init()
5123 perf->ops.oa_enable = gen12_oa_enable; in i915_perf_init()
5124 perf->ops.oa_disable = gen12_oa_disable; in i915_perf_init()
5125 perf->ops.enable_metric_set = gen12_enable_metric_set; in i915_perf_init()
5126 perf->ops.disable_metric_set = gen12_disable_metric_set; in i915_perf_init()
5127 perf->ops.oa_hw_tail_read = gen12_oa_hw_tail_read; in i915_perf_init()
5131 if (perf->ops.enable_metric_set) { in i915_perf_init()
5136 mutex_init(>->perf.lock); in i915_perf_init()
5141 mutex_init(&perf->metrics_lock); in i915_perf_init()
5142 idr_init_base(&perf->metrics_idr, 1); in i915_perf_init()
5154 ratelimit_state_init(&perf->spurious_report_rs, 5 * HZ, 10); in i915_perf_init()
5159 ratelimit_set_flags(&perf->spurious_report_rs, in i915_perf_init()
5162 ratelimit_state_init(&perf->tail_pointer_race, in i915_perf_init()
5164 ratelimit_set_flags(&perf->tail_pointer_race, in i915_perf_init()
5167 atomic64_set(&perf->noa_programming_delay, in i915_perf_init()
5170 perf->i915 = i915; in i915_perf_init()
5172 ret = oa_init_engine_groups(perf); in i915_perf_init()
5179 oa_init_supported_formats(perf); in i915_perf_init()
5208 struct i915_perf *perf = &i915->perf; in i915_perf_fini() local
5212 if (!perf->i915) in i915_perf_fini()
5215 for_each_gt(gt, perf->i915, i) in i915_perf_fini()
5216 kfree(gt->perf.group); in i915_perf_fini()
5218 idr_for_each(&perf->metrics_idr, destroy_config, perf); in i915_perf_fini()
5219 idr_destroy(&perf->metrics_idr); in i915_perf_fini()
5221 memset(&perf->ops, 0, sizeof(perf->ops)); in i915_perf_fini()
5222 perf->i915 = NULL; in i915_perf_fini()
5226 * i915_perf_ioctl_version - Version of the i915-perf subsystem