diff --git a/external/drm/xe_drm.h b/external/drm/xe_drm.h index b6fbe49..e3c4de2 100644 --- a/external/drm/xe_drm.h +++ b/external/drm/xe_drm.h @@ -512,7 +512,9 @@ struct drm_xe_query_gt_list { * containing the following in mask: * ``DSS_COMPUTE ff ff ff ff 00 00 00 00`` * means 32 DSS are available for compute. - * - %DRM_XE_TOPO_L3_BANK - To query the mask of enabled L3 banks + * - %DRM_XE_TOPO_L3_BANK - To query the mask of enabled L3 banks. This type + * may be omitted if the driver is unable to query the mask from the + * hardware. * - %DRM_XE_TOPO_EU_PER_DSS - To query the mask of Execution Units (EU) * available per Dual Sub Slices (DSS). For example a query response * containing the following in mask: @@ -1483,6 +1485,9 @@ struct drm_xe_oa_unit { /** @capabilities: OA capabilities bit-mask */ __u64 capabilities; #define DRM_XE_OA_CAPS_BASE (1 << 0) +#define DRM_XE_OA_CAPS_SYNCS (1 << 1) +#define DRM_XE_OA_CAPS_OA_BUFFER_SIZE (1 << 2) +#define DRM_XE_OA_CAPS_WAIT_NUM_REPORTS ( 1 << 3 ) /** @oa_timestamp_freq: OA timestamp freq */ __u64 oa_timestamp_freq; @@ -1632,6 +1637,36 @@ enum drm_xe_oa_property_id { * to be disabled for the stream exec queue. */ DRM_XE_OA_PROPERTY_NO_PREEMPT, + + /** + * @DRM_XE_OA_PROPERTY_NUM_SYNCS: Number of syncs in the sync array + * specified in @DRM_XE_OA_PROPERTY_SYNCS + */ + DRM_XE_OA_PROPERTY_NUM_SYNCS, + + /** + * @DRM_XE_OA_PROPERTY_SYNCS: Pointer to struct @drm_xe_sync array + * with array size specified via @DRM_XE_OA_PROPERTY_NUM_SYNCS. OA + * configuration will wait till input fences signal. Output fences + * will signal after the new OA configuration takes effect. For + * @DRM_XE_SYNC_TYPE_USER_FENCE, @addr is a user pointer, similar + * to the VM bind case. + */ + DRM_XE_OA_PROPERTY_SYNCS, + + /** + * @DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE: Size of OA buffer to be + * allocated by the driver in bytes. Supported sizes are powers of + * 2 from 128 KiB to 128 MiB. When not specified, a 16 MiB OA + * buffer is allocated by default. + */ + DRM_XE_OA_PROPERTY_OA_BUFFER_SIZE, + + /** + * @DRM_XE_OA_PROPERTY_WAIT_NUM_REPORTS: Number of reports to wait + * for before unblocking poll or read + */ + DRM_XE_OA_PROPERTY_WAIT_NUM_REPORTS, }; /** diff --git a/inc/common/instrumentation/api/metrics_discovery_api.h b/inc/common/instrumentation/api/metrics_discovery_api.h index fbdf961..969ee65 100644 --- a/inc/common/instrumentation/api/metrics_discovery_api.h +++ b/inc/common/instrumentation/api/metrics_discovery_api.h @@ -37,7 +37,7 @@ SPDX-License-Identifier: MIT ////////////////////////////////////////////////////////////////////////////////// // API build number: ////////////////////////////////////////////////////////////////////////////////// -#define MD_API_BUILD_NUMBER_CURRENT 179 +#define MD_API_BUILD_NUMBER_CURRENT 180 namespace MetricsDiscovery { diff --git a/instrumentation/metrics_discovery/linux/inc/md_driver_ifc_linux_xe.h b/instrumentation/metrics_discovery/linux/inc/md_driver_ifc_linux_xe.h index c6af8c9..6ca087f 100644 --- a/instrumentation/metrics_discovery/linux/inc/md_driver_ifc_linux_xe.h +++ b/instrumentation/metrics_discovery/linux/inc/md_driver_ifc_linux_xe.h @@ -25,6 +25,20 @@ using namespace MetricsDiscovery; namespace MetricsDiscoveryInternal { + ////////////////////////////////////////////////////////////////////////////// + // + // Struct: + // SXeObservationCapabilities + // + // Description: + // A structure holding information about Xe observation features support in kernel. + // + ////////////////////////////////////////////////////////////////////////////// + typedef struct SXeObservationCapabilities + { + bool IsOaNotifyNumReportsSupported; + } TXeObservationCapabilities; + ////////////////////////////////////////////////////////////////////////////// // // Class: @@ -104,4 +118,6 @@ namespace MetricsDiscoveryInternal virtual TCompletionCode GetCopyEngineMask( CMetricsDevice& metricsDevice, uint64_t& copyEngineMask ); }; + TXeObservationCapabilities m_xeObservationCapabilities; // Information about Xe observation features supported in current kernel + } // namespace MetricsDiscoveryInternal diff --git a/instrumentation/metrics_discovery/linux/md_driver_ifc_linux_xe.cpp b/instrumentation/metrics_discovery/linux/md_driver_ifc_linux_xe.cpp index b665e05..18ecaec 100644 --- a/instrumentation/metrics_discovery/linux/md_driver_ifc_linux_xe.cpp +++ b/instrumentation/metrics_discovery/linux/md_driver_ifc_linux_xe.cpp @@ -386,6 +386,11 @@ namespace MetricsDiscoveryInternal engines.emplace_back( oaUnit.oa_unit_id, oaUnit.eci[j] ); } + if( oaUnit.oa_unit_type == DRM_XE_OA_UNIT_TYPE_OAG ) + { + m_xeObservationCapabilities.IsOaNotifyNumReportsSupported = oaUnit.capabilities & DRM_XE_OA_CAPS_WAIT_NUM_REPORTS; + } + oaUnitOffset += sizeof( oaUnit ) + oaUnit.num_engines * sizeof( oaUnit.eci[0] ); } @@ -533,6 +538,16 @@ namespace MetricsDiscoveryInternal addProperty( DRM_XE_OA_PROPERTY_OA_FORMAT, oaReportType ); addProperty( DRM_XE_OA_PROPERTY_OA_PERIOD_EXPONENT, timerPeriodExponent ); + // Half-full buffer interrupt. + if( m_xeObservationCapabilities.IsOaNotifyNumReportsSupported ) + { + const uint32_t halfSizeInReports = bufferSize / 2 / oaReportSize; + + addProperty( DRM_XE_OA_PROPERTY_WAIT_NUM_REPORTS, halfSizeInReports ); + + MD_LOG_A( m_adapterId, LOG_DEBUG, "Number of reports KMD needs to wait before unblocking is %u", halfSizeInReports ); + } + param.observation_type = DRM_XE_OBSERVATION_TYPE_OA; param.observation_op = DRM_XE_OBSERVATION_OP_STREAM_OPEN; param.param = reinterpret_cast( properties );