Add support for EU stall sampling
Subsystems (3)
v9 cover Add support for EU stall sampling
The following patch series add support for EU stall sampling, a new hardware feature first added in PVC and is being supported in XE2 and later architecture GPUs. This feature would enable capturing of EU stall data which include the IP address of the instruction stalled and various stall reason counts.
Support for this feature is being added into Mesa:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30142
New IGT tests for EU stall sampling are being added:
https://patchwork.freedesktop.org/series/143030/
This patch series has undergone basic testing with the new IGT tests.
Thank You.
v9: a. Split the big patch in v8 into two patches
b. Moved all drop data handling code into one patch
c. Several other code improvements as mentioned in the patches
v8: a. Used div_u64() instead of / to fix 32-bit build issue.
b. Changed copyright year in new files to 2025.
c. Renamed struct drm_xe_eu_stall_data_pvc to struct xe_eu_stall_data_pvc d. Renamed struct drm_xe_eu_stall_data_xe2 to struct xe_eu_stall_data_xe2
v7: a. Renamed input property DRM_XE_EU_STALL_PROP_EVENT_REPORT_COUNT
to DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS to be consistent with OA. Renamed the corresponding internal variables.
b. Fixed some commit messages based on review feedback. c. Changed sampling_rates from a pointer to flexible array.
v6: a. Changed the uAPI input to accept sampling rate in GPU cycles
instead of sampling rate multiplier.
b. Fix buffer wrap around over write bug (Matt Olson).
c. Include EU stall sampling rates information and per XeCore buffer size in the query information.
v5: Addressed review feedback from v4 including
a. Removed DRM_XE_EU_STALL_PROP_POLL_PERIOD from the uAPI (Ashutosh)
b. Separated the patches for Xe_HPC and Xe2 (Matt R)
c. Moved read() returning -EIO into a separate patch
d. Removed spinlocks around set_bit() and clear_bit() (Matt R)
e. Renamed several variables, structures and enums (Ashutosh and
Matt R)
f. Addressed other review feedback.
v4: Addressed review feedback from v3 including
a. Split the patch into multiple patches (Matt R)
b. Added a new device query to get EU stall info (Ashutosh)
c. Renamed all Dss to xecore (Matt R)
d. Removed buffer size and disable at open input properties. (Matt R)
e. Removed the "_SHIFT" macros (Matt R)
f. Allocate the EU stall buffer only on system memory.
g. Changed the work arounds to OOB (Matt R)
h. Other review feedback.
v3: a. Removed data header and changed read() to return -EIO when data is dropped by the HW.
b. Added a new DRM_XE_OBSERVATION_IOCTL_INFO to query EU stall data record info c. Added struct drm_xe_eu_stall_data_pvc and struct drm_xe_eu_stall_data_xe2
to xe_drm.h. These declarations would help user space to parse the
EU stall data
d. Addressed other review comments from v2
v2: Rename xe perf layer as xe observation layer (Ashutosh)
Harish Chegondi (8):
drm/xe/topology: Add a function to find the index of the last enabled
DSS in a mask
drm/xe/uapi: Introduce API for EU stall sampling drm/xe/eustall: Add support to init, enable and disable EU stall
sampling
drm/xe/eustall: Add support to read() and poll() EU stall data drm/xe/eustall: Add support to handle dropped EU stall data drm/xe/eustall: Add EU stall sampling support for Xe2 drm/xe/uapi: Add a device query to get EU stall sampling information drm/xe/eustall: Add workaround 22016596838 which applies to PVC.
drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_eu_stall_regs.h | 29 + drivers/gpu/drm/xe/xe_eu_stall.c | 1029 ++++++++++++++++++++ drivers/gpu/drm/xe/xe_eu_stall.h | 21 + drivers/gpu/drm/xe/xe_gt.c | 6 + drivers/gpu/drm/xe/xe_gt_topology.h | 13 + drivers/gpu/drm/xe/xe_gt_types.h | 3 + drivers/gpu/drm/xe/xe_observation.c | 14 + drivers/gpu/drm/xe/xe_query.c | 38 + drivers/gpu/drm/xe/xe_trace.h | 33 + drivers/gpu/drm/xe/xe_wa_oob.rules | 1 + include/uapi/drm/xe_drm.h | 74 ++ 12 files changed, 1262 insertions(+) create mode 100644 drivers/gpu/drm/xe/regs/xe_eu_stall_regs.h create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.c create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.h
Signature · 1 line
2.48.1
PATCH v9 1/8 drm/xe/topology: Add a function to find the index of the last enabled DSS in a mask
Last enabled DSS in a DSS mask can help estimate the maximum DSSes enabled in the DSS mask, as the enabled DSSes can be discontiguous.
--- drivers/gpu/drm/xe/xe_gt_topology.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/xe/xe_gt_topology.h +13 -0
@@ -25,6 +25,19 @@ void xe_gt_topology_init(struct xe_gt *gt);void xe_gt_topology_dump (struct xe_gt *gt,struct drm_printer *p); +/** +* xe_gt_topology_mask_last_dss() - Returns the index of the last DSS in a mask. +* @mask: Input DSS mask +* +* Return: Index of the last DSS in the input DSS mask, +* XE_MAX_DSS_FUSE_BITS if DSS mask is empty. +*/ +static inline unsigned int +xe_gt_topology_mask_last_dss (const xe_dss_mask_t mask) +{ +return find_last_bit (mask,XE_MAX_DSS_FUSE_BITS ); +} +unsigned int xe_dss_mask_group_ffs (const xe_dss_mask_t mask,int groupsize,int groupnum);
Signature · 1 line
2.48.1
Re: [PATCH v9 1/8] drm/xe/topology: Add a function to find the index of the last enabled DSS in a mask
drivers/gpu/drm/xe/xe_gt_topology.h void xe_gt_topology_init(struct xe_gt *gt); · line 38
Quoted 5 lines · Harish Chegondi
drivers/gpu/drm/xe/xe_gt_topology.h +4
-0+static inline unsigned int +xe_gt_topology_mask_last_dss (const xe_dss_mask_t mask) +{ +return find_last_bit (mask,XE_MAX_DSS_FUSE_BITS );
I am still wondering if this function should be in the .c instead, because we have not included linux/find.h where find_last_bit is declared, and if this might have problems of circular depenedencies in the future. Anyway, for now things are compiling so this is:
Quoted 8 lines
drivers/gpu/drm/xe/xe_gt_topology.h +2
-1+} +unsigned int xe_dss_mask_group_ffs (const xe_dss_mask_t mask,int groupsize,int groupnum); --2.48.1
PATCH v9 2/8 drm/xe/uapi: Introduce API for EU stall sampling
In reply to Harish ChegondiA new hardware feature first introduced in PVC gives capability to periodically sample EU stall state and record counts for different stall reasons, on a per IP basis, aggregate across all EUs in a subslice and record the samples in a buffer in each subslice. Eventually, the aggregated data is written out to a buffer in the memory. This feature is also supported in XE2 and later architecture GPUs.
Use an existing IOCTL - DRM_IOCTL_XE_OBSERVATION as the interface into the driver from the user space to do initial setup and obtain a file descriptor for the EU stall data stream. Input parameter to the IOCTL is a struct drm_xe_observation_param in which observation_type should be set to DRM_XE_OBSERVATION_TYPE_EU_STALL, observation_op should be DRM_XE_OBSERVATION_OP_STREAM_OPEN and param should point to a chain of drm_xe_ext_set_property structures in which each structure has a pair of property and value. The EU stall sampling input properties are defined in drm_xe_eu_stall_property_id enum.
With the file descriptor obtained from DRM_IOCTL_XE_OBSERVATION, user space can enable and disable EU stall sampling with the IOCTLs:DRM_XE_OBSERVATION_IOCTL_ENABLE and DRM_XE_OBSERVATION_IOCTL_DISABLE. User space can also call poll() to check for availability of data in the buffer. The data can be read with read(). Finally, the file descriptor can be closed with close().
v9: Changed some u32 to unsigned int.
Moved some code around as per review feedback from v8.
v8: Used div_u64 instead of / to fix 32-bit build issue.
Changed copyright year in xe_eu_stall.c/h to 2025.
v7: Renamed input property DRM_XE_EU_STALL_PROP_EVENT_REPORT_COUNT
to DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS to be consistent with OA. Renamed the corresponding internal variables. Fixed some commit messages based on review feedback.
v6: Change the input sampling rate to GPU cycles instead of
GPU cycles multiplier.
--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_eu_stall.c | 280 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_eu_stall.h | 16 ++ drivers/gpu/drm/xe/xe_observation.c | 14 ++ include/uapi/drm/xe_drm.h | 38 ++++ 5 files changed, 349 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.c create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.h
drivers/gpu/drm/xe/Makefile +1 -0
@@ -33,6 +33,7 @@ xe-y += xe_bb.o \ xe_device_sysfs.o \ xe_dma_buf.o \ xe_drm_client.o \ + xe_eu_stall.o \ xe_exec.o \ xe_exec_queue.o \ xe_execlist.o \
drivers/gpu/drm/xe/xe_eu_stall.c new file +280 -0
280 lines not on this page · raw message
drivers/gpu/drm/xe/xe_eu_stall.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef __XE_EU_STALL_H__ +#define __XE_EU_STALL_H__ + +#include <drm/drm_device.h> +#include <drm/drm_file.h> +#include <linux/types.h> + +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file); +#endif
drivers/gpu/drm/xe/xe_observation.c +14 -0
@@ -9,6 +9,7 @@#include <uapi/drm/xe_drm.h> #include "xe_oa.h" +#include "xe_eu_stall.h" #include "xe_observation.h" u32 xe_observation_paranoid = true;
@@ -29,6 +30,17 @@ static int xe_oa_ioctl(struct drm_device *dev, struct drm_xe_observation_param * } } +static int xe_eu_stall_ioctl (struct drm_device *dev,struct drm_xe_observation_param *arg, +struct drm_file *file) +{ +switch (arg->observation_op) { +case DRM_XE_OBSERVATION_OP_STREAM_OPEN : +return xe_eu_stall_stream_open (dev, arg->param, file); +default : +return -EINVAL ; + } +} +/** * xe_observation_ioctl - The top level observation layer ioctl * @dev: @drm_device
@@ -51,6 +63,8 @@ int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *fiswitch (arg->observation_type) {case DRM_XE_OBSERVATION_TYPE_OA :return xe_oa_ioctl (dev, arg, file); +case DRM_XE_OBSERVATION_TYPE_EU_STALL : +return xe_eu_stall_ioctl (dev, arg, file);default :return -EINVAL ; }
include/uapi/drm/xe_drm.h +38 -0
@@ -1496,6 +1496,8 @@ struct drm_xe_wait_user_fence {enum drm_xe_observation_type {/** @DRM_XE_OBSERVATION_TYPE_OA: OA observation stream type */ DRM_XE_OBSERVATION_TYPE_OA , +/** @DRM_XE_OBSERVATION_TYPE_EU_STALL: EU stall sampling observation stream type */ +DRM_XE_OBSERVATION_TYPE_EU_STALL , };/**
@@ -1848,6 +1850,42 @@ enum drm_xe_pxp_session_type {/* ID of the protected content session managed by Xe when PXP is active */ #define DRM_XE_PXP_HWDRM_DEFAULT_SESSION 0xf +/** +* enum drm_xe_eu_stall_property_id - EU stall sampling input property ids. +* +* These properties are passed to the driver at open as a chain of +* @drm_xe_ext_set_property structures with @property set to these +* properties' enums and @value set to the corresponding values of these +* properties. @drm_xe_user_extension base.name should be set to +* @DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY. +* +* With the file descriptor obtained from open, user space must enable +* the EU stall stream fd with @DRM_XE_OBSERVATION_IOCTL_ENABLE before +* calling read(). EIO errno from read() indicates HW dropped data +* due to full buffer. +*/ +enum drm_xe_eu_stall_property_id { +#define DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY 0 +/** +* @DRM_XE_EU_STALL_PROP_GT_ID: @gt_id of the GT on which +* EU stall data will be captured. + */ +DRM_XE_EU_STALL_PROP_GT_ID =1 , + +/** +* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate +* in GPU cycles. +*/ +DRM_XE_EU_STALL_PROP_SAMPLE_RATE , + +/** +* @DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS: Minimum number of +* EU stall data reports to be present in the kernel buffer +* before unblocking poll or read that is blocked. +*/ +DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS , +}; +#if defined(__cplusplus) }#endif
Signature · 1 line
2.48.1
Re: [PATCH v9 2/8] drm/xe/uapi: Introduce API for EU stall sampling
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 86 lines
A new hardware feature first introduced in PVC gives capability to periodically sample EU stall state and record counts for different stall reasons, on a per IP basis, aggregate across all EUs in a subslice and record the samples in a buffer in each subslice. Eventually, the aggregated data is written out to a buffer in the memory. This feature is also supported in XE2 and later architecture GPUs.
Use an existing IOCTL -
DRM_IOCTL_XE_OBSERVATIONas the interface into the driver from the user space to do initial setup and obtain a file descriptor for the EU stall data stream. Input parameter to the IOCTL is a structdrm_xe_observation_paramin whichobservation_typeshould be set toDRM_XE_OBSERVATION_TYPE_EU_STALL,observation_opshould beDRM_XE_OBSERVATION_OP_STREAM_OPENand param should point to a chain ofdrm_xe_ext_set_propertystructures in which each structure has a pair of property and value. The EU stall sampling input properties are defined indrm_xe_eu_stall_property_idenum.With the file descriptor obtained from
DRM_IOCTL_XE_OBSERVATION, user space can enable and disable EU stall sampling with the IOCTLs:DRM_XE_OBSERVATION_IOCTL_ENABLEandDRM_XE_OBSERVATION_IOCTL_DISABLE. User space can also callpoll()to check for availability of data in the buffer. The data can be read withread(). Finally, the file descriptor can be closed withclose().v9: Changed some u32 to unsigned int.
Moved some code around as per review feedback from v8.
v8: Useddiv_u64instead of / to fix 32-bit build issue.
Changed copyright year in xe_eu_stall.c/h to 2025.
v7: Renamed input propertyDRM_XE_EU_STALL_PROP_EVENT_REPORT_COUNT
toDRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTSto be consistent with OA. Renamed the corresponding internal variables. Fixed some commit messages based on review feedback.
v6: Change the input sampling rate to GPU cycles instead of
GPU cycles multiplier.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_eu_stall.c | 280 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_eu_stall.h | 16 ++ drivers/gpu/drm/xe/xe_observation.c | 14 ++ include/uapi/drm/xe_drm.h | 38 ++++ 5 files changed, 349 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.c create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.hdrivers/gpu/drm/xe/Makefile +1
-0@@ -33,6 +33,7 @@ xe-y += xe_bb.o \ xe_device_sysfs.o \ xe_dma_buf.o \ xe_drm_client.o \ + xe_eu_stall.o \ xe_exec.o \ xe_exec_queue.o \ xe_execlist.o \drivers/gpu/drm/xe/xe_eu_stall.c new file +22
-0@@ -0,0 +1,280 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +*/ + +#include <linux/anon_inodes.h> +#include <linux/fs.h> +#include <linux/poll.h> +#include <linux/types.h> + +#include <uapi/drm/xe_drm.h> + +#include "xe_device.h" +#include "xe_eu_stall.h" +#include "xe_gt_printk.h" +#include "xe_gt_topology.h" +#include "xe_macros.h" +#include "xe_observation.h" + +static size_t per_xecore_buf_size =SZ_512K ; + +/**
drivers/gpu/drm/xe/xe_eu_stall.c line 32
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+* struct eu_stall_open_properties - EU stall sampling properties received +* from user space at open. +* @sampling_rate_mult: EU stall sampling rate multiplier. +* HW will sample every (sampling_rate_mult x 251) cycles. +* @wait_num_reports: Minimum number of EU stall data reports to unblock poll(). +* @gt: GT on which EU stall data will be captured. +*/ +struct eu_stall_open_properties { +unsigned int sampling_rate_mult; +unsigned int wait_num_reports;
I already said no need to be so specific. Just use int or u32 as types for these.
Quoted 22 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +22
-0+struct xe_gt *gt; +}; + +/** +* num_data_rows - Return the number of EU stall data rows of 64B each +* for a given data size. +* +* @data_size: EU stall data size +*/ +static u32 num_data_rows (u32 data_size) +{ +return (data_size >>6 ); +} + +static int set_prop_eu_stall_sampling_rate (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ + value =div_u64 (value,251 ); +if (value ==0 || value >7 ) { +drm_dbg (&xe->drm,"Invalid EU stall sampling rate %llu\n" , value); +return -EINVAL ; + }
drivers/gpu/drm/xe/xe_eu_stall.c line 64
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+ props->sampling_rate_mult = value; +return 0 ; +} + +static int set_prop_eu_stall_wait_num_reports (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ +unsigned int max_wait_num_reports; + + max_wait_num_reports =num_data_rows (per_xecore_buf_size *XE_MAX_DSS_FUSE_BITS );
This seems wrong. Instead of XE_MAX_DSS_FUSE_BITS, shouldn't we use the value returned by xe_gt_topology_mask_last_dss()?
Note that a large value can result in the poll/read never getting unblocked!
To solve this issue I think num_xecore should be maintained in struct xe_eu_stall_gt. Though let's see what happens to 'struct xe_device *' arg to these functions if we do this.
Quoted 48 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +48
-0+if (value ==0 || value > max_wait_num_reports) { +drm_dbg (&xe->drm,"Invalid EU stall event report count %llu\n" , value); +drm_dbg (&xe->drm,"Minimum event report count is 1, maximum is %u\n" , + max_wait_num_reports); +return -EINVAL ; + } + props->wait_num_reports = value; +return 0 ; +} + +static int set_prop_eu_stall_gt_id (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ +if (value >= xe->info.gt_count) { +drm_dbg (&xe->drm,"Invalid GT ID %llu for EU stall sampling\n" , value); +return -EINVAL ; + } + props->gt =xe_device_get_gt (xe, value); +return 0 ; +} + +typedef int (*set_eu_stall_property_fn )(struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props); + +static const set_eu_stall_property_fn xe_set_eu_stall_property_funcs[] = { + [DRM_XE_EU_STALL_PROP_SAMPLE_RATE ] = set_prop_eu_stall_sampling_rate, + [DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS ] = set_prop_eu_stall_wait_num_reports, + [DRM_XE_EU_STALL_PROP_GT_ID ] = set_prop_eu_stall_gt_id, +}; + +static int xe_eu_stall_user_ext_set_property (struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props) +{ +u64 __user *address =u64_to_user_ptr (extension); +struct drm_xe_ext_set_property ext; +int err; +u32 idx; + + err =__copy_from_user (&ext, address,sizeof (ext)); +if (XE_IOCTL_DBG (xe, err)) +return -EFAULT ; + +if (XE_IOCTL_DBG (xe, ext.property >=ARRAY_SIZE (xe_set_eu_stall_property_funcs)) || +XE_IOCTL_DBG (xe, ext.pad)) +return -EINVAL ; + + idx =array_index_nospec (ext.property,ARRAY_SIZE (xe_set_eu_stall_property_funcs)); +return xe_set_eu_stall_property_funcs[idx](xe, ext.value, props);
drivers/gpu/drm/xe/xe_eu_stall.c line 122
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+} + +typedef int (*xe_eu_stall_user_extension_fn )(struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props); +static const xe_eu_stall_user_extension_fn xe_eu_stall_user_extension_funcs[] = { + [DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY ] = xe_eu_stall_user_ext_set_property, +}; + +static int xe_eu_stall_user_extensions (struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props)
What is the reason for not using the ext_number argument here, which is used in both exec_queue_user_extensions and in xe_oa_user_extensions?
The reason for ext_number is that the extensions can be chained in a loop, which can cause an infinite loop in the kernel when parsing these extensions. ext_number is used to break out of these potential infinite loops.
Quoted 25 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +25
-0+{ +u64 __user *address =u64_to_user_ptr (extension); +struct drm_xe_user_extension ext; +int err; +u32 idx; + + err =__copy_from_user (&ext, address,sizeof (ext)); +if (XE_IOCTL_DBG (xe, err)) +return -EFAULT ; + +if (XE_IOCTL_DBG (xe, ext.pad) || +XE_IOCTL_DBG (xe, ext.name >=ARRAY_SIZE (xe_eu_stall_user_extension_funcs))) +return -EINVAL ; + + idx =array_index_nospec (ext.name,ARRAY_SIZE (xe_eu_stall_user_extension_funcs)); + err = xe_eu_stall_user_extension_funcs[idx](xe, extension, props); +if (XE_IOCTL_DBG (xe, err)) +return err; + +if (ext.next_extension) +return xe_eu_stall_user_extensions (xe, ext.next_extension, props); + +return 0 ; +} +
drivers/gpu/drm/xe/xe_eu_stall.c line 157
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+/** +* xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* @ppos: (inout) file seek position (unused) +* +* Userspace must enable the EU stall stream with DRM_XE_OBSERVATION_IOCTL_ENABLE +* before calling read().
We can just retain these two lines of comment. See below.
Quoted 38 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +38
-0+* +* Returns: The number of bytes copied or a negative error code on failure. +*/ +static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf, +size_t count,loff_t *ppos) +{ +ssize_t ret =0 ; + +return ret; +} + +/** +* xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @wait: Poll table +* +* Returns: Bit mask of returned events. +*/ +static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) +{ +__poll_t ret =0 ; + +return ret; +} + +/** +* xe_eu_stall_stream_ioctl - support ioctl() of a xe EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @cmd: the ioctl request +* @arg: the ioctl data +* +* Returns: zero on success or a negative error code. +* -EINVAL for an unknown ioctl request. +*/ +static long xe_eu_stall_stream_ioctl(struct file *file, + unsigned int cmd,
drivers/gpu/drm/xe/xe_eu_stall.c line 205
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+ unsigned long arg) +{ +switch (cmd) { +case DRM_XE_OBSERVATION_IOCTL_ENABLE : +return 0 ; +case DRM_XE_OBSERVATION_IOCTL_DISABLE : +return 0 ; + } + +return -EINVAL ;
Just return 0 or -EINVAL in this patch since you are going to add locking in a later patch.
drivers/gpu/drm/xe/xe_eu_stall.c line 215
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+} + +/** +* xe_eu_stall_stream_close - handles userspace close() of a EU stall data +* stream file. +* @inode: anonymous inode associated with file +* @file: An xe EU stall data stream file +* +* Cleans up any resources associated with an open EU stall data stream file. +*/
As I said before, these comments are completely redundant. These are standard file_operations. There are one million instances of these in the kernel, all of them have exactly the same arguments.
If you have anything specific to EU stall here, we can leave it. Otherwise I'd still say get rid of them.
Or get rid them now and send a patch later to add them, we can review that patch later, if you really think they add value. They were included in i915_perf.c, but I don't think they should be in Xe.
If you think these comments should be there, let's get a second opinion, from one of the maintainers.
Quoted 38 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +38
-0+static int xe_eu_stall_stream_close (struct inode *inode,struct file *file) +{ +return 0 ; +} + +static const struct file_operations fops_eu_stall = { + .owner =THIS_MODULE , + .llseek = noop_llseek, + .release = xe_eu_stall_stream_close, + .poll = xe_eu_stall_stream_poll, + .read = xe_eu_stall_stream_read, + .unlocked_ioctl = xe_eu_stall_stream_ioctl, + .compat_ioctl = xe_eu_stall_stream_ioctl, +}; + +static inline bool has_eu_stall_sampling_support (struct xe_device *xe) +{ +return false; +} + +/** +* xe_eu_stall_stream_open - Open a xe EU stall data stream fd +* +* @dev: DRM device pointer +* @data: pointer to first struct @drm_xe_ext_set_property in +* the chain of input properties from the user space. +* @file: DRM file pointer +* +* This function opens a EU stall data stream with input properties from +* the user space. +* +* Returns: EU stall data stream fd on success or a negative error code. +*/ +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file) +{ +struct xe_device *xe =to_xe_device (dev);
drivers/gpu/drm/xe/xe_eu_stall.c line 263
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+struct eu_stall_open_properties props = {}; +int ret, stream_fd; + +if (xe_observation_paranoid && !perfmon_capable ()) { +xe_gt_dbg (props.gt,"Insufficient privileges for EU stall monitoring\n" ); +return -EACCES ; + } +if (!has_eu_stall_sampling_support (xe)) { +xe_gt_dbg (props.gt,"EU stall monitoring is not supported on this platform\n" ); +return -EPERM ;
I think we are using -ENODEV for this, at least in OA.
drivers/gpu/drm/xe/xe_eu_stall.c line 264
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c new file +1
-0+ }
Move this has_eu_stall_sampling_support at the top, this should be even before the perfmon_capable check.
drivers/gpu/drm/xe/xe_eu_stall.c line 273
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +9
-0+ + ret =xe_eu_stall_user_extensions (xe, data, &props); +if (ret) +return ret; + +if (!props.gt) { +drm_dbg (&xe->drm,"GT ID not provided for EU stall sampling\n" ); +return -EINVAL ; + }
This check is not needed. props.gt cannot be NULL the way set_prop_eu_stall_gt_id is implemented.
If you need it, use xe_assert(props->gt) in set_prop_eu_stall_gt_id.
Quoted 14 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +7
-0+ + stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall,NULL ,0 ); +if (stream_fd <0 ) +xe_gt_dbg (props.gt,"EU stall inode get fd failed : %d\n" , stream_fd); + +return stream_fd; +}drivers/gpu/drm/xe/xe_eu_stall.h new file +1
-0@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT */
drivers/gpu/drm/xe/xe_eu_stall.h line 11
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.h new file +10
-0+/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef __XE_EU_STALL_H__ +#define __XE_EU_STALL_H__ + +#include <drm/drm_device.h> +#include <drm/drm_file.h> +#include <linux/types.h>
Because these lines are replaced in a future patch with '#include "xe_gt_types.h"', just do that in this patch itself.
Also, as I said, I am not going to focus too much on the patches, only the final code, but in general, if you are deleting lines in these initial patches, think hard about why you need delete those lines and what you could do differently.
Quoted 83 lines
drivers/gpu/drm/xe/xe_eu_stall.h new file +5
-0+ +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file); +#endif drivers/gpu/drm/xe/xe_observation.c +14
-0@@ -9,6 +9,7 @@#include <uapi/drm/xe_drm.h> #include "xe_oa.h" +#include "xe_eu_stall.h" #include "xe_observation.h" u32 xe_observation_paranoid = true;@@ -29,6 +30,17 @@ static int xe_oa_ioctl(struct drm_device *dev, struct drm_xe_observation_param * } } +static int xe_eu_stall_ioctl (struct drm_device *dev,struct drm_xe_observation_param *arg, +struct drm_file *file) +{ +switch (arg->observation_op) { +case DRM_XE_OBSERVATION_OP_STREAM_OPEN : +return xe_eu_stall_stream_open (dev, arg->param, file); +default : +return -EINVAL ; + } +} +/** * xe_observation_ioctl - The top level observation layer ioctl * @dev: @drm_device @@ -51,6 +63,8 @@ int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *fiswitch (arg->observation_type) {case DRM_XE_OBSERVATION_TYPE_OA :return xe_oa_ioctl (dev, arg, file); +case DRM_XE_OBSERVATION_TYPE_EU_STALL : +return xe_eu_stall_ioctl (dev, arg, file);default :return -EINVAL ; }include/uapi/drm/xe_drm.h +24
-0@@ -1496,6 +1496,8 @@ struct drm_xe_wait_user_fence {enum drm_xe_observation_type {/** @DRM_XE_OBSERVATION_TYPE_OA: OA observation stream type */ DRM_XE_OBSERVATION_TYPE_OA , +/** @DRM_XE_OBSERVATION_TYPE_EU_STALL: EU stall sampling observation stream type */ +DRM_XE_OBSERVATION_TYPE_EU_STALL , };/** @@ -1848,6 +1850,42 @@ enum drm_xe_pxp_session_type {/* ID of the protected content session managed by Xe when PXP is active */ #define DRM_XE_PXP_HWDRM_DEFAULT_SESSION 0xf +/** +* enum drm_xe_eu_stall_property_id - EU stall sampling input property ids. +* +* These properties are passed to the driver at open as a chain of +* @drm_xe_ext_set_property structures with @property set to these +* properties' enums and @value set to the corresponding values of these +* properties. @drm_xe_user_extension base.name should be set to +* @DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY. +* +* With the file descriptor obtained from open, user space must enable +* the EU stall stream fd with @DRM_XE_OBSERVATION_IOCTL_ENABLE before +* calling read(). EIO errno from read() indicates HW dropped data +* due to full buffer. +*/ +enum drm_xe_eu_stall_property_id { +#define DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY 0 +/** +* @DRM_XE_EU_STALL_PROP_GT_ID: @gt_id of the GT on which +* EU stall data will be captured. + */ +DRM_XE_EU_STALL_PROP_GT_ID =1 , +
include/uapi/drm/xe_drm.h enum drm_xe_pxp_session_type { · line 1884
Quoted 10 lines
include/uapi/drm/xe_drm.h +10
-0+/** +* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate +* in GPU cycles. +*/ + DRM_XE_EU_STALL_PROP_SAMPLE_RATE, + +/** +* @DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS: Minimum number of +* EU stall data reports to be present in the kernel buffer +* before unblocking poll or read that is blocked.
before unblocking a blocked poll or read
Quoted 10 lines
include/uapi/drm/xe_drm.h +4
-1+*/ + DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS, +}; +#if defined(__cplusplus) }#endif --2.48.1
Re: [PATCH v9 2/8] drm/xe/uapi: Introduce API for EU stall sampling
Quoted 14 lines · Ashutosh
drivers/gpu/drm/xe/xe_eu_stall.c line 273
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +9
-0+ + ret =xe_eu_stall_user_extensions (xe, data, &props); +if (ret) +return ret; + +if (!props.gt) { +drm_dbg (&xe->drm,"GT ID not provided for EU stall sampling\n" ); +return -EINVAL ; + }This check is not needed. props.gt cannot be NULL the way
set_prop_eu_stall_gt_idis implemented.
Quoted 1 line
If you need it, use
xe_assert(props->gt)inset_prop_eu_stall_gt_id.
Sorry, this is needed in case gt_id is not provided by userland. Unless default gt_id can be 0, in which case this is not needed?
Re: [PATCH v9 2/8] drm/xe/uapi: Introduce API for EU stall sampling
In reply to Dixit, AshutoshQuoted 23 lines · Ashutosh
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +8
-0+static int set_prop_eu_stall_sampling_rate (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ + value =div_u64 (value,251 ); +if (value ==0 || value >7 ) { +drm_dbg (&xe->drm,"Invalid EU stall sampling rate %llu\n" , value); +return -EINVAL ; + }drivers/gpu/drm/xe/xe_eu_stall.c line 64
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+ props->sampling_rate_mult = value; +return 0 ; +} + +static int set_prop_eu_stall_wait_num_reports (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ +unsigned int max_wait_num_reports; + + max_wait_num_reports =num_data_rows (per_xecore_buf_size *XE_MAX_DSS_FUSE_BITS );This seems wrong. Instead of
XE_MAX_DSS_FUSE_BITS, shouldn't we use the value returned byxe_gt_topology_mask_last_dss()?
Quoted 6 lines
Note that a large value can result in the poll/read never getting unblocked!
To solve this issue I think
num_xecoreshould be maintained in structxe_eu_stall_gt. Though let's see what happens to 'structxe_device*' arg to these functions if we do this.
Also, even with num_xecore (instead of XE_MAX_DSS_FUSE_BITS), I think
max_wait_num_reports = num_data_rows(per_xecore_buf_size * num_xecore)
is a very large value. If user specifies this value, we will almost certainly start dropping data. So maybe max_wait_num_reports should be half of this value?
Or do we just leave this max and let the user deal with -EIO returns?
Anyway something to think about.
Re: [PATCH v9 2/8] drm/xe/uapi: Introduce API for EU stall sampling
In reply to Dixit, AshutoshQuoted 3 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Ashutosh,
Quoted 93 lines
Hi Harish,
Quoted 91 lines
A new hardware feature first introduced in PVC gives capability to periodically sample EU stall state and record counts for different stall reasons, on a per IP basis, aggregate across all EUs in a subslice and record the samples in a buffer in each subslice. Eventually, the aggregated data is written out to a buffer in the memory. This feature is also supported in XE2 and later architecture GPUs.
Use an existing IOCTL -
DRM_IOCTL_XE_OBSERVATIONas the interface into the driver from the user space to do initial setup and obtain a file descriptor for the EU stall data stream. Input parameter to the IOCTL is a structdrm_xe_observation_paramin whichobservation_typeshould be set toDRM_XE_OBSERVATION_TYPE_EU_STALL,observation_opshould beDRM_XE_OBSERVATION_OP_STREAM_OPENand param should point to a chain ofdrm_xe_ext_set_propertystructures in which each structure has a pair of property and value. The EU stall sampling input properties are defined indrm_xe_eu_stall_property_idenum.With the file descriptor obtained from
DRM_IOCTL_XE_OBSERVATION, user space can enable and disable EU stall sampling with the IOCTLs:DRM_XE_OBSERVATION_IOCTL_ENABLEandDRM_XE_OBSERVATION_IOCTL_DISABLE. User space can also callpoll()to check for availability of data in the buffer. The data can be read withread(). Finally, the file descriptor can be closed withclose().v9: Changed some u32 to unsigned int.
Moved some code around as per review feedback from v8.
v8: Useddiv_u64instead of / to fix 32-bit build issue.
Changed copyright year in xe_eu_stall.c/h to 2025.
v7: Renamed input propertyDRM_XE_EU_STALL_PROP_EVENT_REPORT_COUNT
toDRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTSto be consistent with OA. Renamed the corresponding internal variables. Fixed some commit messages based on review feedback.
v6: Change the input sampling rate to GPU cycles instead of
GPU cycles multiplier.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_eu_stall.c | 280 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_eu_stall.h | 16 ++ drivers/gpu/drm/xe/xe_observation.c | 14 ++ include/uapi/drm/xe_drm.h | 38 ++++ 5 files changed, 349 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.c create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.hdrivers/gpu/drm/xe/Makefile +1
-0@@ -33,6 +33,7 @@ xe-y += xe_bb.o \ xe_device_sysfs.o \ xe_dma_buf.o \ xe_drm_client.o \ + xe_eu_stall.o \ xe_exec.o \ xe_exec_queue.o \ xe_execlist.o \drivers/gpu/drm/xe/xe_eu_stall.c new file +27
-0@@ -0,0 +1,280 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +*/ + +#include <linux/anon_inodes.h> +#include <linux/fs.h> +#include <linux/poll.h> +#include <linux/types.h> + +#include <uapi/drm/xe_drm.h> + +#include "xe_device.h" +#include "xe_eu_stall.h" +#include "xe_gt_printk.h" +#include "xe_gt_topology.h" +#include "xe_macros.h" +#include "xe_observation.h" + +static size_t per_xecore_buf_size =SZ_512K ; + +/** +* struct eu_stall_open_properties - EU stall sampling properties received +* from user space at open. +* @sampling_rate_mult: EU stall sampling rate multiplier. +* HW will sample every (sampling_rate_mult x 251) cycles. +* @wait_num_reports: Minimum number of EU stall data reports to unblock poll().
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 32
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+* @gt: GT on which EU stall data will be captured. +*/ +struct eu_stall_open_properties { +unsigned int sampling_rate_mult; +unsigned int wait_num_reports;I already said no need to be so specific. Just use int or u32 as types for these.
Okay, will try to change these back to u8/u32 in the next version.
Quoted 28 lines
Quoted 28 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +27
-0+struct xe_gt *gt; +}; + +/** +* num_data_rows - Return the number of EU stall data rows of 64B each +* for a given data size. +* +* @data_size: EU stall data size +*/ +static u32 num_data_rows (u32 data_size) +{ +return (data_size >>6 ); +} + +static int set_prop_eu_stall_sampling_rate (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ + value =div_u64 (value,251 ); +if (value ==0 || value >7 ) { +drm_dbg (&xe->drm,"Invalid EU stall sampling rate %llu\n" , value); +return -EINVAL ; + } + props->sampling_rate_mult = value; +return 0 ; +} + +static int set_prop_eu_stall_wait_num_reports(struct xe_device *xe, u64 value,
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 64
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+ struct eu_stall_open_properties *props) +{ +unsigned int max_wait_num_reports; + + max_wait_num_reports =num_data_rows (per_xecore_buf_size *XE_MAX_DSS_FUSE_BITS );This seems wrong. Instead of
XE_MAX_DSS_FUSE_BITS, shouldn't we use the value returned byxe_gt_topology_mask_last_dss()?
Yes you are correct. But not xe_gt_topology_mask_last_dss() as it would only return the last DSS and the DSSes can be discontiguous. We should use the absolute number of DSSes * buffer size. I can move this validation to xe_eu_stall_stream_init() where we can do a bitmap_weight(all_xecore) to find the actual number of DSSes and return EINVAL if invalid input. I did a simple validation here as I wasn't sure if it is worth doing the extra validation.
Quoted 7 lines
Note that a large value can result in the poll/read never getting unblocked!
To solve this issue I think
num_xecoreshould be maintained in structxe_eu_stall_gt. Though let's see what happens to 'structxe_device*' arg to these functions if we do this.
Probably not required if this validation is done in xe_eu_stall_stream_init() added in the next patch as I described above.
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +53
-0+if (value ==0 || value > max_wait_num_reports) { +drm_dbg (&xe->drm,"Invalid EU stall event report count %llu\n" , value); +drm_dbg (&xe->drm,"Minimum event report count is 1, maximum is %u\n" , + max_wait_num_reports); +return -EINVAL ; + } + props->wait_num_reports = value; +return 0 ; +} + +static int set_prop_eu_stall_gt_id (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ +if (value >= xe->info.gt_count) { +drm_dbg (&xe->drm,"Invalid GT ID %llu for EU stall sampling\n" , value); +return -EINVAL ; + } + props->gt =xe_device_get_gt (xe, value); +return 0 ; +} + +typedef int (*set_eu_stall_property_fn )(struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props); + +static const set_eu_stall_property_fn xe_set_eu_stall_property_funcs[] = { + [DRM_XE_EU_STALL_PROP_SAMPLE_RATE ] = set_prop_eu_stall_sampling_rate, + [DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS ] = set_prop_eu_stall_wait_num_reports, + [DRM_XE_EU_STALL_PROP_GT_ID ] = set_prop_eu_stall_gt_id, +}; + +static int xe_eu_stall_user_ext_set_property (struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props) +{ +u64 __user *address =u64_to_user_ptr (extension); +struct drm_xe_ext_set_property ext; +int err; +u32 idx; + + err =__copy_from_user (&ext, address,sizeof (ext)); +if (XE_IOCTL_DBG (xe, err)) +return -EFAULT ; + +if (XE_IOCTL_DBG (xe, ext.property >=ARRAY_SIZE (xe_set_eu_stall_property_funcs)) || +XE_IOCTL_DBG (xe, ext.pad)) +return -EINVAL ; + + idx =array_index_nospec (ext.property,ARRAY_SIZE (xe_set_eu_stall_property_funcs)); +return xe_set_eu_stall_property_funcs[idx](xe, ext.value, props); +} + +typedef int (*xe_eu_stall_user_extension_fn )(struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props); +static const xe_eu_stall_user_extension_fn xe_eu_stall_user_extension_funcs[] = {
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 122
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+ [DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY] = xe_eu_stall_user_ext_set_property, +}; + +static int xe_eu_stall_user_extensions (struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props)What is the reason for not using the
ext_numberargument here, which is used in bothexec_queue_user_extensionsand inxe_oa_user_extensions?
When I reused this code from the OA code it didn't have the ext_number. I will check that out and make the change.
Quoted 87 lines
The reason for
ext_numberis that the extensions can be chained in a loop, which can cause an infinite loop in the kernel when parsing these extensions.ext_numberis used to break out of these potential infinite loops.Quoted 25 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +25
-0+{ +u64 __user *address =u64_to_user_ptr (extension); +struct drm_xe_user_extension ext; +int err; +u32 idx; + + err =__copy_from_user (&ext, address,sizeof (ext)); +if (XE_IOCTL_DBG (xe, err)) +return -EFAULT ; + +if (XE_IOCTL_DBG (xe, ext.pad) || +XE_IOCTL_DBG (xe, ext.name >=ARRAY_SIZE (xe_eu_stall_user_extension_funcs))) +return -EINVAL ; + + idx =array_index_nospec (ext.name,ARRAY_SIZE (xe_eu_stall_user_extension_funcs)); + err = xe_eu_stall_user_extension_funcs[idx](xe, extension, props); +if (XE_IOCTL_DBG (xe, err)) +return err; + +if (ext.next_extension) +return xe_eu_stall_user_extensions (xe, ext.next_extension, props); + +return 0 ; +} +drivers/gpu/drm/xe/xe_eu_stall.c line 157
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+/** +* xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* @ppos: (inout) file seek position (unused) +* +* Userspace must enable the EU stall stream with DRM_XE_OBSERVATION_IOCTL_ENABLE +* before calling read(). We can just retain these two lines of comment. See below.
Quoted 43 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +43
-0+* +* Returns: The number of bytes copied or a negative error code on failure. +*/ +static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf, +size_t count,loff_t *ppos) +{ +ssize_t ret =0 ; + +return ret; +} + +/** +* xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @wait: Poll table +* +* Returns: Bit mask of returned events. +*/ +static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) +{ +__poll_t ret =0 ; + +return ret; +} + +/** +* xe_eu_stall_stream_ioctl - support ioctl() of a xe EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @cmd: the ioctl request +* @arg: the ioctl data +* +* Returns: zero on success or a negative error code. +* -EINVAL for an unknown ioctl request. +*/ +static long xe_eu_stall_stream_ioctl (struct file *file, +unsigned int cmd, +unsigned long arg) +{ +switch (cmd) { +case DRM_XE_OBSERVATION_IOCTL_ENABLE : +return 0 ;
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 205
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+case DRM_XE_OBSERVATION_IOCTL_DISABLE : +return 0 ; + } + +return -EINVAL ;Just return 0 or
-EINVALin this patch since you are going to add locking in a later patch.
You mean remove the switch statement completely and just return 0 or EINVAL? The intention of this switch statement is to specify the two IOCTLs that will be supported in the uAPI.
Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 215
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+} + +/** +* xe_eu_stall_stream_close - handles userspace close() of a EU stall data +* stream file. +* @inode: anonymous inode associated with file +* @file: An xe EU stall data stream file +* +* Cleans up any resources associated with an open EU stall data stream file. +*/ As I said before, these comments are completely redundant. These are standard
file_operations. There are one million instances of these in the kernel, all of them have exactly the same arguments.If you have anything specific to EU stall here, we can leave it. Otherwise I'd still say get rid of them.
Quoted 7 lines
Or get rid them now and send a patch later to add them, we can review that patch later, if you really think they add value. They were included in
i915_perf.c, but I don't think they should be in Xe.If you think these comments should be there, let's get a second opinion, from one of the maintainers.
Okay, will get feedback from a maintainer and will update.
Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +42
-0+static int xe_eu_stall_stream_close (struct inode *inode,struct file *file) +{ +return 0 ; +} + +static const struct file_operations fops_eu_stall = { + .owner =THIS_MODULE , + .llseek = noop_llseek, + .release = xe_eu_stall_stream_close, + .poll = xe_eu_stall_stream_poll, + .read = xe_eu_stall_stream_read, + .unlocked_ioctl = xe_eu_stall_stream_ioctl, + .compat_ioctl = xe_eu_stall_stream_ioctl, +}; + +static inline bool has_eu_stall_sampling_support (struct xe_device *xe) +{ +return false; +} + +/** +* xe_eu_stall_stream_open - Open a xe EU stall data stream fd +* +* @dev: DRM device pointer +* @data: pointer to first struct @drm_xe_ext_set_property in +* the chain of input properties from the user space. +* @file: DRM file pointer +* +* This function opens a EU stall data stream with input properties from +* the user space. +* +* Returns: EU stall data stream fd on success or a negative error code. +*/ +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file) +{ +struct xe_device *xe =to_xe_device (dev); +struct eu_stall_open_properties props = {}; +int ret, stream_fd; + +if (xe_observation_paranoid && !perfmon_capable ()) {
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 263
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +6
-0+xe_gt_dbg (props.gt,"Insufficient privileges for EU stall monitoring\n" ); +return -EACCES ; + } +if (!has_eu_stall_sampling_support (xe)) { +xe_gt_dbg (props.gt,"EU stall monitoring is not supported on this platform\n" ); +return -EPERM ;I think we are using
-ENODEVfor this, at least in OA.
Okay.
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 264
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +1
-0+ }Move this
has_eu_stall_sampling_supportat the top, this should be even before theperfmon_capablecheck.
Will move.
Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 273
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +9
-0+ + ret =xe_eu_stall_user_extensions (xe, data, &props); +if (ret) +return ret; + +if (!props.gt) { +drm_dbg (&xe->drm,"GT ID not provided for EU stall sampling\n" ); +return -EINVAL ; + }This check is not needed. props.gt cannot be NULL the way
set_prop_eu_stall_gt_idis implemented.
If the user doesn't pass a GT ID, it will be NULL.
Quoted 22 lines
If you need it, use
xe_assert(props->gt)inset_prop_eu_stall_gt_id.Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +7
-0+ + stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall,NULL ,0 ); +if (stream_fd <0 ) +xe_gt_dbg (props.gt,"EU stall inode get fd failed : %d\n" , stream_fd); + +return stream_fd; +}drivers/gpu/drm/xe/xe_eu_stall.h new file +6
-0@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef __XE_EU_STALL_H__
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.h line 11
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.h new file +5
-0+#define __XE_EU_STALL_H__ + +#include <drm/drm_device.h> +#include <drm/drm_file.h> +#include <linux/types.h> Because these lines are replaced in a future patch with '#include "
xe_gt_types.h"', just do that in this patch itself.
Okay.
Quoted 93 lines
Also, as I said, I am not going to focus too much on the patches, only the final code, but in general, if you are deleting lines in these initial patches, think hard about why you need delete those lines and what you could do differently.
Quoted 87 lines
drivers/gpu/drm/xe/xe_eu_stall.h new file +5
-0+ +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file); +#endif drivers/gpu/drm/xe/xe_observation.c +14
-0@@ -9,6 +9,7 @@#include <uapi/drm/xe_drm.h> #include "xe_oa.h" +#include "xe_eu_stall.h" #include "xe_observation.h" u32 xe_observation_paranoid = true;@@ -29,6 +30,17 @@ static int xe_oa_ioctl(struct drm_device *dev, struct drm_xe_observation_param * } } +static int xe_eu_stall_ioctl (struct drm_device *dev,struct drm_xe_observation_param *arg, +struct drm_file *file) +{ +switch (arg->observation_op) { +case DRM_XE_OBSERVATION_OP_STREAM_OPEN : +return xe_eu_stall_stream_open (dev, arg->param, file); +default : +return -EINVAL ; + } +} +/** * xe_observation_ioctl - The top level observation layer ioctl * @dev: @drm_device @@ -51,6 +63,8 @@ int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *fiswitch (arg->observation_type) {case DRM_XE_OBSERVATION_TYPE_OA :return xe_oa_ioctl (dev, arg, file); +case DRM_XE_OBSERVATION_TYPE_EU_STALL : +return xe_eu_stall_ioctl (dev, arg, file);default :return -EINVAL ; }include/uapi/drm/xe_drm.h +28
-0@@ -1496,6 +1496,8 @@ struct drm_xe_wait_user_fence {enum drm_xe_observation_type {/** @DRM_XE_OBSERVATION_TYPE_OA: OA observation stream type */ DRM_XE_OBSERVATION_TYPE_OA , +/** @DRM_XE_OBSERVATION_TYPE_EU_STALL: EU stall sampling observation stream type */ +DRM_XE_OBSERVATION_TYPE_EU_STALL , };/** @@ -1848,6 +1850,42 @@ enum drm_xe_pxp_session_type {/* ID of the protected content session managed by Xe when PXP is active */ #define DRM_XE_PXP_HWDRM_DEFAULT_SESSION 0xf +/** +* enum drm_xe_eu_stall_property_id - EU stall sampling input property ids. +* +* These properties are passed to the driver at open as a chain of +* @drm_xe_ext_set_property structures with @property set to these +* properties' enums and @value set to the corresponding values of these +* properties. @drm_xe_user_extension base.name should be set to +* @DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY. +* +* With the file descriptor obtained from open, user space must enable +* the EU stall stream fd with @DRM_XE_OBSERVATION_IOCTL_ENABLE before +* calling read(). EIO errno from read() indicates HW dropped data +* due to full buffer. +*/ +enum drm_xe_eu_stall_property_id { +#define DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY 0 +/** +* @DRM_XE_EU_STALL_PROP_GT_ID: @gt_id of the GT on which +* EU stall data will be captured. + */ +DRM_XE_EU_STALL_PROP_GT_ID =1 , + +/** +* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate +* in GPU cycles. +*/
Quoted 8 lines
include/uapi/drm/xe_drm.h enum drm_xe_pxp_session_type { · line 1884
Quoted 6 lines
include/uapi/drm/xe_drm.h +6
-0+ DRM_XE_EU_STALL_PROP_SAMPLE_RATE, + +/** +* @DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS: Minimum number of +* EU stall data reports to be present in the kernel buffer +* before unblocking poll or read that is blocked. before unblocking a blocked poll or read
Okay
Quoted 11 lines
Quoted 11 lines
include/uapi/drm/xe_drm.h +4
-1+*/ + DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS, +}; +#if defined(__cplusplus) }#endif --2.48.1
Thank you
Harish.
Re: [PATCH v9 2/8] drm/xe/uapi: Introduce API for EU stall sampling
Quoted 107 lines · Harish Chegondi
Quoted 3 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Ashutosh,
Quoted 93 lines
Hi Harish,
Quoted 91 lines
A new hardware feature first introduced in PVC gives capability to periodically sample EU stall state and record counts for different stall reasons, on a per IP basis, aggregate across all EUs in a subslice and record the samples in a buffer in each subslice. Eventually, the aggregated data is written out to a buffer in the memory. This feature is also supported in XE2 and later architecture GPUs.
Use an existing IOCTL -
DRM_IOCTL_XE_OBSERVATIONas the interface into the driver from the user space to do initial setup and obtain a file descriptor for the EU stall data stream. Input parameter to the IOCTL is a structdrm_xe_observation_paramin whichobservation_typeshould be set toDRM_XE_OBSERVATION_TYPE_EU_STALL,observation_opshould beDRM_XE_OBSERVATION_OP_STREAM_OPENand param should point to a chain ofdrm_xe_ext_set_propertystructures in which each structure has a pair of property and value. The EU stall sampling input properties are defined indrm_xe_eu_stall_property_idenum.With the file descriptor obtained from
DRM_IOCTL_XE_OBSERVATION, user space can enable and disable EU stall sampling with the IOCTLs:DRM_XE_OBSERVATION_IOCTL_ENABLEandDRM_XE_OBSERVATION_IOCTL_DISABLE. User space can also callpoll()to check for availability of data in the buffer. The data can be read withread(). Finally, the file descriptor can be closed withclose().v9: Changed some u32 to unsigned int.
Moved some code around as per review feedback from v8.
v8: Useddiv_u64instead of / to fix 32-bit build issue.
Changed copyright year in xe_eu_stall.c/h to 2025.
v7: Renamed input propertyDRM_XE_EU_STALL_PROP_EVENT_REPORT_COUNT
toDRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTSto be consistent with OA. Renamed the corresponding internal variables. Fixed some commit messages based on review feedback.
v6: Change the input sampling rate to GPU cycles instead of
GPU cycles multiplier.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_eu_stall.c | 280 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_eu_stall.h | 16 ++ drivers/gpu/drm/xe/xe_observation.c | 14 ++ include/uapi/drm/xe_drm.h | 38 ++++ 5 files changed, 349 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.c create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.hdrivers/gpu/drm/xe/Makefile +1
-0@@ -33,6 +33,7 @@ xe-y += xe_bb.o \ xe_device_sysfs.o \ xe_dma_buf.o \ xe_drm_client.o \ + xe_eu_stall.o \ xe_exec.o \ xe_exec_queue.o \ xe_execlist.o \drivers/gpu/drm/xe/xe_eu_stall.c new file +27
-0@@ -0,0 +1,280 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +*/ + +#include <linux/anon_inodes.h> +#include <linux/fs.h> +#include <linux/poll.h> +#include <linux/types.h> + +#include <uapi/drm/xe_drm.h> + +#include "xe_device.h" +#include "xe_eu_stall.h" +#include "xe_gt_printk.h" +#include "xe_gt_topology.h" +#include "xe_macros.h" +#include "xe_observation.h" + +static size_t per_xecore_buf_size =SZ_512K ; + +/** +* struct eu_stall_open_properties - EU stall sampling properties received +* from user space at open. +* @sampling_rate_mult: EU stall sampling rate multiplier. +* HW will sample every (sampling_rate_mult x 251) cycles. +* @wait_num_reports: Minimum number of EU stall data reports to unblock poll(). Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 32
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+* @gt: GT on which EU stall data will be captured. +*/ +struct eu_stall_open_properties { +unsigned int sampling_rate_mult; +unsigned int wait_num_reports;I already said no need to be so specific. Just use int or u32 as types for these.
Quoted 1 line
Okay, will try to change these back to u8/u32 in the next version.
Use int or u32, not u8.
Quoted 44 lines
Quoted 28 lines
Quoted 28 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +27
-0+struct xe_gt *gt; +}; + +/** +* num_data_rows - Return the number of EU stall data rows of 64B each +* for a given data size. +* +* @data_size: EU stall data size +*/ +static u32 num_data_rows (u32 data_size) +{ +return (data_size >>6 ); +} + +static int set_prop_eu_stall_sampling_rate (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ + value =div_u64 (value,251 ); +if (value ==0 || value >7 ) { +drm_dbg (&xe->drm,"Invalid EU stall sampling rate %llu\n" , value); +return -EINVAL ; + } + props->sampling_rate_mult = value; +return 0 ; +} + +static int set_prop_eu_stall_wait_num_reports(struct xe_device *xe, u64 value,Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 64
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+ struct eu_stall_open_properties *props) +{ +unsigned int max_wait_num_reports; + + max_wait_num_reports =num_data_rows (per_xecore_buf_size *XE_MAX_DSS_FUSE_BITS );This seems wrong. Instead of
XE_MAX_DSS_FUSE_BITS, shouldn't we use the value returned byxe_gt_topology_mask_last_dss()?Yes you are correct. But not
xe_gt_topology_mask_last_dss()as it would only return the last DSS and the DSSes can be discontiguous. We should use the absolute number of DSSes * buffer size. I can move this validation toxe_eu_stall_stream_init()where we can do abitmap_weight(all_xecore)to find the actual number of DSSes and return EINVAL if invalid input. I did a simple validation here as I wasn't sure if it is worth doing the extra validation.Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Note that a large value can result in the poll/read never getting unblocked!
To solve this issue I think
num_xecoreshould be maintained in structxe_eu_stall_gt. Though let's see what happens to 'structxe_device*' arg to these functions if we do this.Probably not required if this validation is done in
xe_eu_stall_stream_init()added in the next patch as I described above.
OK, we can do that. But in that case just check for 0 below, remove all the drm_dbg's and also remove max_wait_num_reports, since that will be validated in xe_eu_stall_stream_init(). So that we are not doing any invalid validation here and correcting it later. Maybe even check for 0 in xe_eu_stall_stream_init. You can add xe_gt_dbg's there if needed, or even create a small new function.
Actually I was wrong in saying "num_xecore should be maintained in struct xe_eu_stall_gt" because xe_eu_stall_stream_open() is a device level function so only xe_device is available there not xe_gt. So if we were to store num_xecore, we'd need to create a new device level xe_eu_stall struct and put num_xecore there. This is also device level information. E.g. OA has both device and gt level structs.
So depends on you. But we can do xe_eu_stall_stream_init for now.
Quoted 160 lines
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +53
-0+if (value ==0 || value > max_wait_num_reports) { +drm_dbg (&xe->drm,"Invalid EU stall event report count %llu\n" , value); +drm_dbg (&xe->drm,"Minimum event report count is 1, maximum is %u\n" , + max_wait_num_reports); +return -EINVAL ; + } + props->wait_num_reports = value; +return 0 ; +} + +static int set_prop_eu_stall_gt_id (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ +if (value >= xe->info.gt_count) { +drm_dbg (&xe->drm,"Invalid GT ID %llu for EU stall sampling\n" , value); +return -EINVAL ; + } + props->gt =xe_device_get_gt (xe, value); +return 0 ; +} + +typedef int (*set_eu_stall_property_fn )(struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props); + +static const set_eu_stall_property_fn xe_set_eu_stall_property_funcs[] = { + [DRM_XE_EU_STALL_PROP_SAMPLE_RATE ] = set_prop_eu_stall_sampling_rate, + [DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS ] = set_prop_eu_stall_wait_num_reports, + [DRM_XE_EU_STALL_PROP_GT_ID ] = set_prop_eu_stall_gt_id, +}; + +static int xe_eu_stall_user_ext_set_property (struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props) +{ +u64 __user *address =u64_to_user_ptr (extension); +struct drm_xe_ext_set_property ext; +int err; +u32 idx; + + err =__copy_from_user (&ext, address,sizeof (ext)); +if (XE_IOCTL_DBG (xe, err)) +return -EFAULT ; + +if (XE_IOCTL_DBG (xe, ext.property >=ARRAY_SIZE (xe_set_eu_stall_property_funcs)) || +XE_IOCTL_DBG (xe, ext.pad)) +return -EINVAL ; + + idx =array_index_nospec (ext.property,ARRAY_SIZE (xe_set_eu_stall_property_funcs)); +return xe_set_eu_stall_property_funcs[idx](xe, ext.value, props); +} + +typedef int (*xe_eu_stall_user_extension_fn )(struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props); +static const xe_eu_stall_user_extension_fn xe_eu_stall_user_extension_funcs[] = {Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 122
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+ [DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY] = xe_eu_stall_user_ext_set_property, +}; + +static int xe_eu_stall_user_extensions (struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props)What is the reason for not using the
ext_numberargument here, which is used in bothexec_queue_user_extensionsand inxe_oa_user_extensions?When I reused this code from the OA code it didn't have the
ext_number. I will check that out and make the change.Quoted 87 lines
The reason for
ext_numberis that the extensions can be chained in a loop, which can cause an infinite loop in the kernel when parsing these extensions.ext_numberis used to break out of these potential infinite loops.Quoted 25 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +25
-0+{ +u64 __user *address =u64_to_user_ptr (extension); +struct drm_xe_user_extension ext; +int err; +u32 idx; + + err =__copy_from_user (&ext, address,sizeof (ext)); +if (XE_IOCTL_DBG (xe, err)) +return -EFAULT ; + +if (XE_IOCTL_DBG (xe, ext.pad) || +XE_IOCTL_DBG (xe, ext.name >=ARRAY_SIZE (xe_eu_stall_user_extension_funcs))) +return -EINVAL ; + + idx =array_index_nospec (ext.name,ARRAY_SIZE (xe_eu_stall_user_extension_funcs)); + err = xe_eu_stall_user_extension_funcs[idx](xe, extension, props); +if (XE_IOCTL_DBG (xe, err)) +return err; + +if (ext.next_extension) +return xe_eu_stall_user_extensions (xe, ext.next_extension, props); + +return 0 ; +} +drivers/gpu/drm/xe/xe_eu_stall.c line 157
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+/** +* xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* @ppos: (inout) file seek position (unused) +* +* Userspace must enable the EU stall stream with DRM_XE_OBSERVATION_IOCTL_ENABLE +* before calling read(). We can just retain these two lines of comment. See below.
Quoted 43 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +43
-0+* +* Returns: The number of bytes copied or a negative error code on failure. +*/ +static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf, +size_t count,loff_t *ppos) +{ +ssize_t ret =0 ; + +return ret; +} + +/** +* xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @wait: Poll table +* +* Returns: Bit mask of returned events. +*/ +static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) +{ +__poll_t ret =0 ; + +return ret; +} + +/** +* xe_eu_stall_stream_ioctl - support ioctl() of a xe EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @cmd: the ioctl request +* @arg: the ioctl data +* +* Returns: zero on success or a negative error code. +* -EINVAL for an unknown ioctl request. +*/ +static long xe_eu_stall_stream_ioctl (struct file *file, +unsigned int cmd, +unsigned long arg) +{ +switch (cmd) { +case DRM_XE_OBSERVATION_IOCTL_ENABLE : +return 0 ;Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 205
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+case DRM_XE_OBSERVATION_IOCTL_DISABLE : +return 0 ; + } + +return -EINVAL ;Just return 0 or
-EINVALin this patch since you are going to add locking in a later patch.
Quoted 3 lines
You mean remove the switch statement completely and just return 0 or EINVAL? The intention of this switch statement is to specify the two IOCTLs that will be supported in the uAPI.
Each patch just has to compile and pass checkpatch. You can add the switch statement in the later patch which adds locking, in xe_eu_stall_stream_ioctl_locked (to avoid unnecessary code movement, see deleted lines in that patch).
Quoted 97 lines
Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 215
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+} + +/** +* xe_eu_stall_stream_close - handles userspace close() of a EU stall data +* stream file. +* @inode: anonymous inode associated with file +* @file: An xe EU stall data stream file +* +* Cleans up any resources associated with an open EU stall data stream file. +*/ As I said before, these comments are completely redundant. These are standard
file_operations. There are one million instances of these in the kernel, all of them have exactly the same arguments.If you have anything specific to EU stall here, we can leave it. Otherwise I'd still say get rid of them.
Quoted 7 lines
Or get rid them now and send a patch later to add them, we can review that patch later, if you really think they add value. They were included in
i915_perf.c, but I don't think they should be in Xe.If you think these comments should be there, let's get a second opinion, from one of the maintainers.
Okay, will get feedback from a maintainer and will update.
Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +42
-0+static int xe_eu_stall_stream_close (struct inode *inode,struct file *file) +{ +return 0 ; +} + +static const struct file_operations fops_eu_stall = { + .owner =THIS_MODULE , + .llseek = noop_llseek, + .release = xe_eu_stall_stream_close, + .poll = xe_eu_stall_stream_poll, + .read = xe_eu_stall_stream_read, + .unlocked_ioctl = xe_eu_stall_stream_ioctl, + .compat_ioctl = xe_eu_stall_stream_ioctl, +}; + +static inline bool has_eu_stall_sampling_support (struct xe_device *xe) +{ +return false; +} + +/** +* xe_eu_stall_stream_open - Open a xe EU stall data stream fd +* +* @dev: DRM device pointer +* @data: pointer to first struct @drm_xe_ext_set_property in +* the chain of input properties from the user space. +* @file: DRM file pointer +* +* This function opens a EU stall data stream with input properties from +* the user space. +* +* Returns: EU stall data stream fd on success or a negative error code. +*/ +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file) +{ +struct xe_device *xe =to_xe_device (dev); +struct eu_stall_open_properties props = {}; +int ret, stream_fd; + +if (xe_observation_paranoid && !perfmon_capable ()) {Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 263
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +6
-0+xe_gt_dbg (props.gt,"Insufficient privileges for EU stall monitoring\n" ); +return -EACCES ; + } +if (!has_eu_stall_sampling_support (xe)) { +xe_gt_dbg (props.gt,"EU stall monitoring is not supported on this platform\n" ); +return -EPERM ;I think we are using
-ENODEVfor this, at least in OA.Okay.
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 264
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +1
-0+ }Move this
has_eu_stall_sampling_supportat the top, this should be even before theperfmon_capablecheck.Will move.
Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 273
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +9
-0+ + ret =xe_eu_stall_user_extensions (xe, data, &props); +if (ret) +return ret; + +if (!props.gt) { +drm_dbg (&xe->drm,"GT ID not provided for EU stall sampling\n" ); +return -EINVAL ; + }This check is not needed. props.gt cannot be NULL the way
set_prop_eu_stall_gt_idis implemented.
Quoted 1 line
If the user doesn't pass a GT ID, it will be NULL.
Yeah I commented on this later. Depends on whether we use a default gt_id of 0 or not.
Quoted 147 lines
Quoted 22 lines
If you need it, use
xe_assert(props->gt)inset_prop_eu_stall_gt_id.Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +7
-0+ + stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall,NULL ,0 ); +if (stream_fd <0 ) +xe_gt_dbg (props.gt,"EU stall inode get fd failed : %d\n" , stream_fd); + +return stream_fd; +}drivers/gpu/drm/xe/xe_eu_stall.h new file +6
-0@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef __XE_EU_STALL_H__Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.h line 11
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.h new file +5
-0+#define __XE_EU_STALL_H__ + +#include <drm/drm_device.h> +#include <drm/drm_file.h> +#include <linux/types.h> Because these lines are replaced in a future patch with '#include "
xe_gt_types.h"', just do that in this patch itself.Okay.
Quoted 93 lines
Also, as I said, I am not going to focus too much on the patches, only the final code, but in general, if you are deleting lines in these initial patches, think hard about why you need delete those lines and what you could do differently.
Quoted 87 lines
drivers/gpu/drm/xe/xe_eu_stall.h new file +5
-0+ +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file); +#endif drivers/gpu/drm/xe/xe_observation.c +14
-0@@ -9,6 +9,7 @@#include <uapi/drm/xe_drm.h> #include "xe_oa.h" +#include "xe_eu_stall.h" #include "xe_observation.h" u32 xe_observation_paranoid = true;@@ -29,6 +30,17 @@ static int xe_oa_ioctl(struct drm_device *dev, struct drm_xe_observation_param * } } +static int xe_eu_stall_ioctl (struct drm_device *dev,struct drm_xe_observation_param *arg, +struct drm_file *file) +{ +switch (arg->observation_op) { +case DRM_XE_OBSERVATION_OP_STREAM_OPEN : +return xe_eu_stall_stream_open (dev, arg->param, file); +default : +return -EINVAL ; + } +} +/** * xe_observation_ioctl - The top level observation layer ioctl * @dev: @drm_device @@ -51,6 +63,8 @@ int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *fiswitch (arg->observation_type) {case DRM_XE_OBSERVATION_TYPE_OA :return xe_oa_ioctl (dev, arg, file); +case DRM_XE_OBSERVATION_TYPE_EU_STALL : +return xe_eu_stall_ioctl (dev, arg, file);default :return -EINVAL ; }include/uapi/drm/xe_drm.h +28
-0@@ -1496,6 +1496,8 @@ struct drm_xe_wait_user_fence {enum drm_xe_observation_type {/** @DRM_XE_OBSERVATION_TYPE_OA: OA observation stream type */ DRM_XE_OBSERVATION_TYPE_OA , +/** @DRM_XE_OBSERVATION_TYPE_EU_STALL: EU stall sampling observation stream type */ +DRM_XE_OBSERVATION_TYPE_EU_STALL , };/** @@ -1848,6 +1850,42 @@ enum drm_xe_pxp_session_type {/* ID of the protected content session managed by Xe when PXP is active */ #define DRM_XE_PXP_HWDRM_DEFAULT_SESSION 0xf +/** +* enum drm_xe_eu_stall_property_id - EU stall sampling input property ids. +* +* These properties are passed to the driver at open as a chain of +* @drm_xe_ext_set_property structures with @property set to these +* properties' enums and @value set to the corresponding values of these +* properties. @drm_xe_user_extension base.name should be set to +* @DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY. +* +* With the file descriptor obtained from open, user space must enable +* the EU stall stream fd with @DRM_XE_OBSERVATION_IOCTL_ENABLE before +* calling read(). EIO errno from read() indicates HW dropped data +* due to full buffer. +*/ +enum drm_xe_eu_stall_property_id { +#define DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY 0 +/** +* @DRM_XE_EU_STALL_PROP_GT_ID: @gt_id of the GT on which +* EU stall data will be captured. + */ +DRM_XE_EU_STALL_PROP_GT_ID =1 , + +/** +* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate +* in GPU cycles. +*/ Quoted 8 lines
include/uapi/drm/xe_drm.h enum drm_xe_pxp_session_type { · line 1884
Quoted 6 lines
include/uapi/drm/xe_drm.h +6
-0+ DRM_XE_EU_STALL_PROP_SAMPLE_RATE, + +/** +* @DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS: Minimum number of +* EU stall data reports to be present in the kernel buffer +* before unblocking poll or read that is blocked. before unblocking a blocked poll or read
Okay
Quoted 11 lines
Quoted 11 lines
include/uapi/drm/xe_drm.h +4
-1+*/ + DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS, +}; +#if defined(__cplusplus) }#endif --2.48.1
Thank you
Harish.
Re: [PATCH v9 2/8] drm/xe/uapi: Introduce API for EU stall sampling
Quoted 108 lines · Ashutosh
Quoted 107 lines · Harish Chegondi
Quoted 3 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Ashutosh,
Quoted 101 lines
Hi Harish,
Quoted 86 lines
A new hardware feature first introduced in PVC gives capability to periodically sample EU stall state and record counts for different stall reasons, on a per IP basis, aggregate across all EUs in a subslice and record the samples in a buffer in each subslice. Eventually, the aggregated data is written out to a buffer in the memory. This feature is also supported in XE2 and later architecture GPUs.
Use an existing IOCTL -
DRM_IOCTL_XE_OBSERVATIONas the interface into the driver from the user space to do initial setup and obtain a file descriptor for the EU stall data stream. Input parameter to the IOCTL is a structdrm_xe_observation_paramin whichobservation_typeshould be set toDRM_XE_OBSERVATION_TYPE_EU_STALL,observation_opshould beDRM_XE_OBSERVATION_OP_STREAM_OPENand param should point to a chain ofdrm_xe_ext_set_propertystructures in which each structure has a pair of property and value. The EU stall sampling input properties are defined indrm_xe_eu_stall_property_idenum.With the file descriptor obtained from
DRM_IOCTL_XE_OBSERVATION, user space can enable and disable EU stall sampling with the IOCTLs:DRM_XE_OBSERVATION_IOCTL_ENABLEandDRM_XE_OBSERVATION_IOCTL_DISABLE. User space can also callpoll()to check for availability of data in the buffer. The data can be read withread(). Finally, the file descriptor can be closed withclose().v9: Changed some u32 to unsigned int.
Moved some code around as per review feedback from v8.
v8: Useddiv_u64instead of / to fix 32-bit build issue.
Changed copyright year in xe_eu_stall.c/h to 2025.
v7: Renamed input propertyDRM_XE_EU_STALL_PROP_EVENT_REPORT_COUNT
toDRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTSto be consistent with OA. Renamed the corresponding internal variables. Fixed some commit messages based on review feedback.
v6: Change the input sampling rate to GPU cycles instead of
GPU cycles multiplier.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_eu_stall.c | 280 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_eu_stall.h | 16 ++ drivers/gpu/drm/xe/xe_observation.c | 14 ++ include/uapi/drm/xe_drm.h | 38 ++++ 5 files changed, 349 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.c create mode 100644 drivers/gpu/drm/xe/xe_eu_stall.hdrivers/gpu/drm/xe/Makefile +1
-0@@ -33,6 +33,7 @@ xe-y += xe_bb.o \ xe_device_sysfs.o \ xe_dma_buf.o \ xe_drm_client.o \ + xe_eu_stall.o \ xe_exec.o \ xe_exec_queue.o \ xe_execlist.o \drivers/gpu/drm/xe/xe_eu_stall.c new file +22
-0@@ -0,0 +1,280 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2025 Intel Corporation +*/ + +#include <linux/anon_inodes.h> +#include <linux/fs.h> +#include <linux/poll.h> +#include <linux/types.h> + +#include <uapi/drm/xe_drm.h> + +#include "xe_device.h" +#include "xe_eu_stall.h" +#include "xe_gt_printk.h" +#include "xe_gt_topology.h" +#include "xe_macros.h" +#include "xe_observation.h" + +static size_t per_xecore_buf_size =SZ_512K ; + +/** drivers/gpu/drm/xe/xe_eu_stall.c line 32
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+* struct eu_stall_open_properties - EU stall sampling properties received +* from user space at open. +* @sampling_rate_mult: EU stall sampling rate multiplier. +* HW will sample every (sampling_rate_mult x 251) cycles. +* @wait_num_reports: Minimum number of EU stall data reports to unblock poll(). +* @gt: GT on which EU stall data will be captured. +*/ +struct eu_stall_open_properties { +unsigned int sampling_rate_mult; +unsigned int wait_num_reports;I already said no need to be so specific. Just use int or u32 as types for these.
Quoted 3 lines
Quoted 1 line
Okay, will try to change these back to u8/u32 in the next version.
Use int or u32, not u8.
Any reason why I can't use u8? The maximum value of sampling_rate_mult is 7.
Quoted 488 lines
Quoted 45 lines
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +27
-0+struct xe_gt *gt; +}; + +/** +* num_data_rows - Return the number of EU stall data rows of 64B each +* for a given data size. +* +* @data_size: EU stall data size +*/ +static u32 num_data_rows (u32 data_size) +{ +return (data_size >>6 ); +} + +static int set_prop_eu_stall_sampling_rate (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ + value =div_u64 (value,251 ); +if (value ==0 || value >7 ) { +drm_dbg (&xe->drm,"Invalid EU stall sampling rate %llu\n" , value); +return -EINVAL ; + } + props->sampling_rate_mult = value; +return 0 ; +} + +static int set_prop_eu_stall_wait_num_reports(struct xe_device *xe, u64 value,Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 64
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+ struct eu_stall_open_properties *props) +{ +unsigned int max_wait_num_reports; + + max_wait_num_reports =num_data_rows (per_xecore_buf_size *XE_MAX_DSS_FUSE_BITS );This seems wrong. Instead of
XE_MAX_DSS_FUSE_BITS, shouldn't we use the value returned byxe_gt_topology_mask_last_dss()?Yes you are correct. But not
xe_gt_topology_mask_last_dss()as it would only return the last DSS and the DSSes can be discontiguous. We should use the absolute number of DSSes * buffer size. I can move this validation toxe_eu_stall_stream_init()where we can do abitmap_weight(all_xecore)to find the actual number of DSSes and return EINVAL if invalid input. I did a simple validation here as I wasn't sure if it is worth doing the extra validation.Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Note that a large value can result in the poll/read never getting unblocked!
To solve this issue I think
num_xecoreshould be maintained in structxe_eu_stall_gt. Though let's see what happens to 'structxe_device*' arg to these functions if we do this.Probably not required if this validation is done in
xe_eu_stall_stream_init()added in the next patch as I described above.OK, we can do that. But in that case just check for 0 below, remove all the drm_dbg's and also remove
max_wait_num_reports, since that will be validated inxe_eu_stall_stream_init(). So that we are not doing any invalid validation here and correcting it later. Maybe even check for 0 inxe_eu_stall_stream_init. You can add xe_gt_dbg's there if needed, or even create a small new function.Actually I was wrong in saying "
num_xecoreshould be maintained in structxe_eu_stall_gt" becausexe_eu_stall_stream_open()is a device level function so onlyxe_deviceis available there notxe_gt. So if we were to storenum_xecore, we'd need to create a new device levelxe_eu_stallstruct and putnum_xecorethere. This is also device level information. E.g. OA has both device and gt level structs.So depends on you. But we can do
xe_eu_stall_stream_initfor now.Quoted 160 lines
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +53
-0+if (value ==0 || value > max_wait_num_reports) { +drm_dbg (&xe->drm,"Invalid EU stall event report count %llu\n" , value); +drm_dbg (&xe->drm,"Minimum event report count is 1, maximum is %u\n" , + max_wait_num_reports); +return -EINVAL ; + } + props->wait_num_reports = value; +return 0 ; +} + +static int set_prop_eu_stall_gt_id (struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props) +{ +if (value >= xe->info.gt_count) { +drm_dbg (&xe->drm,"Invalid GT ID %llu for EU stall sampling\n" , value); +return -EINVAL ; + } + props->gt =xe_device_get_gt (xe, value); +return 0 ; +} + +typedef int (*set_eu_stall_property_fn )(struct xe_device *xe,u64 value, +struct eu_stall_open_properties *props); + +static const set_eu_stall_property_fn xe_set_eu_stall_property_funcs[] = { + [DRM_XE_EU_STALL_PROP_SAMPLE_RATE ] = set_prop_eu_stall_sampling_rate, + [DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS ] = set_prop_eu_stall_wait_num_reports, + [DRM_XE_EU_STALL_PROP_GT_ID ] = set_prop_eu_stall_gt_id, +}; + +static int xe_eu_stall_user_ext_set_property (struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props) +{ +u64 __user *address =u64_to_user_ptr (extension); +struct drm_xe_ext_set_property ext; +int err; +u32 idx; + + err =__copy_from_user (&ext, address,sizeof (ext)); +if (XE_IOCTL_DBG (xe, err)) +return -EFAULT ; + +if (XE_IOCTL_DBG (xe, ext.property >=ARRAY_SIZE (xe_set_eu_stall_property_funcs)) || +XE_IOCTL_DBG (xe, ext.pad)) +return -EINVAL ; + + idx =array_index_nospec (ext.property,ARRAY_SIZE (xe_set_eu_stall_property_funcs)); +return xe_set_eu_stall_property_funcs[idx](xe, ext.value, props); +} + +typedef int (*xe_eu_stall_user_extension_fn )(struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props); +static const xe_eu_stall_user_extension_fn xe_eu_stall_user_extension_funcs[] = {Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 122
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+ [DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY] = xe_eu_stall_user_ext_set_property, +}; + +static int xe_eu_stall_user_extensions (struct xe_device *xe,u64 extension, +struct eu_stall_open_properties *props)What is the reason for not using the
ext_numberargument here, which is used in bothexec_queue_user_extensionsand inxe_oa_user_extensions?When I reused this code from the OA code it didn't have the
ext_number. I will check that out and make the change.Quoted 87 lines
The reason for
ext_numberis that the extensions can be chained in a loop, which can cause an infinite loop in the kernel when parsing these extensions.ext_numberis used to break out of these potential infinite loops.Quoted 25 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +25
-0+{ +u64 __user *address =u64_to_user_ptr (extension); +struct drm_xe_user_extension ext; +int err; +u32 idx; + + err =__copy_from_user (&ext, address,sizeof (ext)); +if (XE_IOCTL_DBG (xe, err)) +return -EFAULT ; + +if (XE_IOCTL_DBG (xe, ext.pad) || +XE_IOCTL_DBG (xe, ext.name >=ARRAY_SIZE (xe_eu_stall_user_extension_funcs))) +return -EINVAL ; + + idx =array_index_nospec (ext.name,ARRAY_SIZE (xe_eu_stall_user_extension_funcs)); + err = xe_eu_stall_user_extension_funcs[idx](xe, extension, props); +if (XE_IOCTL_DBG (xe, err)) +return err; + +if (ext.next_extension) +return xe_eu_stall_user_extensions (xe, ext.next_extension, props); + +return 0 ; +} +drivers/gpu/drm/xe/xe_eu_stall.c line 157
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+/** +* xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* @ppos: (inout) file seek position (unused) +* +* Userspace must enable the EU stall stream with DRM_XE_OBSERVATION_IOCTL_ENABLE +* before calling read(). We can just retain these two lines of comment. See below.
Quoted 43 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +43
-0+* +* Returns: The number of bytes copied or a negative error code on failure. +*/ +static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf, +size_t count,loff_t *ppos) +{ +ssize_t ret =0 ; + +return ret; +} + +/** +* xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @wait: Poll table +* +* Returns: Bit mask of returned events. +*/ +static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) +{ +__poll_t ret =0 ; + +return ret; +} + +/** +* xe_eu_stall_stream_ioctl - support ioctl() of a xe EU stall data stream fd. +* +* @file: An xe EU stall data stream file +* @cmd: the ioctl request +* @arg: the ioctl data +* +* Returns: zero on success or a negative error code. +* -EINVAL for an unknown ioctl request. +*/ +static long xe_eu_stall_stream_ioctl (struct file *file, +unsigned int cmd, +unsigned long arg) +{ +switch (cmd) { +case DRM_XE_OBSERVATION_IOCTL_ENABLE : +return 0 ;Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 205
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +5
-0+case DRM_XE_OBSERVATION_IOCTL_DISABLE : +return 0 ; + } + +return -EINVAL ;Just return 0 or
-EINVALin this patch since you are going to add locking in a later patch.Quoted 3 lines
You mean remove the switch statement completely and just return 0 or EINVAL? The intention of this switch statement is to specify the two IOCTLs that will be supported in the uAPI.
Each patch just has to compile and pass checkpatch. You can add the switch statement in the later patch which adds locking, in
xe_eu_stall_stream_ioctl_locked(to avoid unnecessary code movement, see deleted lines in that patch).Quoted 97 lines
Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 215
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +10
-0+} + +/** +* xe_eu_stall_stream_close - handles userspace close() of a EU stall data +* stream file. +* @inode: anonymous inode associated with file +* @file: An xe EU stall data stream file +* +* Cleans up any resources associated with an open EU stall data stream file. +*/ As I said before, these comments are completely redundant. These are standard
file_operations. There are one million instances of these in the kernel, all of them have exactly the same arguments.If you have anything specific to EU stall here, we can leave it. Otherwise I'd still say get rid of them.
Quoted 7 lines
Or get rid them now and send a patch later to add them, we can review that patch later, if you really think they add value. They were included in
i915_perf.c, but I don't think they should be in Xe.If you think these comments should be there, let's get a second opinion, from one of the maintainers.
Okay, will get feedback from a maintainer and will update.
Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +42
-0+static int xe_eu_stall_stream_close (struct inode *inode,struct file *file) +{ +return 0 ; +} + +static const struct file_operations fops_eu_stall = { + .owner =THIS_MODULE , + .llseek = noop_llseek, + .release = xe_eu_stall_stream_close, + .poll = xe_eu_stall_stream_poll, + .read = xe_eu_stall_stream_read, + .unlocked_ioctl = xe_eu_stall_stream_ioctl, + .compat_ioctl = xe_eu_stall_stream_ioctl, +}; + +static inline bool has_eu_stall_sampling_support (struct xe_device *xe) +{ +return false; +} + +/** +* xe_eu_stall_stream_open - Open a xe EU stall data stream fd +* +* @dev: DRM device pointer +* @data: pointer to first struct @drm_xe_ext_set_property in +* the chain of input properties from the user space. +* @file: DRM file pointer +* +* This function opens a EU stall data stream with input properties from +* the user space. +* +* Returns: EU stall data stream fd on success or a negative error code. +*/ +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file) +{ +struct xe_device *xe =to_xe_device (dev); +struct eu_stall_open_properties props = {}; +int ret, stream_fd; + +if (xe_observation_paranoid && !perfmon_capable ()) {Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 263
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +6
-0+xe_gt_dbg (props.gt,"Insufficient privileges for EU stall monitoring\n" ); +return -EACCES ; + } +if (!has_eu_stall_sampling_support (xe)) { +xe_gt_dbg (props.gt,"EU stall monitoring is not supported on this platform\n" ); +return -EPERM ;I think we are using
-ENODEVfor this, at least in OA.Okay.
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 264
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +1
-0+ }Move this
has_eu_stall_sampling_supportat the top, this should be even before theperfmon_capablecheck.Will move.
Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 273
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +9
-0+ + ret =xe_eu_stall_user_extensions (xe, data, &props); +if (ret) +return ret; + +if (!props.gt) { +drm_dbg (&xe->drm,"GT ID not provided for EU stall sampling\n" ); +return -EINVAL ; + }This check is not needed. props.gt cannot be NULL the way
set_prop_eu_stall_gt_idis implemented.Quoted 1 line
If the user doesn't pass a GT ID, it will be NULL.
Yeah I commented on this later. Depends on whether we use a default
gt_idof 0 or not.Quoted 147 lines
Quoted 22 lines
If you need it, use
xe_assert(props->gt)inset_prop_eu_stall_gt_id.Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +7
-0+ + stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall,NULL ,0 ); +if (stream_fd <0 ) +xe_gt_dbg (props.gt,"EU stall inode get fd failed : %d\n" , stream_fd); + +return stream_fd; +}drivers/gpu/drm/xe/xe_eu_stall.h new file +6
-0@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef __XE_EU_STALL_H__Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.h line 11
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.h new file +5
-0+#define __XE_EU_STALL_H__ + +#include <drm/drm_device.h> +#include <drm/drm_file.h> +#include <linux/types.h> Because these lines are replaced in a future patch with '#include "
xe_gt_types.h"', just do that in this patch itself.Okay.
Quoted 93 lines
Also, as I said, I am not going to focus too much on the patches, only the final code, but in general, if you are deleting lines in these initial patches, think hard about why you need delete those lines and what you could do differently.
Quoted 87 lines
drivers/gpu/drm/xe/xe_eu_stall.h new file +5
-0+ +int xe_eu_stall_stream_open (struct drm_device *dev, +u64 data, +struct drm_file *file); +#endif drivers/gpu/drm/xe/xe_observation.c +14
-0@@ -9,6 +9,7 @@#include <uapi/drm/xe_drm.h> #include "xe_oa.h" +#include "xe_eu_stall.h" #include "xe_observation.h" u32 xe_observation_paranoid = true;@@ -29,6 +30,17 @@ static int xe_oa_ioctl(struct drm_device *dev, struct drm_xe_observation_param * } } +static int xe_eu_stall_ioctl (struct drm_device *dev,struct drm_xe_observation_param *arg, +struct drm_file *file) +{ +switch (arg->observation_op) { +case DRM_XE_OBSERVATION_OP_STREAM_OPEN : +return xe_eu_stall_stream_open (dev, arg->param, file); +default : +return -EINVAL ; + } +} +/** * xe_observation_ioctl - The top level observation layer ioctl * @dev: @drm_device @@ -51,6 +63,8 @@ int xe_observation_ioctl(struct drm_device *dev, void *data, struct drm_file *fiswitch (arg->observation_type) {case DRM_XE_OBSERVATION_TYPE_OA :return xe_oa_ioctl (dev, arg, file); +case DRM_XE_OBSERVATION_TYPE_EU_STALL : +return xe_eu_stall_ioctl (dev, arg, file);default :return -EINVAL ; }include/uapi/drm/xe_drm.h +28
-0@@ -1496,6 +1496,8 @@ struct drm_xe_wait_user_fence {enum drm_xe_observation_type {/** @DRM_XE_OBSERVATION_TYPE_OA: OA observation stream type */ DRM_XE_OBSERVATION_TYPE_OA , +/** @DRM_XE_OBSERVATION_TYPE_EU_STALL: EU stall sampling observation stream type */ +DRM_XE_OBSERVATION_TYPE_EU_STALL , };/** @@ -1848,6 +1850,42 @@ enum drm_xe_pxp_session_type {/* ID of the protected content session managed by Xe when PXP is active */ #define DRM_XE_PXP_HWDRM_DEFAULT_SESSION 0xf +/** +* enum drm_xe_eu_stall_property_id - EU stall sampling input property ids. +* +* These properties are passed to the driver at open as a chain of +* @drm_xe_ext_set_property structures with @property set to these +* properties' enums and @value set to the corresponding values of these +* properties. @drm_xe_user_extension base.name should be set to +* @DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY. +* +* With the file descriptor obtained from open, user space must enable +* the EU stall stream fd with @DRM_XE_OBSERVATION_IOCTL_ENABLE before +* calling read(). EIO errno from read() indicates HW dropped data +* due to full buffer. +*/ +enum drm_xe_eu_stall_property_id { +#define DRM_XE_EU_STALL_EXTENSION_SET_PROPERTY 0 +/** +* @DRM_XE_EU_STALL_PROP_GT_ID: @gt_id of the GT on which +* EU stall data will be captured. + */ +DRM_XE_EU_STALL_PROP_GT_ID =1 , + +/** +* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate +* in GPU cycles. +*/ Quoted 8 lines
include/uapi/drm/xe_drm.h enum drm_xe_pxp_session_type { · line 1884
Quoted 6 lines
include/uapi/drm/xe_drm.h +6
-0+ DRM_XE_EU_STALL_PROP_SAMPLE_RATE, + +/** +* @DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS: Minimum number of +* EU stall data reports to be present in the kernel buffer +* before unblocking poll or read that is blocked. before unblocking a blocked poll or read
Okay
Quoted 11 lines
Quoted 11 lines
include/uapi/drm/xe_drm.h +4
-1+*/ + DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS, +}; +#if defined(__cplusplus) }#endif --2.48.1
Thank you
Harish.
Re: [PATCH v9 2/8] drm/xe/uapi: Introduce API for EU stall sampling
Quoted 7 lines · Harish Chegondi
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 32
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +3
-0+struct eu_stall_open_properties { +unsigned int sampling_rate_mult; +unsigned int wait_num_reports;I already said no need to be so specific. Just use int or u32 as types for these.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Okay, will try to change these back to u8/u32 in the next version.
Use int or u32, not u8.
Any reason why I can't use u8? The maximum value of
sampling_rate_multis 7.
Use whatever you want. The real question to ask is why can't we use a generic type like int? Whether you use u8 or int, the CPU will still fetch a 64 byte cacheline. And this structure is only used at initialization, so performance is not a concern.
Re: [PATCH v9 2/8] drm/xe/uapi: Introduce API for EU stall sampling
Quoted 8 lines · Ashutosh
Quoted 7 lines · Harish Chegondi
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c line 32
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c new file +3
-0+struct eu_stall_open_properties { +unsigned int sampling_rate_mult; +unsigned int wait_num_reports;I already said no need to be so specific. Just use int or u32 as types for these.
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Okay, will try to change these back to u8/u32 in the next version.
Use int or u32, not u8.
Any reason why I can't use u8? The maximum value of
sampling_rate_multis 7.
There is zero benefit in using a smaller type just because you think your value range fits the type.
Default to using an int. You need a reason to use smaller types or unsigned, not the other way round.
For example, many hardware registers are u32. That's a good reason to use u32 when reading/writing registers. Sometimes reducing the memory footprint matters, and you may want to use a smaller type. Likely not the case here.
BR,
Jani.
Quoted 5 lines
Use whatever you want. The real question to ask is why can't we use a generic type like int? Whether you use u8 or int, the CPU will still fetch a 64 byte cacheline. And this structure is only used at initialization, so performance is not a concern.
Signature · 1 line
Jani Nikula, Intel
PATCH v9 3/8 drm/xe/eustall: Add support to init, enable and disable EU stall sampling
In reply to Harish ChegondiImplement EU stall sampling APIs introduced in the previous patch for Xe_HPC (PVC). Add register definitions and the code that accesses these registers to the APIs.
Add initialization and clean up functions and their implementations, EU stall enable and disable functions.
v9: Moved structure definitions from xe_eu_stall.h to xe_eu_stall.c
Moved read and poll implementations to the next patch
Used xe_bo_create_pin_map_at_aligned instead of xe_bo_create_pin_map Changed lock names as per review feedback
Moved drop data handling into a subsequent patch
Moved code around as per review feedback
v8: Updated copyright year in xe_eu_stall_regs.h to 2025.
Renamed struct drm_xe_eu_stall_data_pvc to struct xe_eu_stall_data_pvc since it is a local structure.
v6: Fix buffer wrap around over write bug (Matt Olson)
--- drivers/gpu/drm/xe/regs/xe_eu_stall_regs.h | 29 ++ drivers/gpu/drm/xe/xe_eu_stall.c | 379 ++++++++++++++++++++- drivers/gpu/drm/xe/xe_eu_stall.h | 7 +- drivers/gpu/drm/xe/xe_gt.c | 6 + drivers/gpu/drm/xe/xe_gt_types.h | 3 + 5 files changed, 408 insertions(+), 16 deletions(-) create mode 100644 drivers/gpu/drm/xe/regs/xe_eu_stall_regs.h
drivers/gpu/drm/xe/regs/xe_eu_stall_regs.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2025 Intel Corporation +*/ + +#ifndef _XE_EU_STALL_REGS_H_ +#define _XE_EU_STALL_REGS_H_ + +#include "regs/xe_reg_defs.h" + +#define XEHPC_EUSTALL_BASE XE_REG_MCR(0xe520) +#define XEHPC_EUSTALL_BASE_BUF_ADDR REG_GENMASK(31, 6) +#define XEHPC_EUSTALL_BASE_XECORE_BUF_SZ REG_GENMASK(5, 3) +#define XEHPC_EUSTALL_BASE_ENABLE_SAMPLING REG_BIT(1) + +#define XEHPC_EUSTALL_BASE_UPPER XE_REG_MCR(0xe524) + +#define XEHPC_EUSTALL_REPORT XE_REG_MCR(0xe528, XE_REG_OPTION_MASKED) +#define XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK REG_GENMASK(15, 2) +#define XEHPC_EUSTALL_REPORT_OVERFLOW_DROP REG_BIT(1) + +#define XEHPC_EUSTALL_REPORT1 XE_REG_MCR(0xe52c, XE_REG_OPTION_MASKED) +#define XEHPC_EUSTALL_REPORT1_READ_PTR_MASK REG_GENMASK(15, 2) + +#define XEHPC_EUSTALL_CTRL XE_REG_MCR(0xe53c, XE_REG_OPTION_MASKED) +#define EUSTALL_MOCS REG_GENMASK(9, 3) +#define EUSTALL_SAMPLE_RATE REG_GENMASK(2, 0) + +#endif
drivers/gpu/drm/xe/xe_eu_stall.c +366 -13
456 lines not on this page · raw message
drivers/gpu/drm/xe/xe_eu_stall.h +4 -3
@@ -6,9 +6,10 @@#ifndef __XE_EU_STALL_H__#define __XE_EU_STALL_H__ -#include <drm/drm_device.h> -#include <drm/drm_file.h> -#include <linux/types.h> +#include "xe_gt_types.h" + +int xe_eu_stall_init (struct xe_gt *gt); +void xe_eu_stall_fini (struct xe_gt *gt); int xe_eu_stall_stream_open(struct drm_device *dev, u64 data,
drivers/gpu/drm/xe/xe_gt.c +6 -0
@@ -60,6 +60,7 @@#include "xe_vm.h" #include "xe_wa.h" #include "xe_wopcm.h" +#include "xe_eu_stall.h" static void gt_fini (struct drm_device *drm,void *arg) {
@@ -159,6 +160,7 @@ void xe_gt_remove(struct xe_gt *gt)xe_hw_fence_irq_finish (>->fence_irq[i]);xe_gt_disable_host_l2_vram (gt); +xe_eu_stall_fini (gt); }static void gt_reset_worker (struct work_struct *w);
@@ -625,6 +627,10 @@ int xe_gt_init(struct xe_gt *gt)xe_gt_record_user_engines (gt); + err =xe_eu_stall_init (gt); +if (err) +return err; +return 0 ; }
drivers/gpu/drm/xe/xe_gt_types.h +3 -0
@@ -430,6 +430,9 @@ struct xe_gt {/** @oa: oa observation subsystem per gt info */ struct xe_oa_gt oa; + +/** @eu_stall: EU stall counters subsystem per gt info */ + struct xe_eu_stall_gt *eu_stall; };#endif
Signature · 1 line
2.48.1
Re: [PATCH v9 3/8] drm/xe/eustall: Add support to init, enable and disable EU stall sampling
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 72 lines
drivers/gpu/drm/xe/xe_eu_stall.c +46
-0@@ -8,17 +8,57 @@#include <linux/poll.h> #include <linux/types.h> +#include <drm/drm_drv.h> #include <uapi/drm/xe_drm.h> +#include "xe_bo.h" #include "xe_device.h" #include "xe_eu_stall.h" +#include "xe_force_wake.h" +#include "xe_gt_mcr.h" #include "xe_gt_printk.h" #include "xe_gt_topology.h" #include "xe_macros.h" #include "xe_observation.h" +#include "xe_pm.h" + +#include "regs/xe_eu_stall_regs.h" +#include "regs/xe_gt_regs.h" + +#define POLL_PERIOD_MS 10static size_t per_xecore_buf_size =SZ_512K ; +struct per_xecore_buf { +/* Buffer vaddr */ +u8 *vaddr; +/* Write pointer */ +u32 write; +/* Read pointer */ +u32 read; +/* lock to protect read and write pointers */ +struct mutex ptr_lock; +}; + +struct xe_eu_stall_data_stream { +bool enabled; +size_t data_record_size; +size_t per_xecore_buf_size; +unsigned int wait_num_reports; +unsigned int sampling_rate_mult; + +struct xe_gt *gt; +struct xe_bo *bo; +struct per_xecore_buf *xecore_buf; +}; + +struct xe_eu_stall_gt { +/* Lock to protect stream */ +struct mutex stream_lock; +/* EU stall data stream */ +struct xe_eu_stall_data_stream *stream; +}; +/** * struct eu_stall_open_properties - EU stall sampling properties received * from user space at open. @@ -33,6 +73,47 @@ struct eu_stall_open_properties {struct xe_gt *gt; }; +/** +* struct xe_eu_stall_data_pvc - EU stall data format for PVC +* Bits Field +* @ip_addr: 0 to 28 IP (addr) +* @active_count: 29 to 36 active count +* @other_count: 37 to 44 other count
drivers/gpu/drm/xe/xe_eu_stall.c struct eu_stall_open_properties { · line 91
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+* @control_count: 45 to 52 control count +* @pipestall_count: 53 to 60 pipestall count +* @send_count: 61 to 68 send count +* @dist_acc_count: 69 to 76 dist_acc count +* @sbid_count: 77 to 84 sbid count +* @sync_count: 85 to 92 sync count +* @inst_fetch_count: 93 to 100 inst_fetch count +* @unused_bits: 101 to 127 unused bits +* @unused: remaining unused bytes +*/
I'd say delete this comment, it seems to be no zero extra information above what is already included in the struct below.
If you want to document the bit positions, add them on the same line as the struct field, e.g.:
__u64 active_count:8; /* bits 36:29 */
Quoted 101 lines
drivers/gpu/drm/xe/xe_eu_stall.c +87
-0+struct xe_eu_stall_data_pvc { +__u64 ip_addr:29 ; +__u64 active_count:8 ; +__u64 other_count:8 ; +__u64 control_count:8 ; +__u64 pipestall_count:8 ; +__u64 send_count:8 ; +__u64 dist_acc_count:8 ; +__u64 sbid_count:8 ; +__u64 sync_count:8 ; +__u64 inst_fetch_count:8 ; +__u64 unused_bits:27 ; +__u64 unused[6 ]; +} __packed; + +static size_t xe_eu_stall_data_record_size (struct xe_device *xe) +{ +unsigned long record_size =0 ; + +if (xe->info.platform ==XE_PVC ) + record_size =sizeof (struct xe_eu_stall_data_pvc ); + +return record_size; +} +/** * num_data_rows - Return the number of EU stall data rows of 64B each * for a given data size. @@ -44,6 +125,36 @@ static u32 num_data_rows(u32 data_size)return (data_size >>6 ); } +/** +* xe_eu_stall_init() - Allocate and initialize GT level EU stall data +* structure xe_eu_stall_gt within struct xe_gt. +* +* @gt: GT being initialized. +* +* Returns: zero on success or a negative error code. +*/ +int xe_eu_stall_init (struct xe_gt *gt) +{ + gt->eu_stall =kzalloc (sizeof (*gt->eu_stall),GFP_KERNEL ); +if (!gt->eu_stall) +return -ENOMEM ; + +mutex_init (>->eu_stall->stream_lock); +return 0 ; +} + +/** +* xe_eu_stall_fini() - Clean up the GT level EU stall data +* structure xe_eu_stall_gt within struct xe_gt. +* +* @gt: GT being cleaned up. +*/ +void xe_eu_stall_fini (struct xe_gt *gt) +{ +mutex_destroy (>->eu_stall->stream_lock); +kfree (gt->eu_stall); +} +static int set_prop_eu_stall_sampling_rate (struct xe_device *xe,u64 value,struct eu_stall_open_properties *props) {@@ -166,6 +277,120 @@ static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf,return ret; } +static void free_eu_stall_data_buf (struct xe_eu_stall_data_stream *stream) +{ +if (stream->bo) +xe_bo_unpin_map_no_vm (stream->bo); +} + +static int alloc_eu_stall_data_buf (struct xe_eu_stall_data_stream *stream, +u16 num_xecore) +{ +struct xe_tile *tile = stream->gt->tile; +struct xe_bo *bo; +u32 size; + + size = stream->per_xecore_buf_size * num_xecore; + + bo =xe_bo_create_pin_map_at_aligned (tile->xe, tile,NULL , + size, ~0ull , ttm_bo_type_kernel, +XE_BO_FLAG_SYSTEM |XE_BO_FLAG_GGTT ,SZ_64 ); +if (IS_ERR (bo)) +return PTR_ERR (bo); + +XE_WARN_ON (!IS_ALIGNED (xe_bo_ggtt_addr (bo),SZ_64 )); + stream->bo = bo; + +return 0 ; +} + +static int xe_eu_stall_stream_enable (struct xe_eu_stall_data_stream *stream) +{ +u32 write_ptr_reg, write_ptr, read_ptr_reg, reg_value; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt;
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 321
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+u16 group, instance; +unsigned int fw_ref; +int xecore; + +/* Take runtime pm ref and forcewake to disable RC6 */ +xe_pm_runtime_get (gt_to_xe (gt)); + fw_ref =xe_force_wake_get (gt_to_fw (gt),XE_FW_RENDER ); +if (!xe_force_wake_ref_has_domain (fw_ref,XE_FW_RENDER )) { +xe_gt_err (gt,"Failed to get RENDER forcewake\n" ); +xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );
The above line should not be there.
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 330
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+xe_pm_runtime_put (gt_to_xe (gt)); +return -ETIMEDOUT ; + } + +for_each_dss_steering (xecore, gt, group, instance) { + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);
My previous question regarding this is still unanswered: "Why do we need to do all this, read the write ptr reg and write to read ptr register? Can't we just set both read and write ptr to the start of the per xecore buf address (likely stream->bo ggtt_addr).
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 340
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+/* Initialize the read pointer to the write pointer */ +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + write_ptr <<=6 ; + write_ptr &= (stream->per_xecore_buf_size <<1 ) -1 ; + xecore_buf = &stream->xecore_buf[xecore]; + xecore_buf->write = write_ptr; + xecore_buf->read = write_ptr; + } + reg_value = _MASKED_FIELD(EUSTALL_MOCS | EUSTALL_SAMPLE_RATE, + REG_FIELD_PREP(EUSTALL_MOCS, gt->mocs.uc_index << 1) |
Please explain this mocs.uc_index business, as I mentioned in the prev version.
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 347
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+REG_FIELD_PREP (EUSTALL_SAMPLE_RATE , + stream->sampling_rate_mult)); +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_CTRL , reg_value); +/* GGTT addresses can never be > 32 bits */ +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE_UPPER ,0 ); + reg_value =xe_bo_ggtt_addr (stream->bo); + reg_value |=REG_FIELD_PREP (XEHPC_EUSTALL_BASE_XECORE_BUF_SZ ,2 );
This "2" should be derived from per_xecore_buf_size or stream->per_xecore_buf_size by dividing by 256, as I previously indicated.
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ reg_value |=XEHPC_EUSTALL_BASE_ENABLE_SAMPLING ; +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE , reg_value); + +return 0 ;
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 361
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+} + +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream, +struct eu_stall_open_properties *props) +{ +struct per_xecore_buf *xecore_buf; +u16 num_xecore, group, instance; +struct xe_gt *gt = stream->gt; +xe_dss_mask_t all_xecore; +u32 vaddr_offset;
Should probably be size_t
Quoted 12 lines
drivers/gpu/drm/xe/xe_eu_stall.c +12
-0+int ret, xecore; + + stream->sampling_rate_mult = props->sampling_rate_mult; + stream->wait_num_reports = props->wait_num_reports; + stream->per_xecore_buf_size = per_xecore_buf_size; + stream->data_record_size =xe_eu_stall_data_record_size (gt_to_xe (gt)); + +bitmap_or (all_xecore, gt->fuse_topo.g_dss_mask, gt->fuse_topo.c_dss_mask, +XE_MAX_DSS_FUSE_BITS ); +/* +* Enabled subslices can be discontiguous. Find the maximum number of subslices +* that are enabled.
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 383
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ + num_xecore =xe_gt_topology_mask_last_dss (all_xecore) +1 ; + + ret =alloc_eu_stall_data_buf (stream, num_xecore); +if (ret) +return ret; + + stream->xecore_buf =kcalloc (num_xecore,sizeof (*stream->xecore_buf),GFP_KERNEL ); +if (!stream->xecore_buf) +return -ENOMEM ;
What about free_eu_stall_data_buf here?
The way to do this is: either the function succeeds, or if it fails, it frees all resources it allocates before returning.
Quoted 81 lines
drivers/gpu/drm/xe/xe_eu_stall.c +59
-7+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; + vaddr_offset = xecore * stream->per_xecore_buf_size; + xecore_buf->vaddr = stream->bo->vmap.vaddr + vaddr_offset; +mutex_init (&xecore_buf->ptr_lock); + } +return 0 ; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -181,6 +406,49 @@ static __poll_t xe_eu_stall_stream_poll(struct file *file, poll_table *wait)return ret; } +static int xe_eu_stall_enable_locked (struct xe_eu_stall_data_stream *stream) +{ +int ret =0 ; + +if (stream->enabled) +return ret; + + stream->enabled = true; + + ret =xe_eu_stall_stream_enable (stream); +return ret; +} + +static int xe_eu_stall_disable_locked (struct xe_eu_stall_data_stream *stream) +{ +struct xe_gt *gt = stream->gt; + +if (!stream->enabled) +return 0 ; + + stream->enabled = false; + +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); + +xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER ); +xe_pm_runtime_put (gt_to_xe (gt)); + +return 0 ; +} + +static long xe_eu_stall_stream_ioctl_locked (struct xe_eu_stall_data_stream *stream, +unsigned int cmd,unsigned long arg) +{ +switch (cmd) { +case DRM_XE_OBSERVATION_IOCTL_ENABLE : +return xe_eu_stall_enable_locked (stream); +case DRM_XE_OBSERVATION_IOCTL_DISABLE : +return xe_eu_stall_disable_locked (stream); + } + +return -EINVAL ; +} +/** * xe_eu_stall_stream_ioctl - support ioctl() of a xe EU stall data stream fd. * @@ -195,14 +463,22 @@ static long xe_eu_stall_stream_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - switch (cmd) { -case DRM_XE_OBSERVATION_IOCTL_ENABLE : -return 0 ; -case DRM_XE_OBSERVATION_IOCTL_DISABLE : -return 0 ; - } +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +long ret; -return -EINVAL ; +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_ioctl_locked (stream, cmd, arg); +mutex_unlock (>->eu_stall->stream_lock);
drivers/gpu/drm/xe/xe_eu_stall.c static long xe_eu_stall_stream_ioctl(struct file *file, · line 482
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+ +return ret; +} + +static void +xe_eu_stall_stream_close_locked (struct xe_eu_stall_data_stream *stream) +{ +xe_eu_stall_disable_locked (stream); +free_eu_stall_data_buf (stream); }
I don't see the point of this function since it is just called from one place xe_eu_stall_stream_close. You might as well put these 2 lines of code there.
As suggested below we can have a xe_eu_stall_stream_destroy() which can be called from xe_eu_stall_stream_open_locked() and from xe_eu_stall_stream_close(). But optional.
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0/** @@ -215,6 +491,19 @@ static long xe_eu_stall_stream_ioctl(struct file *file,*/
drivers/gpu/drm/xe/xe_eu_stall.c static long xe_eu_stall_stream_ioctl(struct file *file, · line 501
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0static int xe_eu_stall_stream_close (struct inode *inode,struct file *file) { +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; + +mutex_lock (>->eu_stall->stream_lock); +xe_eu_stall_stream_close_locked (stream); +kfree (stream->xecore_buf); +kfree (stream); + gt->eu_stall->stream =NULL ;
This sequence should generally be identical to the error unwind sequence in xe_eu_stall_stream_open_locked.
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+mutex_unlock (>->eu_stall->stream_lock); + +/* Release the reference the EU stall stream kept on the driver */ +drm_dev_put (>->tile->xe->drm); +return 0 ; }
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 522
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-1@@ -230,7 +519,67 @@ static const struct file_operations fops_eu_stall = {static inline bool has_eu_stall_sampling_support (struct xe_device *xe) { -return false; +return ((xe->info.platform ==XE_PVC ) ? true : false);
return xe->info.platform == XE_PVC;
Quoted 27 lines
drivers/gpu/drm/xe/xe_eu_stall.c +27
-0+} + +/** +* xe_eu_stall_stream_open_locked - Open a EU stall data stream FD. +* @dev: drm device instance +* @props: individually validated u64 property value pairs +* @file: drm file +* +* Returns: zero on success or a negative error code. +*/ +static int +xe_eu_stall_stream_open_locked (struct drm_device *dev, +struct eu_stall_open_properties *props, +struct drm_file *file) +{ +struct xe_eu_stall_data_stream *stream; +struct xe_gt *gt = props->gt; +unsigned long f_flags =0 ; +int ret, stream_fd; + +/* Only one session can be active at any time */ +if (gt->eu_stall->stream) { +xe_gt_dbg (gt,"EU stall sampling session already active\n" ); +return -EBUSY ; + } + + stream =kzalloc (sizeof (*stream),GFP_KERNEL );
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 559
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+if (!stream) +return -ENOMEM ; + + gt->eu_stall->stream = stream; + stream->gt = gt; + + ret =xe_eu_stall_stream_init (stream, props); +if (ret) { +xe_gt_dbg (gt,"EU stall stream init failed : %d\n" , ret); + goto err_alloc;
This is wrong as pointed below. If this fails we jump to 'kfree(stream)'.
Also don't invent random label names. See xe_oa_stream_open_ioctl_locked(): err_destroy is for destroy, err_free for free etc.
So this should be goto err_free.
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 566
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ } + + stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall, stream, f_flags); +if (stream_fd <0 ) { + ret = stream_fd; +xe_gt_dbg (gt,"EU stall inode get fd failed : %d\n" , ret); + goto err_open;
goto err_destroy. see below.
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ } + +/* Take a reference on the driver that will be kept with stream_fd +* until its release.
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 580
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ +drm_dev_get (>->tile->xe->drm); + +return stream_fd; + +err_open: +free_eu_stall_data_buf (stream); +err_alloc: + gt->eu_stall->stream =NULL ; +kfree (stream->xecore_buf);
This is wrong, stream->xecore_buf is allocated in xe_eu_stall_stream_init and we are jumping here if xe_eu_stall_stream_init fails.
See xe_oa_stream_open_ioctl_locked() as an example for doing this unwinding correctly. We need a 'destroy' function which will free stuff allocated in xe_eu_stall_stream_init. And that function should be called from close/release too.
Ideally, we should not have to peek inside these functions to see what is being allocated there and then free them. The destroy function is the wrapper which should do all the free's.
Or maybe if you want to skip destroy() we can do that too, but at least the code here needs to be fixed.
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 581
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+kfree (stream);
err_free label before this line. Should do kfree(stream) and 'gt->eu_stall->stream = NULL'.
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 582
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+return ret;
So basically, without destroy(), this is something like:
err_destroy: kfree(stream->xecore_buf); free_eu_stall_data_buf(stream); err_free: kfree(stream); gt->eu_stall->stream = NULL; return ret;
Not what you have above. And the code under err_destroy can go into a destroy() function, but if you want we can skip that for now.
Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-1}/** @@ -252,7 +601,7 @@ int xe_eu_stall_stream_open(struct drm_device *dev, {struct xe_device *xe =to_xe_device (dev);struct eu_stall_open_properties props = {}; -int ret, stream_fd; +int ret;if (xe_observation_paranoid && !perfmon_capable ()) {xe_gt_dbg (props.gt,"Insufficient privileges for EU stall monitoring\n" );
drivers/gpu/drm/xe/xe_eu_stall.c int xe_eu_stall_stream_open(struct drm_device *dev, · line 617
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0@@ -263,6 +612,10 @@ int xe_eu_stall_stream_open(struct drm_device *dev,return -EPERM ; } +/* Initialize and set default values */ + props.wait_num_reports =1 ; + props.sampling_rate_mult =4 ;
What about props.gt? Can it also be initialized to gt[0], corresponding to default gt_id 0, basically default gt if not specified in uapi is gt0?
Quoted 49 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-4+ ret =xe_eu_stall_user_extensions (xe, data, &props);if (ret)return ret;@@ -272,9 +625,9 @@ int xe_eu_stall_stream_open(struct drm_device *dev,return -EINVAL ; } - stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall,NULL ,0 ); -if (stream_fd <0 ) -xe_gt_dbg (props.gt,"EU stall inode get fd failed : %d\n" , stream_fd); +mutex_lock (&props.gt->eu_stall->stream_lock); + ret =xe_eu_stall_stream_open_locked (dev, &props, file); +mutex_unlock (&props.gt->eu_stall->stream_lock); -return stream_fd; +return ret; }drivers/gpu/drm/xe/xe_eu_stall.h +4
-3@@ -6,9 +6,10 @@#ifndef __XE_EU_STALL_H__#define __XE_EU_STALL_H__ -#include <drm/drm_device.h> -#include <drm/drm_file.h> -#include <linux/types.h> +#include "xe_gt_types.h" + +int xe_eu_stall_init (struct xe_gt *gt); +void xe_eu_stall_fini (struct xe_gt *gt); int xe_eu_stall_stream_open(struct drm_device *dev, u64 data,drivers/gpu/drm/xe/xe_gt.c +1
-0@@ -60,6 +60,7 @@#include "xe_vm.h" #include "xe_wa.h" #include "xe_wopcm.h" +#include "xe_eu_stall.h" static void gt_fini (struct drm_device *drm,void *arg) {
drivers/gpu/drm/xe/xe_gt.c void xe_gt_remove(struct xe_gt *gt) · line 163
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt.c +1
-0@@ -159,6 +160,7 @@ void xe_gt_remove(struct xe_gt *gt)xe_hw_fence_irq_finish (>->fence_irq[i]);xe_gt_disable_host_l2_vram (gt); +xe_eu_stall_fini (gt);
Maybe move to the top of the function, so that fini happens in reverse order to init?
Quoted 19 lines
drivers/gpu/drm/xe/xe_gt.c +4
-0}static void gt_reset_worker (struct work_struct *w);@@ -625,6 +627,10 @@ int xe_gt_init(struct xe_gt *gt)xe_gt_record_user_engines (gt); + err =xe_eu_stall_init (gt); +if (err) +return err; +return 0 ; }drivers/gpu/drm/xe/xe_gt_types.h +0
-0
drivers/gpu/drm/xe/xe_gt_types.h struct xe_gt { · line 435
Quoted 6 lines
drivers/gpu/drm/xe/xe_gt_types.h +3
-0@@ -430,6 +430,9 @@ struct xe_gt {/** @oa: oa observation subsystem per gt info */ struct xe_oa_gt oa; + +/** @eu_stall: EU stall counters subsystem per gt info */ +struct xe_eu_stall_gt *eu_stall;
This needs a forward declaration for 'struct xe_eu_stall_gt'.
Quoted 6 lines
drivers/gpu/drm/xe/xe_gt_types.h +0
-1};#endif --2.48.1
Re: [PATCH v9 3/8] drm/xe/eustall: Add support to init, enable and disable EU stall sampling
Quoted 3 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Ashutosh,
Quoted 88 lines
Hi Harish,
Quoted 72 lines
drivers/gpu/drm/xe/xe_eu_stall.c +46
-0@@ -8,17 +8,57 @@#include <linux/poll.h> #include <linux/types.h> +#include <drm/drm_drv.h> #include <uapi/drm/xe_drm.h> +#include "xe_bo.h" #include "xe_device.h" #include "xe_eu_stall.h" +#include "xe_force_wake.h" +#include "xe_gt_mcr.h" #include "xe_gt_printk.h" #include "xe_gt_topology.h" #include "xe_macros.h" #include "xe_observation.h" +#include "xe_pm.h" + +#include "regs/xe_eu_stall_regs.h" +#include "regs/xe_gt_regs.h" + +#define POLL_PERIOD_MS 10static size_t per_xecore_buf_size =SZ_512K ; +struct per_xecore_buf { +/* Buffer vaddr */ +u8 *vaddr; +/* Write pointer */ +u32 write; +/* Read pointer */ +u32 read; +/* lock to protect read and write pointers */ +struct mutex ptr_lock; +}; + +struct xe_eu_stall_data_stream { +bool enabled; +size_t data_record_size; +size_t per_xecore_buf_size; +unsigned int wait_num_reports; +unsigned int sampling_rate_mult; + +struct xe_gt *gt; +struct xe_bo *bo; +struct per_xecore_buf *xecore_buf; +}; + +struct xe_eu_stall_gt { +/* Lock to protect stream */ +struct mutex stream_lock; +/* EU stall data stream */ +struct xe_eu_stall_data_stream *stream; +}; +/** * struct eu_stall_open_properties - EU stall sampling properties received * from user space at open. @@ -33,6 +73,47 @@ struct eu_stall_open_properties {struct xe_gt *gt; }; +/** +* struct xe_eu_stall_data_pvc - EU stall data format for PVC +* Bits Field +* @ip_addr: 0 to 28 IP (addr) +* @active_count: 29 to 36 active count +* @other_count: 37 to 44 other count drivers/gpu/drm/xe/xe_eu_stall.c struct eu_stall_open_properties { · line 91
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+* @control_count: 45 to 52 control count +* @pipestall_count: 53 to 60 pipestall count +* @send_count: 61 to 68 send count +* @dist_acc_count: 69 to 76 dist_acc count +* @sbid_count: 77 to 84 sbid count +* @sync_count: 85 to 92 sync count +* @inst_fetch_count: 93 to 100 inst_fetch count +* @unused_bits: 101 to 127 unused bits +* @unused: remaining unused bytes +*/ I'd say delete this comment, it seems to be no zero extra information above what is already included in the struct below.
Quoted 4 lines
If you want to document the bit positions, add them on the same line as the struct field, e.g.:
__u64 active_count:8; /* bits 36:29 */
hooks scripts complain if I don't describe individual fields. I either have to move the descriptions above each field or remove the description of the structure above - "struct xe_eu_stall_data_pvc - EU stall data format for PVC". Let me check if the hooks scripts complain if I document the bit positions like you suggested.
Quoted 106 lines
Quoted 106 lines
drivers/gpu/drm/xe/xe_eu_stall.c +91
-0+struct xe_eu_stall_data_pvc { +__u64 ip_addr:29 ; +__u64 active_count:8 ; +__u64 other_count:8 ; +__u64 control_count:8 ; +__u64 pipestall_count:8 ; +__u64 send_count:8 ; +__u64 dist_acc_count:8 ; +__u64 sbid_count:8 ; +__u64 sync_count:8 ; +__u64 inst_fetch_count:8 ; +__u64 unused_bits:27 ; +__u64 unused[6 ]; +} __packed; + +static size_t xe_eu_stall_data_record_size (struct xe_device *xe) +{ +unsigned long record_size =0 ; + +if (xe->info.platform ==XE_PVC ) + record_size =sizeof (struct xe_eu_stall_data_pvc ); + +return record_size; +} +/** * num_data_rows - Return the number of EU stall data rows of 64B each * for a given data size. @@ -44,6 +125,36 @@ static u32 num_data_rows(u32 data_size)return (data_size >>6 ); } +/** +* xe_eu_stall_init() - Allocate and initialize GT level EU stall data +* structure xe_eu_stall_gt within struct xe_gt. +* +* @gt: GT being initialized. +* +* Returns: zero on success or a negative error code. +*/ +int xe_eu_stall_init (struct xe_gt *gt) +{ + gt->eu_stall =kzalloc (sizeof (*gt->eu_stall),GFP_KERNEL ); +if (!gt->eu_stall) +return -ENOMEM ; + +mutex_init (>->eu_stall->stream_lock); +return 0 ; +} + +/** +* xe_eu_stall_fini() - Clean up the GT level EU stall data +* structure xe_eu_stall_gt within struct xe_gt. +* +* @gt: GT being cleaned up. +*/ +void xe_eu_stall_fini (struct xe_gt *gt) +{ +mutex_destroy (>->eu_stall->stream_lock); +kfree (gt->eu_stall); +} +static int set_prop_eu_stall_sampling_rate (struct xe_device *xe,u64 value,struct eu_stall_open_properties *props) {@@ -166,6 +277,120 @@ static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf,return ret; } +static void free_eu_stall_data_buf (struct xe_eu_stall_data_stream *stream) +{ +if (stream->bo) +xe_bo_unpin_map_no_vm (stream->bo); +} + +static int alloc_eu_stall_data_buf (struct xe_eu_stall_data_stream *stream, +u16 num_xecore) +{ +struct xe_tile *tile = stream->gt->tile; +struct xe_bo *bo; +u32 size; + + size = stream->per_xecore_buf_size * num_xecore; + + bo =xe_bo_create_pin_map_at_aligned (tile->xe, tile,NULL , + size, ~0ull , ttm_bo_type_kernel, +XE_BO_FLAG_SYSTEM |XE_BO_FLAG_GGTT ,SZ_64 ); +if (IS_ERR (bo)) +return PTR_ERR (bo); + +XE_WARN_ON (!IS_ALIGNED (xe_bo_ggtt_addr (bo),SZ_64 )); + stream->bo = bo; + +return 0 ; +} + +static int xe_eu_stall_stream_enable (struct xe_eu_stall_data_stream *stream) +{ +u32 write_ptr_reg, write_ptr, read_ptr_reg, reg_value; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +u16 group, instance; +unsigned int fw_ref; +int xecore; +
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 321
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+/* Take runtime pm ref and forcewake to disable RC6 */ +xe_pm_runtime_get (gt_to_xe (gt)); + fw_ref =xe_force_wake_get (gt_to_fw (gt),XE_FW_RENDER ); +if (!xe_force_wake_ref_has_domain (fw_ref,XE_FW_RENDER )) { +xe_gt_err (gt,"Failed to get RENDER forcewake\n" ); +xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );The above line should not be there.
I think you are correct. Not sure why there are several places in the xe driver where xe_force_wake_put() is called if a forcewake ref doesn't have a domain. It makes sense for XE_FORCEWAKE_ALL, as getting a reference on XE_FORCEWAKE_ALL will only get reference on applicable domains. Also I didn't use XE_FORCEWAKE_ALL as the all the EU stall hardware is in the XE_FW_RENDER domain so don't need XE_FORCEWAKE_ALL.
Quoted 15 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 330
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+xe_pm_runtime_put (gt_to_xe (gt)); +return -ETIMEDOUT ; + } + +for_each_dss_steering (xecore, gt, group, instance) { + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);My previous question regarding this is still unanswered: "Why do we need to do all this, read the write ptr reg and write to read ptr register? Can't we just set both read and write ptr to the start of the per xecore buf address (likely
stream->boggtt_addr).
Hardware doesn't allow writes to the write pointer. I believe it may be a security risk and therefore doesn't allow it. That's the reason I read the write pointer and set the value to the read pointer.
Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 340
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+/* Initialize the read pointer to the write pointer */ +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + write_ptr <<=6 ; + write_ptr &= (stream->per_xecore_buf_size <<1 ) -1 ; + xecore_buf = &stream->xecore_buf[xecore]; + xecore_buf->write = write_ptr; + xecore_buf->read = write_ptr; + } + reg_value = _MASKED_FIELD(EUSTALL_MOCS | EUSTALL_SAMPLE_RATE, + REG_FIELD_PREP(EUSTALL_MOCS, gt->mocs.uc_index << 1) |Please explain this mocs.uc_index business, as I mentioned in the prev version.
MOCS stands for Memory Object Control State is used to specify memory attributes. MOCS is a set of registers with each register specifying a certain combination of memory attributes. MOCS index is used to look up the set of MOCS registers where the corresponding control parameters are specified.
Bits[3:9] in the control register indicate the MOCS programming that should be applied to stall data eviction. As per the format, bit-0 is reserved and bits 1 to 6 are for MOCS table index. Therefore the index is shifted left by 1.
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 347
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+REG_FIELD_PREP (EUSTALL_SAMPLE_RATE , + stream->sampling_rate_mult)); +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_CTRL , reg_value); +/* GGTT addresses can never be > 32 bits */ +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE_UPPER ,0 ); + reg_value =xe_bo_ggtt_addr (stream->bo); + reg_value |=REG_FIELD_PREP (XEHPC_EUSTALL_BASE_XECORE_BUF_SZ ,2 );This "2" should be derived from
per_xecore_buf_sizeorstream->per_xecore_buf_sizeby dividing by 256, as I previously indicated.
Even though the hardware allows the user to configure the buffer size to 128K/256K/512K, for simplicity we decided to use the highest buffer size 512K for which the register setting is 2. If the future I plan to send out a patch that allows the user to change the buffer size via debugfs as the user may choose to use a smaller buffer size for debug purpose. In that patch I will add as you suggested. But for now, I think it is not required to divide by 256.
Quoted 43 lines
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ reg_value |=XEHPC_EUSTALL_BASE_ENABLE_SAMPLING ; +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE , reg_value); + +return 0 ;drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 361
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+} + +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream, +struct eu_stall_open_properties *props) +{ +struct per_xecore_buf *xecore_buf; +u16 num_xecore, group, instance; +struct xe_gt *gt = stream->gt; +xe_dss_mask_t all_xecore; +u32 vaddr_offset;Should probably be
size_tQuoted 12 lines
drivers/gpu/drm/xe/xe_eu_stall.c +12
-0+int ret, xecore; + + stream->sampling_rate_mult = props->sampling_rate_mult; + stream->wait_num_reports = props->wait_num_reports; + stream->per_xecore_buf_size = per_xecore_buf_size; + stream->data_record_size =xe_eu_stall_data_record_size (gt_to_xe (gt)); + +bitmap_or (all_xecore, gt->fuse_topo.g_dss_mask, gt->fuse_topo.c_dss_mask, +XE_MAX_DSS_FUSE_BITS ); +/* +* Enabled subslices can be discontiguous. Find the maximum number of subslices +* that are enabled. drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 383
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ + num_xecore =xe_gt_topology_mask_last_dss (all_xecore) +1 ; + + ret =alloc_eu_stall_data_buf (stream, num_xecore); +if (ret) +return ret; + + stream->xecore_buf =kcalloc (num_xecore,sizeof (*stream->xecore_buf),GFP_KERNEL ); +if (!stream->xecore_buf) +return -ENOMEM ;What about
free_eu_stall_data_bufhere?
Quoted 2 lines
The way to do this is: either the function succeeds, or if it fails, it frees all resources it allocates before returning.
Will fix it.
Quoted 88 lines
Quoted 88 lines
drivers/gpu/drm/xe/xe_eu_stall.c +65
-7+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; + vaddr_offset = xecore * stream->per_xecore_buf_size; + xecore_buf->vaddr = stream->bo->vmap.vaddr + vaddr_offset; +mutex_init (&xecore_buf->ptr_lock); + } +return 0 ; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -181,6 +406,49 @@ static __poll_t xe_eu_stall_stream_poll(struct file *file, poll_table *wait)return ret; } +static int xe_eu_stall_enable_locked (struct xe_eu_stall_data_stream *stream) +{ +int ret =0 ; + +if (stream->enabled) +return ret; + + stream->enabled = true; + + ret =xe_eu_stall_stream_enable (stream); +return ret; +} + +static int xe_eu_stall_disable_locked (struct xe_eu_stall_data_stream *stream) +{ +struct xe_gt *gt = stream->gt; + +if (!stream->enabled) +return 0 ; + + stream->enabled = false; + +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); + +xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER ); +xe_pm_runtime_put (gt_to_xe (gt)); + +return 0 ; +} + +static long xe_eu_stall_stream_ioctl_locked (struct xe_eu_stall_data_stream *stream, +unsigned int cmd,unsigned long arg) +{ +switch (cmd) { +case DRM_XE_OBSERVATION_IOCTL_ENABLE : +return xe_eu_stall_enable_locked (stream); +case DRM_XE_OBSERVATION_IOCTL_DISABLE : +return xe_eu_stall_disable_locked (stream); + } + +return -EINVAL ; +} +/** * xe_eu_stall_stream_ioctl - support ioctl() of a xe EU stall data stream fd. * @@ -195,14 +463,22 @@ static long xe_eu_stall_stream_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - switch (cmd) { -case DRM_XE_OBSERVATION_IOCTL_ENABLE : -return 0 ; -case DRM_XE_OBSERVATION_IOCTL_DISABLE : -return 0 ; - } +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +long ret; -return -EINVAL ; +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_ioctl_locked (stream, cmd, arg); +mutex_unlock (>->eu_stall->stream_lock); + +return ret; +} + +static void +xe_eu_stall_stream_close_locked (struct xe_eu_stall_data_stream *stream)
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static long xe_eu_stall_stream_ioctl(struct file *file, · line 482
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+{ +xe_eu_stall_disable_locked (stream); +free_eu_stall_data_buf (stream); }I don't see the point of this function since it is just called from one place
xe_eu_stall_stream_close. You might as well put these 2 lines of code there.
Will remove this.
Quoted 31 lines
As suggested below we can have a
xe_eu_stall_stream_destroy()which can be called fromxe_eu_stall_stream_open_locked()and fromxe_eu_stall_stream_close(). But optional.Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0/** @@ -215,6 +491,19 @@ static long xe_eu_stall_stream_ioctl(struct file *file,*/ drivers/gpu/drm/xe/xe_eu_stall.c static long xe_eu_stall_stream_ioctl(struct file *file, · line 501
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0static int xe_eu_stall_stream_close (struct inode *inode,struct file *file) { +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; + +mutex_lock (>->eu_stall->stream_lock); +xe_eu_stall_stream_close_locked (stream); +kfree (stream->xecore_buf); +kfree (stream); + gt->eu_stall->stream =NULL ;This sequence should generally be identical to the error unwind sequence in
xe_eu_stall_stream_open_locked.Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+mutex_unlock (>->eu_stall->stream_lock); + +/* Release the reference the EU stall stream kept on the driver */ +drm_dev_put (>->tile->xe->drm); +return 0 ; }
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 522
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-1@@ -230,7 +519,67 @@ static const struct file_operations fops_eu_stall = {static inline bool has_eu_stall_sampling_support (struct xe_device *xe) { -return false; +return ((xe->info.platform ==XE_PVC ) ? true : false);return
xe->info.platform==XE_PVC;
A subsequent patch adds another check for xe2. So, I used the conditional operator.
Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/xe/xe_eu_stall.c +31
-0+} + +/** +* xe_eu_stall_stream_open_locked - Open a EU stall data stream FD. +* @dev: drm device instance +* @props: individually validated u64 property value pairs +* @file: drm file +* +* Returns: zero on success or a negative error code. +*/ +static int +xe_eu_stall_stream_open_locked (struct drm_device *dev, +struct eu_stall_open_properties *props, +struct drm_file *file) +{ +struct xe_eu_stall_data_stream *stream; +struct xe_gt *gt = props->gt; +unsigned long f_flags =0 ; +int ret, stream_fd; + +/* Only one session can be active at any time */ +if (gt->eu_stall->stream) { +xe_gt_dbg (gt,"EU stall sampling session already active\n" ); +return -EBUSY ; + } + + stream =kzalloc (sizeof (*stream),GFP_KERNEL ); +if (!stream) +return -ENOMEM ; + + gt->eu_stall->stream = stream;
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 559
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ stream->gt = gt; + + ret =xe_eu_stall_stream_init (stream, props); +if (ret) { +xe_gt_dbg (gt,"EU stall stream init failed : %d\n" , ret); + goto err_alloc;This is wrong as pointed below. If this fails we jump to 'kfree(stream)'.
When I wrote this code initially, I may have tried to reduce the goto labels considering the fact that kfree() checks if the input ptr is NULL and returns if so.
Quoted 6 lines
Also don't invent random label names. See
xe_oa_stream_open_ioctl_locked():err_destroyis for destroy,err_freefor free etc.So this should be goto
err_free.
Will change it. I have seen code where the label is named err_alloc to undo an alloc. I think each developer names the labels differently.
Quoted 20 lines
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 566
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ } + + stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall, stream, f_flags); +if (stream_fd <0 ) { + ret = stream_fd; +xe_gt_dbg (gt,"EU stall inode get fd failed : %d\n" , ret); + goto err_open;goto
err_destroy. see below.Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+ } + +/* Take a reference on the driver that will be kept with stream_fd +* until its release. +*/ +drm_dev_get (>->tile->xe->drm); + +return stream_fd; +
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 580
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+err_open: +free_eu_stall_data_buf (stream); +err_alloc: + gt->eu_stall->stream =NULL ; +kfree (stream->xecore_buf);This is wrong,
stream->xecore_bufis allocated inxe_eu_stall_stream_initand we are jumping here ifxe_eu_stall_stream_initfails.
I will change it. But considering the fact that kfree() has a NULL check, this is not a bug.
Quoted 50 lines
See
xe_oa_stream_open_ioctl_locked()as an example for doing this unwinding correctly. We need a 'destroy' function which will free stuff allocated inxe_eu_stall_stream_init. And that function should be called from close/release too.Ideally, we should not have to peek inside these functions to see what is being allocated there and then free them. The destroy function is the wrapper which should do all the free's.
Or maybe if you want to skip
destroy()we can do that too, but at least the code here needs to be fixed.drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 581
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+kfree (stream);
err_freelabel before this line. Should do kfree(stream) and 'gt->eu_stall->stream= NULL'.drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 582
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+return ret;So basically, without
destroy(), this is something like:err_destroy: kfree(stream->xecore_buf); free_eu_stall_data_buf(stream); err_free: kfree(stream); gt->eu_stall->stream = NULL; return ret;Not what you have above. And the code under
err_destroycan go into adestroy()function, but if you want we can skip that for now.Quoted 16 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-1}/** @@ -252,7 +601,7 @@ int xe_eu_stall_stream_open(struct drm_device *dev, {struct xe_device *xe =to_xe_device (dev);struct eu_stall_open_properties props = {}; -int ret, stream_fd; +int ret;if (xe_observation_paranoid && !perfmon_capable ()) {xe_gt_dbg (props.gt,"Insufficient privileges for EU stall monitoring\n" );@@ -263,6 +612,10 @@ int xe_eu_stall_stream_open(struct drm_device *dev,return -EPERM ; }
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c int xe_eu_stall_stream_open(struct drm_device *dev, · line 617
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+/* Initialize and set default values */ + props.wait_num_reports =1 ; + props.sampling_rate_mult =4 ;What about props.gt? Can it also be initialized to gt[0], corresponding to default
gt_id0, basically default gt if not specified in uapi is gt0?
I had that initially, but there was a review comment in the first few versions of this patch review, I think from Matt Roper that GT ID should be mandatory from the user space.
Quoted 52 lines
Quoted 52 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-4+ ret =xe_eu_stall_user_extensions (xe, data, &props);if (ret)return ret;@@ -272,9 +625,9 @@ int xe_eu_stall_stream_open(struct drm_device *dev,return -EINVAL ; } - stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall,NULL ,0 ); -if (stream_fd <0 ) -xe_gt_dbg (props.gt,"EU stall inode get fd failed : %d\n" , stream_fd); +mutex_lock (&props.gt->eu_stall->stream_lock); + ret =xe_eu_stall_stream_open_locked (dev, &props, file); +mutex_unlock (&props.gt->eu_stall->stream_lock); -return stream_fd; +return ret; }drivers/gpu/drm/xe/xe_eu_stall.h +4
-3@@ -6,9 +6,10 @@#ifndef __XE_EU_STALL_H__#define __XE_EU_STALL_H__ -#include <drm/drm_device.h> -#include <drm/drm_file.h> -#include <linux/types.h> +#include "xe_gt_types.h" + +int xe_eu_stall_init (struct xe_gt *gt); +void xe_eu_stall_fini (struct xe_gt *gt); int xe_eu_stall_stream_open(struct drm_device *dev, u64 data,drivers/gpu/drm/xe/xe_gt.c +1
-0@@ -60,6 +60,7 @@#include "xe_vm.h" #include "xe_wa.h" #include "xe_wopcm.h" +#include "xe_eu_stall.h" static void gt_fini (struct drm_device *drm,void *arg) {@@ -159,6 +160,7 @@ void xe_gt_remove(struct xe_gt *gt)xe_hw_fence_irq_finish (>->fence_irq[i]);
Quoted 5 lines
drivers/gpu/drm/xe/xe_gt.c void xe_gt_remove(struct xe_gt *gt) · line 163
Quoted 2 lines
drivers/gpu/drm/xe/xe_gt.c +1
-0xe_gt_disable_host_l2_vram (gt); +xe_eu_stall_fini (gt);Maybe move to the top of the function, so that fini happens in reverse order to init?
Okay.
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/xe/xe_gt.c +4
-0}static void gt_reset_worker (struct work_struct *w);@@ -625,6 +627,10 @@ int xe_gt_init(struct xe_gt *gt)xe_gt_record_user_engines (gt); + err =xe_eu_stall_init (gt); +if (err) +return err; +return 0 ; }drivers/gpu/drm/xe/xe_gt_types.h +0
-0@@ -430,6 +430,9 @@ struct xe_gt {
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_types.h struct xe_gt { · line 435
Quoted 5 lines
drivers/gpu/drm/xe/xe_gt_types.h +3
-0/** @oa: oa observation subsystem per gt info */ struct xe_oa_gt oa; + +/** @eu_stall: EU stall counters subsystem per gt info */ +struct xe_eu_stall_gt *eu_stall;This needs a forward declaration for 'struct
xe_eu_stall_gt'.
I thought so initially, but the compiler didn't complain. I guess because eu_stall is a pointer and not an instance of struct xe_eu_stall_gt ?
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_types.h +0
-1};#endif --2.48.1
Thank You
Harish.
Re: [PATCH v9 3/8] drm/xe/eustall: Add support to init, enable and disable EU stall sampling
Quoted 97 lines · Harish Chegondi
Quoted 3 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Ashutosh,
Quoted 91 lines
Hi Harish,
Quoted 72 lines
drivers/gpu/drm/xe/xe_eu_stall.c +46
-0@@ -8,17 +8,57 @@#include <linux/poll.h> #include <linux/types.h> +#include <drm/drm_drv.h> #include <uapi/drm/xe_drm.h> +#include "xe_bo.h" #include "xe_device.h" #include "xe_eu_stall.h" +#include "xe_force_wake.h" +#include "xe_gt_mcr.h" #include "xe_gt_printk.h" #include "xe_gt_topology.h" #include "xe_macros.h" #include "xe_observation.h" +#include "xe_pm.h" + +#include "regs/xe_eu_stall_regs.h" +#include "regs/xe_gt_regs.h" + +#define POLL_PERIOD_MS 10static size_t per_xecore_buf_size =SZ_512K ; +struct per_xecore_buf { +/* Buffer vaddr */ +u8 *vaddr; +/* Write pointer */ +u32 write; +/* Read pointer */ +u32 read; +/* lock to protect read and write pointers */ +struct mutex ptr_lock; +}; + +struct xe_eu_stall_data_stream { +bool enabled; +size_t data_record_size; +size_t per_xecore_buf_size; +unsigned int wait_num_reports; +unsigned int sampling_rate_mult; + +struct xe_gt *gt; +struct xe_bo *bo; +struct per_xecore_buf *xecore_buf; +}; + +struct xe_eu_stall_gt { +/* Lock to protect stream */ +struct mutex stream_lock; +/* EU stall data stream */ +struct xe_eu_stall_data_stream *stream; +}; +/** * struct eu_stall_open_properties - EU stall sampling properties received * from user space at open. @@ -33,6 +73,47 @@ struct eu_stall_open_properties {struct xe_gt *gt; }; +/** +* struct xe_eu_stall_data_pvc - EU stall data format for PVC +* Bits Field +* @ip_addr: 0 to 28 IP (addr) +* @active_count: 29 to 36 active count +* @other_count: 37 to 44 other count drivers/gpu/drm/xe/xe_eu_stall.c struct eu_stall_open_properties { · line 91
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+* @control_count: 45 to 52 control count +* @pipestall_count: 53 to 60 pipestall count +* @send_count: 61 to 68 send count +* @dist_acc_count: 69 to 76 dist_acc count +* @sbid_count: 77 to 84 sbid count +* @sync_count: 85 to 92 sync count +* @inst_fetch_count: 93 to 100 inst_fetch count +* @unused_bits: 101 to 127 unused bits +* @unused: remaining unused bytes +*/ I'd say delete this comment, it seems to be no zero extra information above what is already included in the struct below.
If you want to document the bit positions, add them on the same line as the struct field, e.g.:
Quoted 7 lines
Quoted 1 line
__u64 active_count:8; /* bits 36:29 */hooks scripts complain if I don't describe individual fields. I either have to move the descriptions above each field or remove the description of the structure above - "struct
xe_eu_stall_data_pvc- EU stall data format for PVC". Let me check if the hooks scripts complain if I document the bit positions like you suggested.
Not sure about hooks, maybe because of kernel doc comment format? As long as we don't have kernel doc comment format, might be ok. Do we want these struct's to appear in documentation generated by kernel doc?
Quoted 115 lines
Quoted 107 lines
Quoted 107 lines
drivers/gpu/drm/xe/xe_eu_stall.c +91
-0+struct xe_eu_stall_data_pvc { +__u64 ip_addr:29 ; +__u64 active_count:8 ; +__u64 other_count:8 ; +__u64 control_count:8 ; +__u64 pipestall_count:8 ; +__u64 send_count:8 ; +__u64 dist_acc_count:8 ; +__u64 sbid_count:8 ; +__u64 sync_count:8 ; +__u64 inst_fetch_count:8 ; +__u64 unused_bits:27 ; +__u64 unused[6 ]; +} __packed; + +static size_t xe_eu_stall_data_record_size (struct xe_device *xe) +{ +unsigned long record_size =0 ; + +if (xe->info.platform ==XE_PVC ) + record_size =sizeof (struct xe_eu_stall_data_pvc ); + +return record_size; +} +/** * num_data_rows - Return the number of EU stall data rows of 64B each * for a given data size. @@ -44,6 +125,36 @@ static u32 num_data_rows(u32 data_size)return (data_size >>6 ); } +/** +* xe_eu_stall_init() - Allocate and initialize GT level EU stall data +* structure xe_eu_stall_gt within struct xe_gt. +* +* @gt: GT being initialized. +* +* Returns: zero on success or a negative error code. +*/ +int xe_eu_stall_init (struct xe_gt *gt) +{ + gt->eu_stall =kzalloc (sizeof (*gt->eu_stall),GFP_KERNEL ); +if (!gt->eu_stall) +return -ENOMEM ; + +mutex_init (>->eu_stall->stream_lock); +return 0 ; +} + +/** +* xe_eu_stall_fini() - Clean up the GT level EU stall data +* structure xe_eu_stall_gt within struct xe_gt. +* +* @gt: GT being cleaned up. +*/ +void xe_eu_stall_fini (struct xe_gt *gt) +{ +mutex_destroy (>->eu_stall->stream_lock); +kfree (gt->eu_stall); +} +static int set_prop_eu_stall_sampling_rate (struct xe_device *xe,u64 value,struct eu_stall_open_properties *props) {@@ -166,6 +277,120 @@ static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf,return ret; } +static void free_eu_stall_data_buf (struct xe_eu_stall_data_stream *stream) +{ +if (stream->bo) +xe_bo_unpin_map_no_vm (stream->bo); +} + +static int alloc_eu_stall_data_buf (struct xe_eu_stall_data_stream *stream, +u16 num_xecore) +{ +struct xe_tile *tile = stream->gt->tile; +struct xe_bo *bo; +u32 size; + + size = stream->per_xecore_buf_size * num_xecore; + + bo =xe_bo_create_pin_map_at_aligned (tile->xe, tile,NULL , + size, ~0ull , ttm_bo_type_kernel, +XE_BO_FLAG_SYSTEM |XE_BO_FLAG_GGTT ,SZ_64 ); +if (IS_ERR (bo)) +return PTR_ERR (bo); + +XE_WARN_ON (!IS_ALIGNED (xe_bo_ggtt_addr (bo),SZ_64 )); + stream->bo = bo; + +return 0 ; +} + +static int xe_eu_stall_stream_enable (struct xe_eu_stall_data_stream *stream) +{ +u32 write_ptr_reg, write_ptr, read_ptr_reg, reg_value; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +u16 group, instance; +unsigned int fw_ref; +int xecore; +Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 321
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+/* Take runtime pm ref and forcewake to disable RC6 */ +xe_pm_runtime_get (gt_to_xe (gt)); + fw_ref =xe_force_wake_get (gt_to_fw (gt),XE_FW_RENDER ); +if (!xe_force_wake_ref_has_domain (fw_ref,XE_FW_RENDER )) { +xe_gt_err (gt,"Failed to get RENDER forcewake\n" ); +xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );The above line should not be there.
Quoted 6 lines
I think you are correct. Not sure why there are several places in the xe driver where
xe_force_wake_put()is called if a forcewake ref doesn't have a domain. It makes sense forXE_FORCEWAKE_ALL, as getting a reference onXE_FORCEWAKE_ALLwill only get reference on applicable domains. Also I didn't useXE_FORCEWAKE_ALLas the all the EU stall hardware is in theXE_FW_RENDERdomain so don't needXE_FORCEWAKE_ALL.
Sorry, I thought I saw this line was not there in several places but now I can't find it. So maybe what you could do is:
xe_force_wake_put(gt_to_fw(gt), fw_ref);
Which is what seems to be done in these instances.
Quoted 16 lines
Quoted 15 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 330
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+xe_pm_runtime_put (gt_to_xe (gt)); +return -ETIMEDOUT ; + } + +for_each_dss_steering (xecore, gt, group, instance) { + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);My previous question regarding this is still unanswered: "Why do we need to do all this, read the write ptr reg and write to read ptr register? Can't we just set both read and write ptr to the start of the per xecore buf address (likely
stream->boggtt_addr).
Quoted 3 lines
Hardware doesn't allow writes to the write pointer. I believe it may be a security risk and therefore doesn't allow it. That's the reason I read the write pointer and set the value to the read pointer.
OK, understood now. I thought the write pointer could be written by a masked write, but I see that was disallowed later in Bspec.
Quoted 19 lines
Quoted 14 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 340
Quoted 12 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+/* Initialize the read pointer to the write pointer */ +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + write_ptr <<=6 ; + write_ptr &= (stream->per_xecore_buf_size <<1 ) -1 ; + xecore_buf = &stream->xecore_buf[xecore]; + xecore_buf->write = write_ptr; + xecore_buf->read = write_ptr; + } + reg_value = _MASKED_FIELD(EUSTALL_MOCS | EUSTALL_SAMPLE_RATE, + REG_FIELD_PREP(EUSTALL_MOCS, gt->mocs.uc_index << 1) |Please explain this mocs.uc_index business, as I mentioned in the prev version.
MOCS stands for Memory Object Control State is used to specify memory attributes. MOCS is a set of registers with each register specifying a certain combination of memory attributes. MOCS index is used to look up the set of MOCS registers where the corresponding control parameters are specified.
Quoted 4 lines
Bits[3:9] in the control register indicate the MOCS programming that should be applied to stall data eviction. As per the format, bit-0 is reserved and bits 1 to 6 are for MOCS table index. Therefore the index is shifted left by 1.
OK, thanks.
Quoted 13 lines
Quoted 12 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 347
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+REG_FIELD_PREP (EUSTALL_SAMPLE_RATE , + stream->sampling_rate_mult)); +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_CTRL , reg_value); +/* GGTT addresses can never be > 32 bits */ +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE_UPPER ,0 ); + reg_value =xe_bo_ggtt_addr (stream->bo); + reg_value |=REG_FIELD_PREP (XEHPC_EUSTALL_BASE_XECORE_BUF_SZ ,2 );This "2" should be derived from
per_xecore_buf_sizeorstream->per_xecore_buf_sizeby dividing by 256, as I previously indicated.
Quoted 7 lines
Even though the hardware allows the user to configure the buffer size to 128K/256K/512K, for simplicity we decided to use the highest buffer size 512K for which the register setting is 2. If the future I plan to send out a patch that allows the user to change the buffer size via debugfs as the user may choose to use a smaller buffer size for debug purpose. In that patch I will add as you suggested. But for now, I think it is not required to divide by 256.
I think we should show the relationship between "2" and 512K in the code, so the connection is clear. Also in case someone changes the default per_xecore_buf_size value and things break.
Can just do something like:
reg_value |= REG_FIELD_PREP(XEHPC_EUSTALL_BASE_XECORE_BUF_SZ, stream->per_xecore_buf_size / 256);
Or define a variable.
You will need to / 256 even for debugfs. Though I am not sure if we should define a property or debugfs. We'll see.
Quoted 177 lines
Quoted 44 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ reg_value |=XEHPC_EUSTALL_BASE_ENABLE_SAMPLING ; +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE , reg_value); + +return 0 ;drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 361
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+} + +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream, +struct eu_stall_open_properties *props) +{ +struct per_xecore_buf *xecore_buf; +u16 num_xecore, group, instance; +struct xe_gt *gt = stream->gt; +xe_dss_mask_t all_xecore; +u32 vaddr_offset;Should probably be
size_tQuoted 12 lines
drivers/gpu/drm/xe/xe_eu_stall.c +12
-0+int ret, xecore; + + stream->sampling_rate_mult = props->sampling_rate_mult; + stream->wait_num_reports = props->wait_num_reports; + stream->per_xecore_buf_size = per_xecore_buf_size; + stream->data_record_size =xe_eu_stall_data_record_size (gt_to_xe (gt)); + +bitmap_or (all_xecore, gt->fuse_topo.g_dss_mask, gt->fuse_topo.c_dss_mask, +XE_MAX_DSS_FUSE_BITS ); +/* +* Enabled subslices can be discontiguous. Find the maximum number of subslices +* that are enabled. drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read(struct file *file, char __user *buf, · line 383
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ + num_xecore =xe_gt_topology_mask_last_dss (all_xecore) +1 ; + + ret =alloc_eu_stall_data_buf (stream, num_xecore); +if (ret) +return ret; + + stream->xecore_buf =kcalloc (num_xecore,sizeof (*stream->xecore_buf),GFP_KERNEL ); +if (!stream->xecore_buf) +return -ENOMEM ;What about
free_eu_stall_data_bufhere?Quoted 2 lines
The way to do this is: either the function succeeds, or if it fails, it frees all resources it allocates before returning.
Will fix it.
Quoted 88 lines
Quoted 88 lines
drivers/gpu/drm/xe/xe_eu_stall.c +65
-7+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; + vaddr_offset = xecore * stream->per_xecore_buf_size; + xecore_buf->vaddr = stream->bo->vmap.vaddr + vaddr_offset; +mutex_init (&xecore_buf->ptr_lock); + } +return 0 ; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -181,6 +406,49 @@ static __poll_t xe_eu_stall_stream_poll(struct file *file, poll_table *wait)return ret; } +static int xe_eu_stall_enable_locked (struct xe_eu_stall_data_stream *stream) +{ +int ret =0 ; + +if (stream->enabled) +return ret; + + stream->enabled = true; + + ret =xe_eu_stall_stream_enable (stream); +return ret; +} + +static int xe_eu_stall_disable_locked (struct xe_eu_stall_data_stream *stream) +{ +struct xe_gt *gt = stream->gt; + +if (!stream->enabled) +return 0 ; + + stream->enabled = false; + +xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); + +xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER ); +xe_pm_runtime_put (gt_to_xe (gt)); + +return 0 ; +} + +static long xe_eu_stall_stream_ioctl_locked (struct xe_eu_stall_data_stream *stream, +unsigned int cmd,unsigned long arg) +{ +switch (cmd) { +case DRM_XE_OBSERVATION_IOCTL_ENABLE : +return xe_eu_stall_enable_locked (stream); +case DRM_XE_OBSERVATION_IOCTL_DISABLE : +return xe_eu_stall_disable_locked (stream); + } + +return -EINVAL ; +} +/** * xe_eu_stall_stream_ioctl - support ioctl() of a xe EU stall data stream fd. * @@ -195,14 +463,22 @@ static long xe_eu_stall_stream_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - switch (cmd) { -case DRM_XE_OBSERVATION_IOCTL_ENABLE : -return 0 ; -case DRM_XE_OBSERVATION_IOCTL_DISABLE : -return 0 ; - } +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +long ret; -return -EINVAL ; +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_ioctl_locked (stream, cmd, arg); +mutex_unlock (>->eu_stall->stream_lock); + +return ret; +} + +static void +xe_eu_stall_stream_close_locked (struct xe_eu_stall_data_stream *stream)Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static long xe_eu_stall_stream_ioctl(struct file *file, · line 482
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+{ +xe_eu_stall_disable_locked (stream); +free_eu_stall_data_buf (stream); }I don't see the point of this function since it is just called from one place
xe_eu_stall_stream_close. You might as well put these 2 lines of code there.Will remove this.
Quoted 33 lines
As suggested below we can have a
xe_eu_stall_stream_destroy()which can be called fromxe_eu_stall_stream_open_locked()and fromxe_eu_stall_stream_close(). But optional.Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0/** @@ -215,6 +491,19 @@ static long xe_eu_stall_stream_ioctl(struct file *file,*/ drivers/gpu/drm/xe/xe_eu_stall.c static long xe_eu_stall_stream_ioctl(struct file *file, · line 501
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0static int xe_eu_stall_stream_close (struct inode *inode,struct file *file) { +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; + +mutex_lock (>->eu_stall->stream_lock); +xe_eu_stall_stream_close_locked (stream); +kfree (stream->xecore_buf); +kfree (stream); + gt->eu_stall->stream =NULL ;This sequence should generally be identical to the error unwind sequence in
xe_eu_stall_stream_open_locked.Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+mutex_unlock (>->eu_stall->stream_lock); + +/* Release the reference the EU stall stream kept on the driver */ +drm_dev_put (>->tile->xe->drm); +return 0 ; }@@ -230,7 +519,67 @@ static const struct file_operations fops_eu_stall = {
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 522
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-1static inline bool has_eu_stall_sampling_support (struct xe_device *xe) { -return false; +return ((xe->info.platform ==XE_PVC ) ? true : false);return
xe->info.platform==XE_PVC;A subsequent patch adds another check for xe2. So, I used the conditional operator.
You don't need the conditional operator there either. So conditional operator needs to go.
Quoted 79 lines
Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/xe/xe_eu_stall.c +31
-0+} + +/** +* xe_eu_stall_stream_open_locked - Open a EU stall data stream FD. +* @dev: drm device instance +* @props: individually validated u64 property value pairs +* @file: drm file +* +* Returns: zero on success or a negative error code. +*/ +static int +xe_eu_stall_stream_open_locked (struct drm_device *dev, +struct eu_stall_open_properties *props, +struct drm_file *file) +{ +struct xe_eu_stall_data_stream *stream; +struct xe_gt *gt = props->gt; +unsigned long f_flags =0 ; +int ret, stream_fd; + +/* Only one session can be active at any time */ +if (gt->eu_stall->stream) { +xe_gt_dbg (gt,"EU stall sampling session already active\n" ); +return -EBUSY ; + } + + stream =kzalloc (sizeof (*stream),GFP_KERNEL ); +if (!stream) +return -ENOMEM ; + + gt->eu_stall->stream = stream;Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 559
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ stream->gt = gt; + + ret =xe_eu_stall_stream_init (stream, props); +if (ret) { +xe_gt_dbg (gt,"EU stall stream init failed : %d\n" , ret); + goto err_alloc;This is wrong as pointed below. If this fails we jump to 'kfree(stream)'.
When I wrote this code initially, I may have tried to reduce the goto labels considering the fact that
kfree()checks if the input ptr is NULL and returns if so.Quoted 6 lines
Also don't invent random label names. See
xe_oa_stream_open_ioctl_locked():err_destroyis for destroy,err_freefor free etc.So this should be goto
err_free.Will change it. I have seen code where the label is named
err_allocto undo an alloc. I think each developer names the labels differently.Quoted 20 lines
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 566
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ } + + stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall, stream, f_flags); +if (stream_fd <0 ) { + ret = stream_fd; +xe_gt_dbg (gt,"EU stall inode get fd failed : %d\n" , ret); + goto err_open;goto
err_destroy. see below.Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+ } + +/* Take a reference on the driver that will be kept with stream_fd +* until its release. +*/ +drm_dev_get (>->tile->xe->drm); + +return stream_fd; +Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 580
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+err_open: +free_eu_stall_data_buf (stream); +err_alloc: + gt->eu_stall->stream =NULL ; +kfree (stream->xecore_buf);This is wrong,
stream->xecore_bufis allocated inxe_eu_stall_stream_initand we are jumping here ifxe_eu_stall_stream_initfails.
Quoted 2 lines
I will change it. But considering the fact that
kfree()has a NULL check, this is not a bug.
OK, but still to keep things clean, let's undo things in the correct order.
Quoted 57 lines
Quoted 50 lines
See
xe_oa_stream_open_ioctl_locked()as an example for doing this unwinding correctly. We need a 'destroy' function which will free stuff allocated inxe_eu_stall_stream_init. And that function should be called from close/release too.Ideally, we should not have to peek inside these functions to see what is being allocated there and then free them. The destroy function is the wrapper which should do all the free's.
Or maybe if you want to skip
destroy()we can do that too, but at least the code here needs to be fixed.drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 581
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+kfree (stream);
err_freelabel before this line. Should do kfree(stream) and 'gt->eu_stall->stream= NULL'.drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 582
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+return ret;So basically, without
destroy(), this is something like:err_destroy: kfree(stream->xecore_buf); free_eu_stall_data_buf(stream); err_free: kfree(stream); gt->eu_stall->stream = NULL; return ret;Not what you have above. And the code under
err_destroycan go into adestroy()function, but if you want we can skip that for now.Quoted 16 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-1}/** @@ -252,7 +601,7 @@ int xe_eu_stall_stream_open(struct drm_device *dev, {struct xe_device *xe =to_xe_device (dev);struct eu_stall_open_properties props = {}; -int ret, stream_fd; +int ret;if (xe_observation_paranoid && !perfmon_capable ()) {xe_gt_dbg (props.gt,"Insufficient privileges for EU stall monitoring\n" );@@ -263,6 +612,10 @@ int xe_eu_stall_stream_open(struct drm_device *dev,return -EPERM ; }Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c int xe_eu_stall_stream_open(struct drm_device *dev, · line 617
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+/* Initialize and set default values */ + props.wait_num_reports =1 ; + props.sampling_rate_mult =4 ;What about props.gt? Can it also be initialized to gt[0], corresponding to default
gt_id0, basically default gt if not specified in uapi is gt0?
Quoted 3 lines
I had that initially, but there was a review comment in the first few versions of this patch review, I think from Matt Roper that GT ID should be mandatory from the user space.
But why? Anyway either way is ok, so let's decide one way or another and go with it. I think I prefer default gt_id 0 (rather than a required parameter), but otherwise is ok too.
Quoted 88 lines
Quoted 53 lines
Quoted 53 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-4+ ret =xe_eu_stall_user_extensions (xe, data, &props);if (ret)return ret;@@ -272,9 +625,9 @@ int xe_eu_stall_stream_open(struct drm_device *dev,return -EINVAL ; } - stream_fd =anon_inode_getfd ("[xe_eu_stall]" , &fops_eu_stall,NULL ,0 ); -if (stream_fd <0 ) -xe_gt_dbg (props.gt,"EU stall inode get fd failed : %d\n" , stream_fd); +mutex_lock (&props.gt->eu_stall->stream_lock); + ret =xe_eu_stall_stream_open_locked (dev, &props, file); +mutex_unlock (&props.gt->eu_stall->stream_lock); -return stream_fd; +return ret; }drivers/gpu/drm/xe/xe_eu_stall.h +4
-3@@ -6,9 +6,10 @@#ifndef __XE_EU_STALL_H__#define __XE_EU_STALL_H__ -#include <drm/drm_device.h> -#include <drm/drm_file.h> -#include <linux/types.h> +#include "xe_gt_types.h" + +int xe_eu_stall_init (struct xe_gt *gt); +void xe_eu_stall_fini (struct xe_gt *gt); int xe_eu_stall_stream_open(struct drm_device *dev, u64 data,drivers/gpu/drm/xe/xe_gt.c +1
-0@@ -60,6 +60,7 @@#include "xe_vm.h" #include "xe_wa.h" #include "xe_wopcm.h" +#include "xe_eu_stall.h" static void gt_fini (struct drm_device *drm,void *arg) {@@ -159,6 +160,7 @@ void xe_gt_remove(struct xe_gt *gt)xe_hw_fence_irq_finish (>->fence_irq[i]);Quoted 5 lines
drivers/gpu/drm/xe/xe_gt.c void xe_gt_remove(struct xe_gt *gt) · line 163
Quoted 2 lines
drivers/gpu/drm/xe/xe_gt.c +1
-0xe_gt_disable_host_l2_vram (gt); +xe_eu_stall_fini (gt);Maybe move to the top of the function, so that fini happens in reverse order to init?
Okay.
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/xe/xe_gt.c +4
-0}static void gt_reset_worker (struct work_struct *w);@@ -625,6 +627,10 @@ int xe_gt_init(struct xe_gt *gt)xe_gt_record_user_engines (gt); + err =xe_eu_stall_init (gt); +if (err) +return err; +return 0 ; }drivers/gpu/drm/xe/xe_gt_types.h +0
-0@@ -430,6 +430,9 @@ struct xe_gt {Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_types.h struct xe_gt { · line 435
Quoted 5 lines
drivers/gpu/drm/xe/xe_gt_types.h +3
-0/** @oa: oa observation subsystem per gt info */ struct xe_oa_gt oa; + +/** @eu_stall: EU stall counters subsystem per gt info */ +struct xe_eu_stall_gt *eu_stall;This needs a forward declaration for 'struct
xe_eu_stall_gt'.
Quoted 2 lines
I thought so initially, but the compiler didn't complain. I guess because
eu_stallis a pointer and not an instance of structxe_eu_stall_gt?
I thought forward declarations are used for pointers (you can't have forward declarations if you have real structs, rather than pointer to struct). So we need that I think.
Quoted 10 lines
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/xe/xe_gt_types.h +0
-1};#endif --2.48.1
Thank You
Harish.
PATCH v9 4/8 drm/xe/eustall: Add support to read() and poll() EU stall data
In reply to Harish ChegondiImplement the EU stall sampling APIs to read() and poll() EU stall data. A work function periodically polls the EU stall data buffer write pointer registers to look for any new data and caches the write pointer. The read function compares the cached read and write pointers and copies any new data to the user space.
v9: New patch split from the previous patch.
Used *_delayed_work functions instead of hrtimer Addressed the review feedback in read and poll functions
--- drivers/gpu/drm/xe/xe_eu_stall.c | 267 ++++++++++++++++++++++++++++++- drivers/gpu/drm/xe/xe_trace.h | 33 ++++ 2 files changed, 298 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_eu_stall.c +265 -2
@@ -21,6 +21,7 @@#include "xe_macros.h" #include "xe_observation.h" #include "xe_pm.h" +#include "xe_trace.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h"
@@ -41,7 +42,9 @@ struct per_xecore_buf { };struct xe_eu_stall_data_stream { +bool pollin;bool enabled; +wait_queue_head_t poll_wq;size_t data_record_size;size_t per_xecore_buf_size;unsigned int wait_num_reports;
@@ -50,6 +53,8 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct delayed_work buf_poll_work; +struct workqueue_struct *buf_poll_wq; };struct xe_eu_stall_gt {
@@ -256,6 +261,190 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,return 0 ; } +/** +* buf_data_size - Calculate the number of bytes in a circular buffer +* given the read and write pointers and the size of +* the buffer. +* +* @buf_size: Size of the circular buffer +* @read_ptr: Read pointer with an additional overflow bit +* @write_ptr: Write pointer with an additional overflow bit +* +* Since the read and write pointers have an additional overflow bit, +* this function calculates the offsets from the pointers and use the +* offsets to calculate the data size in the buffer. +* +* Returns: number of bytes of data in the buffer +*/ +static u32 buf_data_size (size_t buf_size,u32 read_ptr,u32 write_ptr) +{ +u32 read_offset, write_offset, size =0 ; + +if (read_ptr == write_ptr) + goto exit; + + read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + +if (write_offset > read_offset) + size = write_offset - read_offset; +else + size = buf_size - read_offset + write_offset; +exit: +return size; +} + +/** +* eu_stall_data_buf_poll - Poll for EU stall data in the buffer. +* +* @stream: xe EU stall data stream instance +* +* Returns: true if the EU stall buffer contains minimum stall data as +* specified by the event report count, else false. +*/ +static bool eu_stall_data_buf_poll (struct xe_eu_stall_data_stream *stream) +{ +u32 read_ptr, write_ptr_reg, write_ptr, total_data =0 ; +u32 buf_size = stream->per_xecore_buf_size; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +bool min_data_present = false; +u16 group, instance; +unsigned int xecore; + +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock); + read_ptr = xecore_buf->read; + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , + group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + write_ptr <<=6 ; + write_ptr &= ((buf_size <<1 ) -1 ); +if (write_ptr != read_ptr && !min_data_present) { + total_data +=buf_data_size (buf_size, read_ptr, write_ptr); +/* +* Check if there are at least minimum number of stall data +* rows for poll() to indicate that the data is present. +* Each stall data row is 64B (cacheline size). +*/ +if (num_data_rows (total_data) >= stream->wait_num_reports) + min_data_present = true; + } + xecore_buf->write = write_ptr; +mutex_unlock (&xecore_buf->ptr_lock); + } +return min_data_present; +} + +static int xe_eu_stall_data_buf_read (struct xe_eu_stall_data_stream *stream, +char __user *buf,size_t count, +size_t *total_data_size,struct xe_gt *gt, +u16 group,u16 instance,unsigned int xecore) +{ +size_t read_data_size, copy_size, buf_size, data_record_size; +u32 read_ptr_reg, read_ptr, write_ptr; +u8 *xecore_start_vaddr, *read_vaddr; +struct per_xecore_buf *xecore_buf; +u32 read_offset, write_offset; +int ret =0 ; + +/* Hardware increments the read and write pointers such that they can +* overflow into one additional bit. For example, a 256KB size buffer +* offset pointer needs 18 bits. But HW uses 19 bits for the read and +* write pointers. This technique avoids wasting a slot in the buffer. +* Read and write offsets are calculated from the pointers in order to +* check if the write pointer has wrapped around the array. +*/ + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock); + xecore_start_vaddr = xecore_buf->vaddr; + read_ptr = xecore_buf->read; + write_ptr = xecore_buf->write; + buf_size = stream->per_xecore_buf_size; + data_record_size = stream->data_record_size; + + read_data_size =buf_data_size (buf_size, read_ptr, write_ptr); +/* Read only the data that the user space buffer can accommodate */ +if ((*total_data_size + read_data_size) > count) { + read_data_size = count - *total_data_size; + read_data_size = (read_data_size / data_record_size) * data_record_size; + } +if (read_data_size ==0 ) + goto exit; + + read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + read_vaddr = xecore_start_vaddr + read_offset; + +if (write_offset > read_offset) { +if (copy_to_user ((buf + *total_data_size), read_vaddr, read_data_size)) { + ret = -EFAULT ; + goto exit; + } + }else { +if (read_data_size >= (buf_size - read_offset)) + copy_size = buf_size - read_offset; +else + copy_size = read_data_size; +if (copy_to_user ((buf + *total_data_size), read_vaddr, copy_size)) { + ret = -EFAULT ; + goto exit; + } +if (copy_to_user ((buf + *total_data_size + copy_size), + xecore_start_vaddr, read_data_size - copy_size)) { + ret = -EFAULT ; + goto exit; + } + } + + *total_data_size += read_data_size; + read_ptr += read_data_size; + +/* Read pointer can overflow into one additional bit */ + read_ptr &= (buf_size <<1 ) -1 ; + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , (read_ptr >>6 )); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg); +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + xecore_buf->read = read_ptr; +trace_xe_eu_stall_data_read (group, instance, read_ptr, write_ptr, + read_offset, write_offset, *total_data_size); +exit: +mutex_unlock (&xecore_buf->ptr_lock); +return ret; +} + +/** +* xe_eu_stall_stream_read_locked - copy EU stall counters data from the +* per xecore buffers to the userspace buffer +* @stream: A stream opened for EU stall count metrics +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* +* Returns: Number of bytes copied or a negative error code +* If we've successfully copied any data then reporting that takes +* precedence over any internal error status, so the data isn't lost. +*/ +static ssize_t xe_eu_stall_stream_read_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,char __user *buf, +size_t count) +{ +struct xe_gt *gt = stream->gt; +size_t total_size =0 ; +u16 group, instance; +unsigned int xecore; +int ret =0 ; + +for_each_dss_steering (xecore, gt, group, instance) { + ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, + gt, group, instance, xecore); +if (ret || count == total_size) +break ; + } +return total_size ?: (ret ?: -EAGAIN ); +} +/** * xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. *
@@ -272,7 +461,35 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -ssize_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +ssize_t ret; + +if (count ==0 ) +return -EINVAL ; + +if (!stream->enabled) { +xe_gt_dbg (gt,"EU stall data stream not enabled to read\n" ); +return -EINVAL ; + } + +if (!(file->f_flags &O_NONBLOCK )) { +do { + ret =wait_event_interruptible (stream->poll_wq, stream->pollin); +if (ret) +return -EINTR ; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + }while (ret == -EAGAIN ); + }else { +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + } + + stream->pollin = false;return ret; }
@@ -281,6 +498,7 @@ static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) {if (stream->bo)xe_bo_unpin_map_no_vm (stream->bo); +destroy_workqueue (stream->buf_poll_wq); } static int alloc_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream,
@@ -351,6 +569,21 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return 0 ; } +static void eu_stall_data_buf_poll_work_fn (struct work_struct *work) +{ +struct xe_eu_stall_data_stream *stream = +container_of (work,typeof (*stream), buf_poll_work.work); + +if (eu_stall_data_buf_poll (stream)) { + stream->pollin = true; +wake_up (&stream->poll_wq); + } +if (stream->enabled) +queue_delayed_work (stream->buf_poll_wq, + &stream->buf_poll_work, +msecs_to_jiffies (POLL_PERIOD_MS )); +} +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream,struct eu_stall_open_properties *props) {
@@ -361,6 +594,11 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,u32 vaddr_offset;int ret, xecore; +init_waitqueue_head (&stream->poll_wq); +INIT_DELAYED_WORK (&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); + stream->buf_poll_wq =alloc_ordered_workqueue ("xe_eu_stall" ,0 ); +if (!stream->buf_poll_wq) +return -ENOMEM ; stream->sampling_rate_mult = props->sampling_rate_mult; stream->wait_num_reports = props->wait_num_reports; stream->per_xecore_buf_size = per_xecore_buf_size;
@@ -391,6 +629,19 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,return 0 ; } +static __poll_t xe_eu_stall_stream_poll_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,poll_table *wait) +{ +__poll_t events =0 ; + +poll_wait (file, &stream->poll_wq, wait); + +if (stream->pollin) + events |=EPOLLIN ; + +return events; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. *
@@ -401,7 +652,13 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,*/ static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) { -__poll_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +__poll_t ret; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_poll_locked (stream, file, wait); +mutex_unlock (>->eu_stall->stream_lock);return ret; }
@@ -416,6 +673,9 @@ static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = true; ret =xe_eu_stall_stream_enable (stream); +queue_delayed_work (stream->buf_poll_wq, + &stream->buf_poll_work, +msecs_to_jiffies (POLL_PERIOD_MS ));return ret; }
@@ -429,6 +689,9 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = false;xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); +/* Check for any new EU stall data one last time */ +queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 ); +flush_delayed_work (&stream->buf_poll_work);xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));
drivers/gpu/drm/xe/xe_trace.h +33 -0
@@ -427,6 +427,39 @@ DEFINE_EVENT(xe_pm_runtime, xe_pm_runtime_get_ioctl,TP_ARGS (xe, caller) ); +TRACE_EVENT (xe_eu_stall_data_read, + TP_PROTO(u8 slice, u8 subslice, + u32 read_ptr, u32 write_ptr, + u32 read_offset, u32 write_offset, + size_t total_size), +TP_ARGS (slice, subslice, read_ptr, write_ptr, + read_offset, write_offset, total_size), + + TP_STRUCT__entry(__field(u8, slice) + __field(u8, subslice) + __field(u32, read_ptr) + __field(u32, write_ptr) + __field(u32, read_offset) + __field(u32, write_offset) +__field (size_t, total_size) + ), + + TP_fast_assign(__entry->slice = slice; + __entry->subslice = subslice; + __entry->read_ptr = read_ptr; + __entry->write_ptr = write_ptr; + __entry->read_offset = read_offset; + __entry->write_offset = write_offset; + __entry->total_size = total_size; + ), + +TP_printk ("slice:%u subslice:%u readptr:0x%x writeptr:0x%x read off:%u write off:%u size:%zu " , + __entry->slice, __entry->subslice, + __entry->read_ptr, __entry->write_ptr, + __entry->read_offset, __entry->write_offset, + __entry->total_size) +); +#endif /* This part must be outside protection */
Signature · 1 line
2.48.1
Re: [PATCH v9 4/8] drm/xe/eustall: Add support to read() and poll() EU stall data
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 73 lines
Implement the EU stall sampling APIs to
read()andpoll()EU stall data. A work function periodically polls the EU stall data buffer write pointer registers to look for any new data and caches the write pointer. The read function compares the cached read and write pointers and copies any new data to the user space.v9: New patch split from the previous patch.
Used*_delayed_workfunctions instead of hrtimer Addressed the review feedback in read and poll functionsSigned-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 267 ++++++++++++++++++++++++++++++- drivers/gpu/drm/xe/xe_trace.h | 33 ++++ 2 files changed, 298 insertions(+), 2 deletions(-)drivers/gpu/drm/xe/xe_eu_stall.c +27
-0@@ -21,6 +21,7 @@#include "xe_macros.h" #include "xe_observation.h" #include "xe_pm.h" +#include "xe_trace.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h" @@ -41,7 +42,9 @@ struct per_xecore_buf { };struct xe_eu_stall_data_stream { +bool pollin;bool enabled; +wait_queue_head_t poll_wq;size_t data_record_size;size_t per_xecore_buf_size;unsigned int wait_num_reports;@@ -50,6 +53,8 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct delayed_work buf_poll_work; +struct workqueue_struct *buf_poll_wq; };struct xe_eu_stall_gt {@@ -256,6 +261,190 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,return 0 ; } +/** +* buf_data_size - Calculate the number of bytes in a circular buffer +* given the read and write pointers and the size of +* the buffer. +* +* @buf_size: Size of the circular buffer +* @read_ptr: Read pointer with an additional overflow bit +* @write_ptr: Write pointer with an additional overflow bit +* +* Since the read and write pointers have an additional overflow bit, +* this function calculates the offsets from the pointers and use the +* offsets to calculate the data size in the buffer. +* +* Returns: number of bytes of data in the buffer +*/ +static u32 buf_data_size (size_t buf_size,u32 read_ptr,u32 write_ptr) +{ +u32 read_offset, write_offset, size =0 ; + +if (read_ptr == write_ptr) + goto exit; +
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 295
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+ read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + +if (write_offset > read_offset) + size = write_offset - read_offset; +else + size = buf_size - read_offset + write_offset; +exit: +return size; +}
Looks good now :)
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ +/** +* eu_stall_data_buf_poll - Poll for EU stall data in the buffer. +* +* @stream: xe EU stall data stream instance +* +* Returns: true if the EU stall buffer contains minimum stall data as +* specified by the event report count, else false.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 313
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ +static bool eu_stall_data_buf_poll (struct xe_eu_stall_data_stream *stream) +{ +u32 read_ptr, write_ptr_reg, write_ptr, total_data =0 ; +u32 buf_size = stream->per_xecore_buf_size; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +bool min_data_present = false; +u16 group, instance; +unsigned int xecore;
u32 and move above to u32 line?
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 317
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock);
One thing I am wondering about is: do we really need these per xecore_buf locks? How about moving ptr_lock into xe_eu_stall_data_stream and just cover for_each_dss_steering() calls with the ptr lock. Because the polling thread runs every 10 ms, this should give plenty of time for the polling thread and the reads to go through, even with lock contention. And it will eliminate all these locks and the locking/unlocking overhead.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 324
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ read_ptr = xecore_buf->read; + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , + group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + write_ptr <<=6 ; + write_ptr &= ((buf_size <<1 ) -1 ); +if (write_ptr != read_ptr && !min_data_present) {
Don't need to check for 'write_ptr != read_ptr' here, it's already happening in buf_data_size.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 330
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ total_data +=buf_data_size (buf_size, read_ptr, write_ptr); +/* +* Check if there are at least minimum number of stall data +* rows for poll() to indicate that the data is present. +* Each stall data row is 64B (cacheline size). +*/
I'd say this comment is not needed and should be removed, the code below is clear enough.
Quoted 32 lines
drivers/gpu/drm/xe/xe_eu_stall.c +32
-0+if (num_data_rows (total_data) >= stream->wait_num_reports) + min_data_present = true; + } + xecore_buf->write = write_ptr; +mutex_unlock (&xecore_buf->ptr_lock); + } +return min_data_present; +} + +static int xe_eu_stall_data_buf_read (struct xe_eu_stall_data_stream *stream, +char __user *buf,size_t count, +size_t *total_data_size,struct xe_gt *gt, +u16 group,u16 instance,unsigned int xecore) +{ +size_t read_data_size, copy_size, buf_size, data_record_size; +u32 read_ptr_reg, read_ptr, write_ptr; +u8 *xecore_start_vaddr, *read_vaddr; +struct per_xecore_buf *xecore_buf; +u32 read_offset, write_offset; +int ret =0 ; + +/* Hardware increments the read and write pointers such that they can +* overflow into one additional bit. For example, a 256KB size buffer +* offset pointer needs 18 bits. But HW uses 19 bits for the read and +* write pointers. This technique avoids wasting a slot in the buffer. +* Read and write offsets are calculated from the pointers in order to +* check if the write pointer has wrapped around the array. +*/ + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock); + xecore_start_vaddr = xecore_buf->vaddr; + read_ptr = xecore_buf->read;
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 372
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+ write_ptr = xecore_buf->write; + buf_size = stream->per_xecore_buf_size; + data_record_size = stream->data_record_size; + + read_data_size =buf_data_size (buf_size, read_ptr, write_ptr); +/* Read only the data that the user space buffer can accommodate */ +if ((*total_data_size + read_data_size) > count) { + read_data_size = count - *total_data_size; + read_data_size = (read_data_size / data_record_size) * data_record_size; + }
As I said, my preferred way of writing this is as follows. Isn't this cleaner?
read_data_size = buf_data_size(buf_size, read_ptr, write_ptr); XE_WARN_ON(count >= *total_size); read_data_size = min_t(size_t, count - *total_size, read_data_size); read_data_size = ALIGN_DOWN(read_data_size, data_record_size);
Since data_record_size has to be a power of 2 for this to work (which it is), I would even put a
xe_assert(xe, is_power_of_2(record_size));
in xe_eu_stall_data_record_size().
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 381
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+if (read_data_size ==0 ) + goto exit; + + read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + read_vaddr = xecore_start_vaddr + read_offset; + +if (write_offset > read_offset) { +if (copy_to_user ((buf + *total_data_size), read_vaddr, read_data_size)) {
internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 386
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ ret = -EFAULT ; + goto exit; + } + }else { +if (read_data_size >= (buf_size - read_offset))
internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 389
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+ copy_size = buf_size - read_offset; + else + copy_size = read_data_size;
if (write_offset < read_offset) how is this 'else' ever possible? So shouldn't copy_size just be set unconditionally to 'buf_size - read_offset'?
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 390
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+if (copy_to_user ((buf + *total_data_size), read_vaddr, copy_size)) {
internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 394
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ ret = -EFAULT ; + goto exit; + } + if (copy_to_user((buf + *total_data_size + copy_size),
internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 402
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ xecore_start_vaddr, read_data_size - copy_size)) { + ret = -EFAULT ; + goto exit; + } + } + + *total_data_size += read_data_size; + read_ptr += read_data_size;
Because there is an overflow bit we can just add without worrying about wraparound?
Quoted 49 lines
drivers/gpu/drm/xe/xe_eu_stall.c +45
-0+ +/* Read pointer can overflow into one additional bit */ + read_ptr &= (buf_size <<1 ) -1 ; + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , (read_ptr >>6 )); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg); +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + xecore_buf->read = read_ptr; +trace_xe_eu_stall_data_read (group, instance, read_ptr, write_ptr, + read_offset, write_offset, *total_data_size); +exit: +mutex_unlock (&xecore_buf->ptr_lock); +return ret; +} + +/** +* xe_eu_stall_stream_read_locked - copy EU stall counters data from the +* per xecore buffers to the userspace buffer +* @stream: A stream opened for EU stall count metrics +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* +* Returns: Number of bytes copied or a negative error code +* If we've successfully copied any data then reporting that takes +* precedence over any internal error status, so the data isn't lost. +*/ +static ssize_t xe_eu_stall_stream_read_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,char __user *buf, +size_t count) +{ +struct xe_gt *gt = stream->gt; +size_t total_size =0 ; +u16 group, instance; +unsigned int xecore; +int ret =0 ; + +for_each_dss_steering (xecore, gt, group, instance) { + ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, + gt, group, instance, xecore); +if (ret || count == total_size) +break ; + } +return total_size ?: (ret ?: -EAGAIN ); +} +/** * xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. *
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 469
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-1@@ -272,7 +461,35 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -ssize_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +ssize_t ret; + +if (count ==0 ) +return -EINVAL ;
I believe we need to also handle the fact that count might not be a multiple of record_size. The easiest way to handle this seems to be right here:
ssize_t aligned_count = ALIGN_DOWN(count, stream->data_record_size);
And used aligned_count rather than count in xe_eu_stall_stream_read_locked calls. So that we don't have to worry about this in later function calls.
So above will become:
if (aligned_count == 0) return -EINVAL;
Unless there is a minimum user buffer size we want to support, in that case this becomes:
if (aligned_count < minimum_user_buffer_size) return -EINVAL;
But to me looks like a good value for minimum_user_buffer_size is not available.
Anyway, better to handle this degenerate case here itself.
Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c +13
-0+ +if (!stream->enabled) { +xe_gt_dbg (gt,"EU stall data stream not enabled to read\n" ); +return -EINVAL ; + } + +if (!(file->f_flags &O_NONBLOCK )) { + do { + ret = wait_event_interruptible(stream->poll_wq, stream->pollin); + if (ret) + return -EINTR; + + mutex_lock(>->eu_stall->stream_lock);
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 492
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+ ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + }while (ret == -EAGAIN ); + }else { +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + } + + stream->pollin = false;
Carry over comment from previous rev: this breaks if user buffer is smaller than available data. But this is a corner case so let's fix this after the initial merge.
Let's put it a list of to be done's in the cover letter to do after we merge in the next revision.
drivers/gpu/drm/xe/xe_eu_stall.c static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) · line 501
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0return ret; }@@ -281,6 +498,7 @@ static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) {if (stream->bo)xe_bo_unpin_map_no_vm (stream->bo); +destroy_workqueue (stream->buf_poll_wq);
Don't put this here in free_eu_stall_data_buf, put this in the caller of this function, like the destroy/close function.
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0} static int alloc_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream,@@ -351,6 +569,21 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return 0 ; }
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) · line 581
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+static void eu_stall_data_buf_poll_work_fn (struct work_struct *work) +{ +struct xe_eu_stall_data_stream *stream = +container_of (work,typeof (*stream), buf_poll_work.work); + +if (eu_stall_data_buf_poll (stream)) { + stream->pollin = true; +wake_up (&stream->poll_wq); + } +if (stream->enabled)
See comment at xe_eu_stall_disable_locked. If we do cancel_delayed_work_sync there, I think this stream->enabled check might not be needed here. Also see comments at cancel_work_sync in kernel/workqueue.c.
Could you please check and see if it works out. xe_guc_ct.c (and xe_gt_tlb_invalidation.c) seem to be doing that.
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+queue_delayed_work (stream->buf_poll_wq, + &stream->buf_poll_work, +msecs_to_jiffies (POLL_PERIOD_MS )); +} +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream,struct eu_stall_open_properties *props) {
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream, · line 601
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0@@ -361,6 +594,11 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,u32 vaddr_offset;int ret, xecore; +init_waitqueue_head (&stream->poll_wq); +INIT_DELAYED_WORK (&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); + stream->buf_poll_wq =alloc_ordered_workqueue ("xe_eu_stall" ,0 ); +if (!stream->buf_poll_wq) +return -ENOMEM ;
Now we also need to destroy_workqueue during error unwinding (see comments regarding this in Patch 3).
Quoted 39 lines
drivers/gpu/drm/xe/xe_eu_stall.c +20
-1stream->sampling_rate_mult = props->sampling_rate_mult; stream->wait_num_reports = props->wait_num_reports; stream->per_xecore_buf_size = per_xecore_buf_size;@@ -391,6 +629,19 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,return 0 ; } +static __poll_t xe_eu_stall_stream_poll_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,poll_table *wait) +{ +__poll_t events =0 ; + +poll_wait (file, &stream->poll_wq, wait); + +if (stream->pollin) + events |=EPOLLIN ; + +return events; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -401,7 +652,13 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,*/ static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) { -__poll_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +__poll_t ret; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_poll_locked (stream, file, wait); +mutex_unlock (>->eu_stall->stream_lock);return ret; }
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) · line 676
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0@@ -416,6 +673,9 @@ static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = true; ret =xe_eu_stall_stream_enable (stream); + queue_delayed_work(stream->buf_poll_wq,
A blank line before this line would be nice.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 693
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ &stream->buf_poll_work, + msecs_to_jiffies(POLL_PERIOD_MS));return ret; }@@ -429,6 +689,9 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = false;xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); +/* Check for any new EU stall data one last time */ +queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 );
I am not sure if this is needed, especially if we use cancel_delayed_work_sync.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 694
Quoted 1 line
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+flush_delayed_work (&stream->buf_poll_work);
I think here we should use cancel_delayed_work_sync() instead. See e.g. xe_guc_ct.c (and also maybe xe_gt_tlb_invalidation.c).
Quoted 50 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));drivers/gpu/drm/xe/xe_trace.h +33
-1@@ -427,6 +427,39 @@ DEFINE_EVENT(xe_pm_runtime, xe_pm_runtime_get_ioctl,TP_ARGS (xe, caller) ); +TRACE_EVENT (xe_eu_stall_data_read, + TP_PROTO(u8 slice, u8 subslice, + u32 read_ptr, u32 write_ptr, + u32 read_offset, u32 write_offset, + size_t total_size), +TP_ARGS (slice, subslice, read_ptr, write_ptr, + read_offset, write_offset, total_size), + + TP_STRUCT__entry(__field(u8, slice) + __field(u8, subslice) + __field(u32, read_ptr) + __field(u32, write_ptr) + __field(u32, read_offset) + __field(u32, write_offset) +__field (size_t, total_size) + ), + + TP_fast_assign(__entry->slice = slice; + __entry->subslice = subslice; + __entry->read_ptr = read_ptr; + __entry->write_ptr = write_ptr; + __entry->read_offset = read_offset; + __entry->write_offset = write_offset; + __entry->total_size = total_size; + ), + +TP_printk ("slice:%u subslice:%u readptr:0x%x writeptr:0x%x read off:%u write off:%u size:%zu " , + __entry->slice, __entry->subslice, + __entry->read_ptr, __entry->write_ptr, + __entry->read_offset, __entry->write_offset, + __entry->total_size) +); +#endif /* This part must be outside protection */ --2.48.1
Re: [PATCH v9 4/8] drm/xe/eustall: Add support to read() and poll() EU stall data
Quoted 3 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Ashutosh,
Quoted 109 lines
Hi Harish,
Quoted 73 lines
Implement the EU stall sampling APIs to
read()andpoll()EU stall data. A work function periodically polls the EU stall data buffer write pointer registers to look for any new data and caches the write pointer. The read function compares the cached read and write pointers and copies any new data to the user space.v9: New patch split from the previous patch.
Used*_delayed_workfunctions instead of hrtimer Addressed the review feedback in read and poll functionsSigned-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 267 ++++++++++++++++++++++++++++++- drivers/gpu/drm/xe/xe_trace.h | 33 ++++ 2 files changed, 298 insertions(+), 2 deletions(-)drivers/gpu/drm/xe/xe_eu_stall.c +27
-0@@ -21,6 +21,7 @@#include "xe_macros.h" #include "xe_observation.h" #include "xe_pm.h" +#include "xe_trace.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h" @@ -41,7 +42,9 @@ struct per_xecore_buf { };struct xe_eu_stall_data_stream { +bool pollin;bool enabled; +wait_queue_head_t poll_wq;size_t data_record_size;size_t per_xecore_buf_size;unsigned int wait_num_reports;@@ -50,6 +53,8 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct delayed_work buf_poll_work; +struct workqueue_struct *buf_poll_wq; };struct xe_eu_stall_gt {@@ -256,6 +261,190 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,return 0 ; } +/** +* buf_data_size - Calculate the number of bytes in a circular buffer +* given the read and write pointers and the size of +* the buffer. +* +* @buf_size: Size of the circular buffer +* @read_ptr: Read pointer with an additional overflow bit +* @write_ptr: Write pointer with an additional overflow bit +* +* Since the read and write pointers have an additional overflow bit, +* this function calculates the offsets from the pointers and use the +* offsets to calculate the data size in the buffer. +* +* Returns: number of bytes of data in the buffer +*/ +static u32 buf_data_size (size_t buf_size,u32 read_ptr,u32 write_ptr) +{ +u32 read_offset, write_offset, size =0 ; + +if (read_ptr == write_ptr) + goto exit; +drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 295
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+ read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + +if (write_offset > read_offset) + size = write_offset - read_offset; +else + size = buf_size - read_offset + write_offset; +exit: +return size; +}Looks good now :)
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ +/** +* eu_stall_data_buf_poll - Poll for EU stall data in the buffer. +* +* @stream: xe EU stall data stream instance +* +* Returns: true if the EU stall buffer contains minimum stall data as +* specified by the event report count, else false. drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 313
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ +static bool eu_stall_data_buf_poll (struct xe_eu_stall_data_stream *stream) +{ +u32 read_ptr, write_ptr_reg, write_ptr, total_data =0 ; +u32 buf_size = stream->per_xecore_buf_size; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +bool min_data_present = false; +u16 group, instance; +unsigned int xecore;u32 and move above to u32 line?
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 317
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock);One thing I am wondering about is: do we really need these per
xecore_buflocks? How about movingptr_lockintoxe_eu_stall_data_streamand just coverfor_each_dss_steering()calls with the ptr lock. Because the polling thread runs every 10 ms, this should give plenty of time for the polling thread and the reads to go through, even with lcontention. And it will eliminate all these locks and the locking/unlocking overhead.
I used a per dss lock so that polling and read on two different subslices can be done in parallel. I will try moving the ptr_lock into xe_eu_stall_data_stream.
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 324
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ read_ptr = xecore_buf->read; + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , + group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + write_ptr <<=6 ; + write_ptr &= ((buf_size <<1 ) -1 ); +if (write_ptr != read_ptr && !min_data_present) {Don't need to check for '
write_ptr!=read_ptr' here, it's already happening inbuf_data_size.
Yes it is not needed. But eu_stall_data_buf_poll() is invoked approx every 10ms. I am not an expert on compiler optimizations. If the compiler definitely optimizes and prevents call to buf_data_size(), I can remove this check. But if the compiler doesn't optimize, wouldn't this check help avoid function calls given that this function gets executed every 10ms?
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 330
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ total_data +=buf_data_size (buf_size, read_ptr, write_ptr); +/* +* Check if there are at least minimum number of stall data +* rows for poll() to indicate that the data is present. +* Each stall data row is 64B (cacheline size). +*/ I'd say this comment is not needed and should be removed, the code below is clear enough.
Will remove.
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/xe/xe_eu_stall.c +35
-0+if (num_data_rows (total_data) >= stream->wait_num_reports) + min_data_present = true; + } + xecore_buf->write = write_ptr; +mutex_unlock (&xecore_buf->ptr_lock); + } +return min_data_present; +} + +static int xe_eu_stall_data_buf_read (struct xe_eu_stall_data_stream *stream, +char __user *buf,size_t count, +size_t *total_data_size,struct xe_gt *gt, +u16 group,u16 instance,unsigned int xecore) +{ +size_t read_data_size, copy_size, buf_size, data_record_size; +u32 read_ptr_reg, read_ptr, write_ptr; +u8 *xecore_start_vaddr, *read_vaddr; +struct per_xecore_buf *xecore_buf; +u32 read_offset, write_offset; +int ret =0 ; + +/* Hardware increments the read and write pointers such that they can +* overflow into one additional bit. For example, a 256KB size buffer +* offset pointer needs 18 bits. But HW uses 19 bits for the read and +* write pointers. This technique avoids wasting a slot in the buffer. +* Read and write offsets are calculated from the pointers in order to +* check if the write pointer has wrapped around the array. +*/ + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock); + xecore_start_vaddr = xecore_buf->vaddr; + read_ptr = xecore_buf->read; + write_ptr = xecore_buf->write; + buf_size = stream->per_xecore_buf_size; + data_record_size = stream->data_record_size;l> > +
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 372
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ read_data_size =buf_data_size (buf_size, read_ptr, write_ptr); +/* Read only the data that the user space buffer can accommodate */ +if ((*total_data_size + read_data_size) > count) { + read_data_size = count - *total_data_size; + read_data_size = (read_data_size / data_record_size) * data_record_size; + }As I said, my preferred way of writing this is as follows. Isn't this cleaner?
Most of the times, the if condition would evaluate false and the body of the if statement would not be executed. Whereas in your code the two lines of code get executed all the time.
Quoted 3 lines
read_data_size = buf_data_size(buf_size, read_ptr, write_ptr); XE_WARN_ON(count >= *total_size);
Wouldn't count (size of the user buffer) be greater than the total_size most of the time? I am still not convinced with having a WARN_ON here.
Quoted 5 lines
read_data_size = min_t(size_t, count - *total_size, read_data_size); read_data_size = ALIGN_DOWN(read_data_size, data_record_size);Since
data_record_sizehas to be a power of 2 for this to work (which it is), I would even put a
data_record_size is fixed in the hardware. As of now for both PVC and xe2, it is 64 which is a power of 2. I am guessing that it will remain a power of 2 in the future too. Why should we put an assert for the record size which is determined in the hardware?
Quoted 26 lines
xe_assert(xe, is_power_of_2(record_size));in
xe_eu_stall_data_record_size().drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 381
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+if (read_data_size ==0 ) + goto exit; + + read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + read_vaddr = xecore_start_vaddr + read_offset; + +if (write_offset > read_offset) { +if (copy_to_user ((buf + *total_data_size), read_vaddr, read_data_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 386
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ ret = -EFAULT ; + goto exit; + } + }else { +if (read_data_size >= (buf_size - read_offset))internal brackets not needed ^
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 389
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+ copy_size = buf_size - read_offset; + else + copy_size = read_data_size;if (
write_offset<read_offset) how is this 'else' ever possible? So shouldn'tcopy_sizejust be set unconditionally to 'buf_size-read_offset'?
If the user buffer doesn't have enough space to accommodate (buf_size - read_offset) bytes, the else will get executed.
Quoted 12 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 390
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+if (copy_to_user ((buf + *total_data_size), read_vaddr, copy_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 394
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ ret = -EFAULT ; + goto exit; + } + if (copy_to_user((buf + *total_data_size + copy_size),internal brackets not needed ^
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 402
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ xecore_start_vaddr, read_data_size - copy_size)) { + ret = -EFAULT ; + goto exit; + } + } + + *total_data_size += read_data_size; + read_ptr += read_data_size;Because there is an overflow bit we can just add without worrying about wraparound?
I want to make sure only one overflow bit is used and doesn't overflow into the second bit.
Quoted 64 lines
Quoted 50 lines
drivers/gpu/drm/xe/xe_eu_stall.c +45
-0+ +/* Read pointer can overflow into one additional bit */ + read_ptr &= (buf_size <<1 ) -1 ; + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , (read_ptr >>6 )); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg); +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + xecore_buf->read = read_ptr; +trace_xe_eu_stall_data_read (group, instance, read_ptr, write_ptr, + read_offset, write_offset, *total_data_size); +exit: +mutex_unlock (&xecore_buf->ptr_lock); +return ret; +} + +/** +* xe_eu_stall_stream_read_locked - copy EU stall counters data from the +* per xecore buffers to the userspace buffer +* @stream: A stream opened for EU stall count metrics +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* +* Returns: Number of bytes copied or a negative error code +* If we've successfully copied any data then reporting that takes +* precedence over any internal error status, so the data isn't lost. +*/ +static ssize_t xe_eu_stall_stream_read_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,char __user *buf, +size_t count) +{ +struct xe_gt *gt = stream->gt; +size_t total_size =0 ; +u16 group, instance; +unsigned int xecore; +int ret =0 ; + +for_each_dss_steering (xecore, gt, group, instance) { + ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, + gt, group, instance, xecore); +if (ret || count == total_size) +break ; + } +return total_size ?: (ret ?: -EAGAIN ); +} +/** * xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. * drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 469
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-1@@ -272,7 +461,35 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -ssize_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +ssize_t ret; + +if (count ==0 ) +return -EINVAL ;I believe we need to also handle the fact that count might not be a multiple of
record_size. The easiest way to handle this seems to be right here:
Quoted 1 line
ssize_t aligned_count = ALIGN_DOWN(count, stream->data_record_size);
I think the code handles buffer sizes that are not multiples of record size. Copying few lines of code below. Wouldn't read_data_size be only a multiple of record size ? and leave any remaining space empty that is not a multiple of record size ?
/* Read only the data that the user space buffer can accommodate */
if ((*total_data_size + read_data_size) > count) {
read_data_size = count - *total_data_size;
read_data_size = (read_data_size / data_record_size) * data_record_size;Quoted 9 lines
And used
aligned_countrather than count inxe_eu_stall_stream_read_lockedcalls. So that we don't have to worry about this in later function calls.So above will become:
if (aligned_count == 0) return -EINVAL;
Quoted 8 lines
Unless there is a minimum user buffer size we want to support, in that case this becomes:
if (aligned_count < minimum_user_buffer_size) return -EINVAL;But to me looks like a good value for
minimum_user_buffer_sizeis not available.
I guess the minimum user buffer size should be the data record size (64 for PVC and Xe2)? If smaller than the record size, the drive will be unable to copy any data.
Quoted 22 lines
Anyway, better to handle this degenerate case here itself.
Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c +19
-0+ +if (!stream->enabled) { +xe_gt_dbg (gt,"EU stall data stream not enabled to read\n" ); +return -EINVAL ; + } + +if (!(file->f_flags &O_NONBLOCK )) { +do { + ret =wait_event_interruptible (stream->poll_wq, stream->pollin); +if (ret) +return -EINTR ; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + }while (ret == -EAGAIN ); + }else { +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count);
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 492
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+mutex_unlock (>->eu_stall->stream_lock); + } + + stream->pollin = false;Carry over comment from previous rev: this breaks if user buffer is smaller than available data. But this is a corner case so let's fix this after the initial merge.
I will check your fix in OA to better understand the problem here. If the user buffer is smaller than data record size, it just returns without copying any data.
Quoted 3 lines
Let's put it a list of to be done's in the cover letter to do after we merge in the next revision.
Okay.
Quoted 20 lines
drivers/gpu/drm/xe/xe_eu_stall.c static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) · line 501
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0return ret; }@@ -281,6 +498,7 @@ static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) {if (stream->bo)xe_bo_unpin_map_no_vm (stream->bo); +destroy_workqueue (stream->buf_poll_wq);Don't put this here in
free_eu_stall_data_buf, put this in the caller of this function, like the destroy/close function.Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0} static int alloc_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream,@@ -351,6 +569,21 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return 0 ; }
Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) · line 581
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+static void eu_stall_data_buf_poll_work_fn (struct work_struct *work) +{ +struct xe_eu_stall_data_stream *stream = +container_of (work,typeof (*stream), buf_poll_work.work); + +if (eu_stall_data_buf_poll (stream)) { + stream->pollin = true; +wake_up (&stream->poll_wq); + } +if (stream->enabled)See comment at
xe_eu_stall_disable_locked. If we docancel_delayed_work_syncthere, I think thisstream->enabledcheck might
I will explain later why I used flush_delayed_work() instead of cancel_delayed_work_sync()
Quoted 81 lines
not be needed here. Also see comments at
cancel_work_syncinkernel/workqueue.c.Could you please check and see if it works out.
xe_guc_ct.c(andxe_gt_tlb_invalidation.c) seem to be doing that.Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+queue_delayed_work (stream->buf_poll_wq, + &stream->buf_poll_work, +msecs_to_jiffies (POLL_PERIOD_MS )); +} +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream,struct eu_stall_open_properties *props) {drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream, · line 601
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0@@ -361,6 +594,11 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,u32 vaddr_offset;int ret, xecore; +init_waitqueue_head (&stream->poll_wq); +INIT_DELAYED_WORK (&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); + stream->buf_poll_wq =alloc_ordered_workqueue ("xe_eu_stall" ,0 ); +if (!stream->buf_poll_wq) +return -ENOMEM ;Now we also need to
destroy_workqueueduring error unwinding (see comments regarding this in Patch 3).Quoted 39 lines
drivers/gpu/drm/xe/xe_eu_stall.c +20
-1stream->sampling_rate_mult = props->sampling_rate_mult; stream->wait_num_reports = props->wait_num_reports; stream->per_xecore_buf_size = per_xecore_buf_size;@@ -391,6 +629,19 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,return 0 ; } +static __poll_t xe_eu_stall_stream_poll_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,poll_table *wait) +{ +__poll_t events =0 ; + +poll_wait (file, &stream->poll_wq, wait); + +if (stream->pollin) + events |=EPOLLIN ; + +return events; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -401,7 +652,13 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,*/ static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) { -__poll_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +__poll_t ret; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_poll_locked (stream, file, wait); +mutex_unlock (>->eu_stall->stream_lock);return ret; }drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) · line 676
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0@@ -416,6 +673,9 @@ static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = true; ret =xe_eu_stall_stream_enable (stream); + queue_delayed_work(stream->buf_poll_wq,A blank line before this line would be nice.
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +2
-0+ &stream->buf_poll_work, + msecs_to_jiffies(POLL_PERIOD_MS));return ret; }@@ -429,6 +689,9 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = false;
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 693
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +2
-0xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); +/* Check for any new EU stall data one last time */ +queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 );I am not sure if this is needed, especially if we use
cancel_delayed_work_sync.
There was an ask from the user space to check for new data once after disabling EU stall sampling to make sure we capture all the data.
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 694
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+flush_delayed_work (&stream->buf_poll_work);I think here we should use
cancel_delayed_work_sync()instead. See e.g.xe_guc_ct.c(and also maybexe_gt_tlb_invalidation.c).
I though about it and found that the difference between flushed_delayed_work() and cancel_delayed_work_sync() is that cancel_delayed_work_sync() cancels any pending work items and wait for any work under execution to complete. Whereas flushed_delayed_work() schedules any work pending and wait for it to complete. Since I want to execute the work one last time after disable, flushed_delayed_work() is more appropriate here than cancel_delayed_work_sync().
Thank You
Harish.
Quoted 51 lines
Quoted 51 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));drivers/gpu/drm/xe/xe_trace.h +33
-1@@ -427,6 +427,39 @@ DEFINE_EVENT(xe_pm_runtime, xe_pm_runtime_get_ioctl,TP_ARGS (xe, caller) ); +TRACE_EVENT (xe_eu_stall_data_read, + TP_PROTO(u8 slice, u8 subslice, + u32 read_ptr, u32 write_ptr, + u32 read_offset, u32 write_offset, + size_t total_size), +TP_ARGS (slice, subslice, read_ptr, write_ptr, + read_offset, write_offset, total_size), + + TP_STRUCT__entry(__field(u8, slice) + __field(u8, subslice) + __field(u32, read_ptr) + __field(u32, write_ptr) + __field(u32, read_offset) + __field(u32, write_offset) +__field (size_t, total_size) + ), + + TP_fast_assign(__entry->slice = slice; + __entry->subslice = subslice; + __entry->read_ptr = read_ptr; + __entry->write_ptr = write_ptr; + __entry->read_offset = read_offset; + __entry->write_offset = write_offset; + __entry->total_size = total_size; + ), + +TP_printk ("slice:%u subslice:%u readptr:0x%x writeptr:0x%x read off:%u write off:%u size:%zu " , + __entry->slice, __entry->subslice, + __entry->read_ptr, __entry->write_ptr, + __entry->read_offset, __entry->write_offset, + __entry->total_size) +); +#endif /* This part must be outside protection */ --2.48.1
Re: [PATCH v9 4/8] drm/xe/eustall: Add support to read() and poll() EU stall data
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 123 lines · Ashutosh
Quoted 110 lines · Harish Chegondi
Quoted 75 lines
Implement the EU stall sampling APIs to
read()andpoll()EU stall data. A work function periodically polls the EU stall data buffer write pointer registers to look for any new data and caches the write pointer. The read function compares the cached read and write pointers and copies any new data to the user space.v9: New patch split from the previous patch.
Used*_delayed_workfunctions instead of hrtimer Addressed the review feedback in read and poll functionsSigned-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 267 ++++++++++++++++++++++++++++++- drivers/gpu/drm/xe/xe_trace.h | 33 ++++ 2 files changed, 298 insertions(+), 2 deletions(-)drivers/gpu/drm/xe/xe_eu_stall.c +27
-0@@ -21,6 +21,7 @@#include "xe_macros.h" #include "xe_observation.h" #include "xe_pm.h" +#include "xe_trace.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h" @@ -41,7 +42,9 @@ struct per_xecore_buf { };struct xe_eu_stall_data_stream { +bool pollin;bool enabled; +wait_queue_head_t poll_wq;size_t data_record_size;size_t per_xecore_buf_size;unsigned int wait_num_reports;@@ -50,6 +53,8 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct delayed_work buf_poll_work; +struct workqueue_struct *buf_poll_wq; };struct xe_eu_stall_gt {@@ -256,6 +261,190 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,return 0 ; } +/** +* buf_data_size - Calculate the number of bytes in a circular buffer +* given the read and write pointers and the size of +* the buffer. +* +* @buf_size: Size of the circular buffer +* @read_ptr: Read pointer with an additional overflow bit +* @write_ptr: Write pointer with an additional overflow bit +* +* Since the read and write pointers have an additional overflow bit, +* this function calculates the offsets from the pointers and use the +* offsets to calculate the data size in the buffer. +* +* Returns: number of bytes of data in the buffer +*/ +static u32 buf_data_size (size_t buf_size,u32 read_ptr,u32 write_ptr) +{ +u32 read_offset, write_offset, size =0 ; + +if (read_ptr == write_ptr) + goto exit; +drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 295
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+ read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + +if (write_offset > read_offset) + size = write_offset - read_offset; +else + size = buf_size - read_offset + write_offset; +exit: +return size; +}Looks good now :)
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ +/** +* eu_stall_data_buf_poll - Poll for EU stall data in the buffer. +* +* @stream: xe EU stall data stream instance +* +* Returns: true if the EU stall buffer contains minimum stall data as +* specified by the event report count, else false. drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 313
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ +static bool eu_stall_data_buf_poll (struct xe_eu_stall_data_stream *stream) +{ +u32 read_ptr, write_ptr_reg, write_ptr, total_data =0 ; +u32 buf_size = stream->per_xecore_buf_size; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +bool min_data_present = false; +u16 group, instance; +unsigned int xecore;u32 and move above to u32 line?
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 317
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock);One thing I am wondering about is: do we really need these per
xecore_buflocks? How about movingptr_lockintoxe_eu_stall_data_streamand just coverfor_each_dss_steering()calls with the ptr lock. Because the polling thread runs every 10 ms, this should give plenty of time for the polling thread and the reads to go through, even with lcontention. And it will eliminate all these locks and the locking/unlocking overhead.
Quoted 3 lines
I used a per dss lock so that polling and read on two different subslices can be done in parallel. I will try moving the
ptr_lockintoxe_eu_stall_data_stream.
If you do this, please rename it to dss_lock or something like that, to indicate it is guarding dss level info, not just the ptr's. Maybe rename the lock to dss_lock even if you end up not doing this.
Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 324
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ read_ptr = xecore_buf->read; + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , + group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + write_ptr <<=6 ; + write_ptr &= ((buf_size <<1 ) -1 ); +if (write_ptr != read_ptr && !min_data_present) {Don't need to check for '
write_ptr!=read_ptr' here, it's already happening inbuf_data_size.
Quoted 5 lines
Yes it is not needed. But
eu_stall_data_buf_poll()is invoked approx every 10ms. I am not an expert on compiler optimizations. If the compiler definitely optimizes and prevents call tobuf_data_size(), I can remove this check. But if the compiler doesn't optimize, wouldn't this check help avoid function calls given that this function gets executed every 10ms?
The function is called every 10 ms * num_dss and then it is called every dss for every read(). Even then I am not sure why you are obsessed with the function call overhead. See here:
https://github.com/torvalds/linux/blob/master/Documentation/process/4.Coding.rst#inline-functions
Specially "The cost of a function call, after all, is not that high" (it is typically memory accesses which reduce performance, not code execution). I would let the compiler handle this sort of optimization and decide whether or not the function can be inlined.
Another option is to use always_inline if you are really concerned:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html
static __always_inline u32 buf_data_size(...
though I am not sure if just inline is already sufficient:
static inline u32 buf_data_size(...
So let's do one of these two things and remove this check, I'll approve either. Sorry if I asked to remove inline earlier :/
Quoted 56 lines
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 330
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ total_data +=buf_data_size (buf_size, read_ptr, write_ptr); +/* +* Check if there are at least minimum number of stall data +* rows for poll() to indicate that the data is present. +* Each stall data row is 64B (cacheline size). +*/ I'd say this comment is not needed and should be removed, the code below is clear enough.
Will remove.
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/xe/xe_eu_stall.c +35
-0+if (num_data_rows (total_data) >= stream->wait_num_reports) + min_data_present = true; + } + xecore_buf->write = write_ptr; +mutex_unlock (&xecore_buf->ptr_lock); + } +return min_data_present; +} + +static int xe_eu_stall_data_buf_read (struct xe_eu_stall_data_stream *stream, +char __user *buf,size_t count, +size_t *total_data_size,struct xe_gt *gt, +u16 group,u16 instance,unsigned int xecore) +{ +size_t read_data_size, copy_size, buf_size, data_record_size; +u32 read_ptr_reg, read_ptr, write_ptr; +u8 *xecore_start_vaddr, *read_vaddr; +struct per_xecore_buf *xecore_buf; +u32 read_offset, write_offset; +int ret =0 ; + +/* Hardware increments the read and write pointers such that they can +* overflow into one additional bit. For example, a 256KB size buffer +* offset pointer needs 18 bits. But HW uses 19 bits for the read and +* write pointers. This technique avoids wasting a slot in the buffer. +* Read and write offsets are calculated from the pointers in order to +* check if the write pointer has wrapped around the array. +*/ + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock); + xecore_start_vaddr = xecore_buf->vaddr; + read_ptr = xecore_buf->read; + write_ptr = xecore_buf->write; + buf_size = stream->per_xecore_buf_size; + data_record_size = stream->data_record_size;l> > +Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 372
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ read_data_size =buf_data_size (buf_size, read_ptr, write_ptr); +/* Read only the data that the user space buffer can accommodate */ +if ((*total_data_size + read_data_size) > count) { + read_data_size = count - *total_data_size; + read_data_size = (read_data_size / data_record_size) * data_record_size; + }As I said, my preferred way of writing this is as follows. Isn't this cleaner?
Quoted 3 lines
Most of the times, the if condition would evaluate false and the body of the if statement would not be executed. Whereas in your code the two lines of code get executed all the time.
The only thing extra which maybe gets executed unconditionally in my code is the ALIGN_DOWN line. the min_t() part gets executed for you too in the if () check. Correct?
But once again you seem to be obsessed with these micro optimizations: it is not that simple:
1. We don't know how the compiler will optimize
2. The CPU itself does out-of-order and speculative execution, branch prediction etc. So for you the CPU might actually be executing the code in the if () statement (both when result of the if is true and when it is false and then discarding the branch which is not taken).
3. Execution speed is driven more by memory accesses and lock contention rather than code execution itself. So mostly code stalls at locks and for memory accesses to complete.
So with all this going on, my rule is to only make easy to understand and maintain. And let the compiler and CPU take care of running the code efficiently. Of course we can't do ridiculous things, which we are not doing here.
Also, since you are obsessed with optimization, ALIGN_DOWN() uses bit operations (AND etc.), rather than integer division, so is more efficient. Also, use of pre-established, standard macros, like min_t and ALIGN_DOWN, is preferable, rather than rolling your own new code.
Quoted 5 lines
Quoted 3 lines
read_data_size = buf_data_size(buf_size, read_ptr, write_ptr); XE_WARN_ON(count >= *total_size);Wouldn't count (size of the user buffer) be greater than the
total_sizemost of the time? I am still not convinced with having aWARN_ONhere.
Sorry, I meant an xe_assert() here:
xe_assert(xe, count >= *total_size);
To make sure that (count - *total_size >= 0) in the min_t statement below. So if we use XE_WARN_ON(), this would become:
XE_WARN_ON(count < *total_size);
So either is ok. I think it is good to have it.
Quoted 9 lines
Quoted 5 lines
read_data_size = min_t(size_t, count - *total_size, read_data_size); read_data_size = ALIGN_DOWN(read_data_size, data_record_size);Since
data_record_sizehas to be a power of 2 for this to work (which it is), I would even put a
data_record_sizeis fixed in the hardware. As of now for both PVC and xe2, it is 64 which is a power of 2. I am guessing that it will remain a power of 2 in the future too. Why should we put an assert for the record size which is determined in the hardware?
Because we are explicitly making use of the property that data_record_size is a power of 2 in our code. The ALIGN_DOWN results will be wrong if somehow data_record_size were not a power of 2.
And it also makes clear that the code is using this property and will break if it were to be false.
That is the purpose of the assert(). If we weren't making use of that property in *our* code, we wouldn't need the assert.
Quoted 33 lines
Quoted 26 lines
xe_assert(xe, is_power_of_2(record_size));in
xe_eu_stall_data_record_size().drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 381
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+if (read_data_size ==0 ) + goto exit; + + read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + read_vaddr = xecore_start_vaddr + read_offset; + +if (write_offset > read_offset) { +if (copy_to_user ((buf + *total_data_size), read_vaddr, read_data_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 386
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ ret = -EFAULT ; + goto exit; + } + }else { +if (read_data_size >= (buf_size - read_offset))internal brackets not needed ^
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 389
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+ copy_size = buf_size - read_offset; + else + copy_size = read_data_size;if (
write_offset<read_offset) how is this 'else' ever possible? So shouldn'tcopy_sizejust be set unconditionally to 'buf_size-read_offset'?
Quoted 2 lines
If the user buffer doesn't have enough space to accommodate (
buf_size-read_offset) bytes, the else will get executed.
Sorry, yes, you are right here.
Quoted 23 lines
Quoted 12 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 390
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+if (copy_to_user ((buf + *total_data_size), read_vaddr, copy_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 394
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ ret = -EFAULT ; + goto exit; + } + if (copy_to_user((buf + *total_data_size + copy_size),internal brackets not needed ^
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 402
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ xecore_start_vaddr, read_data_size - copy_size)) { + ret = -EFAULT ; + goto exit; + } + } + + *total_data_size += read_data_size; + read_ptr += read_data_size;Because there is an overflow bit we can just add without worrying about wraparound?
Quoted 2 lines
I want to make sure only one overflow bit is used and doesn't overflow into the second bit.
OK, I don't follow, but this was just something I was trying to confirm, so ignore this comment. The code is fine because of the overflow bits.
Quoted 65 lines
Quoted 64 lines
Quoted 50 lines
drivers/gpu/drm/xe/xe_eu_stall.c +45
-0+ +/* Read pointer can overflow into one additional bit */ + read_ptr &= (buf_size <<1 ) -1 ; + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , (read_ptr >>6 )); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg); +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + xecore_buf->read = read_ptr; +trace_xe_eu_stall_data_read (group, instance, read_ptr, write_ptr, + read_offset, write_offset, *total_data_size); +exit: +mutex_unlock (&xecore_buf->ptr_lock); +return ret; +} + +/** +* xe_eu_stall_stream_read_locked - copy EU stall counters data from the +* per xecore buffers to the userspace buffer +* @stream: A stream opened for EU stall count metrics +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* +* Returns: Number of bytes copied or a negative error code +* If we've successfully copied any data then reporting that takes +* precedence over any internal error status, so the data isn't lost. +*/ +static ssize_t xe_eu_stall_stream_read_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,char __user *buf, +size_t count) +{ +struct xe_gt *gt = stream->gt; +size_t total_size =0 ; +u16 group, instance; +unsigned int xecore; +int ret =0 ; + +for_each_dss_steering (xecore, gt, group, instance) { + ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, + gt, group, instance, xecore); +if (ret || count == total_size) +break ; + } +return total_size ?: (ret ?: -EAGAIN ); +} +/** * xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. * drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 469
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-1@@ -272,7 +461,35 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -ssize_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +ssize_t ret; + +if (count ==0 ) +return -EINVAL ;I believe we need to also handle the fact that count might not be a multiple of
record_size. The easiest way to handle this seems to be right here:Quoted 1 line
ssize_t aligned_count = ALIGN_DOWN(count, stream->data_record_size);
Quoted 9 lines
I think the code handles buffer sizes that are not multiples of record size. Copying few lines of code below. Wouldn't
read_data_sizebe only a multiple of record size ? and leave any remaining space empty that is not a multiple of record size ?
/* Read only the data that the user space buffer can accommodate */if ((*total_data_size + read_data_size) > count) { read_data_size = count - *total_data_size; read_data_size = (read_data_size / data_record_size) * data_record_size;
No, I don't think it is handled. The issue is we have this check here:
xe_eu_stall_stream_read_locked()
{
...
if (ret || count == total_size)
break;
}And if count is not a multiple of record_size, the 'count == total_size' will never be true, I think. Since total_size returned by xe_eu_stall_data_buf_read() is always a multiple of record_size.
Quoted 12 lines
Quoted 12 lines
And used
aligned_countrather than count inxe_eu_stall_stream_read_lockedcalls. So that we don't have to worry about this in later function calls.So above will become:
if (aligned_count == 0) return -EINVAL;Unless there is a minimum user buffer size we want to support, in that case this becomes:
Quoted 8 lines
Quoted 5 lines
if (aligned_count < minimum_user_buffer_size) return -EINVAL;But to me looks like a good value for
minimum_user_buffer_sizeis not available.I guess the minimum user buffer size should be the data record size (64 for PVC and Xe2)? If smaller than the record size, the drive will be unable to copy any data.
That is this check:
if (aligned_count == 0) return -EINVAL;
Apart from that, is there a minimum_user_buffer_size which is greater than record_size? That is why I was saying it is not available.
Quoted 30 lines
Quoted 22 lines
Anyway, better to handle this degenerate case here itself.
Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c +19
-0+ +if (!stream->enabled) { +xe_gt_dbg (gt,"EU stall data stream not enabled to read\n" ); +return -EINVAL ; + } + +if (!(file->f_flags &O_NONBLOCK )) { +do { + ret =wait_event_interruptible (stream->poll_wq, stream->pollin); +if (ret) +return -EINTR ; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + }while (ret == -EAGAIN ); + }else { +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count);Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 492
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+mutex_unlock (>->eu_stall->stream_lock); + } + + stream->pollin = false;Carry over comment from previous rev: this breaks if user buffer is smaller than available data. But this is a corner case so let's fix this after the initial merge.
Quoted 3 lines
I will check your fix in OA to better understand the problem here. If the user buffer is smaller than data record size, it just returns without copying any data.
No, it is the issue when user buffer is larger than record_size, but still smaller than the size of total data available. In that case, basically we should let stream->pollin set to true, so that the user thread does not get blocked, enabling it to rapidly consume data, even with a small buffer.
Otherwise the thread is getting blocked every 10 ms, even when data is available. And because new data keeps arriving, the user thread constantly falls behind and soon HW will start dropping data (because the kernel is blocking the user thread, it's a kernel not a user thread issue)
To handle this OA does:
if (ret != -ENOSPC && ret != -EIO) stream->pollin = false;
Anyway, we can do this after the initial merge.
Quoted 37 lines
Quoted 3 lines
Let's put it a list of to be done's in the cover letter to do after we merge in the next revision.
Okay.
Quoted 20 lines
drivers/gpu/drm/xe/xe_eu_stall.c static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) · line 501
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0return ret; }@@ -281,6 +498,7 @@ static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) {if (stream->bo)xe_bo_unpin_map_no_vm (stream->bo); +destroy_workqueue (stream->buf_poll_wq);Don't put this here in
free_eu_stall_data_buf, put this in the caller of this function, like the destroy/close function.Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0} static int alloc_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream,@@ -351,6 +569,21 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return 0 ; }Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) · line 581
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+static void eu_stall_data_buf_poll_work_fn (struct work_struct *work) +{ +struct xe_eu_stall_data_stream *stream = +container_of (work,typeof (*stream), buf_poll_work.work); + +if (eu_stall_data_buf_poll (stream)) { + stream->pollin = true; +wake_up (&stream->poll_wq); + } +if (stream->enabled)See comment at
xe_eu_stall_disable_locked. If we docancel_delayed_work_syncthere, I think thisstream->enabledcheck might
Quoted 2 lines
I will explain later why I used
flush_delayed_work()instead ofcancel_delayed_work_sync()
See below.
Quoted 81 lines
Quoted 81 lines
not be needed here. Also see comments at
cancel_work_syncinkernel/workqueue.c.Could you please check and see if it works out.
xe_guc_ct.c(andxe_gt_tlb_invalidation.c) seem to be doing that.Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+queue_delayed_work (stream->buf_poll_wq, + &stream->buf_poll_work, +msecs_to_jiffies (POLL_PERIOD_MS )); +} +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream,struct eu_stall_open_properties *props) {drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream, · line 601
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0@@ -361,6 +594,11 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,u32 vaddr_offset;int ret, xecore; +init_waitqueue_head (&stream->poll_wq); +INIT_DELAYED_WORK (&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); + stream->buf_poll_wq =alloc_ordered_workqueue ("xe_eu_stall" ,0 ); +if (!stream->buf_poll_wq) +return -ENOMEM ;Now we also need to
destroy_workqueueduring error unwinding (see comments regarding this in Patch 3).Quoted 39 lines
drivers/gpu/drm/xe/xe_eu_stall.c +20
-1stream->sampling_rate_mult = props->sampling_rate_mult; stream->wait_num_reports = props->wait_num_reports; stream->per_xecore_buf_size = per_xecore_buf_size;@@ -391,6 +629,19 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,return 0 ; } +static __poll_t xe_eu_stall_stream_poll_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,poll_table *wait) +{ +__poll_t events =0 ; + +poll_wait (file, &stream->poll_wq, wait); + +if (stream->pollin) + events |=EPOLLIN ; + +return events; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -401,7 +652,13 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,*/ static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) { -__poll_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +__poll_t ret; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_poll_locked (stream, file, wait); +mutex_unlock (>->eu_stall->stream_lock);return ret; }drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) · line 676
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0@@ -416,6 +673,9 @@ static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = true; ret =xe_eu_stall_stream_enable (stream); + queue_delayed_work(stream->buf_poll_wq,A blank line before this line would be nice.
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +2
-0+ &stream->buf_poll_work, + msecs_to_jiffies(POLL_PERIOD_MS));return ret; }@@ -429,6 +689,9 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = false;
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 693
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +2
-0xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); +/* Check for any new EU stall data one last time */ +queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 );I am not sure if this is needed, especially if we use
cancel_delayed_work_sync.There was an ask from the user space to check for new data once after disabling EU stall sampling to make sure we capture all the data.
But they won't be able to read it because we set stream->enabled to false? So what's the point?
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 694
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+flush_delayed_work (&stream->buf_poll_work);I think here we should use
cancel_delayed_work_sync()instead. See e.g.xe_guc_ct.c(and also maybexe_gt_tlb_invalidation.c).
Quoted 7 lines
I though about it and found that the difference between
flushed_delayed_work()andcancel_delayed_work_sync()is thatcancel_delayed_work_sync()cancels any pending work items and wait for any work under execution to complete. Whereasflushed_delayed_work()schedules any work pending and wait for it to complete. Since I want to execute the work one last time after disable,flushed_delayed_work()is more appropriate here thancancel_delayed_work_sync().
Above I am questioning what is the purpose of the last queue_delayed_work. Also we could add the cancel_delayed_work_sync after the flush_delayed_work, if that is needed.
As pointed out above, I think it is preferable to eliminate the 'if (stream->enabled)' check in eu_stall_data_buf_poll_work_fn() and handle it via cancel_delayed_work_sync(). Which I think should work, but probably needs to be checked.
Quoted 48 lines
Quoted 48 lines
Quoted 48 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));drivers/gpu/drm/xe/xe_trace.h +33
-0@@ -427,6 +427,39 @@ DEFINE_EVENT(xe_pm_runtime, xe_pm_runtime_get_ioctl,TP_ARGS (xe, caller) ); +TRACE_EVENT (xe_eu_stall_data_read, + TP_PROTO(u8 slice, u8 subslice, + u32 read_ptr, u32 write_ptr, + u32 read_offset, u32 write_offset, + size_t total_size), +TP_ARGS (slice, subslice, read_ptr, write_ptr, + read_offset, write_offset, total_size), + + TP_STRUCT__entry(__field(u8, slice) + __field(u8, subslice) + __field(u32, read_ptr) + __field(u32, write_ptr) + __field(u32, read_offset) + __field(u32, write_offset) +__field (size_t, total_size) + ), + + TP_fast_assign(__entry->slice = slice; + __entry->subslice = subslice; + __entry->read_ptr = read_ptr; + __entry->write_ptr = write_ptr; + __entry->read_offset = read_offset; + __entry->write_offset = write_offset; + __entry->total_size = total_size; + ), + +TP_printk ("slice:%u subslice:%u readptr:0x%x writeptr:0x%x read off:%u write off:%u size:%zu " , + __entry->slice, __entry->subslice, + __entry->read_ptr, __entry->write_ptr, + __entry->read_offset, __entry->write_offset, + __entry->total_size) +); +#endif
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/xe/xe_trace.h +0
-1/* This part must be outside protection */ --2.48.1
Thanks.
--
Ashutosh
Re: [PATCH v9 4/8] drm/xe/eustall: Add support to read() and poll() EU stall data
Quoted 168 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 123 lines · Ashutosh
Quoted 110 lines · Harish Chegondi
Quoted 75 lines
Implement the EU stall sampling APIs to
read()andpoll()EU stall data. A work function periodically polls the EU stall data buffer write pointer registers to look for any new data and caches the write pointer. The read function compares the cached read and write pointers and copies any new data to the user space.v9: New patch split from the previous patch.
Used*_delayed_workfunctions instead of hrtimer Addressed the review feedback in read and poll functionsSigned-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 267 ++++++++++++++++++++++++++++++- drivers/gpu/drm/xe/xe_trace.h | 33 ++++ 2 files changed, 298 insertions(+), 2 deletions(-)drivers/gpu/drm/xe/xe_eu_stall.c +27
-0@@ -21,6 +21,7 @@#include "xe_macros.h" #include "xe_observation.h" #include "xe_pm.h" +#include "xe_trace.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h" @@ -41,7 +42,9 @@ struct per_xecore_buf { };struct xe_eu_stall_data_stream { +bool pollin;bool enabled; +wait_queue_head_t poll_wq;size_t data_record_size;size_t per_xecore_buf_size;unsigned int wait_num_reports;@@ -50,6 +53,8 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct delayed_work buf_poll_work; +struct workqueue_struct *buf_poll_wq; };struct xe_eu_stall_gt {@@ -256,6 +261,190 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,return 0 ; } +/** +* buf_data_size - Calculate the number of bytes in a circular buffer +* given the read and write pointers and the size of +* the buffer. +* +* @buf_size: Size of the circular buffer +* @read_ptr: Read pointer with an additional overflow bit +* @write_ptr: Write pointer with an additional overflow bit +* +* Since the read and write pointers have an additional overflow bit, +* this function calculates the offsets from the pointers and use the +* offsets to calculate the data size in the buffer. +* +* Returns: number of bytes of data in the buffer +*/ +static u32 buf_data_size (size_t buf_size,u32 read_ptr,u32 write_ptr) +{ +u32 read_offset, write_offset, size =0 ; + +if (read_ptr == write_ptr) + goto exit; +drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 295
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+ read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + +if (write_offset > read_offset) + size = write_offset - read_offset; +else + size = buf_size - read_offset + write_offset; +exit: +return size; +}Looks good now :)
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ +/** +* eu_stall_data_buf_poll - Poll for EU stall data in the buffer. +* +* @stream: xe EU stall data stream instance +* +* Returns: true if the EU stall buffer contains minimum stall data as +* specified by the event report count, else false. drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 313
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ +static bool eu_stall_data_buf_poll (struct xe_eu_stall_data_stream *stream) +{ +u32 read_ptr, write_ptr_reg, write_ptr, total_data =0 ; +u32 buf_size = stream->per_xecore_buf_size; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +bool min_data_present = false; +u16 group, instance; +unsigned int xecore;u32 and move above to u32 line?
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 317
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock);One thing I am wondering about is: do we really need these per
xecore_buflocks? How about movingptr_lockintoxe_eu_stall_data_streamand just coverfor_each_dss_steering()calls with the ptr lock. Because the polling thread runs every 10 ms, this should give plenty of time for the polling thread and the reads to go through, even with lcontention. And it will eliminate all these locks and the locking/unlocking overhead.Quoted 3 lines
I used a per dss lock so that polling and read on two different subslices can be done in parallel. I will try moving the
ptr_lockintoxe_eu_stall_data_stream.If you do this, please rename it to
dss_lockor something like that, to indicate it is guarding dss level info, not just the ptr's. Maybe rename the lock todss_lockeven if you end up not doing this.Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 324
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ read_ptr = xecore_buf->read; + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , + group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + write_ptr <<=6 ; + write_ptr &= ((buf_size <<1 ) -1 ); +if (write_ptr != read_ptr && !min_data_present) {Don't need to check for '
write_ptr!=read_ptr' here, it's already happening inbuf_data_size.Quoted 5 lines
Yes it is not needed. But
eu_stall_data_buf_poll()is invoked approx every 10ms. I am not an expert on compiler optimizations. If the compiler definitely optimizes and prevents call tobuf_data_size(), I can remove this check. But if the compiler doesn't optimize, wouldn't this check help avoid function calls given that this function gets executed every 10ms?The function is called every 10 ms *
num_dssand then it is called every dss for everyread(). Even then I am not sure why you are obsessed with the function call overhead. See here:https://github.com/torvalds/linux/blob/master/Documentation/process/4.Coding.rst#inline-functions
Specially "The cost of a function call, after all, is not that high" (it is typically memory accesses which reduce performance, not code execution). I would let the compiler handle this sort of optimization and decide whether or not the function can be inlined.
Another option is to use
always_inlineif you are really concerned:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html
Quoted 8 lines
static
__always_inlineu32 buf_data_size(...though I am not sure if just inline is already sufficient:
static inline u32 buf_data_size(...
So let's do one of these two things and remove this check, I'll approve either. Sorry if I asked to remove inline earlier :/
Okay, I will remove the if write_ptr != read_ptr. But I am not sure if want to add inline. My understanding is we only add inline for very small functions.
Quoted 93 lines
Quoted 57 lines
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 330
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ total_data +=buf_data_size (buf_size, read_ptr, write_ptr); +/* +* Check if there are at least minimum number of stall data +* rows for poll() to indicate that the data is present. +* Each stall data row is 64B (cacheline size). +*/ I'd say this comment is not needed and should be removed, the code below is clear enough.
Will remove.
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/xe/xe_eu_stall.c +35
-0+if (num_data_rows (total_data) >= stream->wait_num_reports) + min_data_present = true; + } + xecore_buf->write = write_ptr; +mutex_unlock (&xecore_buf->ptr_lock); + } +return min_data_present; +} + +static int xe_eu_stall_data_buf_read (struct xe_eu_stall_data_stream *stream, +char __user *buf,size_t count, +size_t *total_data_size,struct xe_gt *gt, +u16 group,u16 instance,unsigned int xecore) +{ +size_t read_data_size, copy_size, buf_size, data_record_size; +u32 read_ptr_reg, read_ptr, write_ptr; +u8 *xecore_start_vaddr, *read_vaddr; +struct per_xecore_buf *xecore_buf; +u32 read_offset, write_offset; +int ret =0 ; + +/* Hardware increments the read and write pointers such that they can +* overflow into one additional bit. For example, a 256KB size buffer +* offset pointer needs 18 bits. But HW uses 19 bits for the read and +* write pointers. This technique avoids wasting a slot in the buffer. +* Read and write offsets are calculated from the pointers in order to +* check if the write pointer has wrapped around the array. +*/ + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock); + xecore_start_vaddr = xecore_buf->vaddr; + read_ptr = xecore_buf->read; + write_ptr = xecore_buf->write; + buf_size = stream->per_xecore_buf_size; + data_record_size = stream->data_record_size;l> > +Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 372
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ read_data_size =buf_data_size (buf_size, read_ptr, write_ptr); +/* Read only the data that the user space buffer can accommodate */ +if ((*total_data_size + read_data_size) > count) { + read_data_size = count - *total_data_size; + read_data_size = (read_data_size / data_record_size) * data_record_size; + }As I said, my preferred way of writing this is as follows. Isn't this cleaner?
Quoted 3 lines
Most of the times, the if condition would evaluate false and the body of the if statement would not be executed. Whereas in your code the two lines of code get executed all the time.
The only thing extra which maybe gets executed unconditionally in my code is the
ALIGN_DOWNline. themin_t()part gets executed for you too in the if () check. Correct?But once again you seem to be obsessed with these micro optimizations: it is not that simple:
1. We don't know how the compiler will optimize
2. The CPU itself does out-of-order and speculative execution, branch prediction etc. So for you the CPU might actually be executing the code in the if () statement (both when result of the if is true and when it is false and then discarding the branch which is not taken).
3. Execution speed is driven more by memory accesses and lock contention rather than code execution itself. So mostly code stalls at locks and for memory accesses to complete.So with all this going on, my rule is to only make easy to understand and maintain. And let the compiler and CPU take care of running the code efficiently. Of course we can't do ridiculous things, which we are not doing here.
Also, since you are obsessed with optimization,
ALIGN_DOWN()uses bit operations (AND etc.), rather than integer division, so is more efficient. Also, use of pre-established, standard macros, likemin_tandALIGN_DOWN, is preferable, rather than rolling your own new code.Quoted 5 lines
Quoted 3 lines
read_data_size = buf_data_size(buf_size, read_ptr, write_ptr); XE_WARN_ON(count >= *total_size);Wouldn't count (size of the user buffer) be greater than the
total_sizemost of the time? I am still not convinced with having aWARN_ONhere.
Quoted 8 lines
Sorry, I meant an
xe_assert()here:xe_assert(xe, count >= *total_size);To make sure that (count -
*total_size>= 0) in themin_tstatement below. So if we useXE_WARN_ON(), this would become:XE_WARN_ON(count < *total_size);
The code has sufficient checks to make sure this doesn't happen.
Quoted 5 lines
So either is ok. I think it is good to have it.
Quoted 2 lines
Quoted 2 lines
read_data_size = min_t(size_t, count - *total_size, read_data_size); read_data_size = ALIGN_DOWN(read_data_size, data_record_size);
We don't need this ALIGN_DOWN() here if we have the ALIGN_DOWN() you suggested down below.
Quoted 79 lines
Quoted 7 lines
Quoted 3 lines
Since
data_record_sizehas to be a power of 2 for this to work (which it is), I would even put a
data_record_sizeis fixed in the hardware. As of now for both PVC and xe2, it is 64 which is a power of 2. I am guessing that it will remain a power of 2 in the future too. Why should we put an assert for the record size which is determined in the hardware?Because we are explicitly making use of the property that
data_record_sizeis a power of 2 in our code. TheALIGN_DOWNresults will be wrong if somehowdata_record_sizewere not a power of 2.And it also makes clear that the code is using this property and will break if it were to be false.
That is the purpose of the
assert(). If we weren't making use of that property in *our* code, we wouldn't need the assert.Quoted 33 lines
Quoted 26 lines
xe_assert(xe, is_power_of_2(record_size));in
xe_eu_stall_data_record_size().drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 381
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+if (read_data_size ==0 ) + goto exit; + + read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + read_vaddr = xecore_start_vaddr + read_offset; + +if (write_offset > read_offset) { +if (copy_to_user ((buf + *total_data_size), read_vaddr, read_data_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 386
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ ret = -EFAULT ; + goto exit; + } + }else { +if (read_data_size >= (buf_size - read_offset))internal brackets not needed ^
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 389
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+ copy_size = buf_size - read_offset; + else + copy_size = read_data_size;if (
write_offset<read_offset) how is this 'else' ever possible? So shouldn'tcopy_sizejust be set unconditionally to 'buf_size-read_offset'?Quoted 2 lines
If the user buffer doesn't have enough space to accommodate (
buf_size-read_offset) bytes, the else will get executed.Sorry, yes, you are right here.
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 390
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+if (copy_to_user ((buf + *total_data_size), read_vaddr, copy_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 394
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ ret = -EFAULT ; + goto exit; + } + if (copy_to_user((buf + *total_data_size + copy_size),internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 402
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ xecore_start_vaddr, read_data_size - copy_size)) { + ret = -EFAULT ; + goto exit; + } + } + + *total_data_size += read_data_size; + read_ptr += read_data_size;Because there is an overflow bit we can just add without worrying about wraparound?
Quoted 71 lines
Quoted 2 lines
I want to make sure only one overflow bit is used and doesn't overflow into the second bit.
OK, I don't follow, but this was just something I was trying to confirm, so ignore this comment. The code is fine because of the overflow bits.
Quoted 65 lines
Quoted 65 lines
Quoted 50 lines
drivers/gpu/drm/xe/xe_eu_stall.c +45
-0+ +/* Read pointer can overflow into one additional bit */ + read_ptr &= (buf_size <<1 ) -1 ; + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , (read_ptr >>6 )); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg); +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + xecore_buf->read = read_ptr; +trace_xe_eu_stall_data_read (group, instance, read_ptr, write_ptr, + read_offset, write_offset, *total_data_size); +exit: +mutex_unlock (&xecore_buf->ptr_lock); +return ret; +} + +/** +* xe_eu_stall_stream_read_locked - copy EU stall counters data from the +* per xecore buffers to the userspace buffer +* @stream: A stream opened for EU stall count metrics +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* +* Returns: Number of bytes copied or a negative error code +* If we've successfully copied any data then reporting that takes +* precedence over any internal error status, so the data isn't lost. +*/ +static ssize_t xe_eu_stall_stream_read_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,char __user *buf, +size_t count) +{ +struct xe_gt *gt = stream->gt; +size_t total_size =0 ; +u16 group, instance; +unsigned int xecore; +int ret =0 ; + +for_each_dss_steering (xecore, gt, group, instance) { + ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, + gt, group, instance, xecore); +if (ret || count == total_size) +break ; + } +return total_size ?: (ret ?: -EAGAIN ); +} +/** * xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. * drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 469
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-1@@ -272,7 +461,35 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -ssize_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +ssize_t ret; + +if (count ==0 ) +return -EINVAL ;I believe we need to also handle the fact that count might not be a multiple of
record_size. The easiest way to handle this seems to be right here:ssize_t aligned_count = ALIGN_DOWN(count, stream->data_record_size);
If we consider the aligned_count here, we don't need the ALIGN_DOWN() you suggested above.
Quoted 53 lines
Quoted 9 lines
I think the code handles buffer sizes that are not multiples of record size. Copying few lines of code below. Wouldn't
read_data_sizebe only a multiple of record size ? and leave any remaining space empty that is not a multiple of record size ?
/* Read only the data that the user space buffer can accommodate */if ((*total_data_size + read_data_size) > count) { read_data_size = count - *total_data_size; read_data_size = (read_data_size / data_record_size) * data_record_size;No, I don't think it is handled. The issue is we have this check here:
xe_eu_stall_stream_read_locked(){ ... if (ret || count == total_size) break; }And if count is not a multiple of
record_size, the 'count ==total_size' will never be true, I think. Sincetotal_sizereturned byxe_eu_stall_data_buf_read()is always a multiple ofrecord_size.Quoted 12 lines
Quoted 12 lines
And used
aligned_countrather than count inxe_eu_stall_stream_read_lockedcalls. So that we don't have to worry about this in later function calls.So above will become:
if (aligned_count == 0) return -EINVAL;Unless there is a minimum user buffer size we want to support, in that case this becomes:
Quoted 8 lines
Quoted 5 lines
if (aligned_count < minimum_user_buffer_size) return -EINVAL;But to me looks like a good value for
minimum_user_buffer_sizeis not available.I guess the minimum user buffer size should be the data record size (64 for PVC and Xe2)? If smaller than the record size, the drive will be unable to copy any data.
That is this check:
if (aligned_count == 0) return -EINVAL;Apart from that, is there a
minimum_user_buffer_sizewhich is greater thanrecord_size? That is why I was saying it is not available.Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Anyway, better to handle this degenerate case here itself.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 474
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ +if (!stream->enabled) { +xe_gt_dbg (gt,"EU stall data stream not enabled to read\n" ); +return -EINVAL ; + }
I will remove this check. User space should be able to read any last remaining data even after EU stall is disabled.
Quoted 31 lines
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/xe/xe_eu_stall.c +14
-0+ +if (!(file->f_flags &O_NONBLOCK )) { +do { + ret =wait_event_interruptible (stream->poll_wq, stream->pollin); +if (ret) +return -EINTR ; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + }while (ret == -EAGAIN ); + }else { +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count);Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 492
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+mutex_unlock (>->eu_stall->stream_lock); + } + + stream->pollin = false;Carry over comment from previous rev: this breaks if user buffer is smaller than available data. But this is a corner case so let's fix this after the initial merge.
Quoted 3 lines
I will check your fix in OA to better understand the problem here. If the user buffer is smaller than data record size, it just returns without copying any data.
No, it is the issue when user buffer is larger than
record_size, but still smaller than the size of total data available. In that case, basically we should letstream->pollinset to true, so that the user thread does not get blocked, enabling it to rapidly consume data, even with a small buffer.
Quoted 8 lines
Otherwise the thread is getting blocked every 10 ms, even when data is available. And because new data keeps arriving, the user thread constantly falls behind and soon HW will start dropping data (because the kernel is blocking the user thread, it's a kernel not a user thread issue)
To handle this OA does:
if (ret != -ENOSPC && ret != -EIO)
EU stall read() never returns -ENOSPC. Even if the user buffer is smaller then the size of total data in the buffer, only the data that can fit into the user buffer will be copied through read(). As long as there are atleast wait_num_reports data rows in the buffer, stream->pollin is set to true. It sounds to me that this issue is specific to OA code only. Is there something that I missed?
Quoted 133 lines
stream->pollin = false;Anyway, we can do this after the initial merge.
Quoted 37 lines
Quoted 3 lines
Let's put it a list of to be done's in the cover letter to do after we merge in the next revision.
Okay.
Quoted 20 lines
drivers/gpu/drm/xe/xe_eu_stall.c static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) · line 501
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0return ret; }@@ -281,6 +498,7 @@ static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) {if (stream->bo)xe_bo_unpin_map_no_vm (stream->bo); +destroy_workqueue (stream->buf_poll_wq);Don't put this here in
free_eu_stall_data_buf, put this in the caller of this function, like the destroy/close function.Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0} static int alloc_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream,@@ -351,6 +569,21 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return 0 ; }Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) · line 581
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+static void eu_stall_data_buf_poll_work_fn (struct work_struct *work) +{ +struct xe_eu_stall_data_stream *stream = +container_of (work,typeof (*stream), buf_poll_work.work); + +if (eu_stall_data_buf_poll (stream)) { + stream->pollin = true; +wake_up (&stream->poll_wq); + } +if (stream->enabled)See comment at
xe_eu_stall_disable_locked. If we docancel_delayed_work_syncthere, I think thisstream->enabledcheck mightQuoted 2 lines
I will explain later why I used
flush_delayed_work()instead ofcancel_delayed_work_sync()See below.
Quoted 87 lines
Quoted 87 lines
not be needed here. Also see comments at
cancel_work_syncinkernel/workqueue.c.Could you please check and see if it works out.
xe_guc_ct.c(andxe_gt_tlb_invalidation.c) seem to be doing that.Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+queue_delayed_work (stream->buf_poll_wq, + &stream->buf_poll_work, +msecs_to_jiffies (POLL_PERIOD_MS )); +} +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream,struct eu_stall_open_properties *props) {drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream, · line 601
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0@@ -361,6 +594,11 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,u32 vaddr_offset;int ret, xecore; +init_waitqueue_head (&stream->poll_wq); +INIT_DELAYED_WORK (&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); + stream->buf_poll_wq =alloc_ordered_workqueue ("xe_eu_stall" ,0 ); +if (!stream->buf_poll_wq) +return -ENOMEM ;Now we also need to
destroy_workqueueduring error unwinding (see comments regarding this in Patch 3).Quoted 39 lines
drivers/gpu/drm/xe/xe_eu_stall.c +20
-1stream->sampling_rate_mult = props->sampling_rate_mult; stream->wait_num_reports = props->wait_num_reports; stream->per_xecore_buf_size = per_xecore_buf_size;@@ -391,6 +629,19 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,return 0 ; } +static __poll_t xe_eu_stall_stream_poll_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,poll_table *wait) +{ +__poll_t events =0 ; + +poll_wait (file, &stream->poll_wq, wait); + +if (stream->pollin) + events |=EPOLLIN ; + +return events; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -401,7 +652,13 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,*/ static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) { -__poll_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +__poll_t ret; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_poll_locked (stream, file, wait); +mutex_unlock (>->eu_stall->stream_lock);return ret; }drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) · line 676
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0@@ -416,6 +673,9 @@ static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = true; ret =xe_eu_stall_stream_enable (stream); + queue_delayed_work(stream->buf_poll_wq,A blank line before this line would be nice.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 693
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ &stream->buf_poll_work, + msecs_to_jiffies(POLL_PERIOD_MS));return ret; }@@ -429,6 +689,9 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = false;xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); +/* Check for any new EU stall data one last time */ +queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 );I am not sure if this is needed, especially if we use
cancel_delayed_work_sync.
Quoted 5 lines
Quoted 2 lines
There was an ask from the user space to check for new data once after disabling EU stall sampling to make sure we capture all the data.
But they won't be able to read it because we set
stream->enabledto false? So what's the point?
Good point. I will remove check for stream->enabled in the read function xe_eu_stall_stream_read().
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 694
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+flush_delayed_work (&stream->buf_poll_work);I think here we should use
cancel_delayed_work_sync()instead. See e.g.xe_guc_ct.c(and also maybexe_gt_tlb_invalidation.c).Quoted 7 lines
I though about it and found that the difference between
flushed_delayed_work()andcancel_delayed_work_sync()is thatcancel_delayed_work_sync()cancels any pending work items and wait for any work under execution to complete. Whereasflushed_delayed_work()schedules any work pending and wait for it to complete. Since I want to execute the work one last time after disable,flushed_delayed_work()is more appropriate here thancancel_delayed_work_sync().
Quoted 3 lines
Above I am questioning what is the purpose of the last
queue_delayed_work. Also we could add thecancel_delayed_work_syncafter theflush_delayed_work, if that is needed.
Okay, will add cancel_delayed_work_sync() after flush_delayed_work().
Quoted 5 lines
As pointed out above, I think it is preferable to eliminate the 'if (
stream->enabled)' check ineu_stall_data_buf_poll_work_fn()and handle it viacancel_delayed_work_sync(). Which I think should work, but probably needs to be checked.
Will check on this. I need to find a different way to check for any new data and update write pointers one last time after disabling EU stall.
Quoted 57 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));drivers/gpu/drm/xe/xe_trace.h +33
-0@@ -427,6 +427,39 @@ DEFINE_EVENT(xe_pm_runtime, xe_pm_runtime_get_ioctl,TP_ARGS (xe, caller) ); +TRACE_EVENT (xe_eu_stall_data_read, + TP_PROTO(u8 slice, u8 subslice, + u32 read_ptr, u32 write_ptr, + u32 read_offset, u32 write_offset, + size_t total_size), +TP_ARGS (slice, subslice, read_ptr, write_ptr, + read_offset, write_offset, total_size), + + TP_STRUCT__entry(__field(u8, slice) + __field(u8, subslice) + __field(u32, read_ptr) + __field(u32, write_ptr) + __field(u32, read_offset) + __field(u32, write_offset) +__field (size_t, total_size) + ), + + TP_fast_assign(__entry->slice = slice; + __entry->subslice = subslice; + __entry->read_ptr = read_ptr; + __entry->write_ptr = write_ptr; + __entry->read_offset = read_offset; + __entry->write_offset = write_offset; + __entry->total_size = total_size; + ), + +TP_printk ("slice:%u subslice:%u readptr:0x%x writeptr:0x%x read off:%u write off:%u size:%zu " , + __entry->slice, __entry->subslice, + __entry->read_ptr, __entry->write_ptr, + __entry->read_offset, __entry->write_offset, + __entry->total_size) +); +#endif Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/xe/xe_trace.h +0
-1/* This part must be outside protection */ --2.48.1
Thanks.
--
Ashutosh
Re: [PATCH v9 4/8] drm/xe/eustall: Add support to read() and poll() EU stall data
Quoted 174 lines · Harish Chegondi
Quoted 172 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 123 lines · Ashutosh
Quoted 110 lines · Harish Chegondi
Quoted 75 lines
Implement the EU stall sampling APIs to
read()andpoll()EU stall data. A work function periodically polls the EU stall data buffer write pointer registers to look for any new data and caches the write pointer. The read function compares the cached read and write pointers and copies any new data to the user space.v9: New patch split from the previous patch.
Used*_delayed_workfunctions instead of hrtimer Addressed the review feedback in read and poll functionsSigned-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 267 ++++++++++++++++++++++++++++++- drivers/gpu/drm/xe/xe_trace.h | 33 ++++ 2 files changed, 298 insertions(+), 2 deletions(-)drivers/gpu/drm/xe/xe_eu_stall.c +27
-0@@ -21,6 +21,7 @@#include "xe_macros.h" #include "xe_observation.h" #include "xe_pm.h" +#include "xe_trace.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h" @@ -41,7 +42,9 @@ struct per_xecore_buf { };struct xe_eu_stall_data_stream { +bool pollin;bool enabled; +wait_queue_head_t poll_wq;size_t data_record_size;size_t per_xecore_buf_size;unsigned int wait_num_reports;@@ -50,6 +53,8 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct delayed_work buf_poll_work; +struct workqueue_struct *buf_poll_wq; };struct xe_eu_stall_gt {@@ -256,6 +261,190 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,return 0 ; } +/** +* buf_data_size - Calculate the number of bytes in a circular buffer +* given the read and write pointers and the size of +* the buffer. +* +* @buf_size: Size of the circular buffer +* @read_ptr: Read pointer with an additional overflow bit +* @write_ptr: Write pointer with an additional overflow bit +* +* Since the read and write pointers have an additional overflow bit, +* this function calculates the offsets from the pointers and use the +* offsets to calculate the data size in the buffer. +* +* Returns: number of bytes of data in the buffer +*/ +static u32 buf_data_size (size_t buf_size,u32 read_ptr,u32 write_ptr) +{ +u32 read_offset, write_offset, size =0 ; + +if (read_ptr == write_ptr) + goto exit; +drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 295
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+ read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + +if (write_offset > read_offset) + size = write_offset - read_offset; +else + size = buf_size - read_offset + write_offset; +exit: +return size; +}Looks good now :)
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ +/** +* eu_stall_data_buf_poll - Poll for EU stall data in the buffer. +* +* @stream: xe EU stall data stream instance +* +* Returns: true if the EU stall buffer contains minimum stall data as +* specified by the event report count, else false. drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 313
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ +static bool eu_stall_data_buf_poll (struct xe_eu_stall_data_stream *stream) +{ +u32 read_ptr, write_ptr_reg, write_ptr, total_data =0 ; +u32 buf_size = stream->per_xecore_buf_size; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +bool min_data_present = false; +u16 group, instance; +unsigned int xecore;u32 and move above to u32 line?
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 317
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock);One thing I am wondering about is: do we really need these per
xecore_buflocks? How about movingptr_lockintoxe_eu_stall_data_streamand just coverfor_each_dss_steering()calls with the ptr lock. Because the polling thread runs every 10 ms, this should give plenty of time for the polling thread and the reads to go through, even with lcontention. And it will eliminate all these locks and the locking/unlocking overhead.Quoted 3 lines
I used a per dss lock so that polling and read on two different subslices can be done in parallel. I will try moving the
ptr_lockintoxe_eu_stall_data_stream.If you do this, please rename it to
dss_lockor something like that, to indicate it is guarding dss level info, not just the ptr's. Maybe rename the lock todss_lockeven if you end up not doing this.Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 324
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ read_ptr = xecore_buf->read; + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , + group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + write_ptr <<=6 ; + write_ptr &= ((buf_size <<1 ) -1 ); +if (write_ptr != read_ptr && !min_data_present) {Don't need to check for '
write_ptr!=read_ptr' here, it's already happening inbuf_data_size.Quoted 5 lines
Yes it is not needed. But
eu_stall_data_buf_poll()is invoked approx every 10ms. I am not an expert on compiler optimizations. If the compiler definitely optimizes and prevents call tobuf_data_size(), I can remove this check. But if the compiler doesn't optimize, wouldn't this check help avoid function calls given that this function gets executed every 10ms?The function is called every 10 ms *
num_dssand then it is called every dss for everyread(). Even then I am not sure why you are obsessed with the function call overhead. See here:https://github.com/torvalds/linux/blob/master/Documentation/process/4.Coding.rst#inline-functions
Specially "The cost of a function call, after all, is not that high" (it is typically memory accesses which reduce performance, not code execution). I would let the compiler handle this sort of optimization and decide whether or not the function can be inlined.
Another option is to use
always_inlineif you are really concerned:
https://gcc.gnu.org/onlinedocs/gcc/Inline.htmlstatic
__always_inlineu32 buf_data_size(...though I am not sure if just inline is already sufficient:
Quoted 7 lines
Quoted 4 lines
static inline u32 buf_data_size(...
So let's do one of these two things and remove this check, I'll approve either. Sorry if I asked to remove inline earlier :/
Okay, I will remove the if
write_ptr!=read_ptr. But I am not sure if want to add inline. My understanding is we only add inline for very small functions.
You can add __always_inline, there are only 2 instances of this, it is a small function.
Quoted 95 lines
Quoted 95 lines
Quoted 57 lines
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 330
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ total_data +=buf_data_size (buf_size, read_ptr, write_ptr); +/* +* Check if there are at least minimum number of stall data +* rows for poll() to indicate that the data is present. +* Each stall data row is 64B (cacheline size). +*/ I'd say this comment is not needed and should be removed, the code below is clear enough.
Will remove.
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/xe/xe_eu_stall.c +35
-0+if (num_data_rows (total_data) >= stream->wait_num_reports) + min_data_present = true; + } + xecore_buf->write = write_ptr; +mutex_unlock (&xecore_buf->ptr_lock); + } +return min_data_present; +} + +static int xe_eu_stall_data_buf_read (struct xe_eu_stall_data_stream *stream, +char __user *buf,size_t count, +size_t *total_data_size,struct xe_gt *gt, +u16 group,u16 instance,unsigned int xecore) +{ +size_t read_data_size, copy_size, buf_size, data_record_size; +u32 read_ptr_reg, read_ptr, write_ptr; +u8 *xecore_start_vaddr, *read_vaddr; +struct per_xecore_buf *xecore_buf; +u32 read_offset, write_offset; +int ret =0 ; + +/* Hardware increments the read and write pointers such that they can +* overflow into one additional bit. For example, a 256KB size buffer +* offset pointer needs 18 bits. But HW uses 19 bits for the read and +* write pointers. This technique avoids wasting a slot in the buffer. +* Read and write offsets are calculated from the pointers in order to +* check if the write pointer has wrapped around the array. +*/ + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock); + xecore_start_vaddr = xecore_buf->vaddr; + read_ptr = xecore_buf->read; + write_ptr = xecore_buf->write; + buf_size = stream->per_xecore_buf_size; + data_record_size = stream->data_record_size;l> > +Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 372
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ read_data_size =buf_data_size (buf_size, read_ptr, write_ptr); +/* Read only the data that the user space buffer can accommodate */ +if ((*total_data_size + read_data_size) > count) { + read_data_size = count - *total_data_size; + read_data_size = (read_data_size / data_record_size) * data_record_size; + }As I said, my preferred way of writing this is as follows. Isn't this cleaner?
Quoted 3 lines
Most of the times, the if condition would evaluate false and the body of the if statement would not be executed. Whereas in your code the two lines of code get executed all the time.
The only thing extra which maybe gets executed unconditionally in my code is the
ALIGN_DOWNline. themin_t()part gets executed for you too in the if () check. Correct?But once again you seem to be obsessed with these micro optimizations: it is not that simple:
1. We don't know how the compiler will optimize
2. The CPU itself does out-of-order and speculative execution, branch prediction etc. So for you the CPU might actually be executing the code in the if () statement (both when result of the if is true and when it is false and then discarding the branch which is not taken).
3. Execution speed is driven more by memory accesses and lock contention rather than code execution itself. So mostly code stalls at locks and for memory accesses to complete.So with all this going on, my rule is to only make easy to understand and maintain. And let the compiler and CPU take care of running the code efficiently. Of course we can't do ridiculous things, which we are not doing here.
Also, since you are obsessed with optimization,
ALIGN_DOWN()uses bit operations (AND etc.), rather than integer division, so is more efficient. Also, use of pre-established, standard macros, likemin_tandALIGN_DOWN, is preferable, rather than rolling your own new code.Quoted 5 lines
Quoted 3 lines
read_data_size = buf_data_size(buf_size, read_ptr, write_ptr); XE_WARN_ON(count >= *total_size);Wouldn't count (size of the user buffer) be greater than the
total_sizemost of the time? I am still not convinced with having aWARN_ONhere.Sorry, I meant an
xe_assert()here:
Quoted 7 lines
Quoted 6 lines
xe_assert(xe, count >= *total_size);To make sure that (count -
*total_size>= 0) in themin_tstatement below. So if we useXE_WARN_ON(), this would become:XE_WARN_ON(count < *total_size);The code has sufficient checks to make sure this doesn't happen.
OK.
Quoted 7 lines
Quoted 5 lines
So either is ok. I think it is good to have it.
Quoted 2 lines
Quoted 2 lines
read_data_size = min_t(size_t, count - *total_size, read_data_size); read_data_size = ALIGN_DOWN(read_data_size, data_record_size);We don't need this
ALIGN_DOWN()here if we have theALIGN_DOWN()you suggested down below.
Yes, you are right, good catch.
Quoted 150 lines
Quoted 79 lines
Quoted 7 lines
Quoted 3 lines
Since
data_record_sizehas to be a power of 2 for this to work (which it is), I would even put a
data_record_sizeis fixed in the hardware. As of now for both PVC and xe2, it is 64 which is a power of 2. I am guessing that it will remain a power of 2 in the future too. Why should we put an assert for the record size which is determined in the hardware?Because we are explicitly making use of the property that
data_record_sizeis a power of 2 in our code. TheALIGN_DOWNresults will be wrong if somehowdata_record_sizewere not a power of 2.And it also makes clear that the code is using this property and will break if it were to be false.
That is the purpose of the
assert(). If we weren't making use of that property in *our* code, we wouldn't need the assert.Quoted 33 lines
Quoted 26 lines
xe_assert(xe, is_power_of_2(record_size));in
xe_eu_stall_data_record_size().drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 381
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+if (read_data_size ==0 ) + goto exit; + + read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + read_vaddr = xecore_start_vaddr + read_offset; + +if (write_offset > read_offset) { +if (copy_to_user ((buf + *total_data_size), read_vaddr, read_data_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 386
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ ret = -EFAULT ; + goto exit; + } + }else { +if (read_data_size >= (buf_size - read_offset))internal brackets not needed ^
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 389
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+ copy_size = buf_size - read_offset; + else + copy_size = read_data_size;if (
write_offset<read_offset) how is this 'else' ever possible? So shouldn'tcopy_sizejust be set unconditionally to 'buf_size-read_offset'?Quoted 2 lines
If the user buffer doesn't have enough space to accommodate (
buf_size-read_offset) bytes, the else will get executed.Sorry, yes, you are right here.
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 390
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+if (copy_to_user ((buf + *total_data_size), read_vaddr, copy_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 394
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ ret = -EFAULT ; + goto exit; + } + if (copy_to_user((buf + *total_data_size + copy_size),internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 402
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ xecore_start_vaddr, read_data_size - copy_size)) { + ret = -EFAULT ; + goto exit; + } + } + + *total_data_size += read_data_size; + read_ptr += read_data_size;Because there is an overflow bit we can just add without worrying about wraparound?
Quoted 71 lines
Quoted 2 lines
I want to make sure only one overflow bit is used and doesn't overflow into the second bit.
OK, I don't follow, but this was just something I was trying to confirm, so ignore this comment. The code is fine because of the overflow bits.
Quoted 65 lines
Quoted 65 lines
Quoted 50 lines
drivers/gpu/drm/xe/xe_eu_stall.c +45
-0+ +/* Read pointer can overflow into one additional bit */ + read_ptr &= (buf_size <<1 ) -1 ; + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , (read_ptr >>6 )); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg); +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + xecore_buf->read = read_ptr; +trace_xe_eu_stall_data_read (group, instance, read_ptr, write_ptr, + read_offset, write_offset, *total_data_size); +exit: +mutex_unlock (&xecore_buf->ptr_lock); +return ret; +} + +/** +* xe_eu_stall_stream_read_locked - copy EU stall counters data from the +* per xecore buffers to the userspace buffer +* @stream: A stream opened for EU stall count metrics +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* +* Returns: Number of bytes copied or a negative error code +* If we've successfully copied any data then reporting that takes +* precedence over any internal error status, so the data isn't lost. +*/ +static ssize_t xe_eu_stall_stream_read_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,char __user *buf, +size_t count) +{ +struct xe_gt *gt = stream->gt; +size_t total_size =0 ; +u16 group, instance; +unsigned int xecore; +int ret =0 ; + +for_each_dss_steering (xecore, gt, group, instance) { + ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, + gt, group, instance, xecore); +if (ret || count == total_size) +break ; + } +return total_size ?: (ret ?: -EAGAIN ); +} +/** * xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. * drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 469
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-1@@ -272,7 +461,35 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -ssize_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +ssize_t ret; + +if (count ==0 ) +return -EINVAL ;I believe we need to also handle the fact that count might not be a multiple of
record_size. The easiest way to handle this seems to be right here:ssize_t aligned_count = ALIGN_DOWN(count, stream->data_record_size);
Quoted 2 lines
If we consider the
aligned_counthere, we don't need theALIGN_DOWN()you suggested above.
Agreed, correct!
Quoted 55 lines
Quoted 55 lines
Quoted 9 lines
I think the code handles buffer sizes that are not multiples of record size. Copying few lines of code below. Wouldn't
read_data_sizebe only a multiple of record size ? and leave any remaining space empty that is not a multiple of record size ?
/* Read only the data that the user space buffer can accommodate */if ((*total_data_size + read_data_size) > count) { read_data_size = count - *total_data_size; read_data_size = (read_data_size / data_record_size) * data_record_size;No, I don't think it is handled. The issue is we have this check here:
xe_eu_stall_stream_read_locked(){ ... if (ret || count == total_size) break; }And if count is not a multiple of
record_size, the 'count ==total_size' will never be true, I think. Sincetotal_sizereturned byxe_eu_stall_data_buf_read()is always a multiple ofrecord_size.Quoted 12 lines
Quoted 12 lines
And used
aligned_countrather than count inxe_eu_stall_stream_read_lockedcalls. So that we don't have to worry about this in later function calls.So above will become:
if (aligned_count == 0) return -EINVAL;Unless there is a minimum user buffer size we want to support, in that case this becomes:
Quoted 8 lines
Quoted 5 lines
if (aligned_count < minimum_user_buffer_size) return -EINVAL;But to me looks like a good value for
minimum_user_buffer_sizeis not available.I guess the minimum user buffer size should be the data record size (64 for PVC and Xe2)? If smaller than the record size, the drive will be unable to copy any data.
That is this check:
if (aligned_count == 0) return -EINVAL;Apart from that, is there a
minimum_user_buffer_sizewhich is greater thanrecord_size? That is why I was saying it is not available.Quoted 3 lines
Quoted 3 lines
Anyway, better to handle this degenerate case here itself.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 474
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ +if (!stream->enabled) { +xe_gt_dbg (gt,"EU stall data stream not enabled to read\n" ); +return -EINVAL ; + }I will remove this check. User space should be able to read any last remaining data even after EU stall is disabled.
I would advise against it. You will need to carefully consider the consequences of allowing reads in disabled state. When there is no data in disabled state (after the initial data has been read):
* Non-blocking reads will return -EAGAIN, so that is ok
* Blocking reads will indefinitely block, unless userland unblocks these via a signal.
Why can't userland read all data and then disable the stream? What kind of a requirement is that?
They run a workload to capture some stats. They should:
1. stop the workload
2. get all data for the workload: read() till non-blocking reads return -EAGAIN or blocking reads block (unblock using signal). I am assuming if nothing is running on the EU's there is no data?
3. finally disable the stream.
So if they do that, we don't allow reading any data in disabled state.
And anyway, this is what we can implement initially. If they don't agree we can later add a patch to change the behavior. But they need to convince us why they can't do what I just said above. Our default behavior should be to not allow reads in disabled state, I think.
Quoted 36 lines
Quoted 36 lines
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/xe/xe_eu_stall.c +14
-0+ +if (!(file->f_flags &O_NONBLOCK )) { +do { + ret =wait_event_interruptible (stream->poll_wq, stream->pollin); +if (ret) +return -EINTR ; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + }while (ret == -EAGAIN ); + }else { +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count);Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 492
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+mutex_unlock (>->eu_stall->stream_lock); + } + + stream->pollin = false;Carry over comment from previous rev: this breaks if user buffer is smaller than available data. But this is a corner case so let's fix this after the initial merge.
Quoted 3 lines
I will check your fix in OA to better understand the problem here. If the user buffer is smaller than data record size, it just returns without copying any data.
No, it is the issue when user buffer is larger than
record_size, but still smaller than the size of total data available. In that case, basically we should letstream->pollinset to true, so that the user thread does not get blocked, enabling it to rapidly consume data, even with a small buffer.Otherwise the thread is getting blocked every 10 ms, even when data is available. And because new data keeps arriving, the user thread constantly falls behind and soon HW will start dropping data (because the kernel is blocking the user thread, it's a kernel not a user thread issue)
Quoted 6 lines
Quoted 3 lines
To handle this OA does:
if (ret != -ENOSPC && ret != -EIO)EU stall
read()never returns-ENOSPC. Even if the user buffer is smaller then the size of total data in the buffer, only the data that can fit into the user buffer will be copied throughread().
OA read() also doesn't return -ENOSPC to userland. That is the expected read() behavior (return number of bytes if you are returning any data). The full code is this:
if (ret != -ENOSPC && ret != -EIO)
stream->pollin = false;
return offset ?: (ret ?: -EAGAIN);Quoted 3 lines
As long as there are atleast
wait_num_reportsdata rows in the buffer,stream->pollinis set to true. It sounds to me that this issue is specific to OA code only. Is there something that I missed?
No this issue is there in EU stall code. You should not block reads till the next time the polling thread runs, if we could not copy all data in the previous read (because there already is data, don't block the user thread).
Quoted 133 lines
Quoted 133 lines
stream->pollin = false;Anyway, we can do this after the initial merge.
Quoted 37 lines
Quoted 3 lines
Let's put it a list of to be done's in the cover letter to do after we merge in the next revision.
Okay.
Quoted 20 lines
drivers/gpu/drm/xe/xe_eu_stall.c static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) · line 501
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0return ret; }@@ -281,6 +498,7 @@ static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) {if (stream->bo)xe_bo_unpin_map_no_vm (stream->bo); +destroy_workqueue (stream->buf_poll_wq);Don't put this here in
free_eu_stall_data_buf, put this in the caller of this function, like the destroy/close function.Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0} static int alloc_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream,@@ -351,6 +569,21 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return 0 ; }Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) · line 581
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+static void eu_stall_data_buf_poll_work_fn (struct work_struct *work) +{ +struct xe_eu_stall_data_stream *stream = +container_of (work,typeof (*stream), buf_poll_work.work); + +if (eu_stall_data_buf_poll (stream)) { + stream->pollin = true; +wake_up (&stream->poll_wq); + } +if (stream->enabled)See comment at
xe_eu_stall_disable_locked. If we docancel_delayed_work_syncthere, I think thisstream->enabledcheck mightQuoted 2 lines
I will explain later why I used
flush_delayed_work()instead ofcancel_delayed_work_sync()See below.
Quoted 87 lines
Quoted 87 lines
not be needed here. Also see comments at
cancel_work_syncinkernel/workqueue.c.Could you please check and see if it works out.
xe_guc_ct.c(andxe_gt_tlb_invalidation.c) seem to be doing that.Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+queue_delayed_work (stream->buf_poll_wq, + &stream->buf_poll_work, +msecs_to_jiffies (POLL_PERIOD_MS )); +} +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream,struct eu_stall_open_properties *props) {drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream, · line 601
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0@@ -361,6 +594,11 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,u32 vaddr_offset;int ret, xecore; +init_waitqueue_head (&stream->poll_wq); +INIT_DELAYED_WORK (&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); + stream->buf_poll_wq =alloc_ordered_workqueue ("xe_eu_stall" ,0 ); +if (!stream->buf_poll_wq) +return -ENOMEM ;Now we also need to
destroy_workqueueduring error unwinding (see comments regarding this in Patch 3).Quoted 39 lines
drivers/gpu/drm/xe/xe_eu_stall.c +20
-1stream->sampling_rate_mult = props->sampling_rate_mult; stream->wait_num_reports = props->wait_num_reports; stream->per_xecore_buf_size = per_xecore_buf_size;@@ -391,6 +629,19 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,return 0 ; } +static __poll_t xe_eu_stall_stream_poll_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,poll_table *wait) +{ +__poll_t events =0 ; + +poll_wait (file, &stream->poll_wq, wait); + +if (stream->pollin) + events |=EPOLLIN ; + +return events; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -401,7 +652,13 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,*/ static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) { -__poll_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +__poll_t ret; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_poll_locked (stream, file, wait); +mutex_unlock (>->eu_stall->stream_lock);return ret; }drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) · line 676
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0@@ -416,6 +673,9 @@ static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = true; ret =xe_eu_stall_stream_enable (stream); + queue_delayed_work(stream->buf_poll_wq,A blank line before this line would be nice.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 693
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ &stream->buf_poll_work, + msecs_to_jiffies(POLL_PERIOD_MS));return ret; }@@ -429,6 +689,9 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = false;xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); +/* Check for any new EU stall data one last time */ +queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 );I am not sure if this is needed, especially if we use
cancel_delayed_work_sync.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
There was an ask from the user space to check for new data once after disabling EU stall sampling to make sure we capture all the data.
But they won't be able to read it because we set
stream->enabledto false? So what's the point?Good point. I will remove check for
stream->enabledin the read functionxe_eu_stall_stream_read().
See above.
Quoted 82 lines
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 694
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+flush_delayed_work (&stream->buf_poll_work);I think here we should use
cancel_delayed_work_sync()instead. See e.g.xe_guc_ct.c(and also maybexe_gt_tlb_invalidation.c).Quoted 7 lines
I though about it and found that the difference between
flushed_delayed_work()andcancel_delayed_work_sync()is thatcancel_delayed_work_sync()cancels any pending work items and wait for any work under execution to complete. Whereasflushed_delayed_work()schedules any work pending and wait for it to complete. Since I want to execute the work one last time after disable,flushed_delayed_work()is more appropriate here thancancel_delayed_work_sync().Quoted 3 lines
Above I am questioning what is the purpose of the last
queue_delayed_work. Also we could add thecancel_delayed_work_syncafter theflush_delayed_work, if that is needed.Okay, will add
cancel_delayed_work_sync()afterflush_delayed_work().Quoted 5 lines
As pointed out above, I think it is preferable to eliminate the 'if (
stream->enabled)' check ineu_stall_data_buf_poll_work_fn()and handle it viacancel_delayed_work_sync(). Which I think should work, but probably needs to be checked.Will check on this. I need to find a different way to check for any new data and update write pointers one last time after disabling EU stall.
Quoted 57 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));drivers/gpu/drm/xe/xe_trace.h +33
-0@@ -427,6 +427,39 @@ DEFINE_EVENT(xe_pm_runtime, xe_pm_runtime_get_ioctl,TP_ARGS (xe, caller) ); +TRACE_EVENT (xe_eu_stall_data_read, + TP_PROTO(u8 slice, u8 subslice, + u32 read_ptr, u32 write_ptr, + u32 read_offset, u32 write_offset, + size_t total_size), +TP_ARGS (slice, subslice, read_ptr, write_ptr, + read_offset, write_offset, total_size), + + TP_STRUCT__entry(__field(u8, slice) + __field(u8, subslice) + __field(u32, read_ptr) + __field(u32, write_ptr) + __field(u32, read_offset) + __field(u32, write_offset) +__field (size_t, total_size) + ), + + TP_fast_assign(__entry->slice = slice; + __entry->subslice = subslice; + __entry->read_ptr = read_ptr; + __entry->write_ptr = write_ptr; + __entry->read_offset = read_offset; + __entry->write_offset = write_offset; + __entry->total_size = total_size; + ), + +TP_printk ("slice:%u subslice:%u readptr:0x%x writeptr:0x%x read off:%u write off:%u size:%zu " , + __entry->slice, __entry->subslice, + __entry->read_ptr, __entry->write_ptr, + __entry->read_offset, __entry->write_offset, + __entry->total_size) +); +#endif Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/xe/xe_trace.h +0
-1/* This part must be outside protection */ --2.48.1
Thanks.
--
Ashutosh
Re: [PATCH v9 4/8] drm/xe/eustall: Add support to read() and poll() EU stall data
Quoted 596 lines · Ashutosh
Quoted 174 lines · Harish Chegondi
Quoted 172 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 123 lines · Ashutosh
Quoted 110 lines · Harish Chegondi
Quoted 75 lines
Implement the EU stall sampling APIs to
read()andpoll()EU stall data. A work function periodically polls the EU stall data buffer write pointer registers to look for any new data and caches the write pointer. The read function compares the cached read and write pointers and copies any new data to the user space.v9: New patch split from the previous patch.
Used*_delayed_workfunctions instead of hrtimer Addressed the review feedback in read and poll functionsSigned-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 267 ++++++++++++++++++++++++++++++- drivers/gpu/drm/xe/xe_trace.h | 33 ++++ 2 files changed, 298 insertions(+), 2 deletions(-)drivers/gpu/drm/xe/xe_eu_stall.c +27
-0@@ -21,6 +21,7 @@#include "xe_macros.h" #include "xe_observation.h" #include "xe_pm.h" +#include "xe_trace.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h" @@ -41,7 +42,9 @@ struct per_xecore_buf { };struct xe_eu_stall_data_stream { +bool pollin;bool enabled; +wait_queue_head_t poll_wq;size_t data_record_size;size_t per_xecore_buf_size;unsigned int wait_num_reports;@@ -50,6 +53,8 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct delayed_work buf_poll_work; +struct workqueue_struct *buf_poll_wq; };struct xe_eu_stall_gt {@@ -256,6 +261,190 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,return 0 ; } +/** +* buf_data_size - Calculate the number of bytes in a circular buffer +* given the read and write pointers and the size of +* the buffer. +* +* @buf_size: Size of the circular buffer +* @read_ptr: Read pointer with an additional overflow bit +* @write_ptr: Write pointer with an additional overflow bit +* +* Since the read and write pointers have an additional overflow bit, +* this function calculates the offsets from the pointers and use the +* offsets to calculate the data size in the buffer. +* +* Returns: number of bytes of data in the buffer +*/ +static u32 buf_data_size (size_t buf_size,u32 read_ptr,u32 write_ptr) +{ +u32 read_offset, write_offset, size =0 ; + +if (read_ptr == write_ptr) + goto exit; +drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 295
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+ read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + +if (write_offset > read_offset) + size = write_offset - read_offset; +else + size = buf_size - read_offset + write_offset; +exit: +return size; +}Looks good now :)
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ +/** +* eu_stall_data_buf_poll - Poll for EU stall data in the buffer. +* +* @stream: xe EU stall data stream instance +* +* Returns: true if the EU stall buffer contains minimum stall data as +* specified by the event report count, else false. drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 313
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+*/ +static bool eu_stall_data_buf_poll (struct xe_eu_stall_data_stream *stream) +{ +u32 read_ptr, write_ptr_reg, write_ptr, total_data =0 ; +u32 buf_size = stream->per_xecore_buf_size; +struct per_xecore_buf *xecore_buf; +struct xe_gt *gt = stream->gt; +bool min_data_present = false; +u16 group, instance; +unsigned int xecore;u32 and move above to u32 line?
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 317
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ +for_each_dss_steering (xecore, gt, group, instance) { + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock);One thing I am wondering about is: do we really need these per
xecore_buflocks? How about movingptr_lockintoxe_eu_stall_data_streamand just coverfor_each_dss_steering()calls with the ptr lock. Because the polling thread runs every 10 ms, this should give plenty of time for the polling thread and the reads to go through, even with lcontention. And it will eliminate all these locks and the locking/unlocking overhead.Quoted 3 lines
I used a per dss lock so that polling and read on two different subslices can be done in parallel. I will try moving the
ptr_lockintoxe_eu_stall_data_stream.If you do this, please rename it to
dss_lockor something like that, to indicate it is guarding dss level info, not just the ptr's. Maybe rename the lock todss_lockeven if you end up not doing this.Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 324
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +7
-0+ read_ptr = xecore_buf->read; + write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , + group, instance); + write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); + write_ptr <<=6 ; + write_ptr &= ((buf_size <<1 ) -1 ); +if (write_ptr != read_ptr && !min_data_present) {Don't need to check for '
write_ptr!=read_ptr' here, it's already happening inbuf_data_size.Quoted 5 lines
Yes it is not needed. But
eu_stall_data_buf_poll()is invoked approx every 10ms. I am not an expert on compiler optimizations. If the compiler definitely optimizes and prevents call tobuf_data_size(), I can remove this check. But if the compiler doesn't optimize, wouldn't this check help avoid function calls given that this function gets executed every 10ms?The function is called every 10 ms *
num_dssand then it is called every dss for everyread(). Even then I am not sure why you are obsessed with the function call overhead. See here:https://github.com/torvalds/linux/blob/master/Documentation/process/4.Coding.rst#inline-functions
Specially "The cost of a function call, after all, is not that high" (it is typically memory accesses which reduce performance, not code execution). I would let the compiler handle this sort of optimization and decide whether or not the function can be inlined.
Another option is to use
always_inlineif you are really concerned:
https://gcc.gnu.org/onlinedocs/gcc/Inline.htmlstatic
__always_inlineu32 buf_data_size(...though I am not sure if just inline is already sufficient:
Quoted 7 lines
Quoted 4 lines
static inline u32 buf_data_size(...
So let's do one of these two things and remove this check, I'll approve either. Sorry if I asked to remove inline earlier :/
Okay, I will remove the if
write_ptr!=read_ptr. But I am not sure if want to add inline. My understanding is we only add inline for very small functions.You can add
__always_inline, there are only 2 instances of this, it is a small function.Quoted 95 lines
Quoted 95 lines
Quoted 57 lines
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 330
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ total_data +=buf_data_size (buf_size, read_ptr, write_ptr); +/* +* Check if there are at least minimum number of stall data +* rows for poll() to indicate that the data is present. +* Each stall data row is 64B (cacheline size). +*/ I'd say this comment is not needed and should be removed, the code below is clear enough.
Will remove.
Quoted 36 lines
Quoted 36 lines
drivers/gpu/drm/xe/xe_eu_stall.c +35
-0+if (num_data_rows (total_data) >= stream->wait_num_reports) + min_data_present = true; + } + xecore_buf->write = write_ptr; +mutex_unlock (&xecore_buf->ptr_lock); + } +return min_data_present; +} + +static int xe_eu_stall_data_buf_read (struct xe_eu_stall_data_stream *stream, +char __user *buf,size_t count, +size_t *total_data_size,struct xe_gt *gt, +u16 group,u16 instance,unsigned int xecore) +{ +size_t read_data_size, copy_size, buf_size, data_record_size; +u32 read_ptr_reg, read_ptr, write_ptr; +u8 *xecore_start_vaddr, *read_vaddr; +struct per_xecore_buf *xecore_buf; +u32 read_offset, write_offset; +int ret =0 ; + +/* Hardware increments the read and write pointers such that they can +* overflow into one additional bit. For example, a 256KB size buffer +* offset pointer needs 18 bits. But HW uses 19 bits for the read and +* write pointers. This technique avoids wasting a slot in the buffer. +* Read and write offsets are calculated from the pointers in order to +* check if the write pointer has wrapped around the array. +*/ + xecore_buf = &stream->xecore_buf[xecore]; +mutex_lock (&xecore_buf->ptr_lock); + xecore_start_vaddr = xecore_buf->vaddr; + read_ptr = xecore_buf->read; + write_ptr = xecore_buf->write; + buf_size = stream->per_xecore_buf_size; + data_record_size = stream->data_record_size;l> > +Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 372
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-0+ read_data_size =buf_data_size (buf_size, read_ptr, write_ptr); +/* Read only the data that the user space buffer can accommodate */ +if ((*total_data_size + read_data_size) > count) { + read_data_size = count - *total_data_size; + read_data_size = (read_data_size / data_record_size) * data_record_size; + }As I said, my preferred way of writing this is as follows. Isn't this cleaner?
Quoted 3 lines
Most of the times, the if condition would evaluate false and the body of the if statement would not be executed. Whereas in your code the two lines of code get executed all the time.
The only thing extra which maybe gets executed unconditionally in my code is the
ALIGN_DOWNline. themin_t()part gets executed for you too in the if () check. Correct?But once again you seem to be obsessed with these micro optimizations: it is not that simple:
1. We don't know how the compiler will optimize
2. The CPU itself does out-of-order and speculative execution, branch prediction etc. So for you the CPU might actually be executing the code in the if () statement (both when result of the if is true and when it is false and then discarding the branch which is not taken).
3. Execution speed is driven more by memory accesses and lock contention rather than code execution itself. So mostly code stalls at locks and for memory accesses to complete.So with all this going on, my rule is to only make easy to understand and maintain. And let the compiler and CPU take care of running the code efficiently. Of course we can't do ridiculous things, which we are not doing here.
Also, since you are obsessed with optimization,
ALIGN_DOWN()uses bit operations (AND etc.), rather than integer division, so is more efficient. Also, use of pre-established, standard macros, likemin_tandALIGN_DOWN, is preferable, rather than rolling your own new code.Quoted 5 lines
Quoted 3 lines
read_data_size = buf_data_size(buf_size, read_ptr, write_ptr); XE_WARN_ON(count >= *total_size);Wouldn't count (size of the user buffer) be greater than the
total_sizemost of the time? I am still not convinced with having aWARN_ONhere.Sorry, I meant an
xe_assert()here:Quoted 7 lines
Quoted 6 lines
xe_assert(xe, count >= *total_size);To make sure that (count -
*total_size>= 0) in themin_tstatement below. So if we useXE_WARN_ON(), this would become:XE_WARN_ON(count < *total_size);The code has sufficient checks to make sure this doesn't happen.
OK.
Quoted 7 lines
Quoted 5 lines
So either is ok. I think it is good to have it.
Quoted 2 lines
Quoted 2 lines
read_data_size = min_t(size_t, count - *total_size, read_data_size); read_data_size = ALIGN_DOWN(read_data_size, data_record_size);We don't need this
ALIGN_DOWN()here if we have theALIGN_DOWN()you suggested down below.Yes, you are right, good catch.
Quoted 150 lines
Quoted 79 lines
Quoted 7 lines
Quoted 3 lines
Since
data_record_sizehas to be a power of 2 for this to work (which it is), I would even put a
data_record_sizeis fixed in the hardware. As of now for both PVC and xe2, it is 64 which is a power of 2. I am guessing that it will remain a power of 2 in the future too. Why should we put an assert for the record size which is determined in the hardware?Because we are explicitly making use of the property that
data_record_sizeis a power of 2 in our code. TheALIGN_DOWNresults will be wrong if somehowdata_record_sizewere not a power of 2.And it also makes clear that the code is using this property and will break if it were to be false.
That is the purpose of the
assert(). If we weren't making use of that property in *our* code, we wouldn't need the assert.Quoted 33 lines
Quoted 26 lines
xe_assert(xe, is_power_of_2(record_size));in
xe_eu_stall_data_record_size().drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 381
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +9
-0+if (read_data_size ==0 ) + goto exit; + + read_offset = read_ptr & (buf_size -1 ); + write_offset = write_ptr & (buf_size -1 ); + read_vaddr = xecore_start_vaddr + read_offset; + +if (write_offset > read_offset) { +if (copy_to_user ((buf + *total_data_size), read_vaddr, read_data_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 386
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ ret = -EFAULT ; + goto exit; + } + }else { +if (read_data_size >= (buf_size - read_offset))internal brackets not needed ^
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 389
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+ copy_size = buf_size - read_offset; + else + copy_size = read_data_size;if (
write_offset<read_offset) how is this 'else' ever possible? So shouldn'tcopy_sizejust be set unconditionally to 'buf_size-read_offset'?Quoted 2 lines
If the user buffer doesn't have enough space to accommodate (
buf_size-read_offset) bytes, the else will get executed.Sorry, yes, you are right here.
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 390
Quoted 2 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+if (copy_to_user ((buf + *total_data_size), read_vaddr, copy_size)) {internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 394
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ ret = -EFAULT ; + goto exit; + } + if (copy_to_user((buf + *total_data_size + copy_size),internal brackets not needed ^
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 402
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+ xecore_start_vaddr, read_data_size - copy_size)) { + ret = -EFAULT ; + goto exit; + } + } + + *total_data_size += read_data_size; + read_ptr += read_data_size;Because there is an overflow bit we can just add without worrying about wraparound?
Quoted 71 lines
Quoted 2 lines
I want to make sure only one overflow bit is used and doesn't overflow into the second bit.
OK, I don't follow, but this was just something I was trying to confirm, so ignore this comment. The code is fine because of the overflow bits.
Quoted 65 lines
Quoted 65 lines
Quoted 50 lines
drivers/gpu/drm/xe/xe_eu_stall.c +45
-0+ +/* Read pointer can overflow into one additional bit */ + read_ptr &= (buf_size <<1 ) -1 ; + read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , (read_ptr >>6 )); + read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg); +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT1 , read_ptr_reg, group, instance); + xecore_buf->read = read_ptr; +trace_xe_eu_stall_data_read (group, instance, read_ptr, write_ptr, + read_offset, write_offset, *total_data_size); +exit: +mutex_unlock (&xecore_buf->ptr_lock); +return ret; +} + +/** +* xe_eu_stall_stream_read_locked - copy EU stall counters data from the +* per xecore buffers to the userspace buffer +* @stream: A stream opened for EU stall count metrics +* @file: An xe EU stall data stream file +* @buf: destination buffer given by userspace +* @count: the number of bytes userspace wants to read +* +* Returns: Number of bytes copied or a negative error code +* If we've successfully copied any data then reporting that takes +* precedence over any internal error status, so the data isn't lost. +*/ +static ssize_t xe_eu_stall_stream_read_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,char __user *buf, +size_t count) +{ +struct xe_gt *gt = stream->gt; +size_t total_size =0 ; +u16 group, instance; +unsigned int xecore; +int ret =0 ; + +for_each_dss_steering (xecore, gt, group, instance) { + ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, + gt, group, instance, xecore); +if (ret || count == total_size) +break ; + } +return total_size ?: (ret ?: -EAGAIN ); +} +/** * xe_eu_stall_stream_read - handles userspace read() of a EU stall data stream fd. * drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 469
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +6
-1@@ -272,7 +461,35 @@ static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension,static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos) { -ssize_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +ssize_t ret; + +if (count ==0 ) +return -EINVAL ;I believe we need to also handle the fact that count might not be a multiple of
record_size. The easiest way to handle this seems to be right here:ssize_t aligned_count = ALIGN_DOWN(count, stream->data_record_size);Quoted 2 lines
If we consider the
aligned_counthere, we don't need theALIGN_DOWN()you suggested above.Agreed, correct!
Quoted 55 lines
Quoted 55 lines
Quoted 9 lines
I think the code handles buffer sizes that are not multiples of record size. Copying few lines of code below. Wouldn't
read_data_sizebe only a multiple of record size ? and leave any remaining space empty that is not a multiple of record size ?
/* Read only the data that the user space buffer can accommodate */if ((*total_data_size + read_data_size) > count) { read_data_size = count - *total_data_size; read_data_size = (read_data_size / data_record_size) * data_record_size;No, I don't think it is handled. The issue is we have this check here:
xe_eu_stall_stream_read_locked(){ ... if (ret || count == total_size) break; }And if count is not a multiple of
record_size, the 'count ==total_size' will never be true, I think. Sincetotal_sizereturned byxe_eu_stall_data_buf_read()is always a multiple ofrecord_size.Quoted 12 lines
Quoted 12 lines
And used
aligned_countrather than count inxe_eu_stall_stream_read_lockedcalls. So that we don't have to worry about this in later function calls.So above will become:
if (aligned_count == 0) return -EINVAL;Unless there is a minimum user buffer size we want to support, in that case this becomes:
Quoted 8 lines
Quoted 5 lines
if (aligned_count < minimum_user_buffer_size) return -EINVAL;But to me looks like a good value for
minimum_user_buffer_sizeis not available.I guess the minimum user buffer size should be the data record size (64 for PVC and Xe2)? If smaller than the record size, the drive will be unable to copy any data.
That is this check:
if (aligned_count == 0) return -EINVAL;Apart from that, is there a
minimum_user_buffer_sizewhich is greater thanrecord_size? That is why I was saying it is not available.Quoted 3 lines
Quoted 3 lines
Anyway, better to handle this degenerate case here itself.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 474
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+ +if (!stream->enabled) { +xe_gt_dbg (gt,"EU stall data stream not enabled to read\n" ); +return -EINVAL ; + }I will remove this check. User space should be able to read any last remaining data even after EU stall is disabled.
I would advise against it. You will need to carefully consider the consequences of allowing reads in disabled state. When there is no data in disabled state (after the initial data has been read):
* Non-blocking reads will return
-EAGAIN, so that is ok
* Blocking reads will indefinitely block, unless userland unblocks these via a signal.Why can't userland read all data and then disable the stream? What kind of a requirement is that?
They run a workload to capture some stats. They should:
1. stop the workload
2. get all data for the workload:read()till non-blocking reads return-EAGAINor blocking reads block (unblock using signal). I am assuming if nothing is running on the EU's there is no data?
3. finally disable the stream.So if they do that, we don't allow reading any data in disabled state.
And anyway, this is what we can implement initially. If they don't agree we can later add a patch to change the behavior. But they need to convince us why they can't do what I just said above. Our default behavior should be to not allow reads in disabled state, I think.
Quoted 36 lines
Quoted 36 lines
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/xe/xe_eu_stall.c +14
-0+ +if (!(file->f_flags &O_NONBLOCK )) { +do { + ret =wait_event_interruptible (stream->poll_wq, stream->pollin); +if (ret) +return -EINTR ; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count); +mutex_unlock (>->eu_stall->stream_lock); + }while (ret == -EAGAIN ); + }else { +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_read_locked (stream, file, buf, count);Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_user_extensions(struct xe_device *xe, u64 extension, · line 492
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+mutex_unlock (>->eu_stall->stream_lock); + } + + stream->pollin = false;Carry over comment from previous rev: this breaks if user buffer is smaller than available data. But this is a corner case so let's fix this after the initial merge.
Quoted 3 lines
I will check your fix in OA to better understand the problem here. If the user buffer is smaller than data record size, it just returns without copying any data.
No, it is the issue when user buffer is larger than
record_size, but still smaller than the size of total data available. In that case, basically we should letstream->pollinset to true, so that the user thread does not get blocked, enabling it to rapidly consume data, even with a small buffer.Otherwise the thread is getting blocked every 10 ms, even when data is available. And because new data keeps arriving, the user thread constantly falls behind and soon HW will start dropping data (because the kernel is blocking the user thread, it's a kernel not a user thread issue)
Quoted 6 lines
Quoted 3 lines
To handle this OA does:
if (ret != -ENOSPC && ret != -EIO)EU stall
read()never returns-ENOSPC. Even if the user buffer is smaller then the size of total data in the buffer, only the data that can fit into the user buffer will be copied throughread().OA
read()also doesn't return-ENOSPCto userland. That is the expectedread()behavior (return number of bytes if you are returning any data). The full code is this:if (ret != -ENOSPC && ret != -EIO) stream->pollin = false; return offset ?: (ret ?: -EAGAIN);
Quoted 7 lines
Quoted 3 lines
As long as there are atleast
wait_num_reportsdata rows in the buffer,stream->pollinis set to true. It sounds to me that this issue is specific to OA code only. Is there something that I missed?No this issue is there in EU stall code. You should not block reads till the next time the polling thread runs, if we could not copy all data in the previous read (because there already is data, don't block the user thread).
The polling thread runs approximately once every 10ms. The question here is what would be time duration between two successive reads from the user space with no additional delay between them. If the duration is more than 10ms, the polling thread would set pollin to true. If not, the issue you have mentioned would occur. However, I am changing the code here to this:
if (!eu_stall_data_buf_poll(stream))
stream->pollin = false;Wouldn't this fix the issue?
Quoted 226 lines
Quoted 134 lines
Quoted 134 lines
stream->pollin = false;Anyway, we can do this after the initial merge.
Quoted 37 lines
Quoted 3 lines
Let's put it a list of to be done's in the cover letter to do after we merge in the next revision.
Okay.
Quoted 20 lines
drivers/gpu/drm/xe/xe_eu_stall.c static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) · line 501
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0return ret; }@@ -281,6 +498,7 @@ static void free_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream) {if (stream->bo)xe_bo_unpin_map_no_vm (stream->bo); +destroy_workqueue (stream->buf_poll_wq);Don't put this here in
free_eu_stall_data_buf, put this in the caller of this function, like the destroy/close function.Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0} static int alloc_eu_stall_data_buf(struct xe_eu_stall_data_stream *stream,@@ -351,6 +569,21 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return 0 ; }Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) · line 581
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+static void eu_stall_data_buf_poll_work_fn (struct work_struct *work) +{ +struct xe_eu_stall_data_stream *stream = +container_of (work,typeof (*stream), buf_poll_work.work); + +if (eu_stall_data_buf_poll (stream)) { + stream->pollin = true; +wake_up (&stream->poll_wq); + } +if (stream->enabled)See comment at
xe_eu_stall_disable_locked. If we docancel_delayed_work_syncthere, I think thisstream->enabledcheck mightQuoted 2 lines
I will explain later why I used
flush_delayed_work()instead ofcancel_delayed_work_sync()See below.
Quoted 87 lines
Quoted 87 lines
not be needed here. Also see comments at
cancel_work_syncinkernel/workqueue.c.Could you please check and see if it works out.
xe_guc_ct.c(andxe_gt_tlb_invalidation.c) seem to be doing that.Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+queue_delayed_work (stream->buf_poll_wq, + &stream->buf_poll_work, +msecs_to_jiffies (POLL_PERIOD_MS )); +} +static int xe_eu_stall_stream_init (struct xe_eu_stall_data_stream *stream,struct eu_stall_open_properties *props) {drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream, · line 601
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0@@ -361,6 +594,11 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,u32 vaddr_offset;int ret, xecore; +init_waitqueue_head (&stream->poll_wq); +INIT_DELAYED_WORK (&stream->buf_poll_work, eu_stall_data_buf_poll_work_fn); + stream->buf_poll_wq =alloc_ordered_workqueue ("xe_eu_stall" ,0 ); +if (!stream->buf_poll_wq) +return -ENOMEM ;Now we also need to
destroy_workqueueduring error unwinding (see comments regarding this in Patch 3).Quoted 39 lines
drivers/gpu/drm/xe/xe_eu_stall.c +20
-1stream->sampling_rate_mult = props->sampling_rate_mult; stream->wait_num_reports = props->wait_num_reports; stream->per_xecore_buf_size = per_xecore_buf_size;@@ -391,6 +629,19 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,return 0 ; } +static __poll_t xe_eu_stall_stream_poll_locked (struct xe_eu_stall_data_stream *stream, +struct file *file,poll_table *wait) +{ +__poll_t events =0 ; + +poll_wait (file, &stream->poll_wq, wait); + +if (stream->pollin) + events |=EPOLLIN ; + +return events; +} +/** * xe_eu_stall_stream_poll - handles userspace poll() of a EU stall data stream fd. * @@ -401,7 +652,13 @@ static int xe_eu_stall_stream_init(struct xe_eu_stall_data_stream *stream,*/ static __poll_t xe_eu_stall_stream_poll (struct file *file,poll_table *wait) { -__poll_t ret =0 ; +struct xe_eu_stall_data_stream *stream = file->private_data; +struct xe_gt *gt = stream->gt; +__poll_t ret; + +mutex_lock (>->eu_stall->stream_lock); + ret =xe_eu_stall_stream_poll_locked (stream, file, wait); +mutex_unlock (>->eu_stall->stream_lock);return ret; }drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) · line 676
Quoted 4 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0@@ -416,6 +673,9 @@ static int xe_eu_stall_enable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = true; ret =xe_eu_stall_stream_enable (stream); + queue_delayed_work(stream->buf_poll_wq,A blank line before this line would be nice.
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 693
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c +4
-0+ &stream->buf_poll_work, + msecs_to_jiffies(POLL_PERIOD_MS));return ret; }@@ -429,6 +689,9 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) stream->enabled = false;xe_gt_mcr_multicast_write (gt,XEHPC_EUSTALL_BASE ,0 ); +/* Check for any new EU stall data one last time */ +queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 );I am not sure if this is needed, especially if we use
cancel_delayed_work_sync.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
There was an ask from the user space to check for new data once after disabling EU stall sampling to make sure we capture all the data.
But they won't be able to read it because we set
stream->enabledto false? So what's the point?Good point. I will remove check for
stream->enabledin the read functionxe_eu_stall_stream_read().See above.
Quoted 82 lines
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream) · line 694
Quoted 3 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-0+flush_delayed_work (&stream->buf_poll_work);I think here we should use
cancel_delayed_work_sync()instead. See e.g.xe_guc_ct.c(and also maybexe_gt_tlb_invalidation.c).Quoted 7 lines
I though about it and found that the difference between
flushed_delayed_work()andcancel_delayed_work_sync()is thatcancel_delayed_work_sync()cancels any pending work items and wait for any work under execution to complete. Whereasflushed_delayed_work()schedules any work pending and wait for it to complete. Since I want to execute the work one last time after disable,flushed_delayed_work()is more appropriate here thancancel_delayed_work_sync().Quoted 3 lines
Above I am questioning what is the purpose of the last
queue_delayed_work. Also we could add thecancel_delayed_work_syncafter theflush_delayed_work, if that is needed.Okay, will add
cancel_delayed_work_sync()afterflush_delayed_work().Quoted 5 lines
As pointed out above, I think it is preferable to eliminate the 'if (
stream->enabled)' check ineu_stall_data_buf_poll_work_fn()and handle it viacancel_delayed_work_sync(). Which I think should work, but probably needs to be checked.Will check on this. I need to find a different way to check for any new data and update write pointers one last time after disabling EU stall.
Quoted 57 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));drivers/gpu/drm/xe/xe_trace.h +33
-0@@ -427,6 +427,39 @@ DEFINE_EVENT(xe_pm_runtime, xe_pm_runtime_get_ioctl,TP_ARGS (xe, caller) ); +TRACE_EVENT (xe_eu_stall_data_read, + TP_PROTO(u8 slice, u8 subslice, + u32 read_ptr, u32 write_ptr, + u32 read_offset, u32 write_offset, + size_t total_size), +TP_ARGS (slice, subslice, read_ptr, write_ptr, + read_offset, write_offset, total_size), + + TP_STRUCT__entry(__field(u8, slice) + __field(u8, subslice) + __field(u32, read_ptr) + __field(u32, write_ptr) + __field(u32, read_offset) + __field(u32, write_offset) +__field (size_t, total_size) + ), + + TP_fast_assign(__entry->slice = slice; + __entry->subslice = subslice; + __entry->read_ptr = read_ptr; + __entry->write_ptr = write_ptr; + __entry->read_offset = read_offset; + __entry->write_offset = write_offset; + __entry->total_size = total_size; + ), + +TP_printk ("slice:%u subslice:%u readptr:0x%x writeptr:0x%x read off:%u write off:%u size:%zu " , + __entry->slice, __entry->subslice, + __entry->read_ptr, __entry->write_ptr, + __entry->read_offset, __entry->write_offset, + __entry->total_size) +); +#endif Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/xe/xe_trace.h +0
-1/* This part must be outside protection */ --2.48.1
Thanks.
--
Ashutosh
Re: [PATCH v9 4/8] drm/xe/eustall: Add support to read() and poll() EU stall data
Quoted 56 lines · Harish Chegondi
Quoted 56 lines
Quoted 36 lines
Quoted 36 lines
Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
(quoted diff) +13
-0+ if (!(file->f_flags & O_NONBLOCK)) { + do { + ret = wait_event_interruptible(stream->poll_wq, stream->pollin); + if (ret) + return -EINTR; + + mutex_lock(>->eu_stall->stream_lock); + ret = xe_eu_stall_stream_read_locked(stream, file, buf, count); + mutex_unlock(>->eu_stall->stream_lock); + } while (ret == -EAGAIN); + } else { + mutex_lock(>->eu_stall->stream_lock); + ret = xe_eu_stall_stream_read_locked(stream, file, buf, count);Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ mutex_unlock(>->eu_stall->stream_lock); + } + + stream->pollin = false;Carry over comment from previous rev: this breaks if user buffer is smaller than available data. But this is a corner case so let's fix this after the initial merge.
Quoted 3 lines
I will check your fix in OA to better understand the problem here. If the user buffer is smaller than data record size, it just returns without copying any data.
No, it is the issue when user buffer is larger than
record_size, but still smaller than the size of total data available. In that case, basically we should letstream->pollinset to true, so that the user thread does not get blocked, enabling it to rapidly consume data, even with a small buffer.Otherwise the thread is getting blocked every 10 ms, even when data is available. And because new data keeps arriving, the user thread constantly falls behind and soon HW will start dropping data (because the kernel is blocking the user thread, it's a kernel not a user thread issue)
Quoted 6 lines
Quoted 3 lines
To handle this OA does:
if (ret != -ENOSPC && ret != -EIO)EU stall
read()never returns-ENOSPC. Even if the user buffer is smaller then the size of total data in the buffer, only the data that can fit into the user buffer will be copied throughread().OA
read()also doesn't return-ENOSPCto userland. That is the expectedread()behavior (return number of bytes if you are returning any data). The full code is this:if (ret != -ENOSPC && ret != -EIO) stream->pollin = false; return offset ?: (ret ?: -EAGAIN);Quoted 3 lines
As long as there are atleast
wait_num_reportsdata rows in the buffer,stream->pollinis set to true. It sounds to me that this issue is specific to OA code only. Is there something that I missed?
Quoted 8 lines
Quoted 3 lines
No this issue is there in EU stall code. You should not block reads till the next time the polling thread runs, if we could not copy all data in the previous read (because there already is data, don't block the user thread).
The polling thread runs approximately once every 10ms. The question here is what would be time duration between two successive reads from the user space with no additional delay between them. If the duration is more than 10ms, the polling thread would set pollin to true. If not, the issue you have mentioned would occur.
If we don't block the user thread in the kernel, ideally it would call into the kernel continuously to read data, let's say every few us. Say a memcpy in userspace and then back into the kernel to read more data.
Quoted 6 lines
However, I am changing the code here to this:
if (!eu_stall_data_buf_poll(stream)) stream->pollin = false;Wouldn't this fix the issue?
No, this is not correct. There are two requirements:
1. Don't wake up the user thread too frequently, that is why we have the 10 ms timer, so ordinarily, with a large buffer, the user thread only wakes up only every 10 ms.
2. Only when the user buffer is small, that is we have data which we could not copy in the user buffer, we shouldn't block the user thread.
In the above code, you are checking for data after completing the memcpy into the user buffer. This would solve 2., but might break 1. Because the code does not take into account that we should not block the user thread only if the user buffer is small.
Let's not introduce this into the existing patches, this small user buffer handling would need a new patch. As I said, let's do this after we merge what we currently have. I don't want to review this stuff now.
Thanks.
--
Ashutosh
PATCH v9 5/8 drm/xe/eustall: Add support to handle dropped EU stall data
In reply to Harish ChegondiIf the user space doesn't read the EU stall data fast enough, it is possible that the EU stall data buffer can get filled, and if the hardware wants to write more data, it simply drops data due to unavailable buffer space. In that case, hardware sets a bit in a register. If the driver detects data drop, the driver read() returns -EIO error to let the user space know that HW has dropped data. The -EIO error is returned even if there is EU stall data in the buffer. A subsequent read by the user space returns the remaining EU stall data.
v9: Move all data drop handling code to this patch
Clear all drop data bits before returning -EIO.
--- drivers/gpu/drm/xe/xe_eu_stall.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/gpu/drm/xe/xe_eu_stall.c +39 -0
@@ -53,6 +53,10 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct { +bool reported_to_user; +xe_dss_mask_t mask; + } data_drop;struct delayed_work buf_poll_work;struct workqueue_struct *buf_poll_wq; };
@@ -331,12 +335,24 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)if (num_data_rows (total_data) >= stream->wait_num_reports) min_data_present = true; } +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +set_bit (xecore, stream->data_drop.mask); xecore_buf->write = write_ptr;mutex_unlock (&xecore_buf->ptr_lock); }return min_data_present; } +static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) +{ +u32 write_ptr_reg; + +/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); + +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); +} + static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, char __user *buf, size_t count, size_t *total_data_size, struct xe_gt *gt,
@@ -436,6 +452,22 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stunsigned int xecore;int ret =0 ; +if (bitmap_weight (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS )) { +if (!stream->data_drop.reported_to_user) { +for_each_dss_steering (xecore, gt, group, instance) { +if (test_bit (xecore, stream->data_drop.mask)) { +clear_dropped_eviction_line_bit (gt, group, instance); +clear_bit (xecore, stream->data_drop.mask); + } + } + stream->data_drop.reported_to_user = true; +xe_gt_dbg (gt,"EU stall data dropped in XeCores: %*pb\n" , +XE_MAX_DSS_FUSE_BITS , stream->data_drop.mask); +return -EIO ; + } + stream->data_drop.reported_to_user = false; + } +for_each_dss_steering (xecore, gt, group, instance) { ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, gt, group, instance, xecore);
@@ -457,6 +489,7 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st* before calling read(). * * Returns: The number of bytes copied or a negative error code on failure. +* -EIO if HW drops any EU stall data when the buffer is full. */ static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)
@@ -543,6 +576,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); +/* Clear any drop bits set and not cleared in the previous session. */ +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +clear_dropped_eviction_line_bit (gt, group, instance); write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);
@@ -554,6 +590,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) xecore_buf->write = write_ptr; xecore_buf->read = write_ptr; } + stream->data_drop.reported_to_user = false; +bitmap_zero (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS ); + reg_value =_MASKED_FIELD (EUSTALL_MOCS |EUSTALL_SAMPLE_RATE ,REG_FIELD_PREP (EUSTALL_MOCS , gt->mocs.uc_index <<1 ) | REG_FIELD_PREP(EUSTALL_SAMPLE_RATE,
Signature · 1 line
2.48.1
Re: [PATCH v9 5/8] drm/xe/eustall: Add support to handle dropped EU stall data
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 11 lines
If the user space doesn't read the EU stall data fast enough, it is possible that the EU stall data buffer can get filled, and if the hardware wants to write more data, it simply drops data due to unavailable buffer space. In that case, hardware sets a bit in a register. If the driver detects data drop, the driver
read()returns-EIOerror to let the user space know that HW has dropped data. The-EIOerror is returned even if there is EU stall data in the buffer. A subsequent read by the user space returns the remaining EU stall data.v9: Move all data drop handling code to this patch
Good, separating out makes this easier to review. I would actually make this the last patch, but anyway it's ok as is too.
Quoted 49 lines
Clear all drop data bits before returning
-EIO.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)drivers/gpu/drm/xe/xe_eu_stall.c +16
-0@@ -53,6 +53,10 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct { +bool reported_to_user; +xe_dss_mask_t mask; + } data_drop;struct delayed_work buf_poll_work;struct workqueue_struct *buf_poll_wq; };@@ -331,12 +335,24 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)if (num_data_rows (total_data) >= stream->wait_num_reports) min_data_present = true; } +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +set_bit (xecore, stream->data_drop.mask); xecore_buf->write = write_ptr;mutex_unlock (&xecore_buf->ptr_lock); }return min_data_present; } +static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) +{ +u32 write_ptr_reg; + +/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); + +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); +} + static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, char __user *buf, size_t count, size_t *total_data_size, struct xe_gt *gt,@@ -436,6 +452,22 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stunsigned int xecore;
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st · line 462
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0int ret =0 ; +if (bitmap_weight (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS )) { +if (!stream->data_drop.reported_to_user) { +for_each_dss_steering (xecore, gt, group, instance) { +if (test_bit (xecore, stream->data_drop.mask)) { +clear_dropped_eviction_line_bit (gt, group, instance); +clear_bit (xecore, stream->data_drop.mask); + } + }
This is not making any sense. How can we clear_dropped_eviction_line_bit before reading the data? The HW will set it right back up.
At least the code in the previous version made some sense. So we should at least go back to that and review that. Though it also had issue with how many times -EIO is returned etc.
The other issue is the locking. As I suggested in my comments on Patch 4/8, I don't think we need a per xecore_buf lock, just one ptr_lock for reading all the DSS's. And then we can use that here too.
But at least let's get something sane for review first.
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c +15
-1+ stream->data_drop.reported_to_user = true; +xe_gt_dbg (gt,"EU stall data dropped in XeCores: %*pb\n" , +XE_MAX_DSS_FUSE_BITS , stream->data_drop.mask); +return -EIO ; + } + stream->data_drop.reported_to_user = false; + } +for_each_dss_steering (xecore, gt, group, instance) { ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, gt, group, instance, xecore);@@ -457,6 +489,7 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st* before calling read(). * * Returns: The number of bytes copied or a negative error code on failure. +* -EIO if HW drops any EU stall data when the buffer is full. */ static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)@@ -543,6 +576,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); +/* Clear any drop bits set and not cleared in the previous session. */ +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +clear_dropped_eviction_line_bit (gt, group, instance); write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);@@ -554,6 +590,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) xecore_buf->write = write_ptr; xecore_buf->read = write_ptr; } + stream->data_drop.reported_to_user = false; +bitmap_zero (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS ); + reg_value =_MASKED_FIELD (EUSTALL_MOCS |EUSTALL_SAMPLE_RATE ,REG_FIELD_PREP (EUSTALL_MOCS , gt->mocs.uc_index <<1 ) | REG_FIELD_PREP(EUSTALL_SAMPLE_RATE, --2.48.1
Re: [PATCH v9 5/8] drm/xe/eustall: Add support to handle dropped EU stall data
Quoted 3 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Ashutosh,
Quoted 68 lines
Hi Harish,
Quoted 11 lines
If the user space doesn't read the EU stall data fast enough, it is possible that the EU stall data buffer can get filled, and if the hardware wants to write more data, it simply drops data due to unavailable buffer space. In that case, hardware sets a bit in a register. If the driver detects data drop, the driver
read()returns-EIOerror to let the user space know that HW has dropped data. The-EIOerror is returned even if there is EU stall data in the buffer. A subsequent read by the user space returns the remaining EU stall data.v9: Move all data drop handling code to this patch
Good, separating out makes this easier to review. I would actually make this the last patch, but anyway it's ok as is too.
Quoted 51 lines
Clear all drop data bits before returning
-EIO.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)drivers/gpu/drm/xe/xe_eu_stall.c +16
-0@@ -53,6 +53,10 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct { +bool reported_to_user; +xe_dss_mask_t mask; + } data_drop;struct delayed_work buf_poll_work;struct workqueue_struct *buf_poll_wq; };@@ -331,12 +335,24 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)if (num_data_rows (total_data) >= stream->wait_num_reports) min_data_present = true; } +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +set_bit (xecore, stream->data_drop.mask); xecore_buf->write = write_ptr;mutex_unlock (&xecore_buf->ptr_lock); }return min_data_present; } +static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) +{ +u32 write_ptr_reg; + +/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); + +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); +} + static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, char __user *buf, size_t count, size_t *total_data_size, struct xe_gt *gt,@@ -436,6 +452,22 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stunsigned int xecore;int ret =0 ;
Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st · line 462
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+if (bitmap_weight (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS )) { +if (!stream->data_drop.reported_to_user) { +for_each_dss_steering (xecore, gt, group, instance) { +if (test_bit (xecore, stream->data_drop.mask)) { +clear_dropped_eviction_line_bit (gt, group, instance); +clear_bit (xecore, stream->data_drop.mask); + } + }This is not making any sense. How can we
clear_dropped_eviction_line_bitbefore reading the data? The HW will set it right back up.
This bit is being cleared here because the driver has acknowledged to the user space all the data that has been dropped so far. Any new data drop after we clear the bit *should* result in another -EIO return. HW will set the bit again *only* if it drops more data. User space is expected to do another read() to clear the buffer ASAP after getting an -EIO from the first read().
Quoted 4 lines
At least the code in the previous version made some sense. So we should at least go back to that and review that. Though it also had issue with how many times
-EIOis returned etc.
Can you please explain what is the issue? Every time there is a new data drop after the drop bit is cleared, it *should* result in another -EIO return The driver ensures that two successive reads will not return -EIO.
Quoted 4 lines
The other issue is the locking. As I suggested in my comments on Patch 4/8, I don't think we need a per
xecore_buflock, just oneptr_lockfor reading all the DSS's. And then we can use that here too.
I used a per xecore_buf lock so that the polling function can update for example subslice 1's write pointer while read() reads the data from subslice 2. It would lead to more parallelism. With a higher granularity lock, the polling for new data blocks during read and vice versa.
Quoted 2 lines
But at least let's get something sane for review first.
Before I spawn another version of the patch series, I would like to list the approaches to take here and cons for each approach. Feel free to add any other approaches you suggest here. Feedback from one of the EU stall consumers that they read data even after an -EIO return means that any approach to discard data in the buffer is unacceptable.
1. Approach used in version 8:
First read() returns -EIO without clearing any drop bits Second read() reads the data and clears the bit for each subslice
Cons: If the user space buffer is small and all subslice data is not read, those subslices whose drop bit is not cleared can cause -EIO in the next read(). This issue can be mitigated by user space buffer large enough to read data from all the subslices.
2. Approach used in version 9:
First read() returns -EIO after clearing all drop bits Second read() reads all the EU stall data that can fit into the user buffer.
Pros: Unlike in version 8 approach, even if the user buffer is small, all drop bits get cleared in the first read()
Cons: Because the buffers are full, if the user space doesn't call another read() soon to clear the data, there is a higher chance of HW dropping the data again, setting the bit again.
3. New approach: Hybrid of version 8 and 9:
First read() returns -EIO without clearing any drop bits Second read() reads all the EU stall data that can fit into the user buffer, but clears all the drop bits even for those subslices it can't read the data if the user buffer can't accommodate.
Cons: For those subslices whose data buffers are full and drop bits are cleared, there is a chance that the HW can set the bits again if data is dropped again unless user space calls another read() fast enough. This can also be mitigated with a user space buffer large enough to read data from all the subslices.
Please feel free to add any new approaches here that those don't discard data in the buffers, also add any more cons to the above approaches. Let's agree on an approach for the next patch version.
Thank you
Harish.
Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c +15
-1+ stream->data_drop.reported_to_user = true; +xe_gt_dbg (gt,"EU stall data dropped in XeCores: %*pb\n" , +XE_MAX_DSS_FUSE_BITS , stream->data_drop.mask); +return -EIO ; + } + stream->data_drop.reported_to_user = false; + } +for_each_dss_steering (xecore, gt, group, instance) { ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, gt, group, instance, xecore);@@ -457,6 +489,7 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st* before calling read(). * * Returns: The number of bytes copied or a negative error code on failure. +* -EIO if HW drops any EU stall data when the buffer is full. */ static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)@@ -543,6 +576,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); +/* Clear any drop bits set and not cleared in the previous session. */ +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +clear_dropped_eviction_line_bit (gt, group, instance); write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);@@ -554,6 +590,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) xecore_buf->write = write_ptr; xecore_buf->read = write_ptr; } + stream->data_drop.reported_to_user = false; +bitmap_zero (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS ); + reg_value =_MASKED_FIELD (EUSTALL_MOCS |EUSTALL_SAMPLE_RATE ,REG_FIELD_PREP (EUSTALL_MOCS , gt->mocs.uc_index <<1 ) | REG_FIELD_PREP(EUSTALL_SAMPLE_RATE, --2.48.1
Re: [PATCH v9 5/8] drm/xe/eustall: Add support to handle dropped EU stall data
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 146 lines · Ashutosh
Quoted 3 lines · Harish Chegondi
Quoted 1 line
Hi Ashutosh,
Quoted 68 lines
Hi Harish,
Quoted 11 lines
If the user space doesn't read the EU stall data fast enough, it is possible that the EU stall data buffer can get filled, and if the hardware wants to write more data, it simply drops data due to unavailable buffer space. In that case, hardware sets a bit in a register. If the driver detects data drop, the driver
read()returns-EIOerror to let the user space know that HW has dropped data. The-EIOerror is returned even if there is EU stall data in the buffer. A subsequent read by the user space returns the remaining EU stall data.v9: Move all data drop handling code to this patch
Good, separating out makes this easier to review. I would actually make this the last patch, but anyway it's ok as is too.
Quoted 51 lines
Clear all drop data bits before returning
-EIO.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)drivers/gpu/drm/xe/xe_eu_stall.c +16
-0@@ -53,6 +53,10 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct { +bool reported_to_user; +xe_dss_mask_t mask; + } data_drop;struct delayed_work buf_poll_work;struct workqueue_struct *buf_poll_wq; };@@ -331,12 +335,24 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)if (num_data_rows (total_data) >= stream->wait_num_reports) min_data_present = true; } +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +set_bit (xecore, stream->data_drop.mask); xecore_buf->write = write_ptr;mutex_unlock (&xecore_buf->ptr_lock); }return min_data_present; } +static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) +{ +u32 write_ptr_reg; + +/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); + +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); +} + static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, char __user *buf, size_t count, size_t *total_data_size, struct xe_gt *gt,@@ -436,6 +452,22 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stunsigned int xecore;int ret =0 ;Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st · line 462
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+if (bitmap_weight (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS )) { +if (!stream->data_drop.reported_to_user) { +for_each_dss_steering (xecore, gt, group, instance) { +if (test_bit (xecore, stream->data_drop.mask)) { +clear_dropped_eviction_line_bit (gt, group, instance); +clear_bit (xecore, stream->data_drop.mask); + } + }This is not making any sense. How can we
clear_dropped_eviction_line_bitbefore reading the data? The HW will set it right back up.This bit is being cleared here because the driver has acknowledged to the user space all the data that has been dropped so far. Any new data drop after we clear the bit *should* result in another
-EIOreturn. HW will set the bit again *only* if it drops more data. User space is expected to do anotherread()to clear the buffer ASAP after getting an-EIOfrom the firstread().Quoted 4 lines
At least the code in the previous version made some sense. So we should at least go back to that and review that. Though it also had issue with how many times
-EIOis returned etc.Can you please explain what is the issue? Every time there is a new data drop after the drop bit is cleared, it *should* result in another
-EIOreturn The driver ensures that two successive reads will not return-EIO.Quoted 4 lines
The other issue is the locking. As I suggested in my comments on Patch 4/8, I don't think we need a per
xecore_buflock, just oneptr_lockfor reading all the DSS's. And then we can use that here too.I used a per
xecore_buflock so that the polling function can update for example subslice 1's write pointer whileread()reads the data from subslice 2. It would lead to more parallelism. With a higher granularity lock, the polling for new data blocks during read and vice versa.Quoted 2 lines
But at least let's get something sane for review first.
Before I spawn another version of the patch series, I would like to list the approaches to take here and cons for each approach. Feel free to add any other approaches you suggest here. Feedback from one of the EU stall consumers that they read data even after an
-EIOreturn means that any approach to discard data in the buffer is unacceptable.1. Approach used in version 8:
Firstread()returns-EIOwithout clearing any drop bits Secondread()reads the data and clears the bit for each subslice
Cons: If the user space buffer is small and all subslice data is not read, those subslices whose drop bit is not cleared can cause-EIOin the nextread(). This issue can be mitigated by user space buffer large enough to read data from all the subslices.2. Approach used in version 9:
Firstread()returns-EIOafter clearing all drop bits Secondread()reads all the EU stall data that can fit into the user buffer.
Pros: Unlike in version 8 approach, even if the user buffer is small, all drop bits get cleared in the firstread()
Cons: Because the buffers are full, if the user space doesn't call anotherread()soon to clear the data, there is a higher chance of HW dropping the data again, setting the bit again.3. New approach: Hybrid of version 8 and 9:
Firstread()returns-EIOwithout clearing any drop bits Secondread()reads all the EU stall data that can fit into the user buffer, but clears all the drop bits even for those subslices it can't read the data if the user buffer can't accommodate.
Cons: For those subslices whose data buffers are full and drop bits are cleared, there is a chance that the HW can set the bits again if data is dropped again unless user space calls anotherread()fast enough. This can also be mitigated with a user space buffer large enough to read data from all the subslices.
Quoted 3 lines
Please feel free to add any new approaches here that those don't discard data in the buffers, also add any more cons to the above approaches. Let's agree on an approach for the next patch version.
Let's have some ground rules and not do random stuff. The basic ground rule for me is that there is no point doing clear_dropped_eviction_line_bit, till we have read the data (and moved the read pointer) to make some space in the per dss buffer. Otherwise, HW will just set that bit right up. HW is writing data and userspace reads cannot match the speed with which HW is writing data.
So the only approach I see viable is that in your v8. These other approaches you are making up are unworkable imo. I am ok if you don't want to drop data in the driver, I am not pushing that approach which I had suggested. But please post something which follows the ground rule mentioned above. The only thing I see which does that is v8.
Finally, yes, it comes down to that userspace will either have to use a large enough user buffer so that -EIO returns disappear. Or deal with -EIO returns, ignore them etc. Or read data fast enough using a small buffer, which is a bug in the current patches which we are saying we will fix after merging. If they use a small buffer and see multiple -EIO returns, that's fine, they just need to deal with it. The uapi is not promising anything about number of -EIO returns they will see. Maybe the -EIO returns will never clear up (I don't think they will till we fix the small buffer bug in the patches).
Thanks.
--
Ashutosh
Quoted 45 lines
Thank you
Harish.Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c +15
-1+ stream->data_drop.reported_to_user = true; +xe_gt_dbg (gt,"EU stall data dropped in XeCores: %*pb\n" , +XE_MAX_DSS_FUSE_BITS , stream->data_drop.mask); +return -EIO ; + } + stream->data_drop.reported_to_user = false; + } +for_each_dss_steering (xecore, gt, group, instance) { ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, gt, group, instance, xecore);@@ -457,6 +489,7 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st* before calling read(). * * Returns: The number of bytes copied or a negative error code on failure. +* -EIO if HW drops any EU stall data when the buffer is full. */ static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)@@ -543,6 +576,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); +/* Clear any drop bits set and not cleared in the previous session. */ +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +clear_dropped_eviction_line_bit (gt, group, instance); write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);@@ -554,6 +590,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) xecore_buf->write = write_ptr; xecore_buf->read = write_ptr; } + stream->data_drop.reported_to_user = false; +bitmap_zero (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS ); + reg_value =_MASKED_FIELD (EUSTALL_MOCS |EUSTALL_SAMPLE_RATE ,REG_FIELD_PREP (EUSTALL_MOCS , gt->mocs.uc_index <<1 ) | REG_FIELD_PREP(EUSTALL_SAMPLE_RATE, --2.48.1
Re: [PATCH v9 5/8] drm/xe/eustall: Add support to handle dropped EU stall data
Quoted 114 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 108 lines · Ashutosh
Quoted 3 lines · Harish Chegondi
Quoted 1 line
Hi Ashutosh,
Quoted 68 lines
Hi Harish,
Quoted 11 lines
If the user space doesn't read the EU stall data fast enough, it is possible that the EU stall data buffer can get filled, and if the hardware wants to write more data, it simply drops data due to unavailable buffer space. In that case, hardware sets a bit in a register. If the driver detects data drop, the driver
read()returns-EIOerror to let the user space know that HW has dropped data. The-EIOerror is returned even if there is EU stall data in the buffer. A subsequent read by the user space returns the remaining EU stall data.v9: Move all data drop handling code to this patch
Good, separating out makes this easier to review. I would actually make this the last patch, but anyway it's ok as is too.
Quoted 51 lines
Clear all drop data bits before returning
-EIO.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)drivers/gpu/drm/xe/xe_eu_stall.c +16
-0@@ -53,6 +53,10 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct { +bool reported_to_user; +xe_dss_mask_t mask; + } data_drop;struct delayed_work buf_poll_work;struct workqueue_struct *buf_poll_wq; };@@ -331,12 +335,24 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)if (num_data_rows (total_data) >= stream->wait_num_reports) min_data_present = true; } +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +set_bit (xecore, stream->data_drop.mask); xecore_buf->write = write_ptr;mutex_unlock (&xecore_buf->ptr_lock); }return min_data_present; } +static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) +{ +u32 write_ptr_reg; + +/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); + +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); +} + static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, char __user *buf, size_t count, size_t *total_data_size, struct xe_gt *gt,@@ -436,6 +452,22 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stunsigned int xecore;int ret =0 ;Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st · line 462
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+if (bitmap_weight (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS )) { +if (!stream->data_drop.reported_to_user) { +for_each_dss_steering (xecore, gt, group, instance) { +if (test_bit (xecore, stream->data_drop.mask)) { +clear_dropped_eviction_line_bit (gt, group, instance); +clear_bit (xecore, stream->data_drop.mask); + } + }This is not making any sense. How can we
clear_dropped_eviction_line_bitbefore reading the data? The HW will set it right back up.This bit is being cleared here because the driver has acknowledged to the user space all the data that has been dropped so far. Any new data drop after we clear the bit *should* result in another
-EIOreturn. HW will set the bit again *only* if it drops more data. User space is expected to do anotherread()to clear the buffer ASAP after getting an-EIOfrom the firstread().Quoted 4 lines
At least the code in the previous version made some sense. So we should at least go back to that and review that. Though it also had issue with how many times
-EIOis returned etc.Can you please explain what is the issue? Every time there is a new data drop after the drop bit is cleared, it *should* result in another
-EIOreturn The driver ensures that two successive reads will not return-EIO.Quoted 4 lines
The other issue is the locking. As I suggested in my comments on Patch 4/8, I don't think we need a per
xecore_buflock, just oneptr_lockfor reading all the DSS's. And then we can use that here too.I used a per
xecore_buflock so that the polling function can update for example subslice 1's write pointer whileread()reads the data from subslice 2. It would lead to more parallelism. With a higher granularity lock, the polling for new data blocks during read and vice versa.
Why do we need this extra parallelism? I am fine with reads and polling being serialized. Because if we don't do this, there are instances like checking the drop data mask where we either take all the dss locks or don't take any (which is what you are advocating). This situation is solved by having a single lock for all dss's (I am assuming we don't need that extra parallelism).
Quoted 55 lines
Quoted 38 lines
Quoted 2 lines
But at least let's get something sane for review first.
Before I spawn another version of the patch series, I would like to list the approaches to take here and cons for each approach. Feel free to add any other approaches you suggest here. Feedback from one of the EU stall consumers that they read data even after an
-EIOreturn means that any approach to discard data in the buffer is unacceptable.1. Approach used in version 8:
Firstread()returns-EIOwithout clearing any drop bits Secondread()reads the data and clears the bit for each subslice
Cons: If the user space buffer is small and all subslice data is not read, those subslices whose drop bit is not cleared can cause-EIOin the nextread(). This issue can be mitigated by user space buffer large enough to read data from all the subslices.2. Approach used in version 9:
Firstread()returns-EIOafter clearing all drop bits Secondread()reads all the EU stall data that can fit into the user buffer.
Pros: Unlike in version 8 approach, even if the user buffer is small, all drop bits get cleared in the firstread()
Cons: Because the buffers are full, if the user space doesn't call anotherread()soon to clear the data, there is a higher chance of HW dropping the data again, setting the bit again.3. New approach: Hybrid of version 8 and 9:
Firstread()returns-EIOwithout clearing any drop bits Secondread()reads all the EU stall data that can fit into the user buffer, but clears all the drop bits even for those subslices it can't read the data if the user buffer can't accommodate.
Cons: For those subslices whose data buffers are full and drop bits are cleared, there is a chance that the HW can set the bits again if data is dropped again unless user space calls anotherread()fast enough. This can also be mitigated with a user space buffer large enough to read data from all the subslices.Quoted 3 lines
Please feel free to add any new approaches here that those don't discard data in the buffers, also add any more cons to the above approaches. Let's agree on an approach for the next patch version.
Let's have some ground rules and not do random stuff. The basic ground rule for me is that there is no point doing
clear_dropped_eviction_line_bit, till we have read the data (and moved the read pointer) to make some space in the per dss buffer. Otherwise, HW will just set that bit right up. HW is writing data and userspace reads cannot match the speed with which HW is writing data.So the only approach I see viable is that in your v8. These other approaches you are making up are unworkable imo. I am ok if you don't want to drop data in the driver, I am not pushing that approach which I had suggested. But please post something which follows the ground rule mentioned above. The only thing I see which does that is v8.
Quoted 9 lines
Finally, yes, it comes down to that userspace will either have to use a large enough user buffer so that
-EIOreturns disappear. Or deal with-EIOreturns, ignore them etc. Or read data fast enough using a small buffer, which is a bug in the current patches which we are saying we will fix after merging. If they use a small buffer and see multiple-EIOreturns, that's fine, they just need to deal with it. The uapi is not promising anything about number of-EIOreturns they will see. Maybe the-EIOreturns will never clear up (I don't think they will till we fix the small buffer bug in the patches).
My approach would be to start with the stuff in v8 and then see if we can do something there to make sure userspace can read all data even with a small buffer, without seeing multiple -EIO returns till it has completed reading all dss's, with the assumption that the small buffer bug is not there (or has been fixed). Something like that. So at the minimum we start with the code in v8.
Quoted 50 lines
Thanks.
--
AshutoshQuoted 45 lines
Thank you
Harish.Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c +15
-1+ stream->data_drop.reported_to_user = true; +xe_gt_dbg (gt,"EU stall data dropped in XeCores: %*pb\n" , +XE_MAX_DSS_FUSE_BITS , stream->data_drop.mask); +return -EIO ; + } + stream->data_drop.reported_to_user = false; + } +for_each_dss_steering (xecore, gt, group, instance) { ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, gt, group, instance, xecore);@@ -457,6 +489,7 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st* before calling read(). * * Returns: The number of bytes copied or a negative error code on failure. +* -EIO if HW drops any EU stall data when the buffer is full. */ static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)@@ -543,6 +576,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); +/* Clear any drop bits set and not cleared in the previous session. */ +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +clear_dropped_eviction_line_bit (gt, group, instance); write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);@@ -554,6 +590,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) xecore_buf->write = write_ptr; xecore_buf->read = write_ptr; } + stream->data_drop.reported_to_user = false; +bitmap_zero (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS ); + reg_value =_MASKED_FIELD (EUSTALL_MOCS |EUSTALL_SAMPLE_RATE ,REG_FIELD_PREP (EUSTALL_MOCS , gt->mocs.uc_index <<1 ) | REG_FIELD_PREP(EUSTALL_SAMPLE_RATE, --2.48.1
Re: [PATCH v9 5/8] drm/xe/eustall: Add support to handle dropped EU stall data
Quoted 117 lines · Ashutosh
Quoted 114 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 108 lines · Ashutosh
Quoted 3 lines · Harish Chegondi
Quoted 1 line
Hi Ashutosh,
Quoted 68 lines
Hi Harish,
Quoted 11 lines
If the user space doesn't read the EU stall data fast enough, it is possible that the EU stall data buffer can get filled, and if the hardware wants to write more data, it simply drops data due to unavailable buffer space. In that case, hardware sets a bit in a register. If the driver detects data drop, the driver
read()returns-EIOerror to let the user space know that HW has dropped data. The-EIOerror is returned even if there is EU stall data in the buffer. A subsequent read by the user space returns the remaining EU stall data.v9: Move all data drop handling code to this patch
Good, separating out makes this easier to review. I would actually make this the last patch, but anyway it's ok as is too.
Quoted 51 lines
Clear all drop data bits before returning
-EIO.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)drivers/gpu/drm/xe/xe_eu_stall.c +16
-0@@ -53,6 +53,10 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct { +bool reported_to_user; +xe_dss_mask_t mask; + } data_drop;struct delayed_work buf_poll_work;struct workqueue_struct *buf_poll_wq; };@@ -331,12 +335,24 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)if (num_data_rows (total_data) >= stream->wait_num_reports) min_data_present = true; } +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +set_bit (xecore, stream->data_drop.mask); xecore_buf->write = write_ptr;mutex_unlock (&xecore_buf->ptr_lock); }return min_data_present; } +static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) +{ +u32 write_ptr_reg; + +/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); + +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); +} + static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, char __user *buf, size_t count, size_t *total_data_size, struct xe_gt *gt,@@ -436,6 +452,22 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stunsigned int xecore;int ret =0 ;Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st · line 462
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+if (bitmap_weight (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS )) { +if (!stream->data_drop.reported_to_user) { +for_each_dss_steering (xecore, gt, group, instance) { +if (test_bit (xecore, stream->data_drop.mask)) { +clear_dropped_eviction_line_bit (gt, group, instance); +clear_bit (xecore, stream->data_drop.mask); + } + }This is not making any sense. How can we
clear_dropped_eviction_line_bitbefore reading the data? The HW will set it right back up.This bit is being cleared here because the driver has acknowledged to the user space all the data that has been dropped so far. Any new data drop after we clear the bit *should* result in another
-EIOreturn. HW will set the bit again *only* if it drops more data. User space is expected to do anotherread()to clear the buffer ASAP after getting an-EIOfrom the firstread().Quoted 4 lines
At least the code in the previous version made some sense. So we should at least go back to that and review that. Though it also had issue with how many times
-EIOis returned etc.Can you please explain what is the issue? Every time there is a new data drop after the drop bit is cleared, it *should* result in another
-EIOreturn The driver ensures that two successive reads will not return-EIO.Quoted 4 lines
The other issue is the locking. As I suggested in my comments on Patch 4/8, I don't think we need a per
xecore_buflock, just oneptr_lockfor reading all the DSS's. And then we can use that here too.I used a per
xecore_buflock so that the polling function can update for example subslice 1's write pointer whileread()reads the data from subslice 2. It would lead to more parallelism. With a higher granularity lock, the polling for new data blocks during read and vice versa.
Quoted 6 lines
Why do we need this extra parallelism? I am fine with reads and polling being serialized. Because if we don't do this, there are instances like checking the drop data mask where we either take all the dss locks or don't take any (which is what you are advocating). This situation is solved by having a single lock for all dss's (I am assuming we don't need that extra parallelism).
About this: basically the polling thread is reading the write_ptr register (to update its cached copy). So if we have N dss's and it takes T us to read the register, we will block the read thread (which is doing memcpy's which take presumably longer) will be blocked for N * T us, if we use a single lock across dss's.
So my assumption is that even if we are blocked for N * T us, we still have sufficient time to complete the memcpy's. And then we are ok. That is the bandwidth of eu stall data is low enough to tolerate this extra N * T us of lost time.
Note, we have another parameter. We run the polling thread every 10 ms and incur this N * T us "loss" every 10 ms. If we increase this to say 20 ms, we incur the same "loss" every 20 ms. So basically the effect of serialization can be minimized by increasing how frequently the polling thread runs.
It is not difficult to profile this using timestamps in ftrace you've already introduced. It should tell us how much time it takes to complete the memcpy's and how much time is left over, if we use a single lock across dss's. If needed that is.
Of course on larger systems, with more dss's and which are also generating more data, we are getting blocked longer, so that's something we need to assess, if we are short of read bandwidth.
E.g. if T = 20 us, N = 20 dss, we will be blocked for 400 us every 10,000 us. Is that a lot? I don't know. I just made up those T and N numbers. But a single lock also introduces the efficiency of not having to lock/unlock constantly, so we gain some time there too. My guess is having a single lock should be ok. But if possible, it would be nice to back this up with some data, from ftrace.
Quoted 123 lines
Quoted 56 lines
Quoted 39 lines
Quoted 3 lines
But at least let's get something sane for review first.
Before I spawn another version of the patch series, I would like to list the approaches to take here and cons for each approach. Feel free to add any other approaches you suggest here. Feedback from one of the EU stall consumers that they read data even after an
-EIOreturn means that any approach to discard data in the buffer is unacceptable.1. Approach used in version 8:
Firstread()returns-EIOwithout clearing any drop bits Secondread()reads the data and clears the bit for each subslice
Cons: If the user space buffer is small and all subslice data is not read, those subslices whose drop bit is not cleared can cause-EIOin the nextread(). This issue can be mitigated by user space buffer large enough to read data from all the subslices.2. Approach used in version 9:
Firstread()returns-EIOafter clearing all drop bits Secondread()reads all the EU stall data that can fit into the user buffer.
Pros: Unlike in version 8 approach, even if the user buffer is small, all drop bits get cleared in the firstread()
Cons: Because the buffers are full, if the user space doesn't call anotherread()soon to clear the data, there is a higher chance of HW dropping the data again, setting the bit again.3. New approach: Hybrid of version 8 and 9:
Firstread()returns-EIOwithout clearing any drop bits Secondread()reads all the EU stall data that can fit into the user buffer, but clears all the drop bits even for those subslices it can't read the data if the user buffer can't accommodate.
Cons: For those subslices whose data buffers are full and drop bits are cleared, there is a chance that the HW can set the bits again if data is dropped again unless user space calls anotherread()fast enough. This can also be mitigated with a user space buffer large enough to read data from all the subslices.Quoted 3 lines
Please feel free to add any new approaches here that those don't discard data in the buffers, also add any more cons to the above approaches. Let's agree on an approach for the next patch version.
Let's have some ground rules and not do random stuff. The basic ground rule for me is that there is no point doing
clear_dropped_eviction_line_bit, till we have read the data (and moved the read pointer) to make some space in the per dss buffer. Otherwise, HW will just set that bit right up. HW is writing data and userspace reads cannot match the speed with which HW is writing data.So the only approach I see viable is that in your v8. These other approaches you are making up are unworkable imo. I am ok if you don't want to drop data in the driver, I am not pushing that approach which I had suggested. But please post something which follows the ground rule mentioned above. The only thing I see which does that is v8.
Quoted 9 lines
Finally, yes, it comes down to that userspace will either have to use a large enough user buffer so that
-EIOreturns disappear. Or deal with-EIOreturns, ignore them etc. Or read data fast enough using a small buffer, which is a bug in the current patches which we are saying we will fix after merging. If they use a small buffer and see multiple-EIOreturns, that's fine, they just need to deal with it. The uapi is not promising anything about number of-EIOreturns they will see. Maybe the-EIOreturns will never clear up (I don't think they will till we fix the small buffer bug in the patches).My approach would be to start with the stuff in v8 and then see if we can do something there to make sure userspace can read all data even with a small buffer, without seeing multiple
-EIOreturns till it has completed reading all dss's, with the assumption that the small buffer bug is not there (or has been fixed). Something like that. So at the minimum we start with the code in v8.Quoted 50 lines
Thanks.
--
AshutoshQuoted 45 lines
Thank you
Harish.Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c +15
-1+ stream->data_drop.reported_to_user = true; +xe_gt_dbg (gt,"EU stall data dropped in XeCores: %*pb\n" , +XE_MAX_DSS_FUSE_BITS , stream->data_drop.mask); +return -EIO ; + } + stream->data_drop.reported_to_user = false; + } +for_each_dss_steering (xecore, gt, group, instance) { ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, gt, group, instance, xecore);@@ -457,6 +489,7 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st* before calling read(). * * Returns: The number of bytes copied or a negative error code on failure. +* -EIO if HW drops any EU stall data when the buffer is full. */ static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)@@ -543,6 +576,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); +/* Clear any drop bits set and not cleared in the previous session. */ +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +clear_dropped_eviction_line_bit (gt, group, instance); write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);@@ -554,6 +590,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) xecore_buf->write = write_ptr; xecore_buf->read = write_ptr; } + stream->data_drop.reported_to_user = false; +bitmap_zero (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS ); + reg_value =_MASKED_FIELD (EUSTALL_MOCS |EUSTALL_SAMPLE_RATE ,REG_FIELD_PREP (EUSTALL_MOCS , gt->mocs.uc_index <<1 ) | REG_FIELD_PREP(EUSTALL_SAMPLE_RATE, --2.48.1
Re: [PATCH v9 5/8] drm/xe/eustall: Add support to handle dropped EU stall data
Quoted 152 lines · Ashutosh
Quoted 117 lines · Ashutosh
Quoted 114 lines · Ashutosh
Quoted 1 line · Harish Chegondi
Hi Harish,
Quoted 108 lines · Ashutosh
Quoted 3 lines · Harish Chegondi
Quoted 1 line
Hi Ashutosh,
Quoted 68 lines
Hi Harish,
Quoted 11 lines
If the user space doesn't read the EU stall data fast enough, it is possible that the EU stall data buffer can get filled, and if the hardware wants to write more data, it simply drops data due to unavailable buffer space. In that case, hardware sets a bit in a register. If the driver detects data drop, the driver
read()returns-EIOerror to let the user space know that HW has dropped data. The-EIOerror is returned even if there is EU stall data in the buffer. A subsequent read by the user space returns the remaining EU stall data.v9: Move all data drop handling code to this patch
Good, separating out makes this easier to review. I would actually make this the last patch, but anyway it's ok as is too.
Quoted 51 lines
Clear all drop data bits before returning
-EIO.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)drivers/gpu/drm/xe/xe_eu_stall.c +16
-0@@ -53,6 +53,10 @@ struct xe_eu_stall_data_stream {struct xe_gt *gt;struct xe_bo *bo;struct per_xecore_buf *xecore_buf; +struct { +bool reported_to_user; +xe_dss_mask_t mask; + } data_drop;struct delayed_work buf_poll_work;struct workqueue_struct *buf_poll_wq; };@@ -331,12 +335,24 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)if (num_data_rows (total_data) >= stream->wait_num_reports) min_data_present = true; } +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +set_bit (xecore, stream->data_drop.mask); xecore_buf->write = write_ptr;mutex_unlock (&xecore_buf->ptr_lock); }return min_data_present; } +static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) +{ +u32 write_ptr_reg; + +/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); + +xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); +} + static int xe_eu_stall_data_buf_read(struct xe_eu_stall_data_stream *stream, char __user *buf, size_t count, size_t *total_data_size, struct xe_gt *gt,@@ -436,6 +452,22 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *stunsigned int xecore;int ret =0 ;Quoted 11 lines
drivers/gpu/drm/xe/xe_eu_stall.c static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st · line 462
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-0+if (bitmap_weight (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS )) { +if (!stream->data_drop.reported_to_user) { +for_each_dss_steering (xecore, gt, group, instance) { +if (test_bit (xecore, stream->data_drop.mask)) { +clear_dropped_eviction_line_bit (gt, group, instance); +clear_bit (xecore, stream->data_drop.mask); + } + }This is not making any sense. How can we
clear_dropped_eviction_line_bitbefore reading the data? The HW will set it right back up.This bit is being cleared here because the driver has acknowledged to the user space all the data that has been dropped so far. Any new data drop after we clear the bit *should* result in another
-EIOreturn. HW will set the bit again *only* if it drops more data. User space is expected to do anotherread()to clear the buffer ASAP after getting an-EIOfrom the firstread().Quoted 4 lines
At least the code in the previous version made some sense. So we should at least go back to that and review that. Though it also had issue with how many times
-EIOis returned etc.Can you please explain what is the issue? Every time there is a new data drop after the drop bit is cleared, it *should* result in another
-EIOreturn The driver ensures that two successive reads will not return-EIO.Quoted 4 lines
The other issue is the locking. As I suggested in my comments on Patch 4/8, I don't think we need a per
xecore_buflock, just oneptr_lockfor reading all the DSS's. And then we can use that here too.I used a per
xecore_buflock so that the polling function can update for example subslice 1's write pointer whileread()reads the data from subslice 2. It would lead to more parallelism. With a higher granularity lock, the polling for new data blocks during read and vice versa.Quoted 6 lines
Why do we need this extra parallelism? I am fine with reads and polling being serialized. Because if we don't do this, there are instances like checking the drop data mask where we either take all the dss locks or don't take any (which is what you are advocating). This situation is solved by having a single lock for all dss's (I am assuming we don't need that extra parallelism).
About this: basically the polling thread is reading the
write_ptrregister (to update its cached copy). So if we have N dss's and it takes T us to read the register, we will block the read thread (which is doing memcpy's which take presumably longer) will be blocked for N * T us, if we use a single lock across dss's.So my assumption is that even if we are blocked for N * T us, we still have sufficient time to complete the memcpy's. And then we are ok. That is the bandwidth of eu stall data is low enough to tolerate this extra N * T us of lost time.
Note, we have another parameter. We run the polling thread every 10 ms and incur this N * T us "loss" every 10 ms. If we increase this to say 20 ms, we incur the same "loss" every 20 ms. So basically the effect of serialization can be minimized by increasing how frequently the polling thread runs.
It is not difficult to profile this using timestamps in ftrace you've already introduced. It should tell us how much time it takes to complete the memcpy's and how much time is left over, if we use a single lock across dss's. If needed that is.
Of course on larger systems, with more dss's and which are also generating more data, we are getting blocked longer, so that's something we need to assess, if we are short of read bandwidth.
Quoted 6 lines
E.g. if T = 20 us, N = 20 dss, we will be blocked for 400 us every 10,000 us. Is that a lot? I don't know. I just made up those T and N numbers. But a single lock also introduces the efficiency of not having to lock/unlock constantly, so we gain some time there too. My guess is having a single lock should be ok. But if possible, it would be nice to back this up with some data, from ftrace.
If you don't want to do this now, you can leave in the per dss locks, at least for the next version of this series. Then we can look at the dropped data handling and decide if accessing data_drop.mask without taking the locks is ok or not.
But some time we should assess if these per dss locks are actually needed or not. All we need to see is how much time is spent in doing the reads. Which will tell us how much time is left over and whether we can afford to lose that time if we serialize the polling and reading.
Quoted 124 lines
Quoted 124 lines
Quoted 57 lines
Quoted 40 lines
Quoted 4 lines
But at least let's get something sane for review first.
Before I spawn another version of the patch series, I would like to list the approaches to take here and cons for each approach. Feel free to add any other approaches you suggest here. Feedback from one of the EU stall consumers that they read data even after an
-EIOreturn means that any approach to discard data in the buffer is unacceptable.1. Approach used in version 8:
Firstread()returns-EIOwithout clearing any drop bits Secondread()reads the data and clears the bit for each subslice
Cons: If the user space buffer is small and all subslice data is not read, those subslices whose drop bit is not cleared can cause-EIOin the nextread(). This issue can be mitigated by user space buffer large enough to read data from all the subslices.2. Approach used in version 9:
Firstread()returns-EIOafter clearing all drop bits Secondread()reads all the EU stall data that can fit into the user buffer.
Pros: Unlike in version 8 approach, even if the user buffer is small, all drop bits get cleared in the firstread()
Cons: Because the buffers are full, if the user space doesn't call anotherread()soon to clear the data, there is a higher chance of HW dropping the data again, setting the bit again.3. New approach: Hybrid of version 8 and 9:
Firstread()returns-EIOwithout clearing any drop bits Secondread()reads all the EU stall data that can fit into the user buffer, but clears all the drop bits even for those subslices it can't read the data if the user buffer can't accommodate.
Cons: For those subslices whose data buffers are full and drop bits are cleared, there is a chance that the HW can set the bits again if data is dropped again unless user space calls anotherread()fast enough. This can also be mitigated with a user space buffer large enough to read data from all the subslices.Quoted 3 lines
Please feel free to add any new approaches here that those don't discard data in the buffers, also add any more cons to the above approaches. Let's agree on an approach for the next patch version.
Let's have some ground rules and not do random stuff. The basic ground rule for me is that there is no point doing
clear_dropped_eviction_line_bit, till we have read the data (and moved the read pointer) to make some space in the per dss buffer. Otherwise, HW will just set that bit right up. HW is writing data and userspace reads cannot match the speed with which HW is writing data.So the only approach I see viable is that in your v8. These other approaches you are making up are unworkable imo. I am ok if you don't want to drop data in the driver, I am not pushing that approach which I had suggested. But please post something which follows the ground rule mentioned above. The only thing I see which does that is v8.
Quoted 9 lines
Finally, yes, it comes down to that userspace will either have to use a large enough user buffer so that
-EIOreturns disappear. Or deal with-EIOreturns, ignore them etc. Or read data fast enough using a small buffer, which is a bug in the current patches which we are saying we will fix after merging. If they use a small buffer and see multiple-EIOreturns, that's fine, they just need to deal with it. The uapi is not promising anything about number of-EIOreturns they will see. Maybe the-EIOreturns will never clear up (I don't think they will till we fix the small buffer bug in the patches).My approach would be to start with the stuff in v8 and then see if we can do something there to make sure userspace can read all data even with a small buffer, without seeing multiple
-EIOreturns till it has completed reading all dss's, with the assumption that the small buffer bug is not there (or has been fixed). Something like that. So at the minimum we start with the code in v8.Quoted 50 lines
Thanks.
--
AshutoshQuoted 45 lines
Thank you
Harish.Quoted 42 lines
Quoted 42 lines
drivers/gpu/drm/xe/xe_eu_stall.c +15
-1+ stream->data_drop.reported_to_user = true; +xe_gt_dbg (gt,"EU stall data dropped in XeCores: %*pb\n" , +XE_MAX_DSS_FUSE_BITS , stream->data_drop.mask); +return -EIO ; + } + stream->data_drop.reported_to_user = false; + } +for_each_dss_steering (xecore, gt, group, instance) { ret =xe_eu_stall_data_buf_read (stream, buf, count, &total_size, gt, group, instance, xecore);@@ -457,6 +489,7 @@ static ssize_t xe_eu_stall_stream_read_locked(struct xe_eu_stall_data_stream *st* before calling read(). * * Returns: The number of bytes copied or a negative error code on failure. +* -EIO if HW drops any EU stall data when the buffer is full. */ static ssize_t xe_eu_stall_stream_read (struct file *file,char __user *buf,size_t count,loff_t *ppos)@@ -543,6 +576,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance); +/* Clear any drop bits set and not cleared in the previous session. */ +if (write_ptr_reg &XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ) +clear_dropped_eviction_line_bit (gt, group, instance); write_ptr =REG_FIELD_GET (XEHPC_EUSTALL_REPORT_WRITE_PTR_MASK , write_ptr_reg); read_ptr_reg =REG_FIELD_PREP (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , write_ptr); read_ptr_reg =_MASKED_FIELD (XEHPC_EUSTALL_REPORT1_READ_PTR_MASK , read_ptr_reg);@@ -554,6 +590,9 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream) xecore_buf->write = write_ptr; xecore_buf->read = write_ptr; } + stream->data_drop.reported_to_user = false; +bitmap_zero (stream->data_drop.mask,XE_MAX_DSS_FUSE_BITS ); + reg_value =_MASKED_FIELD (EUSTALL_MOCS |EUSTALL_SAMPLE_RATE ,REG_FIELD_PREP (EUSTALL_MOCS , gt->mocs.uc_index <<1 ) | REG_FIELD_PREP(EUSTALL_SAMPLE_RATE, --2.48.1
PATCH v9 6/8 drm/xe/eustall: Add EU stall sampling support for Xe2
In reply to Harish ChegondiAdd EU stall sampling support for Xe2 architecture GPUs - LNL and BMG. EU stall data format for LNL and BMG is different from that of PVC.
v9: Use GRAPHICS_VER() check instead of platform
v8: Renamed struct drm_xe_eu_stall_data_xe2 to struct xe_eu_stall_data_xe2
since it is a local structure.
--- drivers/gpu/drm/xe/xe_eu_stall.c | 51 ++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_eu_stall.c +48 -3
@@ -113,12 +113,51 @@ struct xe_eu_stall_data_pvc {__u64 unused[6 ]; } __packed; +/** +* struct xe_eu_stall_data_xe2 - EU stall data format for LNL, BMG +* Bits Field +* @ip_addr: 0 to 28 IP (addr) +* @tdr_count: 29 to 36 Tdr count +* @other_count: 37 to 44 other count +* @control_count: 45 to 52 control count +* @pipestall_count: 53 to 60 pipestall count +* @send_count: 61 to 68 send count +* @dist_acc_count: 69 to 76 dist_acc count +* @sbid_count: 77 to 84 sbid count +* @sync_count: 85 to 92 sync count +* @inst_fetch_count: 93 to 100 inst_fetch count +* @active_count: 101 to 108 Active count +* @ex_id: 109 to 111 Exid +* @end_flag: 112 EndFlag (is always 1) +* @unused_bits: 113 to 127 unused bits +* @unused: remaining unused bytes +*/ +struct xe_eu_stall_data_xe2 { +__u64 ip_addr:29 ; +__u64 tdr_count:8 ; +__u64 other_count:8 ; +__u64 control_count:8 ; +__u64 pipestall_count:8 ; +__u64 send_count:8 ; +__u64 dist_acc_count:8 ; +__u64 sbid_count:8 ; +__u64 sync_count:8 ; +__u64 inst_fetch_count:8 ; +__u64 active_count:8 ; +__u64 ex_id:3 ; +__u64 end_flag:1 ; +__u64 unused_bits:15 ; +__u64 unused[6 ]; +} __packed; +static size_t xe_eu_stall_data_record_size (struct xe_device *xe) {unsigned long record_size =0 ;if (xe->info.platform ==XE_PVC ) record_size =sizeof (struct xe_eu_stall_data_pvc ); +else if (GRAPHICS_VER (xe) >=20 ) + record_size =sizeof (struct xe_eu_stall_data_xe2 );return record_size; }
@@ -345,10 +384,16 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) { +struct xe_device *xe =gt_to_xe (gt);u32 write_ptr_reg; -/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ - write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); +/* On PVC, the overflow bit has to be cleared by writing 1 to it. +* On other GPUs, the bit has to be cleared by writing 0 to it. +*/ +if (GRAPHICS_VER (xe) >=20 ) + write_ptr_reg =_MASKED_BIT_DISABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); +else + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP );xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); }
@@ -821,7 +866,7 @@ static const struct file_operations fops_eu_stall = {static inline bool has_eu_stall_sampling_support (struct xe_device *xe) { -return ((xe->info.platform ==XE_PVC ) ? true : false); +return ((xe->info.platform ==XE_PVC ||GRAPHICS_VER (xe) >=20 ) ? true : false); }/**
Signature · 1 line
2.48.1
Re: [PATCH v9 6/8] drm/xe/eustall: Add EU stall sampling support for Xe2
Quoted 31 lines · Harish Chegondi
Add EU stall sampling support for Xe2 architecture GPUs - LNL and BMG. EU stall data format for LNL and BMG is different from that of PVC.
v9: Use
GRAPHICS_VER()check instead of platformv8: Renamed struct
drm_xe_eu_stall_data_xe2to structxe_eu_stall_data_xe2
since it is a local structure.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 51 ++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-)drivers/gpu/drm/xe/xe_eu_stall.c +9
-0@@ -113,12 +113,51 @@ struct xe_eu_stall_data_pvc {__u64 unused[6 ]; } __packed; +/** +* struct xe_eu_stall_data_xe2 - EU stall data format for LNL, BMG +* Bits Field +* @ip_addr: 0 to 28 IP (addr) +* @tdr_count: 29 to 36 Tdr count +* @other_count: 37 to 44 other count +* @control_count: 45 to 52 control count +* @pipestall_count: 53 to 60 pipestall count +* @send_count: 61 to 68 send count
drivers/gpu/drm/xe/xe_eu_stall.c struct xe_eu_stall_data_pvc { · line 134
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+* @dist_acc_count: 69 to 76 dist_acc count +* @sbid_count: 77 to 84 sbid count +* @sync_count: 85 to 92 sync count +* @inst_fetch_count: 93 to 100 inst_fetch count +* @active_count: 101 to 108 Active count +* @ex_id: 109 to 111 Exid +* @end_flag: 112 EndFlag (is always 1) +* @unused_bits: 113 to 127 unused bits +* @unused: remaining unused bytes +*/
Same comment about this header as for Patch 3/8.
Quoted 17 lines
drivers/gpu/drm/xe/xe_eu_stall.c +17
-0+struct xe_eu_stall_data_xe2 { +__u64 ip_addr:29 ; +__u64 tdr_count:8 ; +__u64 other_count:8 ; +__u64 control_count:8 ; +__u64 pipestall_count:8 ; +__u64 send_count:8 ; +__u64 dist_acc_count:8 ; +__u64 sbid_count:8 ; +__u64 sync_count:8 ; +__u64 inst_fetch_count:8 ; +__u64 active_count:8 ; +__u64 ex_id:3 ; +__u64 end_flag:1 ; +__u64 unused_bits:15 ; +__u64 unused[6 ]; +} __packed;
drivers/gpu/drm/xe/xe_eu_stall.c struct xe_eu_stall_data_pvc { · line 161
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-0+static size_t xe_eu_stall_data_record_size (struct xe_device *xe) {unsigned long record_size =0 ;if (xe->info.platform ==XE_PVC ) record_size =sizeof (struct xe_eu_stall_data_pvc ); +else if (GRAPHICS_VER (xe) >=20 ) + record_size =sizeof (struct xe_eu_stall_data_xe2 );
In Patch 4/8, I am suggesting adding the following here:
xe_assert(xe, is_power_of_2(record_size));
Even a BUILD_BUG_ON() might work, since we are dealing with sizeof.
drivers/gpu/drm/xe/xe_eu_stall.c static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream) · line 391
Quoted 13 lines
drivers/gpu/drm/xe/xe_eu_stall.c +3
-2return record_size; }@@ -345,10 +384,16 @@ static bool eu_stall_data_buf_poll(struct xe_eu_stall_data_stream *stream)static void clear_dropped_eviction_line_bit (struct xe_gt *gt,u16 group,u16 instance) { +struct xe_device *xe =gt_to_xe (gt);u32 write_ptr_reg; -/* On PVC, the overflow bit has to be cleared by writing 1 to it. */ - write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); +/* On PVC, the overflow bit has to be cleared by writing 1 to it. +* On other GPUs, the bit has to be cleared by writing 0 to it.
s/On other GPUs/On Xe2+/
Quoted 9 lines
drivers/gpu/drm/xe/xe_eu_stall.c +5
-0+*/ +if (GRAPHICS_VER (xe) >=20 ) + write_ptr_reg =_MASKED_BIT_DISABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP ); +else + write_ptr_reg =_MASKED_BIT_ENABLE (XEHPC_EUSTALL_REPORT_OVERFLOW_DROP );xe_gt_mcr_unicast_write (gt,XEHPC_EUSTALL_REPORT , write_ptr_reg, group, instance); }
drivers/gpu/drm/xe/xe_eu_stall.c static const struct file_operations fops_eu_stall = { · line 869
Quoted 5 lines
drivers/gpu/drm/xe/xe_eu_stall.c +1
-1@@ -821,7 +866,7 @@ static const struct file_operations fops_eu_stall = {static inline bool has_eu_stall_sampling_support (struct xe_device *xe) { -return ((xe->info.platform ==XE_PVC ) ? true : false); +return ((xe->info.platform ==XE_PVC ||GRAPHICS_VER (xe) >=20 ) ? true : false);
return xe->info.platform == XE_PVC || GRAPHICS_VER(xe) >= 20;
No brackets needed. I forgot but num_data_rows() also has unneeded brackets after 'return'.
Quoted 6 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-1}/** -- 2.48.1
PATCH v9 7/8 drm/xe/uapi: Add a device query to get EU stall sampling information
In reply to Harish ChegondiUser space can get the EU stall data record size, EU stall capabilities, EU stall sampling rates, and per XeCore buffer size with query IOCTL DRM_IOCTL_XE_DEVICE_QUERY with .query set to DRM_XE_DEVICE_QUERY_EU_STALL. A struct drm_xe_query_eu_stall will be returned to the user space along with an array of supported sampling rates sorted in the fastest sampling rate first order. sampling_rates in struct drm_xe_query_eu_stall will point to the array of sampling rates.
Any capabilities in EU stall sampling as of this patch are considered as base capabilities. New capability bits will be added for any new functionality added later.
v9: Move reserved fields above num_sampling_rates in
struct drm_xe_query_eu_stall.
v7: Change sampling_rates from a pointer to flexible array.
v6: Include EU stall sampling rates information and
per XeCore buffer size in the query information.
--- drivers/gpu/drm/xe/xe_eu_stall.c | 43 ++++++++++++++++++++++++++++++-- drivers/gpu/drm/xe/xe_eu_stall.h | 4 +++ drivers/gpu/drm/xe/xe_query.c | 38 ++++++++++++++++++++++++++++ include/uapi/drm/xe_drm.h | 40 +++++++++++++++++++++++++++-- 4 files changed, 121 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_eu_stall.c +41 -2
@@ -150,9 +150,48 @@ struct xe_eu_stall_data_xe2 {__u64 unused[6 ]; } __packed; -static size_t xe_eu_stall_data_record_size (struct xe_device *xe) +const u64 eu_stall_sampling_rates[] = {251 ,251 *2 ,251 *3 ,251 *4 ,251 *5 ,251 *6 ,251 *7 }; + +/** +* xe_eu_stall_get_sampling_rates - get EU stall sampling rates information. +* +* @num_rates_ptr: Pointer to a u32 to return the number of sampling rates. +* @rates_ptr: double u64 pointer to point to an array of sampling rates. +* +* Stores the number of sampling rates and pointer to the array of +* sampling rates in the input pointers. +* +* Returns: Size of the EU stall sampling rates array. +*/ +size_t xe_eu_stall_get_sampling_rates (u32 *num_rates_ptr,const u64 **rates_ptr) +{ + *num_rates_ptr =ARRAY_SIZE (eu_stall_sampling_rates); + *rates_ptr = eu_stall_sampling_rates; + +return sizeof (eu_stall_sampling_rates); +} + +/** +* xe_eu_stall_get_per_xecore_buf_size - get per XeCore buffer size. +* +* Returns: The per XeCore buffer size used to allocate the per GT +* EU stall data buffer. +*/ +size_t xe_eu_stall_get_per_xecore_buf_size (void ) +{ +return per_xecore_buf_size; +} + +/** +* xe_eu_stall_data_record_size - get EU stall data record size. +* +* @xe: Pointer to a Xe device. +* +* Returns: EU stall data record size. +*/ +size_t xe_eu_stall_data_record_size (struct xe_device *xe) { -unsigned long record_size =0 ; +size_t record_size =0 ;if (xe->info.platform ==XE_PVC ) record_size =sizeof (struct xe_eu_stall_data_pvc );
drivers/gpu/drm/xe/xe_eu_stall.h +4 -0
@@ -8,6 +8,10 @@#include "xe_gt_types.h" +size_t xe_eu_stall_get_per_xecore_buf_size (void ); +size_t xe_eu_stall_data_record_size (struct xe_device *xe); +size_t xe_eu_stall_get_sampling_rates (u32 *num_rates_ptr, +const u64 **rates_ptr);int xe_eu_stall_init (struct xe_gt *gt);void xe_eu_stall_fini (struct xe_gt *gt);
drivers/gpu/drm/xe/xe_query.c +38 -0
@@ -16,6 +16,7 @@#include "regs/xe_gt_regs.h" #include "xe_bo.h" #include "xe_device.h" +#include "xe_eu_stall.h" #include "xe_exec_queue.h" #include "xe_force_wake.h" #include "xe_ggtt.h"
@@ -726,6 +727,42 @@ static int query_pxp_status(struct xe_device *xe, struct drm_xe_device_query *qureturn 0 ; } +static int query_eu_stall (struct xe_device *xe, +struct drm_xe_device_query *query) +{ +void __user *query_ptr =u64_to_user_ptr (query->data); +struct drm_xe_query_eu_stall *info; +size_t size, array_size; +const u64 *rates_ptr; +u32 num_rates; +int ret; + + array_size =xe_eu_stall_get_sampling_rates (&num_rates, &rates_ptr); + size =sizeof (struct drm_xe_query_eu_stall ) + array_size; + +if (query->size ==0 ) { + query->size = size; +return 0 ; + }else if (XE_IOCTL_DBG (xe, query->size != size)) { +return -EINVAL ; + } + + info =kzalloc (size,GFP_KERNEL ); +if (!info) +return -ENOMEM ; + + info->num_sampling_rates = num_rates; + info->capabilities =DRM_XE_EU_STALL_CAPS_BASE ; + info->record_size =xe_eu_stall_data_record_size (xe); + info->per_xecore_buf_size =xe_eu_stall_get_per_xecore_buf_size (); +memcpy (info->sampling_rates, rates_ptr, array_size); + + ret =copy_to_user (query_ptr, info, size); +kfree (info); + +return ret ? -EFAULT :0 ; +} +static int (*const xe_query_funcs[])(struct xe_device *xe,struct drm_xe_device_query *query) = { query_engines,
@@ -738,6 +775,7 @@ static int (* const xe_query_funcs[])(struct xe_device *xe, query_uc_fw_version, query_oa_units, query_pxp_status, + query_eu_stall, };int xe_query_ioctl (struct drm_device *dev,void *data,struct drm_file *file)
include/uapi/drm/xe_drm.h +38 -2
@@ -735,6 +735,7 @@ struct drm_xe_device_query {#define DRM_XE_DEVICE_QUERY_UC_FW_VERSION 7#define DRM_XE_DEVICE_QUERY_OA_UNITS 8#define DRM_XE_DEVICE_QUERY_PXP_STATUS 9 +#define DRM_XE_DEVICE_QUERY_EU_STALL 10/** @query: The type of data to query */ __u32 query;
@@ -1873,8 +1874,8 @@ enum drm_xe_eu_stall_property_id {DRM_XE_EU_STALL_PROP_GT_ID =1 ,/** -* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate -* in GPU cycles. +* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate in +* GPU cycles from @sampling_rates in struct @drm_xe_query_eu_stall */ DRM_XE_EU_STALL_PROP_SAMPLE_RATE,
@@ -1886,6 +1887,41 @@ enum drm_xe_eu_stall_property_id { DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS, }; +/** +* struct drm_xe_query_eu_stall - Information about EU stall sampling. +* +* If a query is made with a struct @drm_xe_device_query where .query +* is equal to @DRM_XE_DEVICE_QUERY_EU_STALL, then the reply uses +* struct @drm_xe_query_eu_stall in .data. +*/ +struct drm_xe_query_eu_stall { +/** @extensions: Pointer to the first extension struct, if any */ +__u64 extensions; + +/** @capabilities: EU stall capabilities bit-mask */ +__u64 capabilities; +#define DRM_XE_EU_STALL_CAPS_BASE (1 << 0) + +/** @record_size: size of each EU stall data record */ +__u64 record_size; + +/** @per_xecore_buf_size: Per XeCore buffer size */ +__u64 per_xecore_buf_size; + +/** @reserved: Reserved */ +__u64 reserved[5 ]; + +/** @num_sampling_rates: Number of sampling rates supported */ +__u64 num_sampling_rates; + +/** +* @sampling_rates: Flexible array of sampling rates +* sorted in the fastest to slowest order. +* Sampling rates are specified in GPU clock cycles. +*/ +__u64 sampling_rates[]; +}; +#if defined(__cplusplus) }#endif
Signature · 1 line
2.48.1
Re: [PATCH v9 7/8] drm/xe/uapi: Add a device query to get EU stall sampling information
Quoted 40 lines · Harish Chegondi
User space can get the EU stall data record size, EU stall capabilities, EU stall sampling rates, and per XeCore buffer size with query IOCTL
DRM_IOCTL_XE_DEVICE_QUERYwith .query set toDRM_XE_DEVICE_QUERY_EU_STALL. A structdrm_xe_query_eu_stallwill be returned to the user space along with an array of supported sampling rates sorted in the fastest sampling rate first order.sampling_ratesin structdrm_xe_query_eu_stallwill point to the array of sampling rates.Any capabilities in EU stall sampling as of this patch are considered as base capabilities. New capability bits will be added for any new functionality added later.
v9: Move reserved fields above
num_sampling_ratesin
structdrm_xe_query_eu_stall.
v7: Changesampling_ratesfrom a pointer to flexible array.
v6: Include EU stall sampling rates information and
per XeCore buffer size in the query information.Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 43 ++++++++++++++++++++++++++++++-- drivers/gpu/drm/xe/xe_eu_stall.h | 4 +++ drivers/gpu/drm/xe/xe_query.c | 38 ++++++++++++++++++++++++++++ include/uapi/drm/xe_drm.h | 40 +++++++++++++++++++++++++++-- 4 files changed, 121 insertions(+), 4 deletions(-)drivers/gpu/drm/xe/xe_eu_stall.c +4
-1@@ -150,9 +150,48 @@ struct xe_eu_stall_data_xe2 {__u64 unused[6 ]; } __packed; -static size_t xe_eu_stall_data_record_size (struct xe_device *xe) +const u64 eu_stall_sampling_rates[] = {251 ,251 *2 ,251 *3 ,251 *4 ,251 *5 ,251 *6 ,251 *7 }; + +/** +* xe_eu_stall_get_sampling_rates - get EU stall sampling rates information.
drivers/gpu/drm/xe/xe_eu_stall.c struct xe_eu_stall_data_xe2 { · line 166
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +10
-0+* +* @num_rates_ptr: Pointer to a u32 to return the number of sampling rates. +* @rates_ptr: double u64 pointer to point to an array of sampling rates. +* +* Stores the number of sampling rates and pointer to the array of +* sampling rates in the input pointers. +* +* Returns: Size of the EU stall sampling rates array. +*/ +size_t xe_eu_stall_get_sampling_rates (u32 *num_rates_ptr,const u64 **rates_ptr)
Just name these function arguments num_rates and rates. No need for _ptr, it's obvious they are pointers.
Quoted 19 lines
drivers/gpu/drm/xe/xe_eu_stall.c +19
-0+{ + *num_rates_ptr =ARRAY_SIZE (eu_stall_sampling_rates); + *rates_ptr = eu_stall_sampling_rates; + +return sizeof (eu_stall_sampling_rates); +} + +/** +* xe_eu_stall_get_per_xecore_buf_size - get per XeCore buffer size. +* +* Returns: The per XeCore buffer size used to allocate the per GT +* EU stall data buffer. +*/ +size_t xe_eu_stall_get_per_xecore_buf_size (void ) +{ +return per_xecore_buf_size; +} + +/**
drivers/gpu/drm/xe/xe_eu_stall.c struct xe_eu_stall_data_xe2 { · line 194
Quoted 10 lines
drivers/gpu/drm/xe/xe_eu_stall.c +8
-1+* xe_eu_stall_data_record_size - get EU stall data record size. +* +* @xe: Pointer to a Xe device. +* +* Returns: EU stall data record size. +*/ +size_t xe_eu_stall_data_record_size (struct xe_device *xe) { -unsigned long record_size =0 ; +size_t record_size =0 ;
This line should not be there in this patch. It should be fixed in the previous patch where it was introduced.
Quoted 8 lines
drivers/gpu/drm/xe/xe_eu_stall.c +0
-0if (xe->info.platform ==XE_PVC ) record_size =sizeof (struct xe_eu_stall_data_pvc );drivers/gpu/drm/xe/xe_eu_stall.h +0
-0
drivers/gpu/drm/xe/xe_eu_stall.h line 14
Quoted 7 lines
drivers/gpu/drm/xe/xe_eu_stall.h +4
-0@@ -8,6 +8,10 @@#include "xe_gt_types.h" +size_t xe_eu_stall_get_per_xecore_buf_size (void ); +size_t xe_eu_stall_data_record_size (struct xe_device *xe); +size_t xe_eu_stall_get_sampling_rates (u32 *num_rates_ptr, +const u64 **rates_ptr);
num_rates/rates
Quoted 16 lines
drivers/gpu/drm/xe/xe_eu_stall.h +0
-0int xe_eu_stall_init (struct xe_gt *gt);void xe_eu_stall_fini (struct xe_gt *gt);drivers/gpu/drm/xe/xe_query.c +1
-0@@ -16,6 +16,7 @@#include "regs/xe_gt_regs.h" #include "xe_bo.h" #include "xe_device.h" +#include "xe_eu_stall.h" #include "xe_exec_queue.h" #include "xe_force_wake.h" #include "xe_ggtt.h"
drivers/gpu/drm/xe/xe_query.c static int query_pxp_status(struct xe_device *xe, struct drm_xe_device_query *qu · line 736
Quoted 10 lines
drivers/gpu/drm/xe/xe_query.c +7
-0@@ -726,6 +727,42 @@ static int query_pxp_status(struct xe_device *xe, struct drm_xe_device_query *qureturn 0 ; } +static int query_eu_stall (struct xe_device *xe, +struct drm_xe_device_query *query) +{ +void __user *query_ptr =u64_to_user_ptr (query->data); +struct drm_xe_query_eu_stall *info; +size_t size, array_size; +const u64 *rates_ptr;
rates, no ptr.
Quoted 76 lines
drivers/gpu/drm/xe/xe_query.c +30
-0+u32 num_rates; +int ret; + + array_size =xe_eu_stall_get_sampling_rates (&num_rates, &rates_ptr); + size =sizeof (struct drm_xe_query_eu_stall ) + array_size; + +if (query->size ==0 ) { + query->size = size; +return 0 ; + }else if (XE_IOCTL_DBG (xe, query->size != size)) { +return -EINVAL ; + } + + info =kzalloc (size,GFP_KERNEL ); +if (!info) +return -ENOMEM ; + + info->num_sampling_rates = num_rates; + info->capabilities =DRM_XE_EU_STALL_CAPS_BASE ; + info->record_size =xe_eu_stall_data_record_size (xe); + info->per_xecore_buf_size =xe_eu_stall_get_per_xecore_buf_size (); +memcpy (info->sampling_rates, rates_ptr, array_size); + + ret =copy_to_user (query_ptr, info, size); +kfree (info); + +return ret ? -EFAULT :0 ; +} +static int (*const xe_query_funcs[])(struct xe_device *xe,struct drm_xe_device_query *query) = { query_engines,@@ -738,6 +775,7 @@ static int (* const xe_query_funcs[])(struct xe_device *xe, query_uc_fw_version, query_oa_units, query_pxp_status, + query_eu_stall, };int xe_query_ioctl (struct drm_device *dev,void *data,struct drm_file *file)include/uapi/drm/xe_drm.h +12
-2@@ -735,6 +735,7 @@ struct drm_xe_device_query {#define DRM_XE_DEVICE_QUERY_UC_FW_VERSION 7#define DRM_XE_DEVICE_QUERY_OA_UNITS 8#define DRM_XE_DEVICE_QUERY_PXP_STATUS 9 +#define DRM_XE_DEVICE_QUERY_EU_STALL 10/** @query: The type of data to query */ __u32 query;@@ -1873,8 +1874,8 @@ enum drm_xe_eu_stall_property_id {DRM_XE_EU_STALL_PROP_GT_ID =1 ,/** -* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate -* in GPU cycles. +* @DRM_XE_EU_STALL_PROP_SAMPLE_RATE: Sampling rate in +* GPU cycles from @sampling_rates in struct @drm_xe_query_eu_stall */ DRM_XE_EU_STALL_PROP_SAMPLE_RATE,@@ -1886,6 +1887,41 @@ enum drm_xe_eu_stall_property_id { DRM_XE_EU_STALL_PROP_WAIT_NUM_REPORTS, }; +/** +* struct drm_xe_query_eu_stall - Information about EU stall sampling. +* +* If a query is made with a struct @drm_xe_device_query where .query +* is equal to @DRM_XE_DEVICE_QUERY_EU_STALL, then the reply uses +* struct @drm_xe_query_eu_stall in .data. +*/ +struct drm_xe_query_eu_stall { +/** @extensions: Pointer to the first extension struct, if any */
include/uapi/drm/xe_drm.h enum drm_xe_eu_stall_property_id { · line 1908
Quoted 10 lines
include/uapi/drm/xe_drm.h +10
-0+__u64 extensions; + +/** @capabilities: EU stall capabilities bit-mask */ +__u64 capabilities; +#define DRM_XE_EU_STALL_CAPS_BASE (1 << 0) + +/** @record_size: size of each EU stall data record */ +__u64 record_size; + +/** @per_xecore_buf_size: Per XeCore buffer size */
/** @per_xecore_buf_size: internal per xecore buffer size */
include/uapi/drm/xe_drm.h enum drm_xe_eu_stall_property_id { · line 1909
Quoted 1 line
include/uapi/drm/xe_drm.h +1
-0+__u64 per_xecore_buf_size;
Sorry to bring this up again. I previously missed that the term 'dss' is already present in xe_drm.h. So not sure we can't just call this per_dss_buf_size? Or do we want to introduce a new 'xecore' term here.
Could we quickly check with Matt Roper about this. xecore is ok too, but now we are introducing two different names for the same thing.
include/uapi/drm/xe_drm.h enum drm_xe_eu_stall_property_id { · line 1914
Quoted 5 lines
include/uapi/drm/xe_drm.h +5
-0+ +/** @reserved: Reserved */ +__u64 reserved[5 ]; + +/** @num_sampling_rates: Number of sampling rates supported */
/** @num_sampling_rates: number of entries in @sampling_rates array */
Quoted 14 lines
include/uapi/drm/xe_drm.h +10
-1+__u64 num_sampling_rates; + +/** +* @sampling_rates: Flexible array of sampling rates +* sorted in the fastest to slowest order. +* Sampling rates are specified in GPU clock cycles. +*/ +__u64 sampling_rates[]; +}; +#if defined(__cplusplus) }#endif --
Quoted 2 lines
2.48.1
Also, incidentally, this eu stall query will need to be added to IGT too, some time.
I will take another look in the next revision of this patch too, but since the comments here are nits, after addressing/fixing those, this is:
PATCH v9 8/8 drm/xe/eustall: Add workaround 22016596838 which applies to PVC.
In reply to Harish ChegondiAdd PVC workaround 22016596838 that disables EU DOP gating during EU stall sampling.
--- drivers/gpu/drm/xe/xe_eu_stall.c | 10 ++++++++++ drivers/gpu/drm/xe/xe_wa_oob.rules | 1 + 2 files changed, 11 insertions(+)
drivers/gpu/drm/xe/xe_eu_stall.c +10 -0
@@ -9,6 +9,7 @@#include <linux/types.h> #include <drm/drm_drv.h> +#include <generated/xe_wa_oob.h> #include <uapi/drm/xe_drm.h> #include "xe_bo.h"
@@ -22,6 +23,7 @@#include "xe_observation.h" #include "xe_pm.h" #include "xe_trace.h" +#include "xe_wa.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h"
@@ -658,6 +660,10 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return -ETIMEDOUT ; } +if (XE_WA (gt,22016596838 )) +xe_gt_mcr_multicast_write (gt,ROW_CHICKEN2 , +_MASKED_BIT_ENABLE (DISABLE_DOP_GATING )); +for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance);/* Clear any drop bits set and not cleared in the previous session. */
@@ -816,6 +822,10 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream)queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 );flush_delayed_work (&stream->buf_poll_work); +if (XE_WA (gt,22016596838 )) +xe_gt_mcr_multicast_write (gt,ROW_CHICKEN2 , +_MASKED_BIT_DISABLE (DISABLE_DOP_GATING )); +xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));
drivers/gpu/drm/xe/xe_wa_oob.rules +1 -0
@@ -5,6 +5,7 @@ 22011391025 PLATFORM(DG2) 22012727170 SUBPLATFORM(DG2, G11) 22012727685 SUBPLATFORM(DG2, G11) +22016596838 PLATFORM(PVC) 18020744125 PLATFORM(PVC) 1509372804 PLATFORM(PVC), GRAPHICS_STEP(A0, C0) 1409600907 GRAPHICS_VERSION_RANGE(1200, 1250)
Signature · 1 line
2.48.1
Re: [PATCH v9 8/8] drm/xe/eustall: Add workaround 22016596838 which applies to PVC.
Quoted 57 lines · Harish Chegondi
Add PVC workaround 22016596838 that disables EU DOP gating during EU stall sampling.
Signed-off-by Harish Chegondi <[email protected]>--- drivers/gpu/drm/xe/xe_eu_stall.c | 10 ++++++++++ drivers/gpu/drm/xe/xe_wa_oob.rules | 1 + 2 files changed, 11 insertions(+)drivers/gpu/drm/xe/xe_eu_stall.c +10
-0@@ -9,6 +9,7 @@#include <linux/types.h> #include <drm/drm_drv.h> +#include <generated/xe_wa_oob.h> #include <uapi/drm/xe_drm.h> #include "xe_bo.h" @@ -22,6 +23,7 @@#include "xe_observation.h" #include "xe_pm.h" #include "xe_trace.h" +#include "xe_wa.h" #include "regs/xe_eu_stall_regs.h" #include "regs/xe_gt_regs.h" @@ -658,6 +660,10 @@ static int xe_eu_stall_stream_enable(struct xe_eu_stall_data_stream *stream)return -ETIMEDOUT ; } +if (XE_WA (gt,22016596838 )) +xe_gt_mcr_multicast_write (gt,ROW_CHICKEN2 , +_MASKED_BIT_ENABLE (DISABLE_DOP_GATING )); +for_each_dss_steering (xecore, gt, group, instance) { write_ptr_reg =xe_gt_mcr_unicast_read (gt,XEHPC_EUSTALL_REPORT , group, instance);/* Clear any drop bits set and not cleared in the previous session. */ @@ -816,6 +822,10 @@ static int xe_eu_stall_disable_locked(struct xe_eu_stall_data_stream *stream)queue_delayed_work (stream->buf_poll_wq, &stream->buf_poll_work,0 );flush_delayed_work (&stream->buf_poll_work); +if (XE_WA (gt,22016596838 )) +xe_gt_mcr_multicast_write (gt,ROW_CHICKEN2 , +_MASKED_BIT_DISABLE (DISABLE_DOP_GATING )); +xe_force_wake_put (gt_to_fw (gt),XE_FW_RENDER );xe_pm_runtime_put (gt_to_xe (gt));drivers/gpu/drm/xe/xe_wa_oob.rules +0
-0
drivers/gpu/drm/xe/xe_wa_oob.rules line 11
Quoted 7 lines
drivers/gpu/drm/xe/xe_wa_oob.rules +1
-0@@ -5,6 +5,7 @@ 22011391025 PLATFORM(DG2) 22012727170 SUBPLATFORM(DG2, G11) 22012727685 SUBPLATFORM(DG2, G11) +22016596838 PLATFORM(PVC) 18020744125 PLATFORM(PVC) 1509372804 PLATFORM(PVC), GRAPHICS_STEP(A0, C0) 1409600907 GRAPHICS_VERSION_RANGE(1200, 1250)
I am assuming:
* 22016596838 is the correct lineage bug number for this
* It is ok to do the enable/disable DOP gating in EU stall enable/disable, rather than in say stream_init/stream_close.
With this, this lgtm:
Patchwork
CI✓ CI.Patch_applied: success for Add support for EU stall sampling
In reply to Harish Chegondi== Series Details ==
== Series Details ==
Series: Add support for EU stall sampling
URL : https://patchwork.freedesktop.org/series/144609/
State : success
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 656e731586e5 drm-tip: 2025y-02m-10d-13h-06m-50s UTC integration manifest === git am output follows ===
Applying: drm/xe/topology: Add a function to find the index of the last enabled DSS in a mask
Applying: drm/xe/uapi: Introduce API for EU stall sampling
Applying: drm/xe/eustall: Add support to init, enable and disable EU stall sampling
Applying: drm/xe/eustall: Add support to read() and poll() EU stall data
Applying: drm/xe/eustall: Add support to handle dropped EU stall data
Applying: drm/xe/eustall: Add EU stall sampling support for Xe2
Applying: drm/xe/uapi: Add a device query to get EU stall sampling information
Applying: drm/xe/eustall: Add workaround 22016596838 which applies to PVC.
Patchwork
CI✗ CI.checkpatch: warning for Add support for EU stall sampling
In reply to Harish Chegondi== Series Details ==
== Series Details ==
Series: Add support for EU stall sampling
URL : https://patchwork.freedesktop.org/series/144609/
State : warning
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master 22f9cda3436b4fe965b5c5f31d2f2c1bcb483189
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 2a84c579ede3aef33ef3ad47689de2e58919408d
Author: Harish Chegondi <[email protected]> Date: Mon Feb 10 05:46:49 2025 -0800
drm/xe/eustall: Add workaround 22016596838 which applies to PVC.
Add PVC workaround 22016596838 that disables EU DOP gating during EU stall sampling.
+ /mt/dim checkpatch 656e731586e568a8633c0bd16d28dcec8d67f237 drm-intel 6a3956ad2764 drm/xe/topology: Add a function to find the index of the last enabled DSS in a mask 3bfb725caddb drm/xe/uapi: Introduce API for EU stall sampling
-:56: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #56:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 385 lines checkedc0bcdec48ead drm/xe/eustall: Add support to init, enable and disable EU stall sampling -:28: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #28:
new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 531 lines checked bf03308b6e3d drm/xe/eustall: Add support to read() and poll() EU stall data f87b3ab276cc drm/xe/eustall: Add support to handle dropped EU stall data bc376b13eca7 drm/xe/eustall: Add EU stall sampling support for Xe2 ce82acf1eb8d drm/xe/uapi: Add a device query to get EU stall sampling information 2a84c579ede3 drm/xe/eustall: Add workaround 22016596838 which applies to PVC.
Patchwork
CI✓ CI.KUnit: success for Add support for EU stall sampling
In reply to Harish Chegondi== Series Details ==
== Series Details ==
Series: Add support for EU stall sampling
URL : https://patchwork.freedesktop.org/series/144609/
State : success
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig [14:33:13] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[14:33:17] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json ARCH=um O=.kunit --jobs=48
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
156 | u64 ioread64_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
163 | u64 ioread64_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
170 | u64 ioread64be_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
178 | u64 ioread64be_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~[14:33:43] Starting KUnit Kernel (1/1)...
[14:33:43] ============================================================ Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [14:33:44] ================== guc_buf (11 subtests) =================== [14:33:44] [PASSED] test_smallest [14:33:44] [PASSED] test_largest [14:33:44] [PASSED] test_granular [14:33:44] [PASSED] test_unique [14:33:44] [PASSED] test_overlap [14:33:44] [PASSED] test_reusable [14:33:44] [PASSED] test_too_big [14:33:44] [PASSED] test_flush [14:33:44] [PASSED] test_lookup [14:33:44] [PASSED] test_data [14:33:44] [PASSED] test_class [14:33:44] ===================== [PASSED] guc_buf ===================== [14:33:44] =================== guc_dbm (7 subtests) =================== [14:33:44] [PASSED] test_empty [14:33:44] [PASSED] test_default [14:33:44] ======================== test_size ======================== [14:33:44] [PASSED] 4 [14:33:44] [PASSED] 8 [14:33:44] [PASSED] 32 [14:33:44] [PASSED] 256 [14:33:44] ==================== [PASSED] test_size ==================== [14:33:44] ======================= test_reuse ======================== [14:33:44] [PASSED] 4 [14:33:44] [PASSED] 8 [14:33:44] [PASSED] 32 [14:33:44] [PASSED] 256 [14:33:44] =================== [PASSED] test_reuse ==================== [14:33:44] =================== test_range_overlap ==================== [14:33:44] [PASSED] 4 [14:33:44] [PASSED] 8 [14:33:44] [PASSED] 32 [14:33:44] [PASSED] 256 [14:33:44] =============== [PASSED] test_range_overlap ================ [14:33:44] =================== test_range_compact ==================== [14:33:44] [PASSED] 4 [14:33:44] [PASSED] 8 [14:33:44] [PASSED] 32 [14:33:44] [PASSED] 256 [14:33:44] =============== [PASSED] test_range_compact ================ [14:33:44] ==================== test_range_spare ===================== [14:33:44] [PASSED] 4 [14:33:44] [PASSED] 8 [14:33:44] [PASSED] 32 [14:33:44] [PASSED] 256 [14:33:44] ================ [PASSED] test_range_spare ================= [14:33:44] ===================== [PASSED] guc_dbm ===================== [14:33:44] =================== guc_idm (6 subtests) =================== [14:33:44] [PASSED] bad_init [14:33:44] [PASSED] no_init [14:33:44] [PASSED] init_fini [14:33:44] [PASSED] check_used [14:33:44] [PASSED] check_quota [14:33:44] [PASSED] check_all [14:33:44] ===================== [PASSED] guc_idm ===================== [14:33:44] ================== no_relay (3 subtests) =================== [14:33:44] [PASSED] xe_drops_guc2pf_if_not_ready [14:33:44] [PASSED] xe_drops_guc2vf_if_not_ready [14:33:44] [PASSED] xe_rejects_send_if_not_ready [14:33:44] ==================== [PASSED] no_relay ===================== [14:33:44] ================== pf_relay (14 subtests) ================== [14:33:44] [PASSED] pf_rejects_guc2pf_too_short [14:33:44] [PASSED] pf_rejects_guc2pf_too_long [14:33:44] [PASSED] pf_rejects_guc2pf_no_payload [14:33:44] [PASSED] pf_fails_no_payload [14:33:44] [PASSED] pf_fails_bad_origin [14:33:44] [PASSED] pf_fails_bad_type [14:33:44] [PASSED] pf_txn_reports_error [14:33:44] [PASSED] pf_txn_sends_pf2guc [14:33:44] [PASSED] pf_sends_pf2guc [14:33:44] [SKIPPED] pf_loopback_nop [14:33:44] [SKIPPED] pf_loopback_echo [14:33:44] [SKIPPED] pf_loopback_fail [14:33:44] [SKIPPED] pf_loopback_busy [14:33:44] [SKIPPED] pf_loopback_retry [14:33:44] ==================== [PASSED] pf_relay ===================== [14:33:44] ================== vf_relay (3 subtests) =================== [14:33:44] [PASSED] vf_rejects_guc2vf_too_short [14:33:44] [PASSED] vf_rejects_guc2vf_too_long [14:33:44] [PASSED] vf_rejects_guc2vf_no_payload [14:33:44] ==================== [PASSED] vf_relay ===================== [14:33:44] ================= pf_service (11 subtests) ================= [14:33:44] [PASSED] pf_negotiate_any [14:33:44] [PASSED] pf_negotiate_base_match [14:33:44] [PASSED] pf_negotiate_base_newer [14:33:44] [PASSED] pf_negotiate_base_next [14:33:44] [SKIPPED] pf_negotiate_base_older [14:33:44] [PASSED] pf_negotiate_base_prev [14:33:44] [PASSED] pf_negotiate_latest_match [14:33:44] [PASSED] pf_negotiate_latest_newer [14:33:44] [PASSED] pf_negotiate_latest_next [14:33:44] [SKIPPED] pf_negotiate_latest_older [14:33:44] [SKIPPED] pf_negotiate_latest_prev [14:33:44] =================== [PASSED] pf_service ==================== [14:33:44] ===================== lmtt (1 subtest) ===================== [14:33:44] ======================== test_ops ========================= [14:33:44] [PASSED] 2-level [14:33:44] [PASSED] multi-level [14:33:44] ==================== [PASSED] test_ops ===================== [14:33:44] ====================== [PASSED] lmtt ======================= [14:33:44] =================== xe_mocs (2 subtests) =================== [14:33:44] ================ xe_live_mocs_kernel_kunit ================ [14:33:44] =========== [SKIPPED] xe_live_mocs_kernel_kunit ============ [14:33:44] ================ xe_live_mocs_reset_kunit ================= [14:33:44] ============ [SKIPPED] xe_live_mocs_reset_kunit ============ [14:33:44] ==================== [SKIPPED] xe_mocs ===================== [14:33:44] ================= xe_migrate (2 subtests) ================== [14:33:44] ================= xe_migrate_sanity_kunit ================= [14:33:44] ============ [SKIPPED] xe_migrate_sanity_kunit ============= [14:33:44] ================== xe_validate_ccs_kunit ================== [14:33:44] ============= [SKIPPED] xe_validate_ccs_kunit ============== [14:33:44] =================== [SKIPPED] xe_migrate =================== [14:33:44] ================== xe_dma_buf (1 subtest) ================== [14:33:44] ==================== xe_dma_buf_kunit ===================== [14:33:44] ================ [SKIPPED] xe_dma_buf_kunit ================ [14:33:44] =================== [SKIPPED] xe_dma_buf =================== [14:33:44] ================= xe_bo_shrink (1 subtest) ================= [14:33:44] =================== xe_bo_shrink_kunit ==================== [14:33:44] =============== [SKIPPED] xe_bo_shrink_kunit =============== [14:33:44] ================== [SKIPPED] xe_bo_shrink ================== [14:33:44] ==================== xe_bo (2 subtests) ==================== [14:33:44] ================== xe_ccs_migrate_kunit =================== [14:33:44] ============== [SKIPPED] xe_ccs_migrate_kunit ============== stty: 'standard input': Inappropriate ioctl for device [14:33:44] ==================== xe_bo_evict_kunit ==================== [14:33:44] =============== [SKIPPED] xe_bo_evict_kunit ================ [14:33:44] ===================== [SKIPPED] xe_bo ====================== [14:33:44] ==================== args (11 subtests) ==================== [14:33:44] [PASSED] count_args_test [14:33:44] [PASSED] call_args_example [14:33:44] [PASSED] call_args_test [14:33:44] [PASSED] drop_first_arg_example [14:33:44] [PASSED] drop_first_arg_test [14:33:44] [PASSED] first_arg_example [14:33:44] [PASSED] first_arg_test [14:33:44] [PASSED] last_arg_example [14:33:44] [PASSED] last_arg_test [14:33:44] [PASSED] pick_arg_example [14:33:44] [PASSED] sep_comma_example [14:33:44] ====================== [PASSED] args ======================= [14:33:44] =================== xe_pci (2 subtests) ==================== [14:33:44] [PASSED] xe_gmdid_graphics_ip [14:33:44] [PASSED] xe_gmdid_media_ip [14:33:44] ===================== [PASSED] xe_pci ====================== [14:33:44] =================== xe_rtp (2 subtests) ==================== [14:33:44] =============== xe_rtp_process_to_sr_tests ================ [14:33:44] [PASSED] coalesce-same-reg [14:33:44] [PASSED] no-match-no-add [14:33:44] [PASSED] match-or [14:33:44] [PASSED] match-or-xfail [14:33:44] [PASSED] no-match-no-add-multiple-rules [14:33:44] [PASSED] two-regs-two-entries [14:33:44] [PASSED] clr-one-set-other [14:33:44] [PASSED] set-field [14:33:44] [PASSED] conflict-duplicate [14:33:44] [PASSED] conflict-not-disjoint [14:33:44] [PASSED] conflict-reg-type [14:33:44] =========== [PASSED] xe_rtp_process_to_sr_tests ============ [14:33:44] ================== xe_rtp_process_tests =================== [14:33:44] [PASSED] active1 [14:33:44] [PASSED] active2 [14:33:44] [PASSED] active-inactive [14:33:44] [PASSED] inactive-active [14:33:44] [PASSED] inactive-1st_or_active-inactive [14:33:44] [PASSED] inactive-2nd_or_active-inactive [14:33:44] [PASSED] inactive-last_or_active-inactive [14:33:44] [PASSED] inactive-no_or_active-inactive [14:33:44] ============== [PASSED] xe_rtp_process_tests =============== [14:33:44] ===================== [PASSED] xe_rtp ====================== [14:33:44] ==================== xe_wa (1 subtest) ===================== [14:33:44] ======================== xe_wa_gt ========================= [14:33:44] [PASSED] TIGERLAKE (B0) [14:33:44] [PASSED] DG1 (A0) [14:33:44] [PASSED] DG1 (B0) [14:33:44] [PASSED] ALDERLAKE_S (A0) [14:33:44] [PASSED] ALDERLAKE_S (B0) [14:33:44] [PASSED] ALDERLAKE_S (C0) [14:33:44] [PASSED] ALDERLAKE_S (D0) [14:33:44] [PASSED] ALDERLAKE_P (A0) [14:33:44] [PASSED] ALDERLAKE_P (B0) [14:33:44] [PASSED] ALDERLAKE_P (C0) [14:33:44] [PASSED] ALDERLAKE_S_RPLS (D0) [14:33:44] [PASSED] ALDERLAKE_P_RPLU (E0) [14:33:44] [PASSED] DG2_G10 (C0) [14:33:44] [PASSED] DG2_G11 (B1) [14:33:44] [PASSED] DG2_G12 (A1) [14:33:44] [PASSED] METEORLAKE (g:A0, m:A0) [14:33:44] [PASSED] METEORLAKE (g:A0, m:A0) [14:33:44] [PASSED] METEORLAKE (g:A0, m:A0) [14:33:44] [PASSED] LUNARLAKE (g:A0, m:A0) [14:33:44] [PASSED] LUNARLAKE (g:B0, m:A0) [14:33:44] [PASSED] BATTLEMAGE (g:A0, m:A1) [14:33:44] ==================== [PASSED] xe_wa_gt ===================== [14:33:44] ====================== [PASSED] xe_wa ====================== [14:33:44] ============================================================ [14:33:44] Testing complete. Ran 133 tests: passed: 117, skipped: 16 [14:33:44] Elapsed time: 30.465s total, 4.170s configuring, 26.029s building, 0.245s running
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/tests/.kunitconfig [14:33:44] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[14:33:46] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json ARCH=um O=.kunit --jobs=48
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
156 | u64 ioread64_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
163 | u64 ioread64_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
170 | u64 ioread64be_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
178 | u64 ioread64be_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~[14:34:06] Starting KUnit Kernel (1/1)...
[14:34:06] ============================================================ Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [14:34:06] =========== drm_validate_clone_mode (2 subtests) =========== [14:34:06] ============== drm_test_check_in_clone_mode =============== [14:34:06] [PASSED] in_clone_mode [14:34:06] [PASSED] not_in_clone_mode [14:34:06] ========== [PASSED] drm_test_check_in_clone_mode =========== [14:34:06] =============== drm_test_check_valid_clones =============== [14:34:06] [PASSED] not_in_clone_mode [14:34:06] [PASSED] valid_clone [14:34:06] [PASSED] invalid_clone [14:34:06] =========== [PASSED] drm_test_check_valid_clones =========== [14:34:06] ============= [PASSED] drm_validate_clone_mode ============= [14:34:06] ============= drm_validate_modeset (1 subtest) ============= [14:34:06] [PASSED] drm_test_check_connector_changed_modeset [14:34:06] ============== [PASSED] drm_validate_modeset =============== [14:34:06] ================== drm_buddy (7 subtests) ================== [14:34:06] [PASSED] drm_test_buddy_alloc_limit [14:34:06] [PASSED] drm_test_buddy_alloc_optimistic [14:34:06] [PASSED] drm_test_buddy_alloc_pessimistic [14:34:06] [PASSED] drm_test_buddy_alloc_pathological [14:34:06] [PASSED] drm_test_buddy_alloc_contiguous [14:34:06] [PASSED] drm_test_buddy_alloc_clear [14:34:06] [PASSED] drm_test_buddy_alloc_range_bias [14:34:06] ==================== [PASSED] drm_buddy ==================== [14:34:06] ============= drm_cmdline_parser (40 subtests) ============= [14:34:06] [PASSED] drm_test_cmdline_force_d_only [14:34:06] [PASSED] drm_test_cmdline_force_D_only_dvi [14:34:06] [PASSED] drm_test_cmdline_force_D_only_hdmi [14:34:06] [PASSED] drm_test_cmdline_force_D_only_not_digital [14:34:06] [PASSED] drm_test_cmdline_force_e_only [14:34:06] [PASSED] drm_test_cmdline_res [14:34:06] [PASSED] drm_test_cmdline_res_vesa [14:34:06] [PASSED] drm_test_cmdline_res_vesa_rblank [14:34:06] [PASSED] drm_test_cmdline_res_rblank [14:34:06] [PASSED] drm_test_cmdline_res_bpp [14:34:06] [PASSED] drm_test_cmdline_res_refresh [14:34:06] [PASSED] drm_test_cmdline_res_bpp_refresh [14:34:06] [PASSED] drm_test_cmdline_res_bpp_refresh_interlaced [14:34:06] [PASSED] drm_test_cmdline_res_bpp_refresh_margins [14:34:06] [PASSED] drm_test_cmdline_res_bpp_refresh_force_off [14:34:06] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on [14:34:06] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on_analog [14:34:06] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on_digital [14:34:06] [PASSED] drm_test_cmdline_res_bpp_refresh_interlaced_margins_force_on [14:34:06] [PASSED] drm_test_cmdline_res_margins_force_on [14:34:06] [PASSED] drm_test_cmdline_res_vesa_margins [14:34:06] [PASSED] drm_test_cmdline_name [14:34:06] [PASSED] drm_test_cmdline_name_bpp [14:34:06] [PASSED] drm_test_cmdline_name_option [14:34:06] [PASSED] drm_test_cmdline_name_bpp_option [14:34:06] [PASSED] drm_test_cmdline_rotate_0 [14:34:06] [PASSED] drm_test_cmdline_rotate_90 [14:34:06] [PASSED] drm_test_cmdline_rotate_180 [14:34:06] [PASSED] drm_test_cmdline_rotate_270 [14:34:06] [PASSED] drm_test_cmdline_hmirror [14:34:06] [PASSED] drm_test_cmdline_vmirror [14:34:06] [PASSED] drm_test_cmdline_margin_options [14:34:06] [PASSED] drm_test_cmdline_multiple_options [14:34:06] [PASSED] drm_test_cmdline_bpp_extra_and_option [14:34:06] [PASSED] drm_test_cmdline_extra_and_option [14:34:06] [PASSED] drm_test_cmdline_freestanding_options [14:34:06] [PASSED] drm_test_cmdline_freestanding_force_e_and_options [14:34:06] [PASSED] drm_test_cmdline_panel_orientation [14:34:06] ================ drm_test_cmdline_invalid ================= [14:34:06] [PASSED] margin_only [14:34:06] [PASSED] interlace_only [14:34:06] [PASSED] res_missing_x [14:34:06] [PASSED] res_missing_y [14:34:06] [PASSED] res_bad_y [14:34:06] [PASSED] res_missing_y_bpp [14:34:06] [PASSED] res_bad_bpp [14:34:06] [PASSED] res_bad_refresh [14:34:06] [PASSED] res_bpp_refresh_force_on_off [14:34:06] [PASSED] res_invalid_mode [14:34:06] [PASSED] res_bpp_wrong_place_mode [14:34:06] [PASSED] name_bpp_refresh [14:34:06] [PASSED] name_refresh [14:34:06] [PASSED] name_refresh_wrong_mode [14:34:06] [PASSED] name_refresh_invalid_mode [14:34:06] [PASSED] rotate_multiple [14:34:06] [PASSED] rotate_invalid_val [14:34:06] [PASSED] rotate_truncated [14:34:06] [PASSED] invalid_option [14:34:06] [PASSED] invalid_tv_option [14:34:06] [PASSED] truncated_tv_option [14:34:06] ============ [PASSED] drm_test_cmdline_invalid ============= [14:34:06] =============== drm_test_cmdline_tv_options =============== [14:34:06] [PASSED] NTSC [14:34:06] [PASSED] NTSC_443 [14:34:06] [PASSED] NTSC_J [14:34:06] [PASSED] PAL [14:34:06] [PASSED] PAL_M [14:34:06] [PASSED] PAL_N [14:34:06] [PASSED] SECAM [14:34:06] [PASSED] MONO_525 [14:34:06] [PASSED] MONO_625 [14:34:06] =========== [PASSED] drm_test_cmdline_tv_options =========== [14:34:06] =============== [PASSED] drm_cmdline_parser ================ [14:34:06] ========== drmm_connector_hdmi_init (20 subtests) ========== [14:34:06] [PASSED] drm_test_connector_hdmi_init_valid [14:34:06] [PASSED] drm_test_connector_hdmi_init_bpc_8 [14:34:06] [PASSED] drm_test_connector_hdmi_init_bpc_10 [14:34:06] [PASSED] drm_test_connector_hdmi_init_bpc_12 [14:34:06] [PASSED] drm_test_connector_hdmi_init_bpc_invalid [14:34:06] [PASSED] drm_test_connector_hdmi_init_bpc_null [14:34:06] [PASSED] drm_test_connector_hdmi_init_formats_empty [14:34:06] [PASSED] drm_test_connector_hdmi_init_formats_no_rgb [14:34:06] === drm_test_connector_hdmi_init_formats_yuv420_allowed === [14:34:06] [PASSED] supported_formats=0x9 yuv420_allowed=1 [14:34:06] [PASSED] supported_formats=0x9 yuv420_allowed=0 [14:34:06] [PASSED] supported_formats=0x3 yuv420_allowed=1 [14:34:06] [PASSED] supported_formats=0x3 yuv420_allowed=0 [14:34:06] === [PASSED] drm_test_connector_hdmi_init_formats_yuv420_allowed === [14:34:06] [PASSED] drm_test_connector_hdmi_init_null_ddc [14:34:06] [PASSED] drm_test_connector_hdmi_init_null_product [14:34:06] [PASSED] drm_test_connector_hdmi_init_null_vendor [14:34:06] [PASSED] drm_test_connector_hdmi_init_product_length_exact [14:34:06] [PASSED] drm_test_connector_hdmi_init_product_length_too_long [14:34:06] [PASSED] drm_test_connector_hdmi_init_product_valid [14:34:06] [PASSED] drm_test_connector_hdmi_init_vendor_length_exact [14:34:06] [PASSED] drm_test_connector_hdmi_init_vendor_length_too_long [14:34:06] [PASSED] drm_test_connector_hdmi_init_vendor_valid [14:34:06] ========= drm_test_connector_hdmi_init_type_valid ========= [14:34:06] [PASSED] HDMI-A [14:34:06] [PASSED] HDMI-B [14:34:06] ===== [PASSED] drm_test_connector_hdmi_init_type_valid ===== [14:34:06] ======== drm_test_connector_hdmi_init_type_invalid ======== [14:34:06] [PASSED] Unknown [14:34:06] [PASSED] VGA [14:34:06] [PASSED] DVI-I [14:34:06] [PASSED] DVI-D [14:34:06] [PASSED] DVI-A [14:34:06] [PASSED] Composite [14:34:06] [PASSED] SVIDEO [14:34:06] [PASSED] LVDS [14:34:06] [PASSED] Component [14:34:06] [PASSED] DIN [14:34:06] [PASSED] DP [14:34:06] [PASSED] TV [14:34:06] [PASSED] eDP [14:34:06] [PASSED] Virtual [14:34:06] [PASSED] DSI [14:34:06] [PASSED] DPI [14:34:06] [PASSED] Writeback [14:34:06] [PASSED] SPI [14:34:06] [PASSED] USB [14:34:06] ==== [PASSED] drm_test_connector_hdmi_init_type_invalid ==== [14:34:06] ============ [PASSED] drmm_connector_hdmi_init ============= [14:34:06] ============= drmm_connector_init (3 subtests) ============= [14:34:06] [PASSED] drm_test_drmm_connector_init [14:34:06] [PASSED] drm_test_drmm_connector_init_null_ddc [14:34:06] ========= drm_test_drmm_connector_init_type_valid ========= [14:34:06] [PASSED] Unknown [14:34:06] [PASSED] VGA [14:34:06] [PASSED] DVI-I [14:34:06] [PASSED] DVI-D [14:34:06] [PASSED] DVI-A [14:34:06] [PASSED] Composite [14:34:06] [PASSED] SVIDEO [14:34:06] [PASSED] LVDS [14:34:06] [PASSED] Component [14:34:06] [PASSED] DIN [14:34:06] [PASSED] DP [14:34:06] [PASSED] HDMI-A [14:34:06] [PASSED] HDMI-B [14:34:06] [PASSED] TV [14:34:06] [PASSED] eDP [14:34:06] [PASSED] Virtual [14:34:06] [PASSED] DSI [14:34:06] [PASSED] DPI [14:34:06] [PASSED] Writeback [14:34:06] [PASSED] SPI [14:34:06] [PASSED] USB [14:34:06] ===== [PASSED] drm_test_drmm_connector_init_type_valid ===== [14:34:06] =============== [PASSED] drmm_connector_init =============== [14:34:06] ========= drm_connector_dynamic_init (6 subtests) ========== [14:34:06] [PASSED] drm_test_drm_connector_dynamic_init [14:34:06] [PASSED] drm_test_drm_connector_dynamic_init_null_ddc [14:34:06] [PASSED] drm_test_drm_connector_dynamic_init_not_added [14:34:06] [PASSED] drm_test_drm_connector_dynamic_init_properties [14:34:06] ===== drm_test_drm_connector_dynamic_init_type_valid ====== [14:34:06] [PASSED] Unknown [14:34:06] [PASSED] VGA [14:34:06] [PASSED] DVI-I [14:34:06] [PASSED] DVI-D [14:34:06] [PASSED] DVI-A [14:34:06] [PASSED] Composite [14:34:06] [PASSED] SVIDEO [14:34:06] [PASSED] LVDS [14:34:06] [PASSED] Component [14:34:06] [PASSED] DIN [14:34:06] [PASSED] DP [14:34:06] [PASSED] HDMI-A [14:34:06] [PASSED] HDMI-B [14:34:06] [PASSED] TV [14:34:06] [PASSED] eDP [14:34:06] [PASSED] Virtual [14:34:06] [PASSED] DSI [14:34:06] [PASSED] DPI [14:34:06] [PASSED] Writeback [14:34:06] [PASSED] SPI [14:34:06] [PASSED] USB [14:34:06] = [PASSED] drm_test_drm_connector_dynamic_init_type_valid == [14:34:06] ======== drm_test_drm_connector_dynamic_init_name ========= [14:34:06] [PASSED] Unknown [14:34:06] [PASSED] VGA [14:34:06] [PASSED] DVI-I [14:34:06] [PASSED] DVI-D [14:34:06] [PASSED] DVI-A [14:34:06] [PASSED] Composite [14:34:06] [PASSED] SVIDEO [14:34:06] [PASSED] LVDS [14:34:06] [PASSED] Component [14:34:06] [PASSED] DIN [14:34:06] [PASSED] DP [14:34:06] [PASSED] HDMI-A [14:34:06] [PASSED] HDMI-B [14:34:06] [PASSED] TV [14:34:06] [PASSED] eDP [14:34:06] [PASSED] Virtual [14:34:06] [PASSED] DSI [14:34:06] [PASSED] DPI [14:34:06] [PASSED] Writeback [14:34:06] [PASSED] SPI [14:34:06] [PASSED] USB [14:34:06] ==== [PASSED] drm_test_drm_connector_dynamic_init_name ===== [14:34:06] =========== [PASSED] drm_connector_dynamic_init ============ [14:34:06] ==== drm_connector_dynamic_register_early (4 subtests) ===== [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_early_on_list [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_early_defer [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_early_no_init [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_early_no_mode_object [14:34:06] ====== [PASSED] drm_connector_dynamic_register_early ======= [14:34:06] ======= drm_connector_dynamic_register (7 subtests) ======== [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_on_list [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_no_defer [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_no_init [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_mode_object [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_sysfs [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_sysfs_name [14:34:06] [PASSED] drm_test_drm_connector_dynamic_register_debugfs [14:34:06] ========= [PASSED] drm_connector_dynamic_register ========== [14:34:06] = drm_connector_attach_broadcast_rgb_property (2 subtests) = [14:34:06] [PASSED] drm_test_drm_connector_attach_broadcast_rgb_property [14:34:06] [PASSED] drm_test_drm_connector_attach_broadcast_rgb_property_hdmi_connector [14:34:06] === [PASSED] drm_connector_attach_broadcast_rgb_property === [14:34:06] ========== drm_get_tv_mode_from_name (2 subtests) ========== [14:34:06] ========== drm_test_get_tv_mode_from_name_valid =========== [14:34:06] [PASSED] NTSC [14:34:06] [PASSED] NTSC-443 [14:34:06] [PASSED] NTSC-J [14:34:06] [PASSED] PAL [14:34:06] [PASSED] PAL-M [14:34:06] [PASSED] PAL-N [14:34:06] [PASSED] SECAM [14:34:06] [PASSED] Mono [14:34:06] ====== [PASSED] drm_test_get_tv_mode_from_name_valid ======= [14:34:06] [PASSED] drm_test_get_tv_mode_from_name_truncated [14:34:06] ============ [PASSED] drm_get_tv_mode_from_name ============ [14:34:06] = drm_test_connector_hdmi_compute_mode_clock (12 subtests) = [14:34:06] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb [14:34:06] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_10bpc [14:34:06] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_10bpc_vic_1 [14:34:06] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_12bpc [14:34:06] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_12bpc_vic_1 [14:34:06] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_double [14:34:06] = drm_test_connector_hdmi_compute_mode_clock_yuv420_valid = [14:34:06] [PASSED] VIC 96 [14:34:06] [PASSED] VIC 97 [14:34:06] [PASSED] VIC 101 [14:34:06] [PASSED] VIC 102 [14:34:06] [PASSED] VIC 106 [14:34:06] [PASSED] VIC 107 [14:34:06] === [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_valid === [14:34:06] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_10_bpc [14:34:06] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_12_bpc [14:34:06] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_8_bpc [14:34:06] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_10_bpc [14:34:06] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_12_bpc [14:34:06] === [PASSED] drm_test_connector_hdmi_compute_mode_clock ==== [14:34:06] == drm_hdmi_connector_get_broadcast_rgb_name (2 subtests) == [14:34:06] === drm_test_drm_hdmi_connector_get_broadcast_rgb_name ==== [14:34:06] [PASSED] Automatic [14:34:06] [PASSED] Full [14:34:06] [PASSED] Limited 16:235 [14:34:06] === [PASSED] drm_test_drm_hdmi_connector_get_broadcast_rgb_name === [14:34:06] [PASSED] drm_test_drm_hdmi_connector_get_broadcast_rgb_name_invalid [14:34:06] ==== [PASSED] drm_hdmi_connector_get_broadcast_rgb_name ==== [14:34:06] == drm_hdmi_connector_get_output_format_name (2 subtests) == [14:34:06] === drm_test_drm_hdmi_connector_get_output_format_name ==== [14:34:06] [PASSED] RGB [14:34:06] [PASSED] YUV 4:2:0 [14:34:06] [PASSED] YUV 4:2:2 [14:34:06] [PASSED] YUV 4:4:4 [14:34:06] === [PASSED] drm_test_drm_hdmi_connector_get_output_format_name === [14:34:06] [PASSED] drm_test_drm_hdmi_connector_get_output_format_name_invalid [14:34:06] ==== [PASSED] drm_hdmi_connector_get_output_format_name ==== [14:34:06] ============= drm_damage_helper (21 subtests) ============== [14:34:06] [PASSED] drm_test_damage_iter_no_damage [14:34:06] [PASSED] drm_test_damage_iter_no_damage_fractional_src [14:34:06] [PASSED] drm_test_damage_iter_no_damage_src_moved [14:34:06] [PASSED] drm_test_damage_iter_no_damage_fractional_src_moved [14:34:06] [PASSED] drm_test_damage_iter_no_damage_not_visible [14:34:06] [PASSED] drm_test_damage_iter_no_damage_no_crtc [14:34:06] [PASSED] drm_test_damage_iter_no_damage_no_fb [14:34:06] [PASSED] drm_test_damage_iter_simple_damage [14:34:06] [PASSED] drm_test_damage_iter_single_damage [14:34:06] [PASSED] drm_test_damage_iter_single_damage_intersect_src [14:34:06] [PASSED] drm_test_damage_iter_single_damage_outside_src [14:34:06] [PASSED] drm_test_damage_iter_single_damage_fractional_src [14:34:06] [PASSED] drm_test_damage_iter_single_damage_intersect_fractional_src [14:34:06] [PASSED] drm_test_damage_iter_single_damage_outside_fractional_src [14:34:06] [PASSED] drm_test_damage_iter_single_damage_src_moved [14:34:06] [PASSED] drm_test_damage_iter_single_damage_fractional_src_moved [14:34:06] [PASSED] drm_test_damage_iter_damage [14:34:06] [PASSED] drm_test_damage_iter_damage_one_intersect [14:34:06] [PASSED] drm_test_damage_iter_damage_one_outside [14:34:06] [PASSED] drm_test_damage_iter_damage_src_moved [14:34:06] [PASSED] drm_test_damage_iter_damage_not_visible [14:34:06] ================ [PASSED] drm_damage_helper ================ [14:34:06] ============== drm_dp_mst_helper (3 subtests) ============== [14:34:06] ============== drm_test_dp_mst_calc_pbn_mode ============== [14:34:06] [PASSED] Clock 154000 BPP 30 DSC disabled [14:34:06] [PASSED] Clock 234000 BPP 30 DSC disabled [14:34:06] [PASSED] Clock 297000 BPP 24 DSC disabled [14:34:06] [PASSED] Clock 332880 BPP 24 DSC enabled [14:34:06] [PASSED] Clock 324540 BPP 24 DSC enabled [14:34:06] ========== [PASSED] drm_test_dp_mst_calc_pbn_mode ========== [14:34:06] ============== drm_test_dp_mst_calc_pbn_div =============== [14:34:06] [PASSED] Link rate 2000000 lane count 4 [14:34:06] [PASSED] Link rate 2000000 lane count 2 [14:34:06] [PASSED] Link rate 2000000 lane count 1 [14:34:06] [PASSED] Link rate 1350000 lane count 4 [14:34:06] [PASSED] Link rate 1350000 lane count 2 [14:34:06] [PASSED] Link rate 1350000 lane count 1 [14:34:06] [PASSED] Link rate 1000000 lane count 4 [14:34:06] [PASSED] Link rate 1000000 lane count 2 [14:34:06] [PASSED] Link rate 1000000 lane count 1 [14:34:06] [PASSED] Link rate 810000 lane count 4 [14:34:06] [PASSED] Link rate 810000 lane count 2 [14:34:06] [PASSED] Link rate 810000 lane count 1 [14:34:06] [PASSED] Link rate 540000 lane count 4 [14:34:06] [PASSED] Link rate 540000 lane count 2 [14:34:06] [PASSED] Link rate 540000 lane count 1 [14:34:06] [PASSED] Link rate 270000 lane count 4 [14:34:06] [PASSED] Link rate 270000 lane count 2 [14:34:06] [PASSED] Link rate 270000 lane count 1 [14:34:06] [PASSED] Link rate 162000 lane count 4 [14:34:06] [PASSED] Link rate 162000 lane count 2 [14:34:06] [PASSED] Link rate 162000 lane count 1 [14:34:06] ========== [PASSED] drm_test_dp_mst_calc_pbn_div =========== [14:34:06] ========= drm_test_dp_mst_sideband_msg_req_decode ========= [14:34:06] [PASSED] DP_ENUM_PATH_RESOURCES with port number [14:34:06] [PASSED] DP_POWER_UP_PHY with port number [14:34:06] [PASSED] DP_POWER_DOWN_PHY with port number [14:34:06] [PASSED] DP_ALLOCATE_PAYLOAD with SDP stream sinks [14:34:06] [PASSED] DP_ALLOCATE_PAYLOAD with port number [14:34:06] [PASSED] DP_ALLOCATE_PAYLOAD with VCPI [14:34:06] [PASSED] DP_ALLOCATE_PAYLOAD with PBN [14:34:06] [PASSED] DP_QUERY_PAYLOAD with port number [14:34:06] [PASSED] DP_QUERY_PAYLOAD with VCPI [14:34:06] [PASSED] DP_REMOTE_DPCD_READ with port number [14:34:06] [PASSED] DP_REMOTE_DPCD_READ with DPCD address [14:34:06] [PASSED] DP_REMOTE_DPCD_READ with max number of bytes [14:34:06] [PASSED] DP_REMOTE_DPCD_WRITE with port number [14:34:06] [PASSED] DP_REMOTE_DPCD_WRITE with DPCD address [14:34:06] [PASSED] DP_REMOTE_DPCD_WRITE with data array [14:34:06] [PASSED] DP_REMOTE_I2C_READ with port number [14:34:06] [PASSED] DP_REMOTE_I2C_READ with I2C device ID [14:34:06] [PASSED] DP_REMOTE_I2C_READ with transactions array [14:34:06] [PASSED] DP_REMOTE_I2C_WRITE with port number [14:34:06] [PASSED] DP_REMOTE_I2C_WRITE with I2C device ID [14:34:06] [PASSED] DP_REMOTE_I2C_WRITE with data array [14:34:06] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream ID [14:34:06] [PASSED] DP_QUERY_STREAM_ENC_STATUS with client ID [14:34:06] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream event [14:34:06] [PASSED] DP_QUERY_STREAM_ENC_STATUS with valid stream event [14:34:06] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream behavior [14:34:06] [PASSED] DP_QUERY_STREAM_ENC_STATUS with a valid stream behavior [14:34:06] ===== [PASSED] drm_test_dp_mst_sideband_msg_req_decode ===== [14:34:06] ================ [PASSED] drm_dp_mst_helper ================ [14:34:06] ================== drm_exec (7 subtests) =================== [14:34:06] [PASSED] sanitycheck [14:34:06] [PASSED] test_lock [14:34:06] [PASSED] test_lock_unlock [14:34:06] [PASSED] test_duplicates [14:34:06] [PASSED] test_prepare [14:34:06] [PASSED] test_prepare_array [14:34:06] [PASSED] test_multiple_loops [14:34:06] ==================== [PASSED] drm_exec ===================== [14:34:06] =========== drm_format_helper_test (17 subtests) =========== [14:34:06] ============== drm_test_fb_xrgb8888_to_gray8 ============== [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ========== [PASSED] drm_test_fb_xrgb8888_to_gray8 ========== [14:34:06] ============= drm_test_fb_xrgb8888_to_rgb332 ============== [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb332 ========== [14:34:06] ============= drm_test_fb_xrgb8888_to_rgb565 ============== [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb565 ========== [14:34:06] ============ drm_test_fb_xrgb8888_to_xrgb1555 ============= [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ======== [PASSED] drm_test_fb_xrgb8888_to_xrgb1555 ========= [14:34:06] ============ drm_test_fb_xrgb8888_to_argb1555 ============= [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ======== [PASSED] drm_test_fb_xrgb8888_to_argb1555 ========= [14:34:06] ============ drm_test_fb_xrgb8888_to_rgba5551 ============= [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ======== [PASSED] drm_test_fb_xrgb8888_to_rgba5551 ========= [14:34:06] ============= drm_test_fb_xrgb8888_to_rgb888 ============== [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb888 ========== [14:34:06] ============ drm_test_fb_xrgb8888_to_argb8888 ============= [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ======== [PASSED] drm_test_fb_xrgb8888_to_argb8888 ========= [14:34:06] =========== drm_test_fb_xrgb8888_to_xrgb2101010 =========== [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ======= [PASSED] drm_test_fb_xrgb8888_to_xrgb2101010 ======= [14:34:06] =========== drm_test_fb_xrgb8888_to_argb2101010 =========== [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ======= [PASSED] drm_test_fb_xrgb8888_to_argb2101010 ======= [14:34:06] ============== drm_test_fb_xrgb8888_to_mono =============== [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ========== [PASSED] drm_test_fb_xrgb8888_to_mono =========== [14:34:06] ==================== drm_test_fb_swab ===================== [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ================ [PASSED] drm_test_fb_swab ================= [14:34:06] ============ drm_test_fb_xrgb8888_to_xbgr8888 ============= [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ======== [PASSED] drm_test_fb_xrgb8888_to_xbgr8888 ========= [14:34:06] ============ drm_test_fb_xrgb8888_to_abgr8888 ============= [14:34:06] [PASSED] single_pixel_source_buffer [14:34:06] [PASSED] single_pixel_clip_rectangle [14:34:06] [PASSED] well_known_colors [14:34:06] [PASSED] destination_pitch [14:34:06] ======== [PASSED] drm_test_fb_xrgb8888_to_abgr8888 ========= [14:34:06] ================= drm_test_fb_clip_offset ================= [14:34:06] [PASSED] pass through [14:34:06] [PASSED] horizontal offset [14:34:06] [PASSED] vertical offset [14:34:06] [PASSED] horizontal and vertical offset [14:34:06] [PASSED] horizontal offset (custom pitch) [14:34:06] [PASSED] vertical offset (custom pitch) [14:34:06] [PASSED] horizontal and vertical offset (custom pitch) [14:34:06] ============= [PASSED] drm_test_fb_clip_offset ============= [14:34:06] ============== drm_test_fb_build_fourcc_list ============== [14:34:06] [PASSED] no native formats [14:34:06] [PASSED] XRGB8888 as native format [14:34:06] [PASSED] remove duplicates [14:34:06] [PASSED] convert alpha formats [14:34:06] [PASSED] random formats [14:34:06] ========== [PASSED] drm_test_fb_build_fourcc_list ========== [14:34:06] =================== drm_test_fb_memcpy ==================== [14:34:06] [PASSED] single_pixel_source_buffer: XR24 little-endian (0x34325258) [14:34:06] [PASSED] single_pixel_source_buffer: XRA8 little-endian (0x38415258) [14:34:06] [PASSED] single_pixel_source_buffer: YU24 little-endian (0x34325559) [14:34:06] [PASSED] single_pixel_clip_rectangle: XB24 little-endian (0x34324258) [14:34:06] [PASSED] single_pixel_clip_rectangle: XRA8 little-endian (0x38415258) [14:34:06] [PASSED] single_pixel_clip_rectangle: YU24 little-endian (0x34325559) [14:34:06] [PASSED] well_known_colors: XB24 little-endian (0x34324258) [14:34:06] [PASSED] well_known_colors: XRA8 little-endian (0x38415258) [14:34:06] [PASSED] well_known_colors: YU24 little-endian (0x34325559) [14:34:06] [PASSED] destination_pitch: XB24 little-endian (0x34324258) [14:34:06] [PASSED] destination_pitch: XRA8 little-endian (0x38415258) [14:34:06] [PASSED] destination_pitch: YU24 little-endian (0x34325559) [14:34:06] =============== [PASSED] drm_test_fb_memcpy ================ [14:34:06] ============= [PASSED] drm_format_helper_test ============== [14:34:06] ================= drm_format (18 subtests) ================= [14:34:06] [PASSED] drm_test_format_block_width_invalid [14:34:06] [PASSED] drm_test_format_block_width_one_plane [14:34:06] [PASSED] drm_test_format_block_width_two_plane [14:34:06] [PASSED] drm_test_format_block_width_three_plane [14:34:06] [PASSED] drm_test_format_block_width_tiled [14:34:06] [PASSED] drm_test_format_block_height_invalid [14:34:06] [PASSED] drm_test_format_block_height_one_plane [14:34:06] [PASSED] drm_test_format_block_height_two_plane [14:34:06] [PASSED] drm_test_format_block_height_three_plane [14:34:06] [PASSED] drm_test_format_block_height_tiled [14:34:06] [PASSED] drm_test_format_min_pitch_invalid [14:34:06] [PASSED] drm_test_format_min_pitch_one_plane_8bpp [14:34:06] [PASSED] drm_test_format_min_pitch_one_plane_16bpp [14:34:06] [PASSED] drm_test_format_min_pitch_one_plane_24bpp [14:34:06] [PASSED] drm_test_format_min_pitch_one_plane_32bpp [14:34:06] [PASSED] drm_test_format_min_pitch_two_plane [14:34:06] [PASSED] drm_test_format_min_pitch_three_plane_8bpp [14:34:06] [PASSED] drm_test_format_min_pitch_tiled [14:34:06] =================== [PASSED] drm_format ==================== [14:34:06] ============== drm_framebuffer (10 subtests) =============== [14:34:06] ========== drm_test_framebuffer_check_src_coords ========== [14:34:06] [PASSED] Success: source fits into fb [14:34:06] [PASSED] Fail: overflowing fb with x-axis coordinate [14:34:06] [PASSED] Fail: overflowing fb with y-axis coordinate [14:34:06] [PASSED] Fail: overflowing fb with source width [14:34:06] [PASSED] Fail: overflowing fb with source height [14:34:06] ====== [PASSED] drm_test_framebuffer_check_src_coords ====== [14:34:06] [PASSED] drm_test_framebuffer_cleanup [14:34:06] =============== drm_test_framebuffer_create =============== [14:34:06] [PASSED] ABGR8888 normal sizes [14:34:06] [PASSED] ABGR8888 max sizes [14:34:06] [PASSED] ABGR8888 pitch greater than min required [14:34:06] [PASSED] ABGR8888 pitch less than min required [14:34:06] [PASSED] ABGR8888 Invalid width [14:34:06] [PASSED] ABGR8888 Invalid buffer handle [14:34:06] [PASSED] No pixel format [14:34:06] [PASSED] ABGR8888 Width 0 [14:34:06] [PASSED] ABGR8888 Height 0 [14:34:06] [PASSED] ABGR8888 Out of bound height * pitch combination [14:34:06] [PASSED] ABGR8888 Large buffer offset [14:34:06] [PASSED] ABGR8888 Buffer offset for inexistent plane [14:34:06] [PASSED] ABGR8888 Invalid flag [14:34:06] [PASSED] ABGR8888 Set DRM_MODE_FB_MODIFIERS without modifiers [14:34:06] [PASSED] ABGR8888 Valid buffer modifier [14:34:06] [PASSED] ABGR8888 Invalid buffer modifier(DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) [14:34:06] [PASSED] ABGR8888 Extra pitches without DRM_MODE_FB_MODIFIERS [14:34:06] [PASSED] ABGR8888 Extra pitches with DRM_MODE_FB_MODIFIERS [14:34:06] [PASSED] NV12 Normal sizes [14:34:06] [PASSED] NV12 Max sizes [14:34:06] [PASSED] NV12 Invalid pitch [14:34:06] [PASSED] NV12 Invalid modifier/missing DRM_MODE_FB_MODIFIERS flag [14:34:06] [PASSED] NV12 different modifier per-plane [14:34:06] [PASSED] NV12 with DRM_FORMAT_MOD_SAMSUNG_64_32_TILE [14:34:06] [PASSED] NV12 Valid modifiers without DRM_MODE_FB_MODIFIERS [14:34:06] [PASSED] NV12 Modifier for inexistent plane [14:34:06] [PASSED] NV12 Handle for inexistent plane [14:34:06] [PASSED] NV12 Handle for inexistent plane without DRM_MODE_FB_MODIFIERS [14:34:06] [PASSED] YVU420 DRM_MODE_FB_MODIFIERS set without modifier [14:34:06] [PASSED] YVU420 Normal sizes [14:34:06] [PASSED] YVU420 Max sizes [14:34:06] [PASSED] YVU420 Invalid pitch [14:34:06] [PASSED] YVU420 Different pitches [14:34:06] [PASSED] YVU420 Different buffer offsets/pitches [14:34:06] [PASSED] YVU420 Modifier set just for plane 0, without DRM_MODE_FB_MODIFIERS [14:34:06] [PASSED] YVU420 Modifier set just for planes 0, 1, without DRM_MODE_FB_MODIFIERS [14:34:06] [PASSED] YVU420 Modifier set just for plane 0, 1, with DRM_MODE_FB_MODIFIERS [14:34:06] [PASSED] YVU420 Valid modifier [14:34:06] [PASSED] YVU420 Different modifiers per plane [14:34:06] [PASSED] YVU420 Modifier for inexistent plane [14:34:06] [PASSED] YUV420_10BIT Invalid modifier(DRM_FORMAT_MOD_LINEAR) [14:34:06] [PASSED] X0L2 Normal sizes [14:34:06] [PASSED] X0L2 Max sizes [14:34:06] [PASSED] X0L2 Invalid pitch [14:34:06] [PASSED] X0L2 Pitch greater than minimum required [14:34:06] [PASSED] X0L2 Handle for inexistent plane [14:34:06] [PASSED] X0L2 Offset for inexistent plane, without DRM_MODE_FB_MODIFIERS set [14:34:06] [PASSED] X0L2 Modifier without DRM_MODE_FB_MODIFIERS set [14:34:06] [PASSED] X0L2 Valid modifier [14:34:06] [PASSED] X0L2 Modifier for inexistent plane [14:34:06] =========== [PASSED] drm_test_framebuffer_create =========== [14:34:06] [PASSED] drm_test_framebuffer_free [14:34:06] [PASSED] drm_test_framebuffer_init [14:34:06] [PASSED] drm_test_framebuffer_init_bad_format [14:34:06] [PASSED] drm_test_framebuffer_init_dev_mismatch [14:34:06] [PASSED] drm_test_framebuffer_lookup [14:34:06] [PASSED] drm_test_framebuffer_lookup_inexistent [14:34:06] [PASSED] drm_test_framebuffer_modifiers_not_supported [14:34:06] ================= [PASSED] drm_framebuffer ================= [14:34:06] ================ drm_gem_shmem (8 subtests) ================ [14:34:06] [PASSED] drm_gem_shmem_test_obj_create [14:34:06] [PASSED] drm_gem_shmem_test_obj_create_private [14:34:06] [PASSED] drm_gem_shmem_test_pin_pages [14:34:06] [PASSED] drm_gem_shmem_test_vmap [14:34:06] [PASSED] drm_gem_shmem_test_get_pages_sgt [14:34:06] [PASSED] drm_gem_shmem_test_get_sg_table [14:34:06] [PASSED] drm_gem_shmem_test_madvise [14:34:06] [PASSED] drm_gem_shmem_test_purge [14:34:06] ================== [PASSED] drm_gem_shmem ================== [14:34:06] === drm_atomic_helper_connector_hdmi_check (23 subtests) === [14:34:06] [PASSED] drm_test_check_broadcast_rgb_auto_cea_mode [14:34:06] [PASSED] drm_test_check_broadcast_rgb_auto_cea_mode_vic_1 [14:34:06] [PASSED] drm_test_check_broadcast_rgb_full_cea_mode [14:34:06] [PASSED] drm_test_check_broadcast_rgb_full_cea_mode_vic_1 [14:34:06] [PASSED] drm_test_check_broadcast_rgb_limited_cea_mode [14:34:06] [PASSED] drm_test_check_broadcast_rgb_limited_cea_mode_vic_1 [14:34:06] [PASSED] drm_test_check_broadcast_rgb_crtc_mode_changed [14:34:06] [PASSED] drm_test_check_broadcast_rgb_crtc_mode_not_changed [14:34:06] [PASSED] drm_test_check_disable_connector [14:34:06] [PASSED] drm_test_check_hdmi_funcs_reject_rate [14:34:06] [PASSED] drm_test_check_max_tmds_rate_bpc_fallback [14:34:06] [PASSED] drm_test_check_max_tmds_rate_format_fallback [14:34:06] [PASSED] drm_test_check_output_bpc_crtc_mode_changed [14:34:06] [PASSED] drm_test_check_output_bpc_crtc_mode_not_changed [14:34:06] [PASSED] drm_test_check_output_bpc_dvi [14:34:06] [PASSED] drm_test_check_output_bpc_format_vic_1 [14:34:06] [PASSED] drm_test_check_output_bpc_format_display_8bpc_only [14:34:06] [PASSED] drm_test_check_output_bpc_format_display_rgb_only [14:34:06] [PASSED] drm_test_check_output_bpc_format_driver_8bpc_only [14:34:06] [PASSED] drm_test_check_output_bpc_format_driver_rgb_only [14:34:06] [PASSED] drm_test_check_tmds_char_rate_rgb_8bpc [14:34:06] [PASSED] drm_test_check_tmds_char_rate_rgb_10bpc [14:34:06] [PASSED] drm_test_check_tmds_char_rate_rgb_12bpc [14:34:06] ===== [PASSED] drm_atomic_helper_connector_hdmi_check ====== [14:34:06] === drm_atomic_helper_connector_hdmi_reset (6 subtests) ==== [14:34:06] [PASSED] drm_test_check_broadcast_rgb_value [14:34:06] [PASSED] drm_test_check_bpc_8_value [14:34:06] [PASSED] drm_test_check_bpc_10_value [14:34:06] [PASSED] drm_test_check_bpc_12_value [14:34:06] [PASSED] drm_test_check_format_value [14:34:06] [PASSED] drm_test_check_tmds_char_value [14:34:06] ===== [PASSED] drm_atomic_helper_connector_hdmi_reset ====== [14:34:06] = drm_atomic_helper_connector_hdmi_mode_valid (4 subtests) = [14:34:06] [PASSED] drm_test_check_mode_valid [14:34:06] [PASSED] drm_test_check_mode_valid_reject [14:34:06] [PASSED] drm_test_check_mode_valid_reject_rate [14:34:06] [PASSED] drm_test_check_mode_valid_reject_max_clock [14:34:06] === [PASSED] drm_atomic_helper_connector_hdmi_mode_valid === [14:34:06] ================= drm_managed (2 subtests) ================= [14:34:06] [PASSED] drm_test_managed_release_action [14:34:06] [PASSED] drm_test_managed_run_action [14:34:06] =================== [PASSED] drm_managed =================== [14:34:06] =================== drm_mm (6 subtests) ==================== [14:34:06] [PASSED] drm_test_mm_init [14:34:06] [PASSED] drm_test_mm_debug [14:34:06] [PASSED] drm_test_mm_align32 [14:34:06] [PASSED] drm_test_mm_align64 [14:34:06] [PASSED] drm_test_mm_lowest [14:34:06] [PASSED] drm_test_mm_highest [14:34:06] ===================== [PASSED] drm_mm ====================== [14:34:06] ============= drm_modes_analog_tv (5 subtests) ============= [14:34:06] [PASSED] drm_test_modes_analog_tv_mono_576i [14:34:06] [PASSED] drm_test_modes_analog_tv_ntsc_480i [14:34:06] [PASSED] drm_test_modes_analog_tv_ntsc_480i_inlined [14:34:06] [PASSED] drm_test_modes_analog_tv_pal_576i [14:34:06] [PASSED] drm_test_modes_analog_tv_pal_576i_inlined [14:34:06] =============== [PASSED] drm_modes_analog_tv =============== [14:34:06] ============== drm_plane_helper (2 subtests) =============== [14:34:06] =============== drm_test_check_plane_state ================ [14:34:06] [PASSED] clipping_simple [14:34:06] [PASSED] clipping_rotate_reflect [14:34:06] [PASSED] positioning_simple [14:34:06] [PASSED] upscaling [14:34:06] [PASSED] downscaling [14:34:06] [PASSED] rounding1 [14:34:06] [PASSED] rounding2 [14:34:06] [PASSED] rounding3 [14:34:06] [PASSED] rounding4 [14:34:06] =========== [PASSED] drm_test_check_plane_state ============ [14:34:06] =========== drm_test_check_invalid_plane_state ============ [14:34:06] [PASSED] positioning_invalid [14:34:06] [PASSED] upscaling_invalid [14:34:06] [PASSED] downscaling_invalid [14:34:06] ======= [PASSED] drm_test_check_invalid_plane_state ======== [14:34:06] ================ [PASSED] drm_plane_helper ================= [14:34:06] ====== drm_connector_helper_tv_get_modes (1 subtest) ======= [14:34:06] ====== drm_test_connector_helper_tv_get_modes_check ======= [14:34:06] [PASSED] None [14:34:06] [PASSED] PAL [14:34:06] [PASSED] NTSC [14:34:06] [PASSED] Both, NTSC Default [14:34:06] [PASSED] Both, PAL Default [14:34:06] [PASSED] Both, NTSC Default, with PAL on command-line [14:34:06] [PASSED] Both, PAL Default, with NTSC on command-line [14:34:06] == [PASSED] drm_test_connector_helper_tv_get_modes_check === [14:34:06] ======== [PASSED] drm_connector_helper_tv_get_modes ======== [14:34:06] ================== drm_rect (9 subtests) =================== [14:34:06] [PASSED] drm_test_rect_clip_scaled_div_by_zero [14:34:06] [PASSED] drm_test_rect_clip_scaled_not_clipped [14:34:06] [PASSED] drm_test_rect_clip_scaled_clipped [14:34:06] [PASSED] drm_test_rect_clip_scaled_signed_vs_unsigned [14:34:06] ================= drm_test_rect_intersect ================= [14:34:06] [PASSED] top-left x bottom-right: 2x2+1+1 x 2x2+0+0 [14:34:06] [PASSED] top-right x bottom-left: 2x2+0+0 x 2x2+1-1 [14:34:06] [PASSED] bottom-left x top-right: 2x2+1-1 x 2x2+0+0 [14:34:06] [PASSED] bottom-right x top-left: 2x2+0+0 x 2x2+1+1 [14:34:06] [PASSED] right x left: 2x1+0+0 x 3x1+1+0 [14:34:06] [PASSED] left x right: 3x1+1+0 x 2x1+0+0 [14:34:06] [PASSED] up x bottom: 1x2+0+0 x 1x3+0-1 [14:34:06] [PASSED] bottom x up: 1x3+0-1 x 1x2+0+0 [14:34:06] [PASSED] touching corner: 1x1+0+0 x 2x2+1+1 [14:34:06] [PASSED] touching side: 1x1+0+0 x 1x1+1+0 [14:34:06] [PASSED] equal rects: 2x2+0+0 x 2x2+0+0 [14:34:06] [PASSED] inside another: 2x2+0+0 x 1x1+1+1 [14:34:06] [PASSED] far away: 1x1+0+0 x 1x1+3+6 [14:34:06] [PASSED] points intersecting: 0x0+5+10 x 0x0+5+10 [14:34:06] [PASSED] points not intersecting: 0x0+0+0 x 0x0+5+10 [14:34:06] ============= [PASSED] drm_test_rect_intersect ============= [14:34:06] ================ drm_test_rect_calc_hscale ================ [14:34:06] [PASSED] normal use [14:34:06] [PASSED] out of max range [14:34:06] [PASSED] out of min range [14:34:06] [PASSED] zero dst [14:34:06] [PASSED] negative src [14:34:06] [PASSED] negative dst [14:34:06] ============ [PASSED] drm_test_rect_calc_hscale ============ [14:34:06] ================ drm_test_rect_calc_vscale ================ [14:34:06] [PASSED] normal use [14:34:06] [PASSED] out of max range [14:34:06] [PASSED] out of min range [14:34:06] [PASSED] zero dst [14:34:06] [PASSED] negative src [14:34:06] [PASSED] negative dst [14:34:06] ============ [PASSED] drm_test_rect_calc_vscale ============ [14:34:06] ================== drm_test_rect_rotate =================== [14:34:06] [PASSED] reflect-x [14:34:06] [PASSED] reflect-y [14:34:06] [PASSED] rotate-0 [14:34:06] [PASSED] rotate-90 [14:34:06] [PASSED] rotate-180 [14:34:06] [PASSED] rotate-270 stty: 'standard input': Inappropriate ioctl for device [14:34:06] ============== [PASSED] drm_test_rect_rotate =============== [14:34:06] ================ drm_test_rect_rotate_inv ================= [14:34:06] [PASSED] reflect-x [14:34:06] [PASSED] reflect-y [14:34:06] [PASSED] rotate-0 [14:34:06] [PASSED] rotate-90 [14:34:06] [PASSED] rotate-180 [14:34:06] [PASSED] rotate-270 [14:34:06] ============ [PASSED] drm_test_rect_rotate_inv ============= [14:34:06] ==================== [PASSED] drm_rect ===================== [14:34:06] ============================================================ [14:34:06] Testing complete. Ran 598 tests: passed: 598 [14:34:06] Elapsed time: 22.494s total, 1.680s configuring, 20.644s building, 0.138s running
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/ttm/tests/.kunitconfig [14:34:06] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [14:34:08] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json ARCH=um O=.kunit --jobs=48 [14:34:16] Starting KUnit Kernel (1/1)... [14:34:16] ============================================================ Running tests with: $ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [14:34:16] ================= ttm_device (5 subtests) ================== [14:34:16] [PASSED] ttm_device_init_basic [14:34:16] [PASSED] ttm_device_init_multiple [14:34:16] [PASSED] ttm_device_fini_basic [14:34:16] [PASSED] ttm_device_init_no_vma_man [14:34:16] ================== ttm_device_init_pools ================== [14:34:16] [PASSED] No DMA allocations, no DMA32 required [14:34:16] [PASSED] DMA allocations, DMA32 required [14:34:16] [PASSED] No DMA allocations, DMA32 required [14:34:16] [PASSED] DMA allocations, no DMA32 required [14:34:16] ============== [PASSED] ttm_device_init_pools ============== [14:34:16] =================== [PASSED] ttm_device ==================== [14:34:16] ================== ttm_pool (8 subtests) =================== [14:34:16] ================== ttm_pool_alloc_basic =================== [14:34:16] [PASSED] One page [14:34:16] [PASSED] More than one page [14:34:16] [PASSED] Above the allocation limit [14:34:16] [PASSED] One page, with coherent DMA mappings enabled [14:34:16] [PASSED] Above the allocation limit, with coherent DMA mappings enabled [14:34:16] ============== [PASSED] ttm_pool_alloc_basic =============== [14:34:16] ============== ttm_pool_alloc_basic_dma_addr ============== [14:34:16] [PASSED] One page [14:34:16] [PASSED] More than one page [14:34:16] [PASSED] Above the allocation limit [14:34:16] [PASSED] One page, with coherent DMA mappings enabled [14:34:16] [PASSED] Above the allocation limit, with coherent DMA mappings enabled [14:34:16] ========== [PASSED] ttm_pool_alloc_basic_dma_addr ========== [14:34:16] [PASSED] ttm_pool_alloc_order_caching_match [14:34:16] [PASSED] ttm_pool_alloc_caching_mismatch [14:34:16] [PASSED] ttm_pool_alloc_order_mismatch [14:34:16] [PASSED] ttm_pool_free_dma_alloc [14:34:16] [PASSED] ttm_pool_free_no_dma_alloc [14:34:16] [PASSED] ttm_pool_fini_basic [14:34:16] ==================== [PASSED] ttm_pool ===================== [14:34:16] ================ ttm_resource (8 subtests) ================= [14:34:16] ================= ttm_resource_init_basic ================= [14:34:16] [PASSED] Init resource in TTM_PL_SYSTEM [14:34:16] [PASSED] Init resource in TTM_PL_VRAM [14:34:16] [PASSED] Init resource in a private placement [14:34:16] [PASSED] Init resource in TTM_PL_SYSTEM, set placement flags [14:34:16] ============= [PASSED] ttm_resource_init_basic ============= [14:34:16] [PASSED] ttm_resource_init_pinned [14:34:16] [PASSED] ttm_resource_fini_basic [14:34:16] [PASSED] ttm_resource_manager_init_basic [14:34:16] [PASSED] ttm_resource_manager_usage_basic [14:34:16] [PASSED] ttm_resource_manager_set_used_basic [14:34:16] [PASSED] ttm_sys_man_alloc_basic [14:34:16] [PASSED] ttm_sys_man_free_basic [14:34:16] ================== [PASSED] ttm_resource =================== [14:34:16] =================== ttm_tt (15 subtests) =================== [14:34:16] ==================== ttm_tt_init_basic ==================== [14:34:16] [PASSED] Page-aligned size [14:34:16] [PASSED] Extra pages requested [14:34:16] ================ [PASSED] ttm_tt_init_basic ================ [14:34:16] [PASSED] ttm_tt_init_misaligned [14:34:16] [PASSED] ttm_tt_fini_basic [14:34:16] [PASSED] ttm_tt_fini_sg [14:34:16] [PASSED] ttm_tt_fini_shmem [14:34:16] [PASSED] ttm_tt_create_basic [14:34:16] [PASSED] ttm_tt_create_invalid_bo_type [14:34:16] [PASSED] ttm_tt_create_ttm_exists [14:34:16] [PASSED] ttm_tt_create_failed [14:34:16] [PASSED] ttm_tt_destroy_basic [14:34:16] [PASSED] ttm_tt_populate_null_ttm [14:34:16] [PASSED] ttm_tt_populate_populated_ttm [14:34:16] [PASSED] ttm_tt_unpopulate_basic [14:34:16] [PASSED] ttm_tt_unpopulate_empty_ttm [14:34:16] [PASSED] ttm_tt_swapin_basic [14:34:16] ===================== [PASSED] ttm_tt ====================== [14:34:16] =================== ttm_bo (14 subtests) =================== [14:34:16] =========== ttm_bo_reserve_optimistic_no_ticket =========== [14:34:16] [PASSED] Cannot be interrupted and sleeps [14:34:16] [PASSED] Cannot be interrupted, locks straight away [14:34:16] [PASSED] Can be interrupted, sleeps [14:34:16] ======= [PASSED] ttm_bo_reserve_optimistic_no_ticket ======= [14:34:16] [PASSED] ttm_bo_reserve_locked_no_sleep [14:34:16] [PASSED] ttm_bo_reserve_no_wait_ticket [14:34:16] [PASSED] ttm_bo_reserve_double_resv [14:34:16] [PASSED] ttm_bo_reserve_interrupted [14:34:16] [PASSED] ttm_bo_reserve_deadlock [14:34:16] [PASSED] ttm_bo_unreserve_basic [14:34:16] [PASSED] ttm_bo_unreserve_pinned [14:34:16] [PASSED] ttm_bo_unreserve_bulk [14:34:16] [PASSED] ttm_bo_put_basic [14:34:16] [PASSED] ttm_bo_put_shared_resv [14:34:16] [PASSED] ttm_bo_pin_basic [14:34:16] [PASSED] ttm_bo_pin_unpin_resource [14:34:16] [PASSED] ttm_bo_multiple_pin_one_unpin [14:34:16] ===================== [PASSED] ttm_bo ====================== [14:34:16] ============== ttm_bo_validate (22 subtests) =============== [14:34:16] ============== ttm_bo_init_reserved_sys_man =============== [14:34:16] [PASSED] Buffer object for userspace [14:34:16] [PASSED] Kernel buffer object [14:34:16] [PASSED] Shared buffer object [14:34:16] ========== [PASSED] ttm_bo_init_reserved_sys_man =========== [14:34:16] ============== ttm_bo_init_reserved_mock_man ============== [14:34:16] [PASSED] Buffer object for userspace [14:34:16] [PASSED] Kernel buffer object [14:34:16] [PASSED] Shared buffer object [14:34:16] ========== [PASSED] ttm_bo_init_reserved_mock_man ========== [14:34:16] [PASSED] ttm_bo_init_reserved_resv [14:34:16] ================== ttm_bo_validate_basic ================== [14:34:16] [PASSED] Buffer object for userspace [14:34:16] [PASSED] Kernel buffer object [14:34:16] [PASSED] Shared buffer object [14:34:16] ============== [PASSED] ttm_bo_validate_basic ============== [14:34:16] [PASSED] ttm_bo_validate_invalid_placement [14:34:16] ============= ttm_bo_validate_same_placement ============== [14:34:16] [PASSED] System manager [14:34:16] [PASSED] VRAM manager [14:34:16] ========= [PASSED] ttm_bo_validate_same_placement ========== [14:34:16] [PASSED] ttm_bo_validate_failed_alloc [14:34:16] [PASSED] ttm_bo_validate_pinned [14:34:16] [PASSED] ttm_bo_validate_busy_placement [14:34:16] ================ ttm_bo_validate_multihop ================= [14:34:16] [PASSED] Buffer object for userspace [14:34:16] [PASSED] Kernel buffer object [14:34:16] [PASSED] Shared buffer object [14:34:16] ============ [PASSED] ttm_bo_validate_multihop ============= [14:34:16] ========== ttm_bo_validate_no_placement_signaled ========== [14:34:16] [PASSED] Buffer object in system domain, no page vector [14:34:16] [PASSED] Buffer object in system domain with an existing page vector [14:34:16] ====== [PASSED] ttm_bo_validate_no_placement_signaled ====== [14:34:16] ======== ttm_bo_validate_no_placement_not_signaled ======== [14:34:16] [PASSED] Buffer object for userspace [14:34:16] [PASSED] Kernel buffer object [14:34:16] [PASSED] Shared buffer object [14:34:16] ==== [PASSED] ttm_bo_validate_no_placement_not_signaled ==== [14:34:16] [PASSED] ttm_bo_validate_move_fence_signaled [14:34:16] ========= ttm_bo_validate_move_fence_not_signaled ========= [14:34:16] [PASSED] Waits for GPU [14:34:16] [PASSED] Tries to lock straight away [14:34:16] ===== [PASSED] ttm_bo_validate_move_fence_not_signaled ===== [14:34:16] [PASSED] ttm_bo_validate_swapout [14:34:16] [PASSED] ttm_bo_validate_happy_evict [14:34:16] [PASSED] ttm_bo_validate_all_pinned_evict [14:34:16] [PASSED] ttm_bo_validate_allowed_only_evict [14:34:16] [PASSED] ttm_bo_validate_deleted_evict [14:34:16] [PASSED] ttm_bo_validate_busy_domain_evict [14:34:16] [PASSED] ttm_bo_validate_evict_gutting [14:34:16] [PASSED] ttm_bo_validate_recrusive_evict stty: 'standard input': Inappropriate ioctl for device [14:34:16] ================= [PASSED] ttm_bo_validate ================= [14:34:16] ============================================================ [14:34:16] Testing complete. Ran 102 tests: passed: 102 [14:34:16] Elapsed time: 9.921s total, 1.655s configuring, 7.598s building, 0.539s running
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel
Patchwork
CI✓ CI.Build: success for Add support for EU stall sampling
In reply to Harish Chegondi== Series Details ==
== Series Details ==
Series: Add support for EU stall sampling
URL : https://patchwork.freedesktop.org/series/144609/
State : success
== Summary ==
lib/modules/6.14.0-rc2-xe+/kernel/arch/x86/events/amd/ lib/modules/6.14.0-rc2-xe+/kernel/arch/x86/events/amd/amd-uncore.ko lib/modules/6.14.0-rc2-xe+/kernel/arch/x86/events/rapl.ko lib/modules/6.14.0-rc2-xe+/kernel/arch/x86/kvm/ lib/modules/6.14.0-rc2-xe+/kernel/arch/x86/kvm/kvm.ko lib/modules/6.14.0-rc2-xe+/kernel/arch/x86/kvm/kvm-intel.ko lib/modules/6.14.0-rc2-xe+/kernel/arch/x86/kvm/kvm-amd.ko lib/modules/6.14.0-rc2-xe+/kernel/kernel/ lib/modules/6.14.0-rc2-xe+/kernel/kernel/kheaders.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/ lib/modules/6.14.0-rc2-xe+/kernel/crypto/ecrdsa_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/xcbc.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/serpent_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/aria_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/crypto_simd.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/adiantum.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/tcrypt.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/crypto_engine.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/zstd.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/asymmetric_keys/ lib/modules/6.14.0-rc2-xe+/kernel/crypto/asymmetric_keys/pkcs7_test_key.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/asymmetric_keys/pkcs8_key_parser.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/des_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/xctr.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/authenc.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/sm4_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/camellia_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/sm3.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/pcrypt.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/aegis128.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/af_alg.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/algif_aead.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/cmac.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/sm3_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/aes_ti.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/chacha_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/poly1305_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/nhpoly1305.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/crc32_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/essiv.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/ccm.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/wp512.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/streebog_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/authencesn.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/echainiv.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/lrw.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/cryptd.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/crypto_user.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/algif_hash.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/polyval-generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/hctr2.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/842.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/pcbc.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/ansi_cprng.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/cast6_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/twofish_common.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/twofish_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/lz4hc.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/blowfish_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/md4.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/chacha20poly1305.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/curve25519-generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/lz4.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/rmd160.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/algif_skcipher.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/cast5_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/fcrypt.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/ecdsa_generic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/sm4.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/cast_common.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/blowfish_common.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/michael_mic.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/async_tx/ lib/modules/6.14.0-rc2-xe+/kernel/crypto/async_tx/async_xor.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/async_tx/async_tx.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/async_tx/async_memcpy.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/async_tx/async_pq.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/async_tx/async_raid6_recov.ko lib/modules/6.14.0-rc2-xe+/kernel/crypto/algif_rng.ko lib/modules/6.14.0-rc2-xe+/kernel/block/ lib/modules/6.14.0-rc2-xe+/kernel/block/bfq.ko lib/modules/6.14.0-rc2-xe+/kernel/block/kyber-iosched.ko lib/modules/6.14.0-rc2-xe+/build lib/modules/6.14.0-rc2-xe+/modules.alias.bin lib/modules/6.14.0-rc2-xe+/modules.builtin lib/modules/6.14.0-rc2-xe+/modules.softdep lib/modules/6.14.0-rc2-xe+/modules.alias lib/modules/6.14.0-rc2-xe+/modules.order lib/modules/6.14.0-rc2-xe+/modules.symbols lib/modules/6.14.0-rc2-xe+/modules.dep.bin
+ mv kernel-nodebug.tar.gz ..
+ cd ..
+ rm -rf archive
++ date +%s
+ echo -e '\e[0Ksection_end:1739199039:package_x86_64_nodebug\r\e[0K' [0Ksection_end:1739199039:package_x86_64_nodebug
[0K
+ sync
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel