i915 perf support for command stream based OA, GPU and workload metrics capture
Subsystems (3)
cover i915 perf support for command stream based OA, GPU and workload metrics capture
This is follow up series based on reviews for
https://patchwork.freedesktop.org/series/28104/
Major change is assignment of samples at the time of request submission onto HW instead of assigning at user submission time. Restructured patches to make some of the earlier code-heavy patches little lighter by modularizing them. Added new IGT testcase intel_perf_dapc for testing exposed sample fields like PID, Timestamps, CTX ID etc.
Reiterating the intent of this series:
1. Collection of OA reports associated with the render command stream, which are collected around batchbuffer boundaries.
2. Collect other metadata such as ctx_id, pid, tag etc. with the samples, and thus we can establish the association of samples collected with the corresponding process/workload.
3. Collection of GPU performance metrics associated with the command stream of a particular engine. These metrics include timestamps of work submission and completion on engines, mmio metrics, etc. These metrics are are collected around batchbuffer boundaries.
Functionality to be added in future patches:
1. GPU/CPU cross-timestamp sync patches need to be reworked as requested by kernel maintainers.
2. Some of the data types being collected through these patches can be done in the userspace and that is yet to be finalized. Based on that some of the functionality from this series can be pruned.
Testcase: igt/intel_perf_dapc
Sagar Arun Kamble (2):
drm/i915: Define CTX_ID property for perf sampling drm/i915: Link perf stream structures with Engines
Sourab Gupta (12):
drm/i915: Add ctx getparam ioctl parameter to retrieve ctx unique id drm/i915: Expose OA sample source to userspace
drm/i915: Framework for capturing command stream based OA reports. drm/i915: Flush periodic samples, in case of no pending CS sample
requests
drm/i915: Inform userspace about command stream OA buf overflow drm/i915: Populate ctx ID for periodic OA reports drm/i915: Add support for having pid output with OA report drm/i915: Add support for emitting execbuffer tags through OA counter
reports
drm/i915: Add support for collecting timestamps on all gpu engines drm/i915: Extract raw GPU timestamps from OA reports to forward in
perf samples
drm/i915: Async check for streams data availability with hrtimer
rescheduling
drm/i915: Support for capturing MMIO register values
drivers/gpu/drm/i915/i915_drv.h | 176 ++- drivers/gpu/drm/i915/i915_gem.c | 1 + drivers/gpu/drm/i915/i915_gem_context.c | 3 + drivers/gpu/drm/i915/i915_gem_execbuffer.c | 11 + drivers/gpu/drm/i915/i915_gem_request.c | 2 + drivers/gpu/drm/i915/i915_gem_request.h | 10 + drivers/gpu/drm/i915/i915_perf.c | 1919 ++++++++++++++++++++++++---- drivers/gpu/drm/i915/i915_reg.h | 6 + drivers/gpu/drm/i915/intel_engine_cs.c | 4 + drivers/gpu/drm/i915/intel_ringbuffer.c | 2 + drivers/gpu/drm/i915/intel_ringbuffer.h | 11 + include/uapi/drm/i915_drm.h | 72 ++ 12 files changed, 1947 insertions(+), 270 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/14 drm/i915: Add ctx getparam ioctl parameter to retrieve ctx unique id
From: Sourab Gupta <[email protected]>
This patch adds a new ctx getparam ioctl parameter, which can be used to retrieve ctx unique id by userspace.
This can be used by userspace to map the OA reports received in the i915 perf samples with their associated ctx's (The OA reports have the hw ctx ID information embedded for Gen8+).
Otherwise the userspace has no way of maintaining this association, since it has the knowledge of only per-drm file specific ctx handles.
--- drivers/gpu/drm/i915/i915_gem_context.c | 3 +++ include/uapi/drm/i915_drm.h | 1 + 2 files changed, 4 insertions(+)
drivers/gpu/drm/i915/i915_gem_context.c +3 -0
@@ -1036,6 +1036,9 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,case I915_CONTEXT_PARAM_BANNABLE : args->value =i915_gem_context_is_bannable (ctx);break ; +case I915_CONTEXT_PARAM_HW_ID : + args->value = ctx->hw_id; +break ;default : ret = -EINVAL ;break ;
include/uapi/drm/i915_drm.h +1 -0
@@ -1358,6 +1358,7 @@ struct drm_i915_gem_context_param {#define I915_CONTEXT_PARAM_GTT_SIZE 0x3#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4#define I915_CONTEXT_PARAM_BANNABLE 0x5 +#define I915_CONTEXT_PARAM_HW_ID 0x6__u64 value; };
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/14 drm/i915: Expose OA sample source to userspace
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
This patch exposes a new sample source field to userspace. This field can be populated to specify the origin of the OA report.
Currently, the OA samples are being generated only periodically, and hence there's only source flag enum definition right now, but there are other means of generating OA samples, such as via MI_RPC commands. The OA_SOURCE sample type is introducing a mechanism (for userspace) to distinguish various OA reports generated via different sources.
This is not intended as a replacement for the reason field that's part of Gen8+ OA reports. For automatically triggered reports written to the OABUFFER the reason field will distinguish e.g. periodic vs ctx-switch vs GO transition reasons for the OA unit writing a report. However, The reason field is overloaded as the RPT_ID field for MI_RPC reports so we need our own way of tracking the difference.
v2: Renamed the source enum type and values. Updated commit description. (Robert). Changed payload field source to u64 to keep all sample data aligned at 8 bytes. (Lionel)
Testcase: igt/intel_perf_dapc/oa-source
--- drivers/gpu/drm/i915/i915_perf.c | 25 +++++++++++++++++++++++++ include/uapi/drm/i915_drm.h | 13 +++++++++++++ 2 files changed, 38 insertions(+)
drivers/gpu/drm/i915/i915_perf.c +25 -0
@@ -330,6 +330,7 @@ };#define SAMPLE_OA_REPORT (1<<0) +#define SAMPLE_OA_SOURCE (1<<1)/** * struct perf_open_properties - for validated properties given to open a stream
@@ -608,6 +609,22 @@ static int append_oa_sample(struct i915_perf_stream *stream,return -EFAULT ; buf +=sizeof (header); +/* +* Sample has metadata containting OA_SOURCE followed by OA_REPORT. +* Need to maintain this uapi w.r.t any reorganizing later not realizing +* the ordering. +* Currently there are a number of different automatic triggers for +* writing OA reports to the OABUFFER like periodic, ctx-switch, go +* transition. These are considered as source 'OABUFFER'. +*/ +if (sample_flags &SAMPLE_OA_SOURCE ) { +u64 source =I915_PERF_SAMPLE_OA_SOURCE_OABUFFER ; + +if (copy_to_user (buf, &source,8 )) +return -EFAULT ; + buf +=8 ; + } +if (sample_flags &SAMPLE_OA_REPORT ) {if (copy_to_user (buf, report, report_size))return -EFAULT ;
@@ -2087,6 +2104,11 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream, stream->sample_flags |=SAMPLE_OA_REPORT ; stream->sample_size += format_size; +if (props->sample_flags &SAMPLE_OA_SOURCE ) { + stream->sample_flags |=SAMPLE_OA_SOURCE ; + stream->sample_size +=8 ; + } + dev_priv->perf.oa.oa_buffer.format_size = format_size;if (WARN_ON (dev_priv->perf.oa.oa_buffer.format_size ==0 ))return -EINVAL ;
@@ -2805,6 +2827,9 @@ static int read_properties_unlocked(struct drm_i915_private *dev_priv, props->oa_periodic = true; props->oa_period_exponent = value;break ; +case DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE : + props->sample_flags |=SAMPLE_OA_SOURCE ; +break ;case DRM_I915_PERF_PROP_MAX :MISSING_CASE (id);return -EINVAL ;
include/uapi/drm/i915_drm.h +13 -0
@@ -1379,6 +1379,11 @@ enum drm_i915_oa_format {I915_OA_FORMAT_MAX /* non-ABI */ }; +enum drm_i915_perf_sample_oa_source { +I915_PERF_SAMPLE_OA_SOURCE_OABUFFER , +I915_PERF_SAMPLE_OA_SOURCE_MAX /* non-ABI */ +}; +enum drm_i915_perf_property_id {/** * Open the stream for a specific context handle (as used with
@@ -1413,6 +1418,13 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_OA_EXPONENT , +/** +* The value of this property set to 1 requests inclusion of sample +* source field to be given to userspace. The sample source field +* specifies the origin of OA report. +*/ +DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
@@ -1478,6 +1490,7 @@ enum drm_i915_perf_record_type {* struct { * struct drm_i915_perf_record_header header; * +* { u64 source; } && DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA * }; */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/14 drm/i915: Framework for capturing command stream based OA reports.
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
This patch introduces a framework to capture OA counter reports associated with Render command stream. We can then associate the reports captured through this mechanism with their corresponding context id's. This can be further extended to associate any other metadata information with the corresponding samples (since the association with Render command stream gives us the ability to capture these information while inserting the corresponding capture commands into the command stream).
The OA reports generated in this way are associated with a corresponding workload, and thus can be used the delimit the workload (i.e. sample the counters at the workload boundaries), within an ongoing stream of periodic counter snapshots.
There may be usecases wherein we need more than periodic OA capture mode which is supported currently. This mode is primarily used for two usecases:
- Ability to capture system wide metrics, alongwith the ability to map the reports back to individual contexts (particularly for HSW).
- Ability to inject tags for work, into the reports. This provides visibility into the multiple stages of work within single context.
The userspace will be able to distinguish between the periodic and CS based OA reports by the virtue of source_info sample field.
The command MI_REPORT_PERF_COUNT can be used to capture snapshots of OA counters, and is inserted at BB boundaries.
The data thus captured will be stored in a separate buffer, which will be different from the buffer used otherwise for periodic OA capture mode. The metadata information pertaining to snapshot is maintained in a list, which also has offsets into the gem buffer object per captured snapshot. In order to track whether the gpu has completed processing the node, a field pertaining to corresponding gem request is added, which is tracked for completion of the command.
Both periodic and CS based reports are associated with a single stream (corresponding to render engine), and it is expected to have the samples in the sequential order according to their timestamps. Now, since these reports are collected in separate buffers, these are merge sorted at the time of forwarding to userspace during the read call.
v2: Aligning with the non-perf interface (custom drm ioctl based). Also, few related patches are squashed together for better readability
v3: Updated perf sample capture emit hook name. Reserving space upfront in the ring for emitting sample capture commands and using req->fence.seqno for tracking samples. Added SRCU protection for streams. Changed the stream last_request tracking to resv object. (Chris) Updated perf.sample_lock spin_lock usage to avoid softlockups. Moved stream to global per-engine structure. (Sagar)
Update unpin and put in the free routines to i915_vma_unpin_and_release. Making use of perf stream cs_buffer vma resv instead of separate resv obj. Pruned perf stream vma resv during gem_idle. (Chris)
Changed payload field ctx_id to u64 to keep all sample data aligned at 8 bytes. (Lionel)
stall/flush prior to sample capture is not added. Do we need to give this control to user to select whether to stall/flush at each sample?
v4: Removed state enum and relying on bool state. Kept single srcu as currently only RCS stream is opened. Removed ctx id support, will be added in the next patch in series. polling workqueue related structures are kept singleton too for now. (Lionel)
Moved the CS samples allocation from request emission to submission as the backed __i915_gem_request_submit determines the order of execution on the hardware. Changed assigning the offset from cs_buffer vma to sample based to make sure we reuse the samples non-linearly in case some samples are discarded due to preemption later.
Added sample identifier to know where in the request execution sample is captured. This can be useful to associate OA reports based on begin and end of request execution.
v5: Removed periodic check from stream_wait_ioctl to allow opening stream without OA data but with other CS properties. Added comment about handling preemption while reading cs_samples.
Testcase: igt/intel_perf_dapc
--- drivers/gpu/drm/i915/i915_drv.h | 94 ++- drivers/gpu/drm/i915/i915_gem.c | 1 + drivers/gpu/drm/i915/i915_gem_execbuffer.c | 8 + drivers/gpu/drm/i915/i915_gem_request.c | 2 + drivers/gpu/drm/i915/i915_gem_request.h | 3 + drivers/gpu/drm/i915/i915_perf.c | 1147 ++++++++++++++++++++++------ include/uapi/drm/i915_drm.h | 8 + 7 files changed, 1040 insertions(+), 223 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +87 -7
@@ -2032,6 +2032,30 @@ struct i915_perf_stream_ops {* The stream will always be disabled before this is called. */ void (*destroy)(struct i915_perf_stream *stream); + +/* +* @emit_sample_capture: Emit the commands in the command streamer +* for a particular gpu engine. +* +* The commands are inserted to capture the perf sample data at +* specific points during workload execution, such as before and after +* the batch buffer. +*/ +void (*emit_sample_capture)(struct i915_perf_stream *stream, +struct drm_i915_gem_request *request, +bool preallocate); + +/* +* @patch_sample_capture: Patch the offsets in commands to capture perf +* sample data in the ringbuffer corresponding to request. +* +* To get the perf samples in the order of execution on the engines, we +* emit the commands to capture the data while populating the request in +* the ringbuffer but update the location and maintain the ordered list +* during __i915_gem_request_submit. +*/ +void (*patch_request)(struct i915_perf_stream *stream, +struct drm_i915_gem_request *request); };/**
@@ -2044,11 +2068,6 @@ struct i915_perf_stream {struct drm_i915_private *dev_priv;/** -* @link: Links the stream into ``&drm_i915_private->streams`` -*/ -struct list_head link; - -/** * @sample_flags: Flags representing the `DRM_I915_PERF_PROP_SAMPLE_*` * properties given when opening a stream, representing the contents * of a single sample as read() by userspace.
@@ -2085,6 +2104,27 @@ struct i915_perf_stream {* @oa_config: The OA configuration used by the stream. */ struct i915_oa_config *oa_config; + +/** +* @cs_mode: Whether command stream based perf sample collection is +* enabled for this stream +*/ +bool cs_mode; + +/** +* @using_oa: Whether OA unit is in use for this particular stream +*/ +bool using_oa; + +/* Command stream based perf data buffer */ +struct { +struct i915_vma *vma; +u8 *vaddr; + } cs_buffer; + +struct list_head cs_samples; +struct list_head free_samples; +spinlock_t samples_lock; };/**
@@ -2159,7 +2199,8 @@ struct i915_oa_ops {int (*read)(struct i915_perf_stream *stream,char __user *buf,size_t count, -size_t *offset); +size_t *offset, +u32 ts);/** * @oa_hw_tail_read: read the OA tail pointer register
@@ -2171,6 +2212,41 @@ struct i915_oa_ops {u32 (*oa_hw_tail_read)(struct drm_i915_private *dev_priv); }; +enum request_sample_id { +PRE_REQUEST_SAMPLE_ID , +POST_REQUEST_SAMPLE_ID , +MAX_REQUEST_SAMPLE_ID +}; + +/* +* i915_perf_cs_sample - Sample element to hold info about a single perf +* sample data associated with a particular GPU command stream. +*/ +struct i915_perf_cs_sample { +/** +* @link: Links the sample into ``&stream->cs_samples`` or +* ``&stream->free_samples`` +*/ +struct list_head link; + +/** +* @request: GEM request associated with the sample. The commands to +* capture the perf metrics are inserted into the command streamer in +* context of this request. +*/ +struct drm_i915_gem_request *request; + +/** +* @oa_offset: Offset into ``&stream->cs_buffer`` +* where the perf metrics will be collected, when the commands inserted +* into the command stream are executed by GPU. +*/ +u32 oa_offset; + +/* Is this sample prior to request start or post request end */ +enum request_sample_id id; +}; +struct intel_cdclk_state {unsigned int cdclk, vco, ref; };
@@ -2513,7 +2589,6 @@ struct drm_i915_private {* except exclusive_stream. */ struct mutex lock; -struct list_head streams;struct {/*
@@ -2523,6 +2598,7 @@ struct drm_i915_private {* dev_priv->drm.struct_mutex. */ struct i915_perf_stream *exclusive_stream; +struct srcu_struct srcu;u32 specific_ctx_id;
@@ -3883,6 +3959,10 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,extern void i915_perf_fini (struct drm_i915_private *dev_priv);extern void i915_perf_register (struct drm_i915_private *dev_priv);extern void i915_perf_unregister (struct drm_i915_private *dev_priv); +void i915_perf_emit_sample_capture (struct drm_i915_gem_request *req, +bool preallocate); +void i915_perf_patch_request (struct drm_i915_gem_request *request); +void i915_perf_streams_mark_idle (struct drm_i915_private *dev_priv);/* i915_suspend.c */ extern int i915_save_state (struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_gem.c +1 -0
@@ -3226,6 +3226,7 @@ bool i915_gem_unset_wedged(struct drm_i915_private *i915)intel_engines_mark_idle (dev_priv);i915_gem_timelines_mark_idle (dev_priv); +i915_perf_streams_mark_idle (dev_priv);GEM_BUG_ON (!dev_priv->gt.awake); dev_priv->gt.awake = false;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +8 -0
@@ -1115,12 +1115,16 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,if (err) goto err_request; +i915_perf_emit_sample_capture (rq, true); + err = eb->engine->emit_bb_start (rq, batch->node.start,PAGE_SIZE , cache->gen >5 ?0 :I915_DISPATCH_SECURE );if (err) goto err_request; +i915_perf_emit_sample_capture (rq, false); +GEM_BUG_ON (!reservation_object_test_signaled_rcu (batch->resv, true));i915_vma_move_to_active (batch, rq,0 );reservation_object_lock (batch->resv,NULL );
@@ -1970,6 +1974,8 @@ static int eb_submit(struct i915_execbuffer *eb)return err; } +i915_perf_emit_sample_capture (eb->request, true); + err = eb->engine->emit_bb_start(eb->request, eb->batch->node.start + eb->batch_start_offset,
@@ -1978,6 +1984,8 @@ static int eb_submit(struct i915_execbuffer *eb)if (err)return err; +i915_perf_emit_sample_capture (eb->request, false); +return 0 ; }
drivers/gpu/drm/i915/i915_gem_request.c +2 -0
@@ -481,6 +481,8 @@ void __i915_gem_request_submit(struct drm_i915_gem_request *request)list_move_tail (&request->link, &timeline->requests);spin_unlock (&request->timeline->lock); +i915_perf_patch_request (request); +wake_up_all (&request->execute); }
drivers/gpu/drm/i915/i915_gem_request.h +3 -0
@@ -195,6 +195,9 @@ struct drm_i915_gem_request {struct drm_i915_file_private *file_priv;/** file_priv list entry for this request */ struct list_head client_link; + +u32 *pre_oa_offset; +u32 *post_oa_offset; };extern const struct dma_fence_ops i915_fence_ops;
drivers/gpu/drm/i915/i915_perf.c +931 -216
1,594 lines not on this page · raw message
include/uapi/drm/i915_drm.h +8 -0
@@ -1381,6 +1381,7 @@ enum drm_i915_oa_format {enum drm_i915_perf_sample_oa_source {I915_PERF_SAMPLE_OA_SOURCE_OABUFFER , +I915_PERF_SAMPLE_OA_SOURCE_CS ,I915_PERF_SAMPLE_OA_SOURCE_MAX /* non-ABI */ };
@@ -1425,6 +1426,13 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE , +/** +* The value of this property specifies the GPU engine for which +* the samples need to be collected. Specifying this property also +* implies the command stream based sample collection. +*/ +DRM_I915_PERF_PROP_ENGINE , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/14 drm/i915: Define CTX_ID property for perf sampling
In reply to Sagar Arun KambleThis patch enables to sample CTX ID corresponding to requests being submitted on the engines through perf stream. OA report already embed this information from Gen8+. For previous Gens we can leverage value sampled from request->ctx->hw_id to associate with OA reports.
v2: Updated stream->last_ctx_id to INVALID_CTX_ID during stream_init.
Testcase: igt/intel_perf_dapc/perf-ctxid
--- drivers/gpu/drm/i915/i915_drv.h | 5 ++++ drivers/gpu/drm/i915/i915_perf.c | 56 ++++++++++++++++++++++++++++++++++++++++ include/uapi/drm/i915_drm.h | 7 +++++ 3 files changed, 68 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -2245,6 +2245,11 @@ struct i915_perf_cs_sample {/* Is this sample prior to request start or post request end */ enum request_sample_id id; + +/** +* @ctx_id: Context ID associated with this perf sample +*/ +u32 ctx_id; };struct intel_cdclk_state {
drivers/gpu/drm/i915/i915_perf.c +56 -0
122 lines not on this page · raw message
include/uapi/drm/i915_drm.h +7 -0
@@ -1433,6 +1433,12 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_ENGINE , +/** +* The value of this property set to 1 requests inclusion of context ID +* in the perf sample data. +*/ +DRM_I915_PERF_PROP_SAMPLE_CTX_ID , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
@@ -1499,6 +1505,7 @@ enum drm_i915_perf_record_type {* struct drm_i915_perf_record_header header; * * { u64 source; } && DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE +* { u64 ctx_id; } && DRM_I915_PERF_PROP_SAMPLE_CTX_ID * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA * }; */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/14 drm/i915: Flush periodic samples, in case of no pending CS sample requests
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
When there are no pending CS OA samples, flush the periodic OA samples collected so far.
We can safely forward the periodic OA samples in the case we have no pending CS samples, but we can't do so in the case we have pending CS samples, since we don't know what the ordering between pending CS samples and periodic samples will eventually be. If we have no pending CS sample, it won't be possible for future pending CS sample to have timestamps earlier than current periodic timestamp.
--- drivers/gpu/drm/i915/i915_drv.h | 5 +- drivers/gpu/drm/i915/i915_perf.c | 142 ++++++++++++++++++++++++++++++--------- 2 files changed, 113 insertions(+), 34 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -1
@@ -2200,7 +2200,8 @@ struct i915_oa_ops {char __user *buf, size_t count, size_t *offset, - u32 ts); + u32 ts, + u32 max_reports);/** * @oa_hw_tail_read: read the OA tail pointer register
@@ -2698,6 +2699,8 @@ struct drm_i915_private {u32 gen7_latched_oastatus1;u32 ctx_oactxctrl_offset;u32 ctx_flexeu0_offset; +u32 n_pending_periodic_samples; +u32 pending_periodic_ts;/** * The RPT_ID/reason field for Gen8+ includes a bit
drivers/gpu/drm/i915/i915_perf.c +109 -33
343 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/14 drm/i915: Inform userspace about command stream OA buf overflow
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
Considering how we don't currently give userspace control over the OA buffer size and always configure a large 16MB buffer, then a buffer overflow does anyway likely indicate that something has gone quite badly wrong.
Here we set a status flag to detect overflow and inform userspace of the report_lost condition accordingly. This is in line with the behavior of the periodic OA buffer.
--- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_perf.c | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -2120,6 +2120,8 @@ struct i915_perf_stream {struct {struct i915_vma *vma;u8 *vaddr; +#define I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW (1<<0) +u32 status; } cs_buffer;struct list_head cs_samples;
drivers/gpu/drm/i915/i915_perf.c +15 -1
@@ -613,8 +613,11 @@ static void i915_perf_stream_patch_request(struct i915_perf_stream *stream,while (sample_id <MAX_REQUEST_SAMPLE_ID ) {spin_lock_irqsave (&stream->samples_lock, flags); -if (list_empty (&stream->free_samples)) +if (list_empty (&stream->free_samples)) { + stream->cs_buffer.status |= +I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW ;release_perf_sample (stream); + } sample =list_first_entry_or_null (&stream->free_samples, struct i915_perf_cs_sample, link);WARN_ON (sample ==NULL );
@@ -1572,6 +1575,17 @@ static int append_cs_buffer_samples(struct i915_perf_stream *stream,LIST_HEAD (free_list);int ret =0 ;unsigned long flags; +u32 status = stream->cs_buffer.status; + +if (unlikely (status &I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW )) { + ret =append_oa_status (stream, buf, count, offset, +DRM_I915_PERF_RECORD_OA_BUFFER_LOST ); +if (ret) +return ret; + + stream->cs_buffer.status &= + ~I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW ; + }spin_lock_irqsave (&stream->samples_lock, flags);if (list_empty (&stream->cs_samples)) {
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/14 drm/i915: Populate ctx ID for periodic OA reports
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
This adds support for populating the ctx id for the periodic OA reports when requested through the corresponding property.
For Gen8, the OA reports itself have the ctx ID and it is the one programmed into HW while submitting workloads. Thus it's retrieved from reports itself.
For Gen7, the OA reports don't have any such field, and we can populate this field with the last seen ctx ID while sending CS reports.
v2: Updated last_ctx_id for stream based on the id of perf sample as the periodic OA reports after the request gets completed should not be associated with any context.
--- drivers/gpu/drm/i915/i915_drv.h | 8 +++++ drivers/gpu/drm/i915/i915_perf.c | 68 +++++++++++++++++++++++++++++++++------- 2 files changed, 64 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +8 -0
@@ -2127,6 +2127,8 @@ struct i915_perf_stream {struct list_head cs_samples;struct list_head free_samples;spinlock_t samples_lock; + +u32 last_ctx_id; };/**
@@ -2213,6 +2215,12 @@ struct i915_oa_ops {* generations. */ u32 (*oa_hw_tail_read)(struct drm_i915_private *dev_priv); + +/** +* @get_ctx_id: Retrieve the ctx_id associated with the (periodic) OA +* report. +*/ +u32 (*get_ctx_id)(struct i915_perf_stream *stream,const u8 *report); };enum request_sample_id {
drivers/gpu/drm/i915/i915_perf.c +56 -12
104 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/14 drm/i915: Add support for having pid output with OA report
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
This patch introduces flags and adds support for having pid output with the OA reports generated through the RCS commands.
When the stream is opened with pid sample type, the pid information is also captured through the command stream samples and forwarded along with the OA reports.
v2: Changed payload field pid to u64 to keep all sample data aligned at 8 bytes. (Lionel)
Updated last_pid for stream based on the id of perf sample as the periodic OA reports after the request gets completed should not be associated with any pid.
v3: Updated stream->last_pid to INVALID_PID during stream_init.
Testcase: igt/intel_perf_dapc/perf-pid
--- drivers/gpu/drm/i915/i915_drv.h | 7 +++++ drivers/gpu/drm/i915/i915_gem_request.h | 1 + drivers/gpu/drm/i915/i915_perf.c | 56 ++++++++++++++++++++++++++++++++- include/uapi/drm/i915_drm.h | 7 +++++ 4 files changed, 70 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_drv.h +7 -0
@@ -2129,6 +2129,7 @@ struct i915_perf_stream {spinlock_t samples_lock;u32 last_ctx_id; +u64 last_pid; };/**
@@ -2261,6 +2262,12 @@ struct i915_perf_cs_sample {* @ctx_id: Context ID associated with this perf sample */ u32 ctx_id; + +/** +* @pid: PID of the process in context of which the workload was +* submitted, pertaining to this perf sample +*/ +u64 pid; };struct intel_cdclk_state {
drivers/gpu/drm/i915/i915_gem_request.h +1 -0
@@ -198,6 +198,7 @@ struct drm_i915_gem_request {u32 *pre_oa_offset;u32 *post_oa_offset; +u64 pid; };extern const struct dma_fence_ops i915_fence_ops;
drivers/gpu/drm/i915/i915_perf.c +55 -1
134 lines not on this page · raw message
include/uapi/drm/i915_drm.h +7 -0
@@ -1439,6 +1439,12 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_SAMPLE_CTX_ID , +/** +* The value of this property set to 1 requests inclusion of pid in the +* perf sample data. +*/ +DRM_I915_PERF_PROP_SAMPLE_PID , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
@@ -1506,6 +1512,7 @@ enum drm_i915_perf_record_type {* * { u64 source; } && DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE * { u64 ctx_id; } && DRM_I915_PERF_PROP_SAMPLE_CTX_ID +* { u64 pid; } && DRM_I915_PERF_PROP_SAMPLE_PID * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA * }; */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/14 drm/i915: Add support for emitting execbuffer tags through OA counter reports
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
This patch enables userspace to specify tags (per workload), provided via execbuffer ioctl, which could be added to OA reports, to help associate reports with the corresponding workloads.
There may be multiple stages within a single context, from a userspace perspective. An ability is needed to individually associate the OA reports with their corresponding workloads(execbuffers), which may not be possible solely with ctx_id or pid information. This patch enables such a mechanism.
In this patch, upper 32 bits of rsvd1 field, which were previously unused are now being used to pass in the tag.
v2: Updated i915_execbuffer2_get_tag to get the tag properly. (Sagar) Changed tag size to 64 bit to ensure all sample fields are aligned at 8 bytes. (Lionel)
Updated last_tag for stream based on the id of perf sample as the periodic OA reports after the request gets completed should not be associated with any tag.
v3: Updated last_tag to INVALID_TAG during stream_init. Added definition of i915_execbuffer2_set_tag.
Testcase: igt/intel_perf_dapc/perf-tag
--- drivers/gpu/drm/i915/i915_drv.h | 18 +++++++++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 11 ++++--- drivers/gpu/drm/i915/i915_gem_request.h | 1 + drivers/gpu/drm/i915/i915_perf.c | 50 +++++++++++++++++++++++++++--- include/uapi/drm/i915_drm.h | 15 +++++++++ 5 files changed, 84 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +16 -2
@@ -2043,7 +2043,8 @@ struct i915_perf_stream_ops {*/ void (*emit_sample_capture)(struct i915_perf_stream *stream,struct drm_i915_gem_request *request, -bool preallocate); +bool preallocate, +u32 tag);/* * @patch_sample_capture: Patch the offsets in commands to capture perf
@@ -2130,6 +2131,7 @@ struct i915_perf_stream {u32 last_ctx_id;u64 last_pid; +u32 last_tag; };/**
@@ -2268,6 +2270,17 @@ struct i915_perf_cs_sample {* submitted, pertaining to this perf sample */ u64 pid; + +/** +* @tag: Tag associated with workload, for which the perf sample is +* being collected. +* +* Userspace can specify tags (provided via execbuffer ioctl), which +* can be associated with the perf samples, and be used to functionally +* distinguish different workload stages, and associate samples with +* these different stages. +*/ +u32 tag; };struct intel_cdclk_state {
@@ -3985,7 +3998,8 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,extern void i915_perf_register (struct drm_i915_private *dev_priv);extern void i915_perf_unregister (struct drm_i915_private *dev_priv);void i915_perf_emit_sample_capture (struct drm_i915_gem_request *req, -bool preallocate); +bool preallocate, +u32 tag);void i915_perf_patch_request (struct drm_i915_gem_request *request);void i915_perf_streams_mark_idle (struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +7 -4
@@ -245,6 +245,7 @@ struct i915_execbuffer {*/ int lut_size;struct hlist_head *buckets;/** ht for relocation handles */ +uint32_t tag; };#define exec_entry (EB ,VMA ) (&(EB)->exec[(VMA)->exec_flags - (EB)->flags])
@@ -1115,7 +1116,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,if (err) goto err_request; -i915_perf_emit_sample_capture (rq, true); +i915_perf_emit_sample_capture (rq, true, eb->tag); err = eb->engine->emit_bb_start(rq, batch->node.start, PAGE_SIZE,
@@ -1123,7 +1124,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,if (err) goto err_request; -i915_perf_emit_sample_capture (rq, false); +i915_perf_emit_sample_capture (rq, false, eb->tag);GEM_BUG_ON (!reservation_object_test_signaled_rcu (batch->resv, true));i915_vma_move_to_active (batch, rq,0 );
@@ -1974,7 +1975,7 @@ static int eb_submit(struct i915_execbuffer *eb)return err; } -i915_perf_emit_sample_capture (eb->request, true); +i915_perf_emit_sample_capture (eb->request, true, eb->tag); err = eb->engine->emit_bb_start(eb->request, eb->batch->node.start +
@@ -1984,7 +1985,7 @@ static int eb_submit(struct i915_execbuffer *eb)if (err)return err; -i915_perf_emit_sample_capture (eb->request, false); +i915_perf_emit_sample_capture (eb->request, false, eb->tag);return 0 ; }
@@ -2232,6 +2233,8 @@ static int eb_submit(struct i915_execbuffer *eb)if (!eb.engine)return -EINVAL ; + eb.tag =i915_execbuffer2_get_tag (*args); +if (args->flags &I915_EXEC_RESOURCE_STREAMER ) {if (!HAS_RESOURCE_STREAMER (eb.i915)) {DRM_DEBUG ("RS is only allowed for Haswell, Gen8 and above\n" );
drivers/gpu/drm/i915/i915_gem_request.h +1 -0
@@ -199,6 +199,7 @@ struct drm_i915_gem_request {u32 *pre_oa_offset;u32 *post_oa_offset;u64 pid; +u32 tag; };extern const struct dma_fence_ops i915_fence_ops;
drivers/gpu/drm/i915/i915_perf.c +45 -5
149 lines not on this page · raw message
include/uapi/drm/i915_drm.h +15 -0
@@ -966,6 +966,14 @@ struct drm_i915_gem_execbuffer2 {#define i915_execbuffer2_get_context_id (eb2) \ ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK) +/* upper 32 bits of rsvd1 field contain tag */ +#define I915_EXEC_TAG_MASK (0xffffffff00000000UL) +#define i915_execbuffer2_set_tag (eb2, tag) \ + (eb2).rsvd1 = ((eb2).rsvd1 & ~I915_EXEC_TAG_MASK) |\ + ((tag << 32) & I915_EXEC_TAG_MASK) +#define i915_execbuffer2_get_tag (eb2) \ + (((eb2).rsvd1 & I915_EXEC_TAG_MASK) >> 32) +struct drm_i915_gem_pin {/** Handle of the buffer to be pinned. */ __u32 handle;
@@ -1445,6 +1453,12 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_SAMPLE_PID , +/** +* The value of this property set to 1 requests inclusion of tag in the +* perf sample data. +*/ +DRM_I915_PERF_PROP_SAMPLE_TAG , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
@@ -1513,6 +1527,7 @@ enum drm_i915_perf_record_type {* { u64 source; } && DRM_I915_PERF_PROP_SAMPLE_OA_SOURCE * { u64 ctx_id; } && DRM_I915_PERF_PROP_SAMPLE_CTX_ID * { u64 pid; } && DRM_I915_PERF_PROP_SAMPLE_PID +* { u64 tag; } && DRM_I915_PERF_PROP_SAMPLE_TAG * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA * }; */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 10/14 drm/i915: Link perf stream structures with Engines
In reply to Sagar Arun KambleTo allow opening CS perf streams for other engines, this patch associates exclusive stream with each engine and correspondingly updates the required fields per stream.
--- drivers/gpu/drm/i915/i915_drv.h | 26 +++-- drivers/gpu/drm/i915/i915_perf.c | 168 +++++++++++++++----------------- drivers/gpu/drm/i915/intel_engine_cs.c | 4 + drivers/gpu/drm/i915/intel_ringbuffer.c | 2 + drivers/gpu/drm/i915/intel_ringbuffer.h | 8 ++ 5 files changed, 104 insertions(+), 104 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +11 -15
@@ -2068,6 +2068,11 @@ struct i915_perf_stream {*/ struct drm_i915_private *dev_priv; +/* +* @engine: Engine to which this stream corresponds. +*/ +struct intel_engine_cs *engine; +/** * @sample_flags: Flags representing the `DRM_I915_PERF_PROP_SAMPLE_*` * properties given when opening a stream, representing the contents
@@ -2132,6 +2137,10 @@ struct i915_perf_stream {u32 last_ctx_id;u64 last_pid;u32 last_tag; + +u32 specific_ctx_id; +wait_queue_head_t poll_wq; +bool pollin; };/**
@@ -2620,6 +2629,8 @@ struct drm_i915_private {*/ struct idr metrics_idr; +struct hrtimer poll_check_timer; +/* * Lock associated with anything below within this structure * except exclusive_stream.
@@ -2627,21 +2638,6 @@ struct drm_i915_private {struct mutex lock;struct { -/* -* The stream currently using the OA unit. If accessed -* outside a syscall associated to its file -* descriptor, you need to hold -* dev_priv->drm.struct_mutex. -*/ -struct i915_perf_stream *exclusive_stream; -struct srcu_struct srcu; - -u32 specific_ctx_id; - -struct hrtimer poll_check_timer; -wait_queue_head_t poll_wq; -bool pollin; -/** * For rate limiting any notifications of spurious * invalid OA reports
drivers/gpu/drm/i915/i915_perf.c +79 -89
410 lines not on this page · raw message
drivers/gpu/drm/i915/intel_engine_cs.c +4 -0
@@ -317,6 +317,10 @@ int intel_engines_init(struct drm_i915_private *dev_priv) goto cleanup;GEM_BUG_ON (!engine->submit_request); + +/* Perf stream related initialization for Engine */ +rcu_assign_pointer (engine->exclusive_stream,NULL ); +init_srcu_struct (&engine->srcu); }return 0 ;
drivers/gpu/drm/i915/intel_ringbuffer.c +2 -0
@@ -1622,6 +1622,8 @@ void intel_engine_cleanup(struct intel_engine_cs *engine)intel_engine_cleanup_common (engine); +cleanup_srcu_struct (&engine->srcu); + dev_priv->engine[engine->id] =NULL ;kfree (engine); }
drivers/gpu/drm/i915/intel_ringbuffer.h +8 -0
@@ -441,6 +441,14 @@ struct intel_engine_cs {* certain bits to encode the command length in the header). */ u32 (*get_cmd_length_mask)(u32 cmd_header); + +/* +* For RCS, This stream can use the OA unit. All accesses guarded by +* SRCU including those in syscall as we can't hold +* dev_priv->drm.struct_mutex in the execbuf path. +*/ +struct i915_perf_stream __rcu *exclusive_stream; +struct srcu_struct srcu; }; static inline unsigned int
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 11/14 drm/i915: Add support for collecting timestamps on all gpu engines
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
With this patch, for RCS, timestamps and OA reports can be collected together, and provided to userspace in separate sample fields. For other engines, the capabilility to collect timestamps is added.
The thing to note is that, still only a single stream instance can be opened at any particular time. Though that stream may now be opened for any gpu engine, for collection of timestamp samples.
So, this patch doesn't add the support to open multiple concurrent streams, as yet.
v2: Patching the offsets for TS capture similar to OA.
Testcase: igt/intel_perf_dapc/perf-ts
--- drivers/gpu/drm/i915/i915_drv.h | 18 ++- drivers/gpu/drm/i915/i915_gem_request.h | 2 + drivers/gpu/drm/i915/i915_perf.c | 223 +++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/i915_reg.h | 2 + include/uapi/drm/i915_drm.h | 7 + 5 files changed, 230 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +15 -3
@@ -2260,12 +2260,24 @@ struct i915_perf_cs_sample {struct drm_i915_gem_request *request;/** -* @oa_offset: Offset into ``&stream->cs_buffer`` -* where the perf metrics will be collected, when the commands inserted -* into the command stream are executed by GPU. +* @oa_offset: Offset into ``&stream->cs_buffer +* where the OA report will be collected (if the stream is configured +* for collection of OA samples). */ u32 oa_offset; +/** +* @ts_offset: Offset into ``&stream->cs_buffer +* where the timestamps will be collected (if the stream is configured +* for collection of timestamp data) +*/ +u32 ts_offset; + +/** +* @size: buffer size corresponding to this perf sample +*/ +u32 size; +/* Is this sample prior to request start or post request end */ enum request_sample_id id;
drivers/gpu/drm/i915/i915_gem_request.h +2 -0
@@ -200,6 +200,8 @@ struct drm_i915_gem_request {u32 *post_oa_offset;u64 pid;u32 tag; +u32 *pre_ts_offset; +u32 *post_ts_offset; };extern const struct dma_fence_ops i915_fence_ops;
drivers/gpu/drm/i915/i915_perf.c +204 -19
337 lines not on this page · raw message
drivers/gpu/drm/i915/i915_reg.h +2 -0
@@ -547,6 +547,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)#define MI_FLUSH_DW_STORE_INDEX (1<<21)#define MI_INVALIDATE_TLB (1<<18)#define MI_FLUSH_DW_OP_STOREDW (1<<14) +#define MI_FLUSH_DW_OP_STAMP (3<<14)#define MI_FLUSH_DW_OP_MASK (3<<14)#define MI_FLUSH_DW_NOTIFY (1<<8)#define MI_INVALIDATE_BSD (1<<7)
@@ -630,6 +631,7 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)#define PIPE_CONTROL_TLB_INVALIDATE (1<<18)#define PIPE_CONTROL_MEDIA_STATE_CLEAR (1<<16)#define PIPE_CONTROL_QW_WRITE (1<<14) +#define PIPE_CONTROL_TIMESTAMP_WRITE (3<<14)#define PIPE_CONTROL_POST_SYNC_OP_MASK (3<<14)#define PIPE_CONTROL_DEPTH_STALL (1<<13)#define PIPE_CONTROL_WRITE_FLUSH (1<<12)
include/uapi/drm/i915_drm.h +7 -0
@@ -1459,6 +1459,12 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_SAMPLE_TAG , +/** +* The value of this property set to 1 requests inclusion of timestamp +* in the perf sample data. +*/ +DRM_I915_PERF_PROP_SAMPLE_TS , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
@@ -1528,6 +1534,7 @@ enum drm_i915_perf_record_type {* { u64 ctx_id; } && DRM_I915_PERF_PROP_SAMPLE_CTX_ID * { u64 pid; } && DRM_I915_PERF_PROP_SAMPLE_PID * { u64 tag; } && DRM_I915_PERF_PROP_SAMPLE_TAG +* { u64 timestamp; } && DRM_I915_PERF_PROP_SAMPLE_TS * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA * }; */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 12/14 drm/i915: Extract raw GPU timestamps from OA reports to forward in perf samples
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
The OA reports contain the least significant 32 bits of the gpu timestamp. This patch enables retrieval of the timestamp field from OA reports, to forward as 64 bit raw gpu timestamps in the perf samples.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_perf.c | 48 ++++++++++++++++++++++++++++++---------- drivers/gpu/drm/i915/i915_reg.h | 4 ++++ 3 files changed, 41 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2739,6 +2739,7 @@ struct drm_i915_private {u32 ctx_flexeu0_offset;u32 n_pending_periodic_samples;u32 pending_periodic_ts; +u64 last_gpu_ts;/** * The RPT_ID/reason field for Gen8+ includes a bit
drivers/gpu/drm/i915/i915_perf.c +36 -12
90 lines not on this page · raw message
drivers/gpu/drm/i915/i915_reg.h +4 -0
@@ -730,6 +730,10 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)#define PS_DEPTH_COUNT _MMIO(0x2350)#define PS_DEPTH_COUNT_UDW _MMIO(0x2350 + 4) +/* Timestamp count register */ +#define GT_TIMESTAMP_COUNT _MMIO(0x2358) +#define GT_TIMESTAMP_COUNT_UDW _MMIO(0x2358 + 4) +/* There are the 4 64-bit counter registers, one for each stream output */ #define GEN7_SO_NUM_PRIMS_WRITTEN (n) _MMIO(0x5200 + (n) * 8)#define GEN7_SO_NUM_PRIMS_WRITTEN_UDW (n) _MMIO(0x5200 + (n) * 8 + 4)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 13/14 drm/i915: Async check for streams data availability with hrtimer rescheduling
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
This patch ensures hrtimer is rescheduled immediately during cb by doing async call to check for streams data availability.
--- drivers/gpu/drm/i915/i915_perf.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +11 -4
@@ -3465,12 +3465,10 @@ static ssize_t i915_perf_read(struct file *file,return ret; } -static enum hrtimer_restart poll_check_timer_cb (struct hrtimer *hrtimer) +static void wake_up_perf_streams (void *data,async_cookie_t cookie) { +struct drm_i915_private *dev_priv = data;struct i915_perf_stream *stream; -struct drm_i915_private *dev_priv = -container_of (hrtimer,typeof (*dev_priv), - perf.poll_check_timer);int idx;struct intel_engine_cs *engine;enum intel_engine_id id;
@@ -3486,6 +3484,15 @@ static enum hrtimer_restart poll_check_timer_cb(struct hrtimer *hrtimer) }srcu_read_unlock (&engine->srcu, idx); } +} + +static enum hrtimer_restart poll_check_timer_cb (struct hrtimer *hrtimer) +{ +struct drm_i915_private *dev_priv = +container_of (hrtimer,typeof (*dev_priv), + perf.poll_check_timer); + +async_schedule (wake_up_perf_streams, dev_priv);hrtimer_forward_now (hrtimer,ns_to_ktime (POLL_PERIOD ));
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 14/14 drm/i915: Support for capturing MMIO register values
In reply to Sagar Arun KambleFrom: Sourab Gupta <[email protected]>
This patch adds support for capturing MMIO register values through i915 perf interface.
The userspace can request upto 8 MMIO register values to be dumped. The addresses of these registers can be passed through the corresponding property 'value' field while opening the stream.
The commands to dump the values of these MMIO registers are then inserted into the ring alongwith other commands.
v2: Updated error return on copy_from_user failure. (Chris)
v3: Adjusted the patching of request ringbuffer contents w.r.t new of allocating samples.
Testcase: igt/intel_perf_dapc/perf-mmio
--- drivers/gpu/drm/i915/i915_drv.h | 10 ++ drivers/gpu/drm/i915/i915_gem_request.h | 3 + drivers/gpu/drm/i915/i915_perf.c | 193 +++++++++++++++++++++++++++++++- drivers/gpu/drm/i915/intel_ringbuffer.h | 3 + include/uapi/drm/i915_drm.h | 14 +++ 5 files changed, 220 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +10 -0
@@ -2274,6 +2274,13 @@ struct i915_perf_cs_sample {u32 ts_offset;/** +* @mmio_offset: Offset into ``&stream->cs_buffer`` where the mmio reg +* values for this perf sample will be collected (if the stream is +* configured for collection of mmio data) +*/ +u32 mmio_offset; + +/** * @size: buffer size corresponding to this perf sample */ u32 size;
@@ -2751,6 +2758,9 @@ struct drm_i915_private {struct i915_oa_ops ops;const struct i915_oa_format *oa_formats; } oa; + +u32 num_mmio; +u32 mmio_list[I915_PERF_MMIO_NUM_MAX ]; } perf;/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
drivers/gpu/drm/i915/i915_gem_request.h +3 -0
@@ -29,6 +29,7 @@#include "i915_gem.h" #include "i915_sw_fence.h" +#include <drm/i915_drm.h> struct drm_file ;struct drm_i915_gem_object ;
@@ -202,6 +203,8 @@ struct drm_i915_gem_request {u32 tag;u32 *pre_ts_offset;u32 *post_ts_offset; +u32 *pre_mmio_offset[I915_PERF_MMIO_NUM_MAX ]; +u32 *post_mmio_offset[I915_PERF_MMIO_NUM_MAX ]; };extern const struct dma_fence_ops i915_fence_ops;
drivers/gpu/drm/i915/i915_perf.c +190 -3
296 lines not on this page · raw message
drivers/gpu/drm/i915/intel_ringbuffer.h +3 -0
@@ -449,6 +449,9 @@ struct intel_engine_cs {*/ struct i915_perf_stream __rcu *exclusive_stream;struct srcu_struct srcu; + +u32 num_mmio; +u32 mmio_list[I915_PERF_MMIO_NUM_MAX ]; }; static inline unsigned int
include/uapi/drm/i915_drm.h +14 -0
@@ -1393,6 +1393,12 @@ enum drm_i915_perf_sample_oa_source {I915_PERF_SAMPLE_OA_SOURCE_MAX /* non-ABI */ }; +#define I915_PERF_MMIO_NUM_MAX 8 +struct drm_i915_perf_mmio_list { +__u32 num_mmio; +__u32 mmio_list[I915_PERF_MMIO_NUM_MAX ]; +}; +enum drm_i915_perf_property_id {/** * Open the stream for a specific context handle (as used with
@@ -1465,6 +1471,13 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_SAMPLE_TS , +/** +* This property requests inclusion of mmio register values in the perf +* sample data. The value of this property specifies the address of user +* struct having the register addresses. +*/ +DRM_I915_PERF_PROP_SAMPLE_MMIO , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
@@ -1535,6 +1548,7 @@ enum drm_i915_perf_record_type {* { u64 pid; } && DRM_I915_PERF_PROP_SAMPLE_PID * { u64 tag; } && DRM_I915_PERF_PROP_SAMPLE_TAG * { u64 timestamp; } && DRM_I915_PERF_PROP_SAMPLE_TS +* { u32 mmio[]; } && DRM_I915_PERF_PROP_SAMPLE_MMIO * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA * }; */
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for i915 perf support for command stream based OA, GPU and workload metrics capture (rev3)
In reply to Sagar Arun Kamble== Series Details ==
== Series Details ==
Series: i915 perf support for command stream based OA, GPU and workload metrics capture (rev3)
URL : https://patchwork.freedesktop.org/series/28104/
State : success
== Summary ==
Series 28104v3 i915 perf support for command stream based OA, GPU and workload metrics capture
https://patchwork.freedesktop.org/api/1.0/series/28104/revisions/3/mbox/
Test kms_cursor_legacy:
Subgroup basic-busy-flip-before-cursor-atomic:
fail -> PASS (fi-snb-2600) fdo#100215
Test kms_flip:
Subgroup basic-flip-vs-modeset:
skip -> PASS (fi-skl-x1585l) fdo#101781
Test drv_module_reload:
Subgroup basic-reload-inject:
dmesg-fail -> DMESG-WARN (fi-cfl-s) k.org#196765fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215
fdo#101781 https://bugs.freedesktop.org/show_bug.cgi?id=101781
k.org#196765 https://bugzilla.kernel.org/show_bug.cgi?id=196765
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:456s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:442s fi-blb-e6850 total:289 pass:224 dwarn:1 dfail:0 fail:0 skip:64 time:362s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:570s fi-bwr-2160 total:289 pass:184 dwarn:0 dfail:0 fail:0 skip:105 time:253s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:522s fi-byt-j1900 total:289 pass:254 dwarn:1 dfail:0 fail:0 skip:34 time:527s fi-byt-n2820 total:289 pass:250 dwarn:1 dfail:0 fail:0 skip:38 time:515s fi-cfl-s total:289 pass:249 dwarn:4 dfail:0 fail:0 skip:36 time:472s fi-elk-e7500 total:289 pass:230 dwarn:0 dfail:0 fail:0 skip:59 time:434s fi-glk-2a total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:614s fi-hsw-4770 total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:445s fi-hsw-4770r total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:425s fi-ilk-650 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:429s fi-ivb-3520m total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:508s fi-ivb-3770 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:471s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:510s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:601s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:594s fi-pnv-d510 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:531s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:475s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:534s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:509s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:454s fi-skl-x1585l total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:506s fi-snb-2520m total:289 pass:251 dwarn:0 dfail:0 fail:0 skip:38 time:558s fi-snb-2600 total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:414s
00f9b49384df3d7874273e1368c770cc651464df drm-tip: 2017y-09m-07d-09h-58m-50s UTC integration manifest 92dd86491d35 drm/i915: Support for capturing MMIO register valuesfd97889c83cb drm/i915: Async check for streams data availability with hrtimer rescheduling bc17e32e799b drm/i915: Extract raw GPU timestamps from OA reports to forward in perf samples 7f6621bb93da drm/i915: Add support for collecting timestamps on all gpu engines c4b34ce42b38 drm/i915: Link perf stream structures with Engines428180dcebd8 drm/i915: Add support for emitting execbuffer tags through OA counter reports 77f11008bc9e drm/i915: Add support for having pid output with OA report9e8dcfb07d8d drm/i915: Populate ctx ID for periodic OA reports43935a1bc4b6 drm/i915: Inform userspace about command stream OA buf overflow 911dcacfa6d7 drm/i915: Flush periodic samples, in case of no pending CS sample requests 7b422094f909 drm/i915: Define CTX_ID property for perf samplingd47575a4f876 drm/i915: Framework for capturing command stream based OA reports. 3d99c563c12d drm/i915: Expose OA sample source to userspaced0b114a774b5 drm/i915: Add ctx getparam ioctl parameter to retrieve ctx unique id
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5606/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: failure for i915 perf support for command stream based OA, GPU and workload metrics capture (rev3)
In reply to Sagar Arun Kamble== Series Details ==
== Series Details ==
Series: i915 perf support for command stream based OA, GPU and workload metrics capture (rev3)
URL : https://patchwork.freedesktop.org/series/28104/
State : failure
== Summary ==
Test perf:
Subgroup short-reads:
pass -> FAIL (shard-hsw)
Subgroup i915-ref-count:
pass -> FAIL (shard-hsw)
Subgroup polling:
pass -> FAIL (shard-hsw) fdo#102252 +1
Subgroup buffer-fill:
pass -> INCOMPLETE (shard-hsw)
Subgroup missing-sample-flags:
pass -> INCOMPLETE (shard-hsw)
Subgroup non-sampling-read-error:
pass -> INCOMPLETE (shard-hsw)
Test gem_ctx_param:
Subgroup invalid-param-get:
pass -> FAIL (shard-hsw)
Test pm_lpsp:
Subgroup screens-disabled:
fail -> PASS (shard-hsw) fdo#102579
Test kms_flip:
Subgroup blt-wf_vblank-vs-dpms:
pass -> DMESG-WARN (shard-hsw)fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#102579 https://bugs.freedesktop.org/show_bug.cgi?id=102579
shard-hsw total:2122 pass:1141 dwarn:1 dfail:0 fail:15 skip:960 time:9040s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_5606/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx