Collect command stream based GPU metrics for all engines using i915 perf
cover Collect command stream based GPU metrics for all engines using i915 perf
From: Sourab Gupta <[email protected]>
This series adds framework for collection of gpu performance metrics associated with the command stream of a particular engine. These metrics include OA reports for render stream and timestamps, mmio metrics, etc. for other gpu engine streams. These metrics are are collected around batchbuffer boundaries.
Essentially, it expands upon Robert's i915 perf framework for collecting periodic OA reports, to enable it to collect metrics on multiple GPU engines concurrently, by having concurrent streams each associated with a particular GPU engine.
This series is based on top of the patch series for collecting OA metrics for render stream, which I sent earlier:
https://patchwork.freedesktop.org/series/21351/
There are a couple of patches which add support for using the cross-timestamp framework for retrieving tightly coupled device/system timestamps. In our case, this framework enables us to have correlated pairs of gpu+system time which can be used over a period of time to correct the frequency of timestamp clock, and thus enable to accurately send system time (_MONO_RAW) as requested to the userspace. The results are generally observed to quite better with the use of cross timestamps and the frequency delta gradually tapers down to 0 with increasing correction periods.
The use of cross timestamp framework though requires us to have clockcounter/timecounter abstraction for the timestamp clocksource, and further requires few changes in the kernel timekeeping/clocksource code. I am looking for feedback on the use of this framework and the changes involved.
The patches can also be found at:
https://github.com/sourabgu/linux/tree/oa-6march2017
Sourab Gupta (6):
drm/i915: Extend i915 perf framework for collecting timestamps on all
gpu engines
drm/i915: Extract raw GPU timestamps from OA reports to forward in
perf samples
drm/i915: Support opening multiple concurrent perf streams
time: Expose current clocksource in use by timekeeping framework drm/i915: Mechanism to forward clock monotonic raw time in perf
samples
drm/i915: Support for capturing MMIO register values
drivers/gpu/drm/i915/i915_drv.c | 15 + drivers/gpu/drm/i915/i915_drv.h | 90 ++- drivers/gpu/drm/i915/i915_perf.c | 1136 +++++++++++++++++++++++++++++--------- drivers/gpu/drm/i915/i915_reg.h | 6 + include/linux/timekeeping.h | 5 + include/uapi/drm/i915_drm.h | 28 + kernel/time/timekeeping.c | 12 + 7 files changed, 1029 insertions(+), 263 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/6 drm/i915: Extend i915 perf framework for collecting timestamps on all gpu engines
From: Sourab Gupta <[email protected]>
This patch extends the i915 perf framework to handle the perf sample collection for any given gpu engine. Particularly, the support for collecting timestamp sample type is added, which can be requested for any engine.
With this, 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. Though it lays the groundwork for this support to be added susequently. Part of this groundwork involves having separate command stream buffers, per engine, for holding the samples generated. Likewise for a few other data structures maintaining per-engine state.
--- drivers/gpu/drm/i915/i915_drv.h | 52 ++- drivers/gpu/drm/i915/i915_perf.c | 696 +++++++++++++++++++++++++-------------- drivers/gpu/drm/i915/i915_reg.h | 2 + include/uapi/drm/i915_drm.h | 7 + 4 files changed, 502 insertions(+), 255 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +39 -13
@@ -2045,6 +2045,11 @@ struct i915_perf_stream {bool cs_mode;/** +* @using_oa: Whether OA unit is in use for this particular stream +*/ +bool using_oa; + +/** * @last_request: Contains an RCU guarded pointer to the last request * associated with the stream, when command stream mode is enabled for * the stream.
@@ -2156,11 +2161,33 @@ struct i915_perf_cs_sample {struct drm_i915_gem_request *request;/** -* @offset: Offset into ``&drm_i915_private->perf.command_stream_buf`` -* where the perf metrics will be collected, when the commands inserted -* into the command stream are executed by GPU. +* @start_offset: Offset into ``&drm_i915_private-> +* perf.command_stream_buf`` where the metrics for this perf sample +* will be collected, when the commands inserted into the command stream +* are executed by GPU. +*/ +u32 start_offset; + +/** +* @oa_offset: Offset into ``&drm_i915_private-> +* perf.command_stream_buf`` where the OA report for this perf sample +* will be collected (if the stream is configured for collection of OA +* samples). */ -u32 offset; +u32 oa_offset; + +/** +* @ts_offset: Offset into ``&drm_i915_private-> +* perf.command_stream_buf`` where the timestamps for this perf sample +* 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;/** * @ctx_id: Context ID associated with this perf sample
@@ -2519,15 +2546,14 @@ struct drm_i915_private {spinlock_t hook_lock; -struct { -struct i915_perf_stream *exclusive_stream; +struct hrtimer poll_check_timer; +struct i915_perf_stream *exclusive_stream; +wait_queue_head_t poll_wq[I915_NUM_ENGINES ]; +bool pollin[I915_NUM_ENGINES ]; +struct {u32 specific_ctx_id; -struct hrtimer poll_check_timer; -wait_queue_head_t poll_wq; -bool pollin; -bool periodic;int period_exponent;
@@ -2635,13 +2661,13 @@ struct drm_i915_private {u8 *vaddr;#define I915_PERF_CMD_STREAM_BUF_STATUS_OVERFLOW (1<<0)u32 status; - } command_stream_buf; + } command_stream_buf[I915_NUM_ENGINES ];u32 last_cmd_stream_ctx_id;u32 last_pid;u32 last_tag; -struct list_head cs_samples; -spinlock_t sample_lock; +struct list_head cs_samples[I915_NUM_ENGINES ]; +spinlock_t sample_lock[I915_NUM_ENGINES ]; } perf;/* Abstract the submission mechanism (legacy ringbuffer or execlists) away */
drivers/gpu/drm/i915/i915_perf.c +454 -242
1,240 lines not on this page · raw message
drivers/gpu/drm/i915/i915_reg.h +2 -0
@@ -417,6 +417,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)
@@ -500,6 +501,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
@@ -1390,6 +1390,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 */ };
@@ -1459,6 +1465,7 @@ enum drm_i915_perf_record_type {* { u32 ctx_id; } && DRM_I915_PERF_PROP_SAMPLE_CTX_ID * { u32 pid; } && DRM_I915_PERF_PROP_SAMPLE_PID * { u32 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
Re: [PATCH 1/6] drm/i915: Extend i915 perf framework for collecting timestamps on all gpu engines
Quoted 23 lines · On Thu, Mar 16, 2017 at 11:50:06AM +0530, [email protected] wrote:
From: Sourab Gupta <[email protected]>
This patch extends the i915 perf framework to handle the perf sample collection for any given gpu engine. Particularly, the support for collecting timestamp sample type is added, which can be requested for any engine.
With this, 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. Though it lays the groundwork for this support to be added susequently. Part of this groundwork involves having separate command stream buffers, per engine, for holding the samples generated. Likewise for a few other data structures maintaining per-engine state.
Signed-off-by Sourab Gupta <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private { · line 2552
Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +4
-2@@ -2519,15 +2546,14 @@ struct drm_i915_private {spinlock_t hook_lock; -struct { -struct i915_perf_stream *exclusive_stream; +struct hrtimer poll_check_timer; +struct i915_perf_stream *exclusive_stream; +wait_queue_head_t poll_wq[I915_NUM_ENGINES ]; +bool pollin[I915_NUM_ENGINES ];
So what's the rationale for not storing these [NUM_ENGINES] on the engines?
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 1/6] drm/i915: Extend i915 perf framework for collecting timestamps on all gpu engines
Quoted 27 lines · Chris Wilson
Quoted 26 lines · On Thu, Mar 16, 2017 at 11:50:06AM +0530, [email protected] wrote:
From: Sourab Gupta <[email protected]>
This patch extends the i915 perf framework to handle the perf sample collection for any given gpu engine. Particularly, the support for collecting timestamp sample type is added, which can be requested for any engine.
With this, 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. Though it lays the groundwork for this support to be added susequently. Part of this groundwork involves having separate command stream buffers, per engine, for holding the samples generated. Likewise for a few other data structures maintaining per-engine state.
Signed-off-by Sourab Gupta <[email protected]>---
drivers/gpu/drm/i915/i915_drv.h +0
-0@@ -2519,15 +2546,14 @@ struct drm_i915_private {spinlock_t hook_lock;
Quoted 11 lines
drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private { · line 2552
Quoted 6 lines
drivers/gpu/drm/i915/i915_drv.h +4
-2-struct { -struct i915_perf_stream *exclusive_stream; +struct hrtimer poll_check_timer; +struct i915_perf_stream *exclusive_stream; +wait_queue_head_t poll_wq[I915_NUM_ENGINES ]; +bool pollin[I915_NUM_ENGINES ];So what's the rationale for not storing these [
NUM_ENGINES] on the engines?
-Chris
I wanted to keep the perf related stuff clubbed together under dev_priv->perf, and not distribute this stuff over intel_engine_cs. Thus, the design choice of having [NUM_ENGINES] instances of these fields.
Does this seem okay?
Regards,
Sourab
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/6 drm/i915: Extract raw GPU timestamps from OA reports to forward in perf samples
In reply to [email protected]From: 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 | 49 +++++++++++++++++++++++++++++----------- drivers/gpu/drm/i915/i915_reg.h | 4 ++++ 3 files changed, 41 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -2643,6 +2643,7 @@ struct drm_i915_private {u32 ctx_flexeu0_off;u32 n_pending_periodic_samples;u32 pending_periodic_ts; +u64 last_gpu_ts;/* The RPT_ID/reason field for Gen8+ includes a bit * to determine if the CTX ID in the report is valid
drivers/gpu/drm/i915/i915_perf.c +36 -13
92 lines not on this page · raw message
drivers/gpu/drm/i915/i915_reg.h +4 -0
@@ -600,6 +600,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 3/6 drm/i915: Support opening multiple concurrent perf streams
In reply to [email protected]From: Sourab Gupta <[email protected]>
This patch adds support for opening multiple concurrent perf streams for different gpu engines, while having the restriction to open only a single stream open for a particular gpu engine.
This enables userspace client to open multiple streams, one per engine, at any time to capture sample data for multiple gpu engines.
--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_perf.c | 41 ++++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -2547,7 +2547,7 @@ struct drm_i915_private {spinlock_t hook_lock;struct hrtimer poll_check_timer; -struct i915_perf_stream *exclusive_stream; +struct i915_perf_stream *engine_stream[I915_NUM_ENGINES ];wait_queue_head_t poll_wq[I915_NUM_ENGINES ];bool pollin[I915_NUM_ENGINES ];
drivers/gpu/drm/i915/i915_perf.c +23 -18
100 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 4/6 time: Expose current clocksource in use by timekeeping framework
In reply to [email protected]From: Sourab Gupta <[email protected]>
For the drivers to be able to use the cross timestamp framework, they need the information of current clocksource being used by the kernel timekeeping. This is needed since the callback given by driver into the get_device_system_crosststamp(), in order to synchronously read the device time and system counter value, requires the knowledge of the clocksource being used to read system counter value (as a part of struct system_counterval_t).
--- include/linux/timekeeping.h | 5 +++++ kernel/time/timekeeping.c | 12 ++++++++++++ 2 files changed, 17 insertions(+)
include/linux/timekeeping.h +5 -0
@@ -337,6 +337,11 @@ extern int get_device_system_crosststamp( struct system_device_crosststamp *xtstamp);/* +* Get current clocksource used by system timekeeping framework +*/ +struct clocksource *get_current_clocksource (void ); + +/* * Simultaneously snapshot realtime and monotonic raw clocks */ extern void ktime_get_snapshot (struct system_time_snapshot *systime_snapshot);
kernel/time/timekeeping.c +12 -0
@@ -1167,6 +1167,18 @@ int get_device_system_crosststamp(int (*get_time_fn)EXPORT_SYMBOL_GPL (get_device_system_crosststamp);/** +* get_current_clocksource - Returns the current clocksource in used by tk_core +* +*/ +struct clocksource *get_current_clocksource (void ) +{ +struct timekeeper *tk = &tk_core.timekeeper; + +return tk->tkr_mono.clock; +} +EXPORT_SYMBOL_GPL (get_current_clocksource); + +/** * do_gettimeofday - Returns the time of day in a timeval * @tv: pointer to the timeval to be set *
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/6] time: Expose current clocksource in use by timekeeping framework
On Thu, 16 Mar 2017, [email protected] wrote:
Please Cc LKML for patches which touch subsystems managed on LKML. Also CC'ing people on the 0/N letter would be helpful, so we can see what this is about.
Quoted 3 lines
For the drivers to be able to use the cross timestamp framework, they need the information of current clocksource being used by the kernel timekeeping.
No.
Quoted 5 lines
This is needed since the callback given by driver into the
get_device_system_crosststamp(), in order to synchronously read the device time and system counter value, requires the knowledge of the clocksource being used to read system counter value (as a part of structsystem_counterval_t).
Again you are saying WHAT you want but not WHY. The device callback does not need to know anything about the timekeeping clocksource.
get_device_system_crosststamp() is for timestamps taken via a clock which is directly correlated with the timekeeper clocksource.
ART and TSC are correlated via:
TSC = (ART * scale) + offset
get_device_system_crosststamp() invokes the device function which reads ART, which is converted to CLOCK_MONOTONIC_RAW by the conversion above, and then uses interpolation to map the CLOCK_MONOTONIC_RAW value to CLOCK_MONOTONIC.
The device function does not know anything about TSC. All it knows about is ART.
I have no idea what you are trying to do, but given the explanation above it's wrong.
Thanks,
tglx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/6 drm/i915: Mechanism to forward clock monotonic raw time in perf samples
In reply to [email protected]From: Sourab Gupta <[email protected]>
Currently, we have the ability to only forward the GPU timestamps in the samples (which are generated via OA reports or PIPE_CONTROL commands inserted in the ring). This limits the ability to correlate these samples with the system events. If we scale the GPU timestamps according the timestamp base/frequency info present in bspec, it is observed that the timestamps drift really quickly from the system time.
An ability is therefore needed to report timestamps in different clock domains, such as CLOCK_MONOTONIC (or _MONO_RAW), in the perf samples to be of more practical use to the userspace. This ability becomes important when we want to correlate/plot GPU events/samples with other system events on the same timeline (e.g. vblank events, or timestamps when work was submitted to kernel, etc.)
The patch here proposes a mechanism to achieve this. The correlation between gpu time and system time is established using the cross timestamp framework. For this purpose, the timestamp clock associated with the command stream, is abstracted as timecounter/cyclecounter, before utilizing cross timestamp framework to retrieve gpu/system time correlated values. Different such gpu/system time values are then used to detect and correct the error in published gpu timestamp clock frequency. The userspace can request CLOCK_MONOTONIC_RAW timestamps in samples by requesting the corresponding property while opening the stream.
v2: Added i915_driver_init_late() function to capture the new late init phase for perf (Chris)
--- drivers/gpu/drm/i915/i915_drv.c | 15 +++ drivers/gpu/drm/i915/i915_drv.h | 26 ++++ drivers/gpu/drm/i915/i915_perf.c | 267 +++++++++++++++++++++++++++++++++++++-- include/uapi/drm/i915_drm.h | 9 +- 4 files changed, 305 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +15 -0
@@ -899,6 +899,19 @@ static void i915_driver_cleanup_early(struct drm_i915_private *dev_priv)i915_engines_cleanup (dev_priv); } +/** +* i915_driver_init_late - initialize late stage driver components +* @dev_priv: device private +* +* Setup the driver components, which need to be inited after driver state has +* been registered and device enabled. +*/ +static void i915_driver_init_late (struct drm_i915_private *dev_priv) +{ +i915_perf_init_late (dev_priv); +} + +static int i915_mmio_setup (struct drm_i915_private *dev_priv) {struct pci_dev *pdev = dev_priv->drm.pdev;
@@ -1279,6 +1292,8 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)i915_driver_register (dev_priv); +i915_driver_init_late (dev_priv); +intel_runtime_pm_enable (dev_priv); dev_priv->ipc_enabled = false;
drivers/gpu/drm/i915/i915_drv.h +26 -0
@@ -43,6 +43,9 @@#include <linux/pm_qos.h> #include <linux/reservation.h> #include <linux/shmem_fs.h> +#include <linux/timecounter.h> +#include <linux/clocksource.h> +#include <linux/timekeeping.h> #include <drm/drmP.h> #include <drm/intel-gtt.h>
@@ -2057,6 +2060,12 @@ struct i915_perf_stream {struct i915_gem_active last_request;/** +* @last_sample_ts: monotonic_raw clk timestamp (in ns) for last sample +* belonging to this perf stream. +*/ +u64 last_sample_ts; + +/** * @ops: The callbacks providing the implementation of this specific * type of configured stream. */
@@ -2212,6 +2221,20 @@ struct i915_perf_cs_sample {u32 tag; }; +/** +* struct i915_clock_info - decribes i915 timestamp clock +* +*/ +struct i915_clock_info { +struct cyclecounter cc; +struct timecounter tc; +struct system_device_crosststamp xtstamp; +ktime_t clk_offset;/* Offset (in ns) between monoraw clk and gpu time */ +u32 timestamp_frequency; +u32 resync_period;/* in msecs */ +struct delayed_work clk_sync_work; +}; +struct intel_cdclk_state {unsigned int cdclk, vco, ref; };
@@ -2533,6 +2556,8 @@ struct drm_i915_private {struct i915_runtime_pm pm; +struct i915_clock_info ts_clk_info; +struct {bool initialized;
@@ -3889,6 +3914,7 @@ int intel_engine_cmd_parser(struct intel_engine_cs *engine,/* i915_perf.c */ extern void i915_perf_init (struct drm_i915_private *dev_priv); +extern void i915_perf_init_late (struct drm_i915_private *dev_priv);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);
drivers/gpu/drm/i915/i915_perf.c +256 -11
406 lines not on this page · raw message
include/uapi/drm/i915_drm.h +8 -1
@@ -1396,6 +1396,12 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_SAMPLE_TS , +/** +* This property requests inclusion of CLOCK_MONOTONIC system time in +* the perf sample data. +*/ +DRM_I915_PERF_PROP_SAMPLE_CLOCK_MONOTONIC_RAW , + DRM_I915_PERF_PROP_MAX /* non-ABI */ };
@@ -1465,7 +1471,8 @@ enum drm_i915_perf_record_type {* { u32 ctx_id; } && DRM_I915_PERF_PROP_SAMPLE_CTX_ID * { u32 pid; } && DRM_I915_PERF_PROP_SAMPLE_PID * { u32 tag; } && DRM_I915_PERF_PROP_SAMPLE_TAG -* { u64 timestamp; } && DRM_I915_PERF_PROP_SAMPLE_TS +* { u64 gpu_ts; } && DRM_I915_PERF_PROP_SAMPLE_TS +* { u64 clk_mono; } && DRM_I915_PERF_PROP_SAMPLE_CLOCK_MONOTONIC * { 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 6/6 drm/i915: Support for capturing MMIO register values
In reply to [email protected]From: 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.
--- drivers/gpu/drm/i915/i915_drv.h | 11 +++ drivers/gpu/drm/i915/i915_perf.c | 157 ++++++++++++++++++++++++++++++++++++++- include/uapi/drm/i915_drm.h | 14 ++++ 3 files changed, 179 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +11 -0
@@ -2194,6 +2194,14 @@ struct i915_perf_cs_sample {u32 ts_offset;/** +* @mmio_offset: Offset into ``&drm_i915_private-> +* perf.command_stream_buf`` 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;
@@ -2576,6 +2584,9 @@ struct drm_i915_private {wait_queue_head_t poll_wq[I915_NUM_ENGINES ];bool pollin[I915_NUM_ENGINES ]; +u32 num_mmio; +u32 mmio_list[I915_PERF_MMIO_NUM_MAX ]; +struct {u32 specific_ctx_id;
drivers/gpu/drm/i915/i915_perf.c +154 -3
249 lines not on this page · raw message
include/uapi/drm/i915_drm.h +14 -0
@@ -1324,6 +1324,12 @@ enum drm_i915_perf_oa_event_source {I915_PERF_OA_EVENT_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
@@ -1402,6 +1408,13 @@ enum drm_i915_perf_property_id {*/ DRM_I915_PERF_PROP_SAMPLE_CLOCK_MONOTONIC_RAW , +/** +* 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 */ };
@@ -1473,6 +1486,7 @@ enum drm_i915_perf_record_type {* { u32 tag; } && DRM_I915_PERF_PROP_SAMPLE_TAG * { u64 gpu_ts; } && DRM_I915_PERF_PROP_SAMPLE_TS * { u64 clk_mono; } && DRM_I915_PERF_PROP_SAMPLE_CLOCK_MONOTONIC +* { 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
Re: [PATCH 6/6] drm/i915: Support for capturing MMIO register values
Quoted 9 lines · On Thu, Mar 16, 2017 at 11:50:11AM +0530, [email protected] wrote:
drivers/gpu/drm/i915/i915_perf.c +9
-0+static int copy_mmio_list (struct drm_i915_private *dev_priv, +void __user *mmio) +{ +void __user *mmio_list = ((u8 __user *)mmio +4 ); +u32 num_mmio; +int ret; + +if (!mmio) +return -EINVAL ;
drivers/gpu/drm/i915/i915_perf.c static int i915_perf_release(struct inode *inode, struct file *file) · line 4121
Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +10
-0+ + ret =get_user (num_mmio, (u32 __user *)mmio); +if (ret) +return ret; + +if (num_mmio >I915_PERF_MMIO_NUM_MAX ) +return -EINVAL ; + +memset (dev_priv->perf.mmio_list,0 ,I915_PERF_MMIO_NUM_MAX ); +if (copy_from_user (dev_priv->perf.mmio_list, mmio_list,4 *num_mmio))
return -EFAULT;
check all the others (copy_from_user and copy_to_user). -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx