Add OAM support for MTL
Subsystems (3)
PATCH v4 1/9 drm/i915/perf: Drop wakeref on GuC RC error
In reply to Umesh Nerlige RamappaFrom: Chris Wilson <[email protected]>
If we fail to adjust the GuC run-control on opening the perf stream, make sure we unwind the wakeref just taken.
v2: Retain old goto label names (Ashutosh)
--- drivers/gpu/drm/i915/i915_perf.c | 14 +++++++++----- drivers/gpu/drm/i915/i915_perf_types.h | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +9 -5
@@ -1592,9 +1592,7 @@ static void i915_oa_stream_destroy(struct i915_perf_stream *stream)/* * Wa_16011777198:dg2: Unset the override of GUCRC mode to enable rc6. */ -if (intel_uc_uses_guc_rc (>->uc) && - (IS_DG2_GRAPHICS_STEP (gt->i915,G10 ,STEP_A0 ,STEP_C0 ) || -IS_DG2_GRAPHICS_STEP (gt->i915,G11 ,STEP_A0 ,STEP_B0 ))) +if (stream->override_gucrc)drm_WARN_ON (>->i915->drm,intel_guc_slpc_unset_gucrc_mode (>->uc.guc.slpc));
@@ -3305,8 +3303,10 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,if (ret) {drm_dbg (&stream->perf->i915->drm,"Unable to override gucrc mode\n" ); - goto err_config; + goto err_gucrc; } + + stream->override_gucrc = true; } ret =alloc_oa_buffer (stream);
@@ -3345,11 +3345,15 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,free_oa_buffer (stream); err_oa_buf_alloc: -free_oa_configs (stream); +if (stream->override_gucrc) +intel_guc_slpc_unset_gucrc_mode (>->uc.guc.slpc); +err_gucrc:intel_uncore_forcewake_put (stream->uncore,FORCEWAKE_ALL );intel_engine_pm_put (stream->engine); +free_oa_configs (stream); + err_config:free_noa_wait (stream);
drivers/gpu/drm/i915/i915_perf_types.h +6 -0
@@ -316,6 +316,12 @@ struct i915_perf_stream {* buffer should be checked for available data. */ u64 poll_oa_period; + +/** +* @override_gucrc: GuC RC has been overridden for the perf stream, +* and we need to restore the default configuration on release. +*/ + bool override_gucrc:1; };/**
Signature · 1 line
2.36.1
PATCH v4 4/9 drm/i915/perf: Group engines into respective OA groups
In reply to Umesh Nerlige RamappaNow that we may have multiple OA units in a single GT as well as on separate GTs, create an engine group that maps to a single OA unit.
v2: (Jani)
- Drop warning on ENOMEM
- Reorder patch in the series
v3: (Ashutosh)
- Remove unused members from perf structs
- Update comments
- Update engine_supports_oa check
- Just return 1 in num_perf_groups_per_gt for now
- Set engine->oa_group to NULL to begin with
v4: Use engine_supports_oa() check in oa_init_reg_state (Ashutosh)
--- drivers/gpu/drm/i915/gt/intel_engine_types.h | 10 +++ drivers/gpu/drm/i915/gt/intel_sseu.c | 3 +- drivers/gpu/drm/i915/i915_perf.c | 95 +++++++++++++++++--- drivers/gpu/drm/i915/i915_perf_types.h | 33 ++++++- 4 files changed, 123 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_types.h +10 -0
@@ -53,6 +53,8 @@ struct intel_gt;struct intel_ring ;struct intel_uncore ;struct intel_breadcrumbs ; +struct intel_engine_cs ; +struct i915_perf_group ;typedef u32 intel_engine_mask_t ;#define ALL_ENGINES ((intel_engine_mask_t)~0ul)
@@ -603,6 +605,14 @@ struct intel_engine_cs { } props, defaults; I915_SELFTEST_DECLARE(struct fault_attr reset_timeout); + +/* +* The perf group maps to one OA unit which controls one OA buffer. All +* reports corresponding to this engine will be reported to this OA +* buffer. An engine will map to a single OA unit, but a single OA unit +* can generate reports for multiple engines. +*/ +struct i915_perf_group *oa_group; }; static inline bool
drivers/gpu/drm/i915/gt/intel_sseu.c +2 -1
@@ -6,6 +6,7 @@#include <linux/string_helpers.h> #include "i915_drv.h" +#include "i915_perf_types.h" #include "intel_engine_regs.h" #include "intel_gt_regs.h" #include "intel_sseu.h"
@@ -677,7 +678,7 @@ u32 intel_sseu_make_rpcs(struct intel_gt *gt,* If i915/perf is active, we want a stable powergating configuration * on the system. Use the configuration pinned by i915/perf. */ -if (gt->perf.exclusive_stream) +if (gt->perf.group && gt->perf.group[PERF_GROUP_OAG ].exclusive_stream) req_sseu = >->perf.sseu; slices =hweight8 (req_sseu->slice_mask);
drivers/gpu/drm/i915/i915_perf.c +82 -13
184 lines not on this page · raw message
drivers/gpu/drm/i915/i915_perf_types.h +29 -4
@@ -17,6 +17,7 @@#include <linux/wait.h> #include <uapi/drm/i915_drm.h> +#include "gt/intel_engine_types.h" #include "gt/intel_sseu.h" #include "i915_reg_defs.h" #include "intel_wakeref.h"
@@ -30,6 +31,13 @@ struct i915_vma;struct intel_context ;struct intel_engine_cs ; +enum { +PERF_GROUP_OAG =0 , + +PERF_GROUP_MAX , +PERF_GROUP_INVALID =U32_MAX , +}; +struct i915_oa_format {u32 format;int size;
@@ -390,6 +398,20 @@ struct i915_oa_ops {u32 (*oa_hw_tail_read)(struct i915_perf_stream *stream); }; +struct i915_perf_group { +/* +* @exclusive_stream: The stream currently using the OA unit. This is +* sometimes accessed outside a syscall associated to its file +* descriptor. +*/ +struct i915_perf_stream *exclusive_stream; + +/* +* @num_engines: The number of engines using this OA unit. +*/ +u32 num_engines; +}; +struct i915_perf_gt {/* * Lock associated with anything below within this structure.
@@ -402,12 +424,15 @@ struct i915_perf_gt {*/ struct intel_sseu sseu; +/** +* @num_perf_groups: number of perf groups per gt. +*/ +u32 num_perf_groups; +/* -* @exclusive_stream: The stream currently using the OA unit. This is -* sometimes accessed outside a syscall associated to its file -* descriptor. +* @group: list of OA groups - one for each OA buffer. */ -struct i915_perf_stream *exclusive_stream; +struct i915_perf_group *group; };struct i915_perf {
Signature · 1 line
2.36.1
PATCH v4 8/9 drm/i915/perf: Add engine class instance parameters to perf
In reply to Umesh Nerlige RamappaOne or more engines map to a specific OA unit. All reports from these engines are captured in the OA buffer managed by this OA unit.
Current i915 OA implementation supports only the OAG unit. OAG primarily caters to render engine, so i915 OA uses render as the default engine in the OA implementation. Since there are more OA units on newer hardware that map to other engines, allow user to pass engine class and instance to select and program specific OA units.
UMD specific changes for GPUvis support:
https://patchwork.freedesktop.org/patch/522827/?series=114023
https://patchwork.freedesktop.org/patch/522822/?series=114023
https://patchwork.freedesktop.org/patch/522826/?series=114023
https://patchwork.freedesktop.org/patch/522828/?series=114023
https://patchwork.freedesktop.org/patch/522816/?series=114023
https://patchwork.freedesktop.org/patch/522825/?series=114023
v2: (Ashutosh)
- Clarify commit message
- Add drm_dbg
- Clarify uapi description
v3: (Ashutosh)
- Remove irrelevant info from the uapi comment
--- drivers/gpu/drm/i915/i915_perf.c | 60 ++++++++++++++++++-------------- include/uapi/drm/i915_drm.h | 17 +++++++++ 2 files changed, 50 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +33 -27
@@ -4013,47 +4013,29 @@ static int read_properties_unlocked(struct i915_perf *perf,struct drm_i915_gem_context_param_sseu user_sseu;u64 __user *uprop = uprops;bool config_sseu = false; +u8 class, instance;u32 i;int ret;memset (props,0 ,sizeof (struct perf_open_properties )); props->poll_oa_period =DEFAULT_POLL_PERIOD_NS ; -if (!n_props) { -drm_dbg (&perf->i915->drm, -"No i915 perf properties given\n" ); -return -EINVAL ; - } - -/* At the moment we only support using i915-perf on the RCS. */ - props->engine =intel_engine_lookup_user (perf->i915, -I915_ENGINE_CLASS_RENDER , -0 ); -if (!props->engine) { -drm_dbg (&perf->i915->drm, -"No RENDER-capable engines\n" ); -return -EINVAL ; - } - -if (!engine_supports_oa (props->engine)) { -drm_dbg (&perf->i915->drm, -"Engine not supported by OA %d:%d\n" , -I915_ENGINE_CLASS_RENDER ,0 ); -return -EINVAL ; - } -/* Considering that ID = 0 is reserved and assuming that we don't * (currently) expect any configurations to ever specify duplicate * values for a particular property ID then the last _PROP_MAX value is * one greater than the maximum number of properties we expect to get * from userspace. */ -if (n_props >=DRM_I915_PERF_PROP_MAX ) { +if (!n_props || n_props >=DRM_I915_PERF_PROP_MAX ) {drm_dbg (&perf->i915->drm, -"More i915 perf properties specified than exist\n" ); +"Invalid number of i915 perf properties given\n" );return -EINVAL ; } +/* Defaults when class:instance is not passed */ + class =I915_ENGINE_CLASS_RENDER ; + instance =0 ; +for (i =0 ; i < n_props; i++) {u64 oa_period, oa_freq_hz;u64 id, value;
@@ -4174,7 +4156,13 @@ static int read_properties_unlocked(struct i915_perf *perf, } props->poll_oa_period = value;break ; -case DRM_I915_PERF_PROP_MAX : +case DRM_I915_PERF_PROP_OA_ENGINE_CLASS : + class = (u8 )value; +break ; +case DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE : + instance = (u8 )value; +break ; +default :MISSING_CASE (id);return -EINVAL ; }
@@ -4182,6 +4170,21 @@ static int read_properties_unlocked(struct i915_perf *perf, uprop +=2 ; } + props->engine =intel_engine_lookup_user (perf->i915, class, instance); +if (!props->engine) { +drm_dbg (&perf->i915->drm, +"OA engine class and instance invalid %d:%d\n" , + class, instance); +return -EINVAL ; + } + +if (!engine_supports_oa (props->engine)) { +drm_dbg (&perf->i915->drm, +"Engine not supported by OA %d:%d\n" , + class, instance); +return -EINVAL ; + } +if (config_sseu) { ret =get_sseu_config (&props->sseu, props->engine, &user_sseu);if (ret) {
@@ -5158,8 +5161,11 @@ int i915_perf_ioctl_version(void)* * 5: Add DRM_I915_PERF_PROP_POLL_OA_PERIOD parameter that controls the * interval for the hrtimer used to check for OA data. +* +* 6: Add DRM_I915_PERF_PROP_OA_ENGINE_CLASS and +* DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE */ -return 5 ; +return 6 ; }#if IS_ENABLED (CONFIG_DRM_I915_SELFTEST )
include/uapi/drm/i915_drm.h +17 -0
@@ -2758,6 +2758,23 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_POLL_OA_PERIOD , +/** +* Multiple engines may be mapped to the same OA unit. The OA unit is +* identified by class:instance of any engine mapped to it". +* +* This parameter specifies the engine class. +* +* This property is available in perf revision 6. +*/ +DRM_I915_PERF_PROP_OA_ENGINE_CLASS , + +/** +* This parameter specifies the engine instance. +* +* This property is available in perf revision 6. +*/ +DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
Signature · 1 line
2.36.1
PATCH v4 6/9 drm/i915/perf: Parse 64bit report header formats correctly
In reply to Umesh Nerlige RamappaNow that OA formats come in flavor of 64 bit reports, the report header has 64 bit report-id, timestamp, context-id and gpu-ticks fields. When filtering these reports, use the right width for these fields.
Note that upper dword of context id is reserved, so squash lower dword only.
v2: (Ashutosh)
- Drop inline
- Update comment with dword definitions - report id and timestamp
--- drivers/gpu/drm/i915/i915_perf.c | 109 +++++++++++++++++++------ drivers/gpu/drm/i915/i915_perf_types.h | 6 ++ 2 files changed, 90 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +84 -25
@@ -441,6 +441,67 @@ static u32 gen7_oa_hw_tail_read(struct i915_perf_stream *stream)return oastatus1 &GEN7_OASTATUS1_TAIL_MASK ; } +#define oa_report_header_64bit (__s) \ + ((__s)->oa_buffer.format->header == HDR_64_BIT) + +static u64 oa_report_id (struct i915_perf_stream *stream,void *report) +{ +return oa_report_header_64bit (stream) ? *(u64 *)report : *(u32 *)report; +} + +static u64 oa_report_reason (struct i915_perf_stream *stream,void *report) +{ +return (oa_report_id (stream, report) >>OAREPORT_REASON_SHIFT ) & + (GRAPHICS_VER (stream->perf->i915) ==12 ? +OAREPORT_REASON_MASK_EXTENDED : +OAREPORT_REASON_MASK ); +} + +static void oa_report_id_clear (struct i915_perf_stream *stream,u32 *report) +{ +if (oa_report_header_64bit (stream)) + *(u64 *)report =0 ; +else + *report =0 ; +} + +static bool oa_report_ctx_invalid (struct i915_perf_stream *stream,void *report) +{ +return !(oa_report_id (stream, report) & + stream->perf->gen8_valid_ctx_bit) && +GRAPHICS_VER (stream->perf->i915) <=11 ; +} + +static u64 oa_timestamp (struct i915_perf_stream *stream,void *report) +{ +return oa_report_header_64bit (stream) ? + *((u64 *)report +1 ) : + *((u32 *)report +1 ); +} + +static void oa_timestamp_clear (struct i915_perf_stream *stream,u32 *report) +{ +if (oa_report_header_64bit (stream)) + *(u64 *)&report[2 ] =0 ; +else + report[1 ] =0 ; +} + +static u32 oa_context_id (struct i915_perf_stream *stream,u32 *report) +{ +u32 ctx_id =oa_report_header_64bit (stream) ? report[4 ] : report[2 ]; + +return ctx_id & stream->specific_ctx_id_mask; +} + +static void oa_context_id_squash (struct i915_perf_stream *stream,u32 *report) +{ +if (oa_report_header_64bit (stream)) + report[4 ] =INVALID_CTX_ID ; +else + report[2 ] =INVALID_CTX_ID ; +} +/** * oa_buffer_check_unlocked - check for data and update tail ptr state * @stream: i915 stream instance
@@ -509,21 +570,22 @@ static bool oa_buffer_check_unlocked(struct i915_perf_stream *stream) hw_tail -= gtt_offset; tail = hw_tail; -/* Walk the stream backward until we find a report with dword 0 -* & 1 not at 0. Since the circular buffer pointers progress by -* increments of 64 bytes and that reports can be up to 256 -* bytes long, we can't tell whether a report has fully landed -* in memory before the first 2 dwords of the following report -* have effectively landed. +/* Walk the stream backward until we find a report with report +* id and timestmap not at 0. Since the circular buffer pointers +* progress by increments of 64 bytes and that reports can be up +* to 256 bytes long, we can't tell whether a report has fully +* landed in memory before the report id and timestamp of the +* following report have effectively landed. * * This is assuming that the writes of the OA unit land in * memory in the order they were written to. * If not : (╯°□°)╯︵ ┻━┻ */ while (OA_TAKEN (tail, aged_tail) >= report_size) { -u32 *report32 = (void *)(stream->oa_buffer.vaddr + tail); +void *report = stream->oa_buffer.vaddr + tail; -if (report32[0 ] !=0 || report32[1 ] !=0 ) +if (oa_report_id (stream, report) || +oa_timestamp (stream, report))break ; tail = (tail - report_size) & (OA_BUFFER_SIZE -1 );
@@ -702,7 +764,7 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,u8 *report = oa_buf_base + head;u32 *report32 = (void *)report;u32 ctx_id; -u32 reason; +u64 reason;/* * All the report sizes factor neatly into the buffer
@@ -725,16 +787,12 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,* triggered this specific report (mostly timer * triggered or e.g. due to a context switch). * -* This field is never expected to be zero so we can -* check that the report isn't invalid before copying -* it to userspace... +* In MMIO triggered reports, some platforms do not set the +* reason bit in this field and it is valid to have a reason +* field of zero. */ - reason = ((report32[0 ] >>OAREPORT_REASON_SHIFT ) & - (GRAPHICS_VER (stream->perf->i915) ==12 ? -OAREPORT_REASON_MASK_EXTENDED : -OAREPORT_REASON_MASK )); - - ctx_id = report32[2 ] & stream->specific_ctx_id_mask; + reason =oa_report_reason (stream, report); + ctx_id =oa_context_id (stream, report32);/* * Squash whatever is in the CTX_ID field if it's marked as
@@ -744,9 +802,10 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,* Note: that we don't clear the valid_ctx_bit so userspace can * understand that the ID has been squashed by the kernel. */ -if (!(report32[0 ] & stream->perf->gen8_valid_ctx_bit) && -GRAPHICS_VER (stream->perf->i915) <=11 ) - ctx_id = report32[2 ] =INVALID_CTX_ID ; +if (oa_report_ctx_invalid (stream, report)) { + ctx_id =INVALID_CTX_ID ; +oa_context_id_squash (stream, report32); + }/* * NB: For Gen 8 the OA unit no longer supports clock gating
@@ -790,7 +849,7 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,*/ if (stream->ctx && stream->specific_ctx_id != ctx_id) { - report32[2 ] =INVALID_CTX_ID ; +oa_context_id_squash (stream, report32); } ret = append_oa_sample(stream, buf, count, offset,
@@ -802,11 +861,11 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream, }/* -* Clear out the first 2 dword as a mean to detect unlanded +* Clear out the report id and timestamp as a means to detect unlanded * reports. */ - report32[0 ] =0 ; - report32[1 ] =0 ; +oa_report_id_clear (stream, report32); +oa_timestamp_clear (stream, report32); }if (start_offset != *offset) {
drivers/gpu/drm/i915/i915_perf_types.h +6 -0
@@ -38,9 +38,15 @@ enum { PERF_GROUP_INVALID = U32_MAX, }; +enum report_header { +HDR_32_BIT =0 , +HDR_64_BIT , +}; +struct i915_oa_format {u32 format;int size; +enum report_header header; };struct i915_oa_reg {
Signature · 1 line
2.36.1
PATCH v4 7/9 drm/i915/perf: Handle non-power-of-2 reports
In reply to Umesh Nerlige RamappaSome of the newer OA formats are not powers of 2. For those formats, adjust the hw_tail accordingly when checking for new reports.
v2: (Ashutosh)
- Switch to OA_TAKEN for diff calculation
- Use OA_BUFFER_SIZE instead of the vma size
- Update comments
--- drivers/gpu/drm/i915/i915_perf.c | 51 +++++++++++++++++--------------- 1 file changed, 27 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +27 -24
@@ -534,6 +534,7 @@ static bool oa_buffer_check_unlocked(struct i915_perf_stream *stream)bool pollin;u32 hw_tail;u64 now; +u32 partial_report_size;/* We have to consider the (unlikely) possibility that read() errors * could result in an OA buffer reset which might reset the head and
@@ -543,10 +544,15 @@ static bool oa_buffer_check_unlocked(struct i915_perf_stream *stream) hw_tail = stream->perf->ops.oa_hw_tail_read (stream); -/* The tail pointer increases in 64 byte increments, -* not in report_size steps... +/* The tail pointer increases in 64 byte increments, not in report_size +* steps. Also the report size may not be a power of 2. Compute +* potentially partially landed report in the OA buffer */ - hw_tail &= ~(report_size -1 ); + partial_report_size =OA_TAKEN (hw_tail, stream->oa_buffer.tail); + partial_report_size %= report_size; + +/* Subtract partial amount off the tail */ + hw_tail = gtt_offset +OA_TAKEN (hw_tail, partial_report_size); now =ktime_get_mono_fast_ns ();
@@ -669,6 +675,8 @@ static int append_oa_sample(struct i915_perf_stream *stream, {int report_size = stream->oa_buffer.format->size;struct drm_i915_perf_record_header header; +int report_size_partial; +u8 *oa_buf_end; header.type =DRM_I915_PERF_RECORD_SAMPLE ; header.pad =0 ;
@@ -682,8 +690,20 @@ static int append_oa_sample(struct i915_perf_stream *stream,return -EFAULT ; buf +=sizeof (header); -if (copy_to_user (buf, report, report_size)) + oa_buf_end = stream->oa_buffer.vaddr +OA_BUFFER_SIZE ; + report_size_partial = oa_buf_end - report; + +if (report_size_partial < report_size) { +if (copy_to_user (buf, report, report_size_partial)) +return -EFAULT ; + buf += report_size_partial; + +if (copy_to_user (buf, stream->oa_buffer.vaddr, + report_size - report_size_partial)) +return -EFAULT ; + }else if (copy_to_user (buf, report, report_size)) {return -EFAULT ; + } (*offset) += header.size;
@@ -747,12 +767,11 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,* An out of bounds or misaligned head or tail pointer implies a driver * bug since we validate + align the tail pointers we read from the * hardware and we are in full control of the head pointer which should -* only be incremented by multiples of the report size (notably also -* all a power of two). +* only be incremented by multiples of the report size. */ if (drm_WARN_ONCE (&uncore->i915->drm, - head >OA_BUFFER_SIZE || head % report_size || - tail >OA_BUFFER_SIZE || tail % report_size, + head >OA_BUFFER_SIZE || + tail >OA_BUFFER_SIZE ,"Inconsistent OA buffer pointers: head = %u, tail = %u\n" , head, tail))return -EIO ;
@@ -766,22 +785,6 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,u32 ctx_id;u64 reason; -/* -* All the report sizes factor neatly into the buffer -* size so we never expect to see a report split -* between the beginning and end of the buffer. -* -* Given the initial alignment check a misalignment -* here would imply a driver bug that would result -* in an overrun. -*/ -if (drm_WARN_ON (&uncore->i915->drm, - (OA_BUFFER_SIZE - head) < report_size)) { -drm_err (&uncore->i915->drm, -"Spurious OA head ptr: non-integral report offset\n" ); -break ; - } -/* * The reason field includes flags identifying what * triggered this specific report (mostly timer
Signature · 1 line
2.36.1
v4 cover Add OAM support for MTL
The OAM unit captures OA reports specific to the media engines. Add support to program the OAM unit on media tile on MTL.
The OAM unit is selected by passing the class:instance of a media engine to perf parameters. Corresponding UMD changes are posted to the igt-dev repo as part of supporting the GPUvis tool.
v2: Incorporate review feedback (Jani, Ashutosh)
v3: Incorporate review feedback (Jani, Ashutosh)
v4: Incorporate review feedback (Ashutosh)
Test-with: [email protected]
Chris Wilson (1):
drm/i915/perf: Drop wakeref on GuC RC error
Umesh Nerlige Ramappa (8):
drm/i915/perf: Add helper to check supported OA engines drm/i915/perf: Validate OA sseu config outside switch drm/i915/perf: Group engines into respective OA groups drm/i915/perf: Fail modprobe if i915_perf_init fails on OOM drm/i915/perf: Parse 64bit report header formats correctly drm/i915/perf: Handle non-power-of-2 reports drm/i915/perf: Add engine class instance parameters to perf drm/i915/perf: Add support for OA media units
drivers/gpu/drm/i915/gt/intel_engine_types.h | 10 + drivers/gpu/drm/i915/gt/intel_sseu.c | 3 +- drivers/gpu/drm/i915/i915_driver.c | 4 +- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/i915_pci.c | 1 + drivers/gpu/drm/i915/i915_perf.c | 527 +++++++++++++++---- drivers/gpu/drm/i915/i915_perf.h | 2 +- drivers/gpu/drm/i915/i915_perf_oa_regs.h | 78 +++ drivers/gpu/drm/i915/i915_perf_types.h | 75 ++- drivers/gpu/drm/i915/intel_device_info.h | 1 + include/uapi/drm/i915_drm.h | 21 + 11 files changed, 603 insertions(+), 121 deletions(-)
Signature · 1 line
2.36.1
PATCH v4 3/9 drm/i915/perf: Validate OA sseu config outside switch
Once OA supports media engine class:instance, the engine can only be validated outside the switch since class and instance parameters are separate entities. Since OA sseu config depends on engine class:instance, validate OA sseu config outside the switch.
v2: (Ashutosh)
- Clarify commit message
- Use drm_dbg instead of DRM_DEBUG
- Reorder stack variables
--- drivers/gpu/drm/i915/i915_perf.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +13 -10
@@ -3950,7 +3950,9 @@ static int read_properties_unlocked(struct i915_perf *perf,u32 n_props, struct perf_open_properties *props) { + struct drm_i915_gem_context_param_sseu user_sseu;u64 __user *uprop = uprops; +bool config_sseu = false;u32 i;int ret;
@@ -4079,8 +4081,6 @@ static int read_properties_unlocked(struct i915_perf *perf, props->hold_preemption = !!value;break ;case DRM_I915_PERF_PROP_GLOBAL_SSEU : { -struct drm_i915_gem_context_param_sseu user_sseu; -if (GRAPHICS_VER_FULL (perf->i915) >=IP_VER (12 ,50 )) { drm_dbg(&perf->i915->drm, "SSEU config not supported on gfx %x\n",
@@ -4095,14 +4095,7 @@ static int read_properties_unlocked(struct i915_perf *perf, "Unable to copy global sseu parameter\n");return -EFAULT ; } - - ret =get_sseu_config (&props->sseu, props->engine, &user_sseu); -if (ret) { -drm_dbg (&perf->i915->drm, -"Invalid SSEU configuration\n" ); -return ret; - } - props->has_sseu = true; + config_sseu = true;break ; }case DRM_I915_PERF_PROP_POLL_OA_PERIOD :
@@ -4122,6 +4115,16 @@ static int read_properties_unlocked(struct i915_perf *perf, uprop +=2 ; } +if (config_sseu) { + ret =get_sseu_config (&props->sseu, props->engine, &user_sseu); +if (ret) { +drm_dbg (&perf->i915->drm, +"Invalid SSEU configuration\n" ); +return ret; + } + props->has_sseu = true; + } +return 0 ; }
Signature · 1 line
2.36.1
PATCH v4 5/9 drm/i915/perf: Fail modprobe if i915_perf_init fails on OOM
In reply to Umesh Nerlige Ramappai915_perf_init can fail due to OOM. Fail driver init if i915_perf_init fails.
v2: (Jani)
- Reorder patch in the series
--- drivers/gpu/drm/i915/i915_driver.c | 4 +++- drivers/gpu/drm/i915/i915_perf.c | 8 ++++++-- drivers/gpu/drm/i915/i915_perf.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_driver.c +3 -1
@@ -477,7 +477,9 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)if (ret)return ret; -i915_perf_init (dev_priv); + ret =i915_perf_init (dev_priv); +if (ret) +return ret; ret =i915_ggtt_probe_hw (dev_priv);if (ret)
drivers/gpu/drm/i915/i915_perf.c +6 -2
@@ -4902,7 +4902,7 @@ static void i915_perf_init_info(struct drm_i915_private *i915)* Note: i915-perf initialization is split into an 'init' and 'register' * phase with the i915_perf_register() exposing state to userspace. */ -void i915_perf_init (struct drm_i915_private *i915) +int i915_perf_init (struct drm_i915_private *i915) {struct i915_perf *perf = &i915->perf;
@@ -5018,12 +5018,16 @@ void i915_perf_init(struct drm_i915_private *i915) perf->i915 = i915; ret =oa_init_engine_groups (perf); -if (ret) +if (ret) {drm_err (&i915->drm,"OA initialization failed %d\n" , ret); +return ret; + }oa_init_supported_formats (perf); } + +return 0 ; }static int destroy_config (int id,void *p,void *data)
drivers/gpu/drm/i915/i915_perf.h +1 -1
@@ -18,7 +18,7 @@ struct i915_oa_config;struct intel_context ;struct intel_engine_cs ; -void i915_perf_init (struct drm_i915_private *i915); +int i915_perf_init (struct drm_i915_private *i915);void i915_perf_fini (struct drm_i915_private *i915);void i915_perf_register (struct drm_i915_private *i915);void i915_perf_unregister (struct drm_i915_private *i915);
Signature · 1 line
2.36.1
PATCH v4 2/9 drm/i915/perf: Add helper to check supported OA engines
In reply to Umesh Nerlige RamappaWith an intention to add more engines that are supported by OA, add helper to check for supported OA engines.
v2: (Ashutosh)
- Update commit message
- Drop virtual engine check since we support only one render engine
--- drivers/gpu/drm/i915/i915_perf.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +13 -3
@@ -1570,6 +1570,16 @@ free_noa_wait(struct i915_perf_stream *stream)i915_vma_unpin_and_release (&stream->noa_wait,0 ); } +static bool engine_supports_oa (const struct intel_engine_cs *engine) +{ +enum intel_platform platform =INTEL_INFO (engine->i915)->platform; + +switch (platform) { +default : +return engine->class ==RENDER_CLASS ; + } +} +static void i915_oa_stream_destroy (struct i915_perf_stream *stream) {struct i915_perf *perf = stream->perf;
@@ -2505,7 +2515,7 @@ static int gen8_configure_context(struct i915_gem_context *ctx,for_each_gem_engine (ce,i915_gem_context_lock_engines (ctx), it) {GEM_BUG_ON (ce == ce->engine->kernel_context); -if (ce->engine->class !=RENDER_CLASS ) +if (!engine_supports_oa (ce->engine))continue ;/* Otherwise OA settings will be set upon first use */
@@ -2656,7 +2666,7 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,for_each_uabi_engine (engine, i915) {struct intel_context *ce = engine->kernel_context; -if (engine->class !=RENDER_CLASS ) +if (!engine_supports_oa (ce->engine))continue ; regs[0 ].value =intel_sseu_make_rpcs (engine->gt, &ce->sseu);
@@ -3369,7 +3379,7 @@ void i915_oa_init_reg_state(const struct intel_context *ce, {struct i915_perf_stream *stream; -if (engine->class !=RENDER_CLASS ) +if (!engine_supports_oa (engine))return ;/* perf.exclusive_stream serialised by lrc_configure_all_contexts() */
Signature · 1 line
2.36.1
PATCH v4 9/9 drm/i915/perf: Add support for OA media units
In reply to Umesh Nerlige RamappaMTL introduces additional OA units dedicated to media use cases. Add support for programming these OA units by passing the media engine class and instance parameters.
UMD specific changes for GPUvis support:
https://patchwork.freedesktop.org/patch/522827/?series=114023
https://patchwork.freedesktop.org/patch/522822/?series=114023
https://patchwork.freedesktop.org/patch/522826/?series=114023
https://patchwork.freedesktop.org/patch/522828/?series=114023
https://patchwork.freedesktop.org/patch/522816/?series=114023
https://patchwork.freedesktop.org/patch/522825/?series=114023
v2: (Ashutosh)
- check for IP_VER(12, 70) instead of MTL
- remove PERF_GROUP_OAG comment in mtl_oa_base
- remove oa_buffer.group
- use engine->oa_group->type in engine_supports_oa_format
- remove fw_domains and use FORCEWAKE_ALL
- remove MPES/MPEC comment
- s/xehp/mtl/ in b counter validation function name
- remove engine_supports_oa in __oa_engine_group
- remove warn_ON from __oam_engine_group
- refactor oa_init_groups and oa_init_regs
- assign g->type correctly
- use enum oa_type definition
v3: (Ashutosh)
- Drop oa_unit_functional as engine_supports_oa is enough
--- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/i915_pci.c | 1 + drivers/gpu/drm/i915/i915_perf.c | 189 ++++++++++++++++++++--- drivers/gpu/drm/i915/i915_perf_oa_regs.h | 78 ++++++++++ drivers/gpu/drm/i915/i915_perf_types.h | 30 ++++ drivers/gpu/drm/i915/intel_device_info.h | 1 + include/uapi/drm/i915_drm.h | 4 + 7 files changed, 281 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -856,6 +856,8 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915, (INTEL_INFO(dev_priv)->has_oa_bpc_reporting)#define HAS_OA_SLICE_CONTRIB_LIMITS (dev_priv) \ (INTEL_INFO(dev_priv)->has_oa_slice_contrib_limits) +#define HAS_OAM (dev_priv) \ + (INTEL_INFO(dev_priv)->has_oam)/* * Set this flag, when platform requires 64K GTT page sizes or larger for
drivers/gpu/drm/i915/i915_pci.c +1 -0
@@ -1028,6 +1028,7 @@ static const struct intel_device_info adl_p_info = { .has_mslice_steering = 1, \ .has_oa_bpc_reporting = 1, \ .has_oa_slice_contrib_limits = 1, \ + .has_oam = 1, \ .has_rc6 = 1, \ .has_reset_engine = 1, \ .has_rps = 1, \
drivers/gpu/drm/i915/i915_perf.c +165 -24
368 lines not on this page · raw message
drivers/gpu/drm/i915/i915_perf_oa_regs.h +78 -0
82 lines not on this page · raw message
drivers/gpu/drm/i915/i915_perf_types.h +30 -0
@@ -20,6 +20,7 @@#include "gt/intel_engine_types.h" #include "gt/intel_sseu.h" #include "i915_reg_defs.h" +#include "intel_uncore.h" #include "intel_wakeref.h" struct drm_i915_private ;
@@ -33,6 +34,7 @@ struct intel_engine_cs;enum {PERF_GROUP_OAG =0 , +PERF_GROUP_OAM_SAMEDIA_0 =0 ,PERF_GROUP_MAX ,PERF_GROUP_INVALID =U32_MAX ,
@@ -43,9 +45,27 @@ enum report_header { HDR_64_BIT, }; +struct i915_perf_regs { +u32 base; +i915_reg_t oa_head_ptr; +i915_reg_t oa_tail_ptr; +i915_reg_t oa_buffer; +i915_reg_t oa_ctx_ctrl; +i915_reg_t oa_ctrl; +i915_reg_t oa_debug; +i915_reg_t oa_status; +u32 oa_ctrl_counter_format_shift; +}; + +enum oa_type { +TYPE_OAG , +TYPE_OAM , +}; +struct i915_oa_format {u32 format;int size; +int type;enum report_header header; };
@@ -416,6 +436,16 @@ struct i915_perf_group {* @num_engines: The number of engines using this OA unit. */ u32 num_engines; + +/* +* @regs: OA buffer register group for programming the OA unit. +*/ +struct i915_perf_regs regs; + +/* +* @type: Type of OA unit - OAM, OAG etc. +*/ +enum oa_type type; };struct i915_perf_gt {
drivers/gpu/drm/i915/intel_device_info.h +1 -0
@@ -166,6 +166,7 @@ enum intel_ppgtt_type {func (has_mslice_steering); \func (has_oa_bpc_reporting); \func (has_oa_slice_contrib_limits); \ +func (has_oam); \func (has_one_eu_per_fuse_bit); \func (has_pxp); \func (has_rc6); \
include/uapi/drm/i915_drm.h +4 -0
@@ -2676,6 +2676,10 @@ enum drm_i915_oa_format { I915_OAR_FORMAT_A32u40_A4u32_B8_C8, I915_OA_FORMAT_A24u40_A14u32_B8_C8, +/* MTL OAM */ + I915_OAM_FORMAT_MPEC8u64_B8_C8, + I915_OAM_FORMAT_MPEC8u32_B8_C8, + I915_OA_FORMAT_MAX /* non-ABI */ };
Signature · 1 line
2.36.1
Re: [Intel-gfx] [PATCH v4 8/9] drm/i915/perf: Add engine class instance parameters to perf
In reply to Umesh Nerlige RamappaQuoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +4
-0+/* Defaults when class:instance is not passed */ + class =I915_ENGINE_CLASS_RENDER ; + instance =0 ; +for (i = 0; i < n_props; i++) { u64 oa_period, oa_freq_hz; u64 id, value;
drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct i915_perf *perf, · line 4164
Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +6
-1@@ -4174,7 +4156,13 @@ static int read_properties_unlocked(struct i915_perf *perf, } props->poll_oa_period = value;break ; -case DRM_I915_PERF_PROP_MAX : +case DRM_I915_PERF_PROP_OA_ENGINE_CLASS : + class = (u8 )value; +break ; +case DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE : + instance = (u8 )value; +break ;
I am wondering since this is uapi we should make it robust. So if the user passes either class or instance he must pass both and we should check for that. If only one is passed we should not implicitly assume the other as we are doing here (if only instance is passed here we will assume RCS and if only class is passed we will assume instance 0). I think making this explicit will avoid confusion later. Thoughts?
Quoted 5 lines
drivers/gpu/drm/i915/i915_perf.c +1
-0+default :MISSING_CASE (id);return -EINVAL ; }
drivers/gpu/drm/i915/i915_perf.c static int read_properties_unlocked(struct i915_perf *perf, · line 4179
Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +7
-0@@ -4182,6 +4170,21 @@ static int read_properties_unlocked(struct i915_perf *perf, uprop +=2 ; } + props->engine =intel_engine_lookup_user (perf->i915, class, instance); +if (!props->engine) { +drm_dbg (&perf->i915->drm, +"OA engine class and instance invalid %d:%d\n" , + class, instance); +return -EINVAL ; + }
Thanks.
--
Ashutosh
Re: [Intel-gfx] [PATCH v4 8/9] drm/i915/perf: Add engine class instance parameters to perf
In reply to Umesh Nerlige RamappaQuoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 8 lines
One or more engines map to a specific OA unit. All reports from these engines are captured in the OA buffer managed by this OA unit.
Current i915 OA implementation supports only the OAG unit. OAG primarily caters to render engine, so i915 OA uses render as the default engine in the OA implementation. Since there are more OA units on newer hardware that map to other engines, allow user to pass engine class and instance to select and program specific OA units.
I believe there is another uapi issue to be resolved here: how the engines are associated with OA units, since from the point of view of the uapi there are multiple engines and multiple OA units (even if in the actual implementation at present there is only one OA unit per gt). In the internal tree we had added oa_unit_id to engine_info for this. So if multiple engines had the same oa_unit_id, user could pass class:instance of any of those engines to get oa data from that OA unit (and generally know how engines are hooked up to OA units (the OA unit topology)).
So the question is even if we don't implement it as part of this series (or do we have to?) do we at least need to agree to that uapi which will be used to associate OA units with engines?
Thanks.
--
Ashutosh
Re: [Intel-gfx] [PATCH v4 8/9] drm/i915/perf: Add engine class instance parameters to perf
Quoted 23 lines · Ashutosh
Quoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 8 lines
One or more engines map to a specific OA unit. All reports from these engines are captured in the OA buffer managed by this OA unit.
Current i915 OA implementation supports only the OAG unit. OAG primarily caters to render engine, so i915 OA uses render as the default engine in the OA implementation. Since there are more OA units on newer hardware that map to other engines, allow user to pass engine class and instance to select and program specific OA units.
I believe there is another uapi issue to be resolved here: how the engines are associated with OA units, since from the point of view of the uapi there are multiple engines and multiple OA units (even if in the actual implementation at present there is only one OA unit per gt). In the internal tree we had added
oa_unit_idtoengine_infofor this. So if multiple engines had the sameoa_unit_id, user could pass class:instance of any of those engines to get oa data from that OA unit (and generally know how engines are hooked up to OA units (the OA unit topology)).
Quoted 3 lines
So the question is even if we don't implement it as part of this series (or do we have to?) do we at least need to agree to that uapi which will be used to associate OA units with engines?
It did make more sense for xehpsdv and other platforms where we had multiple OA units per GT and each GT had render and/or compute engines. In those cases, media and compute/render UMDs may have needed to know that topology.
For MTL, I don't think that an end user will benefit from the engine<->oa_unit mapping because
(1) media and render are separate GTs
(2) there is just one OA unit per GT and
(3) assuming media and render/compute are separate UMDs,
That's also the reason why the corresponding IGT series just uses a static mapping for MTL.
If we come across a case where the UMD needs this info OR we are supporting a platform with multiple OA units per tile, we should add the topology.
Thanks,
Umesh
Quoted 4 lines
Thanks.
--
Ashutosh
Re: [Intel-gfx] [PATCH v4 8/9] drm/i915/perf: Add engine class instance parameters to perf
In reply to Dixit, AshutoshQuoted 22 lines · Ashutosh
Quoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 17 lines
drivers/gpu/drm/i915/i915_perf.c +4
-0+/* Defaults when class:instance is not passed */ + class =I915_ENGINE_CLASS_RENDER ; + instance =0 ; +for (i = 0; i < n_props; i++) { u64 oa_period, oa_freq_hz; u64 id, value;drivers/gpu/drm/i915/i915_perf.c +5
-1@@ -4174,7 +4156,13 @@ static int read_properties_unlocked(struct i915_perf *perf, } props->poll_oa_period = value;break ; -case DRM_I915_PERF_PROP_MAX : +case DRM_I915_PERF_PROP_OA_ENGINE_CLASS : + class = (u8 )value; +break ; +case DRM_I915_PERF_PROP_OA_ENGINE_INSTANCE : + instance = (u8 )value;
Quoted 8 lines
Review static int read_properties_unlocked(struct i915_perf *perf, · line 4164
Quoted 1 line
(quoted diff) +1
-0+ break;I am wondering since this is uapi we should make it robust. So if the user passes either class or instance he must pass both and we should check for that. If only one is passed we should not implicitly assume the other as we are doing here (if only instance is passed here we will assume RCS and if only class is passed we will assume instance 0). I think making this explicit will avoid confusion later. Thoughts?
Agree. We should only allow this configuration as a pair.
Thanks,
Umesh
Re: [Intel-gfx] [PATCH v4 9/9] drm/i915/perf: Add support for OA media units
In reply to Umesh Nerlige RamappaQuoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 36 lines
drivers/gpu/drm/i915/i915_perf.c +2
-1-static int gen8_configure_context(struct i915_gem_context *ctx, +static int gen8_configure_context(struct i915_perf_stream *stream, + struct i915_gem_context *ctx,struct flex *flex, unsigned int count)
{ struct i915_gem_engines_iter it;drivers/gpu/drm/i915/i915_perf.c +5
-3@@ -2573,7 +2594,8 @@ static int gen8_configure_context(struct i915_gem_context *ctx,for_each_gem_engine (ce,i915_gem_context_lock_engines (ctx), it) {GEM_BUG_ON (ce == ce->engine->kernel_context); -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ;/* Otherwise OA settings will be set upon first use */ @@ -2704,7 +2726,7 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,spin_unlock (&i915->gem.contexts.lock); - err =gen8_configure_context (ctx, regs, num_regs); + err =gen8_configure_context (stream, ctx, regs, num_regs);if (err) {i915_gem_context_put (ctx);return err;@@ -2724,7 +2746,8 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,for_each_uabi_engine (engine, i915) {struct intel_context *ce = engine->kernel_context; -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ; regs[0 ].value =intel_sseu_make_rpcs (engine->gt, &ce->sseu);
drivers/gpu/drm/i915/i915_perf.c gen12_configure_all_contexts(struct i915_perf_stream *stream, · line 2780
Quoted 9 lines
drivers/gpu/drm/i915/i915_perf.c +3
-0@@ -2749,6 +2772,9 @@ gen12_configure_all_contexts(struct i915_perf_stream *stream, }, }; +if (stream->engine->class !=RENDER_CLASS ) +return 0 ; +return oa_configure_all_contexts (stream, regs,ARRAY_SIZE (regs), active);
Can you please explain the above changes? Why are we checking for engine->class above? Should we be checking for both class and instance? Or all engines connected to an OA unit (multiple classes can be connected to an OA unit and be different from stream->engine->class, e.g. VDBOX and VEBOX)? oa_configure_all_contexts is also called from lrc_configure_all_contexts.
Thanks.
--
Ashutosh
Re: [Intel-gfx] [PATCH v4 8/9] drm/i915/perf: Add engine class instance parameters to perf
In reply to Umesh Nerlige RamappaQuoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 31 lines · Ashutosh
Quoted 21 lines · Umesh Nerlige Ramappa
Quoted 10 lines
One or more engines map to a specific OA unit. All reports from these engines are captured in the OA buffer managed by this OA unit.
Current i915 OA implementation supports only the OAG unit. OAG primarily caters to render engine, so i915 OA uses render as the default engine in the OA implementation. Since there are more OA units on newer hardware that map to other engines, allow user to pass engine class and instance to select and program specific OA units.
I believe there is another uapi issue to be resolved here: how the engines are associated with OA units, since from the point of view of the uapi there are multiple engines and multiple OA units (even if in the actual implementation at present there is only one OA unit per gt). In the internal tree we had added
oa_unit_idtoengine_infofor this. So if multiple engines had the sameoa_unit_id, user could pass class:instance of any of those engines to get oa data from that OA unit (and generally know how engines are hooked up to OA units (the OA unit topology)).Quoted 3 lines
So the question is even if we don't implement it as part of this series (or do we have to?) do we at least need to agree to that uapi which will be used to associate OA units with engines?
It did make more sense for xehpsdv and other platforms where we had multiple OA units per GT and each GT had render and/or compute engines. In those cases, media and compute/render UMDs may have needed to know that topology.
Quoted 6 lines
For MTL, I don't think that an end user will benefit from the engine<->oa_unit mapping because
(1) media and render are separate GTs
(2) there is just one OA unit per GT and
(3) assuming media and render/compute are separate UMDs,
Well our uapi does not expose any of this so we are relying on outside information here. So I think it is needed even for MTL, but that's a problem for the person reviewing the uapi. Afaiac we can do it later if/when there is a specific ask for it, it's ok with me as is.
I will R-b the patch after we fix the engine class/instance pairing.
Thanks.
--
Ashutosh
Quoted 6 lines
That's also the reason why the corresponding IGT series just uses a static mapping for MTL.
If we come across a case where the UMD needs this info OR we are supporting a platform with multiple OA units per tile, we should add the topology.
Re: [Intel-gfx] [PATCH v4 9/9] drm/i915/perf: Add support for OA media units
In reply to Dixit, AshutoshQuoted 44 lines · Ashutosh
Quoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 39 lines
drivers/gpu/drm/i915/i915_perf.c +2
-1-static int gen8_configure_context(struct i915_gem_context *ctx, +static int gen8_configure_context(struct i915_perf_stream *stream, + struct i915_gem_context *ctx,struct flex *flex, unsigned int count)
{ struct i915_gem_engines_iter it;drivers/gpu/drm/i915/i915_perf.c +5
-3@@ -2573,7 +2594,8 @@ static int gen8_configure_context(struct i915_gem_context *ctx,for_each_gem_engine (ce,i915_gem_context_lock_engines (ctx), it) {GEM_BUG_ON (ce == ce->engine->kernel_context); -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ;/* Otherwise OA settings will be set upon first use */ @@ -2704,7 +2726,7 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,spin_unlock (&i915->gem.contexts.lock); - err =gen8_configure_context (ctx, regs, num_regs); + err =gen8_configure_context (stream, ctx, regs, num_regs);if (err) {i915_gem_context_put (ctx);return err;@@ -2724,7 +2746,8 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,for_each_uabi_engine (engine, i915) {struct intel_context *ce = engine->kernel_context; -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ; regs[0 ].value =intel_sseu_make_rpcs (engine->gt, &ce->sseu);@@ -2749,6 +2772,9 @@ gen12_configure_all_contexts(struct i915_perf_stream *stream, }, };
Quoted 13 lines
drivers/gpu/drm/i915/i915_perf.c gen12_configure_all_contexts(struct i915_perf_stream *stream, · line 2780
Quoted 6 lines
drivers/gpu/drm/i915/i915_perf.c +3
-0+if (stream->engine->class !=RENDER_CLASS ) +return 0 ; +return oa_configure_all_contexts (stream, regs,ARRAY_SIZE (regs), active);Can you please explain the above changes? Why are we checking for
engine->classabove? Should we be checking for both class and instance? Or all engines connected to an OA unit (multiple classes can be connected to an OA unit and be different fromstream->engine->class, e.g. VDBOX and VEBOX)?oa_configure_all_contextsis also called fromlrc_configure_all_contexts.
Only render (and compute when we support it) have OA specific configuration in the context image. Media engines do not have any context specific configurations.
Thanks,
Umesh
Quoted 4 lines
Thanks.
--
Ashutosh
Re: [Intel-gfx] [PATCH v4 9/9] drm/i915/perf: Add support for OA media units
Quoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 56 lines · Ashutosh
Quoted 41 lines · Umesh Nerlige Ramappa
Quoted 40 lines
drivers/gpu/drm/i915/i915_perf.c +2
-1-static int gen8_configure_context(struct i915_gem_context *ctx, +static int gen8_configure_context(struct i915_perf_stream *stream, + struct i915_gem_context *ctx,struct flex *flex, unsigned int count)
{ struct i915_gem_engines_iter it;drivers/gpu/drm/i915/i915_perf.c +5
-3@@ -2573,7 +2594,8 @@ static int gen8_configure_context(struct i915_gem_context *ctx,for_each_gem_engine (ce,i915_gem_context_lock_engines (ctx), it) {GEM_BUG_ON (ce == ce->engine->kernel_context); -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ;/* Otherwise OA settings will be set upon first use */ @@ -2704,7 +2726,7 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,spin_unlock (&i915->gem.contexts.lock); - err =gen8_configure_context (ctx, regs, num_regs); + err =gen8_configure_context (stream, ctx, regs, num_regs);if (err) {i915_gem_context_put (ctx);return err;@@ -2724,7 +2746,8 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,for_each_uabi_engine (engine, i915) {struct intel_context *ce = engine->kernel_context; -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ; regs[0 ].value =intel_sseu_make_rpcs (engine->gt, &ce->sseu);@@ -2749,6 +2772,9 @@ gen12_configure_all_contexts(struct i915_perf_stream *stream, }, };Quoted 13 lines
drivers/gpu/drm/i915/i915_perf.c gen12_configure_all_contexts(struct i915_perf_stream *stream, · line 2780
Quoted 6 lines
drivers/gpu/drm/i915/i915_perf.c +3
-0+if (stream->engine->class !=RENDER_CLASS ) +return 0 ; +return oa_configure_all_contexts (stream, regs,ARRAY_SIZE (regs), active);Can you please explain the above changes? Why are we checking for
engine->classabove? Should we be checking for both class and instance? Or all engines connected to an OA unit (multiple classes can be connected to an OA unit and be different fromstream->engine->class, e.g. VDBOX and VEBOX)?oa_configure_all_contextsis also called fromlrc_configure_all_contexts.
Quoted 3 lines
Only render (and compute when we support it) have OA specific configuration in the context image. Media engines do not have any context specific configurations.
Yes I remember you answered this previously too. My question still is why did we make the 2 instances of this change above:
From the original code in drm-tip:
if (engine->class != RENDER_CLASS) continue;
To the final code (changed in two patches):
if (!engine_supports_oa(ce->engine) || ce->engine->class != stream->engine->class) continue;
Thanks.
--
Ashutosh
Re: [Intel-gfx] [PATCH v4 9/9] drm/i915/perf: Add support for OA media units
Quoted 60 lines · Ashutosh
Quoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 55 lines · Ashutosh
Quoted 54 lines · Umesh Nerlige Ramappa
Quoted 37 lines
drivers/gpu/drm/i915/i915_perf.c +2
-1-static int gen8_configure_context(struct i915_gem_context *ctx, +static int gen8_configure_context(struct i915_perf_stream *stream, + struct i915_gem_context *ctx,struct flex *flex, unsigned int count)
{ struct i915_gem_engines_iter it;drivers/gpu/drm/i915/i915_perf.c +5
-3@@ -2573,7 +2594,8 @@ static int gen8_configure_context(struct i915_gem_context *ctx,for_each_gem_engine (ce,i915_gem_context_lock_engines (ctx), it) {GEM_BUG_ON (ce == ce->engine->kernel_context); -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ;/* Otherwise OA settings will be set upon first use */ @@ -2704,7 +2726,7 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,spin_unlock (&i915->gem.contexts.lock); - err =gen8_configure_context (ctx, regs, num_regs); + err =gen8_configure_context (stream, ctx, regs, num_regs);if (err) {i915_gem_context_put (ctx);return err;@@ -2724,7 +2746,8 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,for_each_uabi_engine (engine, i915) {struct intel_context *ce = engine->kernel_context; -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ; regs[0 ].value =intel_sseu_make_rpcs (engine->gt, &ce->sseu);drivers/gpu/drm/i915/i915_perf.c gen12_configure_all_contexts(struct i915_perf_stream *stream, · line 2780
Quoted 9 lines
drivers/gpu/drm/i915/i915_perf.c +3
-0@@ -2749,6 +2772,9 @@ gen12_configure_all_contexts(struct i915_perf_stream *stream, }, }; +if (stream->engine->class !=RENDER_CLASS ) +return 0 ; +return oa_configure_all_contexts (stream, regs,ARRAY_SIZE (regs), active);Can you please explain the above changes? Why are we checking for
engine->classabove? Should we be checking for both class and instance? Or all engines connected to an OA unit (multiple classes can be connected to an OA unit and be different fromstream->engine->class, e.g. VDBOX and VEBOX)?oa_configure_all_contextsis also called fromlrc_configure_all_contexts.
This check primarily blocks media engine use cases from entering oa_configure_all_contexts().
lrc_configure_all_contexts applies to pre-gen12 only. On pre-gen12, engine_supports_oa() should return true only for render.
Quoted 10 lines
Quoted 4 lines
Only render (and compute when we support it) have OA specific configuration in the context image. Media engines do not have any context specific configurations.
Yes I remember you answered this previously too. My question still is why did we make the 2 instances of this change above:
From the original code in drm-tip:
Quoted 8 lines
if (engine->class != RENDER_CLASS) continue;To the final code (changed in two patches):
if (!engine_supports_oa(ce->engine) || ce->engine->class != stream->engine->class) continue;
I think some changes are a result of incrementally supporting compute and then media in OA. Since we have not upstreamed the compute support, some lines of code remain.
With compute support the "if (engine->class != RENDER_CLASS)" changed to "if (!engine_supports_oa(ce->engine)). Later, OAM support brought the other condition that checks classes because this code is under for_each_uabi_engine(engine, i915). When we run this for an OA use case where user has passed rcs0 for ex, it will still iterate over the media engines. Since we now support media engines, we should skip them in this loop.
The other question on whether this should be class specific or span multiple engines, I have to check that specifically for OAG. Ideally, the PWR_CLK_STATE should be configured for all engines that support it (render and compute where available), so the above check should be
if (!engine_supports_oa(ce->engine) ||
!engine_has_pwr_clk_state(ce->engine))
A jira will help track this and I can address that in a separate patch/series if it turns out to be an issue.
Thanks,
Umesh
Quoted 4 lines
Thanks.
--
Ashutosh
Re: [Intel-gfx] [PATCH v4 9/9] drm/i915/perf: Add support for OA media units
Quoted 103 lines · Umesh Nerlige Ramappa
Quoted 60 lines · Ashutosh
Quoted 1 line · Umesh Nerlige Ramappa
Hi Umesh,
Quoted 55 lines · Ashutosh
Quoted 54 lines · Umesh Nerlige Ramappa
Quoted 37 lines
drivers/gpu/drm/i915/i915_perf.c +2
-1-static int gen8_configure_context(struct i915_gem_context *ctx, +static int gen8_configure_context(struct i915_perf_stream *stream, + struct i915_gem_context *ctx,struct flex *flex, unsigned int count)
{ struct i915_gem_engines_iter it;drivers/gpu/drm/i915/i915_perf.c +5
-3@@ -2573,7 +2594,8 @@ static int gen8_configure_context(struct i915_gem_context *ctx,for_each_gem_engine (ce,i915_gem_context_lock_engines (ctx), it) {GEM_BUG_ON (ce == ce->engine->kernel_context); -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ;/* Otherwise OA settings will be set upon first use */ @@ -2704,7 +2726,7 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,spin_unlock (&i915->gem.contexts.lock); - err =gen8_configure_context (ctx, regs, num_regs); + err =gen8_configure_context (stream, ctx, regs, num_regs);if (err) {i915_gem_context_put (ctx);return err;@@ -2724,7 +2746,8 @@ oa_configure_all_contexts(struct i915_perf_stream *stream,for_each_uabi_engine (engine, i915) {struct intel_context *ce = engine->kernel_context; -if (!engine_supports_oa (ce->engine)) +if (!engine_supports_oa (ce->engine) || + ce->engine->class != stream->engine->class)continue ; regs[0 ].value =intel_sseu_make_rpcs (engine->gt, &ce->sseu);drivers/gpu/drm/i915/i915_perf.c gen12_configure_all_contexts(struct i915_perf_stream *stream, · line 2780
Quoted 9 lines
drivers/gpu/drm/i915/i915_perf.c +3
-0@@ -2749,6 +2772,9 @@ gen12_configure_all_contexts(struct i915_perf_stream *stream, }, }; +if (stream->engine->class !=RENDER_CLASS ) +return 0 ; +return oa_configure_all_contexts (stream, regs,ARRAY_SIZE (regs), active);Can you please explain the above changes? Why are we checking for
engine->classabove? Should we be checking for both class and instance? Or all engines connected to an OA unit (multiple classes can be connected to an OA unit and be different fromstream->engine->class, e.g. VDBOX and VEBOX)?oa_configure_all_contextsis also called fromlrc_configure_all_contexts.This check primarily blocks media engine use cases from entering
oa_configure_all_contexts().
lrc_configure_all_contextsapplies to pre-gen12 only. On pre-gen12,engine_supports_oa()should return true only for render.Quoted 10 lines
Quoted 4 lines
Only render (and compute when we support it) have OA specific configuration in the context image. Media engines do not have any context specific configurations.
Yes I remember you answered this previously too. My question still is why did we make the 2 instances of this change above:
From the original code in drm-tip:
Quoted 8 lines
if (engine->class != RENDER_CLASS) continue;To the final code (changed in two patches):
if (!engine_supports_oa(ce->engine) || ce->engine->class != stream->engine->class) continue;I think some changes are a result of incrementally supporting compute and then media in OA. Since we have not upstreamed the compute support, some lines of code remain.
With compute support the "if (
engine->class!=RENDER_CLASS)" changed to "if (!engine_supports_oa(ce->engine)). Later, OAM support brought the other condition that checks classes because this code is underfor_each_uabi_engine(engine, i915). When we run this for an OA use case where user has passed rcs0 for ex, it will still iterate over the media engines. Since we now support media engines, we should skip them in this loop.
The other question on whether this should be class specific or span multiple engines, I have to check that specifically for OAG. Ideally, thePWR_CLK_STATEshould be configured for all engines that support it (render and compute where available), so the above check should be
if (!engine_supports_oa(ce->engine) ||
Quoted 4 lines
!engine_has_pwr_clk_state(ce->engine))A jira will help track this and I can address that in a separate patch/series if it turns out to be an issue.
OK, this is my last question on this patch, everything else is fine. Since you will post another version of the series I will review your (hopefully final) changes about the above segment there and let's go from there.
Thanks.
--
Ashutosh
Patchwork
CI[Intel-gfx] ✗ Fi.CI.SPARSE: warning for Add OAM support for MTL
In reply to Umesh Nerlige Ramappa== Series Details ==
== Series Details ==
Series: Add OAM support for MTL
URL : https://patchwork.freedesktop.org/series/114801/
State : warning
== Summary ==
Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.