Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xe KMD: Half-full OA Buffer interrupt support #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion external/drm/xe_drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
};

/**
Expand Down
2 changes: 1 addition & 1 deletion inc/common/instrumentation/api/metrics_discovery_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
15 changes: 15 additions & 0 deletions instrumentation/metrics_discovery/linux/md_driver_ifc_linux_xe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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] );
}

Expand Down Expand Up @@ -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<uint64_t>( properties );
Expand Down