Skip to content

Commit e04dac1

Browse files
committed
drm/xe/oa/uapi: Expose media OA units
On Xe2+ platforms, media engines are attached to "SCMI" OA media (OAM) units. One or more SCMI OAM units might be present on a platform. In addition there is another OAM unit for global events, called OAM-SAG. Performance metrics for media workloads can be obtained from these OAM units, similar to OAG. Expose these OAM units for userspace to use. OAM-SAG is exposed as an OA unit without any attached engines. Bspec: 70819, 67103, 63844, 72572, 74476, 61284 v2: Fix xe_gt_WARN_ON in __hwe_oam_unit for < 12.7 platforms v3: Return XE_OA_UNIT_INVALID for < 12.7 to indicate no OAM units v4: Move xe_oa_print_oa_units() to separate patch v5: Introduce DRM_XE_OA_UNIT_TYPE_OAM_SAG v6: Introduce DRM_XE_OA_CAPS_OAM Signed-off-by: Ashutosh Dixit <[email protected]> Reviewed-by: Umesh Nerlige Ramappa <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2e273e4 commit e04dac1

File tree

3 files changed

+57
-19
lines changed

3 files changed

+57
-19
lines changed

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
#define DEFAULT_POLL_PERIOD_NS (NSEC_PER_SEC / DEFAULT_POLL_FREQUENCY_HZ)
4444
#define XE_OA_UNIT_INVALID U32_MAX
4545

46+
enum xe_oam_unit_type {
47+
XE_OAM_UNIT_SAG,
48+
XE_OAM_UNIT_SCMI_0,
49+
XE_OAM_UNIT_SCMI_1,
50+
};
51+
4652
enum xe_oa_submit_deps {
4753
XE_OA_SUBMIT_NO_DEPS,
4854
XE_OA_SUBMIT_ADD_DEPS,
@@ -1881,6 +1887,7 @@ static bool engine_supports_oa_format(const struct xe_hw_engine *hwe, int type)
18811887
return type == DRM_XE_OA_FMT_TYPE_OAG || type == DRM_XE_OA_FMT_TYPE_OAR ||
18821888
type == DRM_XE_OA_FMT_TYPE_OAC || type == DRM_XE_OA_FMT_TYPE_PEC;
18831889
case DRM_XE_OA_UNIT_TYPE_OAM:
1890+
case DRM_XE_OA_UNIT_TYPE_OAM_SAG:
18841891
return type == DRM_XE_OA_FMT_TYPE_OAM || type == DRM_XE_OA_FMT_TYPE_OAM_MPEC;
18851892
default:
18861893
return false;
@@ -2448,20 +2455,38 @@ int xe_oa_register(struct xe_device *xe)
24482455

24492456
static u32 num_oa_units_per_gt(struct xe_gt *gt)
24502457
{
2451-
return 1;
2458+
if (!xe_gt_is_media_type(gt) || GRAPHICS_VER(gt_to_xe(gt)) < 20)
2459+
return 1;
2460+
else if (!IS_DGFX(gt_to_xe(gt)))
2461+
return XE_OAM_UNIT_SCMI_0 + 1; /* SAG + SCMI_0 */
2462+
else
2463+
return XE_OAM_UNIT_SCMI_1 + 1; /* SAG + SCMI_0 + SCMI_1 */
24522464
}
24532465

24542466
static u32 __hwe_oam_unit(struct xe_hw_engine *hwe)
24552467
{
2456-
if (GRAPHICS_VERx100(gt_to_xe(hwe->gt)) >= 1270) {
2457-
/*
2458-
* There's 1 SAMEDIA gt and 1 OAM per SAMEDIA gt. All media slices
2459-
* within the gt use the same OAM. All MTL/LNL SKUs list 1 SA MEDIA
2460-
*/
2461-
xe_gt_WARN_ON(hwe->gt, hwe->gt->info.type != XE_GT_TYPE_MEDIA);
2468+
if (GRAPHICS_VERx100(gt_to_xe(hwe->gt)) < 1270)
2469+
return XE_OA_UNIT_INVALID;
24622470

2471+
xe_gt_WARN_ON(hwe->gt, !xe_gt_is_media_type(hwe->gt));
2472+
2473+
if (GRAPHICS_VER(gt_to_xe(hwe->gt)) < 20)
24632474
return 0;
2464-
}
2475+
/*
2476+
* XE_OAM_UNIT_SAG has only GSCCS attached to it, but only on some platforms. Also
2477+
* GSCCS cannot be used to submit batches to program the OAM unit. Therefore we don't
2478+
* assign an OA unit to GSCCS. This means that XE_OAM_UNIT_SAG is exposed as an OA
2479+
* unit without attached engines. Fused off engines can also result in oa_unit's with
2480+
* num_engines == 0. OA streams can be opened on all OA units.
2481+
*/
2482+
else if (hwe->engine_id == XE_HW_ENGINE_GSCCS0)
2483+
return XE_OA_UNIT_INVALID;
2484+
else if (!IS_DGFX(gt_to_xe(hwe->gt)))
2485+
return XE_OAM_UNIT_SCMI_0;
2486+
else if (hwe->class == XE_ENGINE_CLASS_VIDEO_DECODE)
2487+
return (hwe->instance / 2 & 0x1) + 1;
2488+
else if (hwe->class == XE_ENGINE_CLASS_VIDEO_ENHANCE)
2489+
return (hwe->instance & 0x1) + 1;
24652490

24662491
return XE_OA_UNIT_INVALID;
24672492
}
@@ -2475,6 +2500,7 @@ static u32 __hwe_oa_unit(struct xe_hw_engine *hwe)
24752500

24762501
case XE_ENGINE_CLASS_VIDEO_DECODE:
24772502
case XE_ENGINE_CLASS_VIDEO_ENHANCE:
2503+
case XE_ENGINE_CLASS_OTHER:
24782504
return __hwe_oam_unit(hwe);
24792505

24802506
default:
@@ -2514,18 +2540,25 @@ static struct xe_oa_regs __oag_regs(void)
25142540

25152541
static void __xe_oa_init_oa_units(struct xe_gt *gt)
25162542
{
2517-
const u32 mtl_oa_base[] = { 0x13000 };
2543+
/* Actual address is MEDIA_GT_GSI_OFFSET + oam_base_addr[i] */
2544+
const u32 oam_base_addr[] = {
2545+
[XE_OAM_UNIT_SAG] = 0x13000,
2546+
[XE_OAM_UNIT_SCMI_0] = 0x14000,
2547+
[XE_OAM_UNIT_SCMI_1] = 0x14800,
2548+
};
25182549
int i, num_units = gt->oa.num_oa_units;
25192550

25202551
for (i = 0; i < num_units; i++) {
25212552
struct xe_oa_unit *u = &gt->oa.oa_unit[i];
25222553

2523-
if (gt->info.type != XE_GT_TYPE_MEDIA) {
2554+
if (!xe_gt_is_media_type(gt)) {
25242555
u->regs = __oag_regs();
25252556
u->type = DRM_XE_OA_UNIT_TYPE_OAG;
2526-
} else if (GRAPHICS_VERx100(gt_to_xe(gt)) >= 1270) {
2527-
u->regs = __oam_regs(mtl_oa_base[i]);
2528-
u->type = DRM_XE_OA_UNIT_TYPE_OAM;
2557+
} else {
2558+
xe_gt_assert(gt, GRAPHICS_VERx100(gt_to_xe(gt)) >= 1270);
2559+
u->regs = __oam_regs(oam_base_addr[i]);
2560+
u->type = i == XE_OAM_UNIT_SAG && GRAPHICS_VER(gt_to_xe(gt)) >= 20 ?
2561+
DRM_XE_OA_UNIT_TYPE_OAM_SAG : DRM_XE_OA_UNIT_TYPE_OAM;
25292562
}
25302563

25312564
xe_mmio_write32(&gt->mmio, u->regs.oa_ctrl, 0);
@@ -2560,10 +2593,6 @@ static int xe_oa_init_gt(struct xe_gt *gt)
25602593
}
25612594
}
25622595

2563-
/*
2564-
* Fused off engines can result in oa_unit's with num_engines == 0. These units
2565-
* will appear in OA unit query, but no OA streams can be opened on them.
2566-
*/
25672596
gt->oa.num_oa_units = num_oa_units;
25682597
gt->oa.oa_unit = u;
25692598

@@ -2579,6 +2608,11 @@ static int xe_oa_init_oa_units(struct xe_oa *oa)
25792608
struct xe_gt *gt;
25802609
int i, ret;
25812610

2611+
/* Needed for OAM implementation here */
2612+
BUILD_BUG_ON(XE_OAM_UNIT_SAG != 0);
2613+
BUILD_BUG_ON(XE_OAM_UNIT_SCMI_0 != 1);
2614+
BUILD_BUG_ON(XE_OAM_UNIT_SCMI_1 != 2);
2615+
25822616
for_each_gt(gt, oa->xe, i) {
25832617
ret = xe_oa_init_gt(gt);
25842618
if (ret)

drivers/gpu/drm/xe/xe_query.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,8 +683,8 @@ static int query_oa_units(struct xe_device *xe,
683683
du->oa_timestamp_freq = xe_oa_timestamp_frequency(gt);
684684
du->capabilities = DRM_XE_OA_CAPS_BASE | DRM_XE_OA_CAPS_SYNCS |
685685
DRM_XE_OA_CAPS_OA_BUFFER_SIZE |
686-
DRM_XE_OA_CAPS_WAIT_NUM_REPORTS;
687-
686+
DRM_XE_OA_CAPS_WAIT_NUM_REPORTS |
687+
DRM_XE_OA_CAPS_OAM;
688688
j = 0;
689689
for_each_hw_engine(hwe, gt, hwe_id) {
690690
if (!xe_hw_engine_is_reserved(hwe) &&

include/uapi/drm/xe_drm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,6 +1617,9 @@ enum drm_xe_oa_unit_type {
16171617

16181618
/** @DRM_XE_OA_UNIT_TYPE_OAM: OAM OA unit */
16191619
DRM_XE_OA_UNIT_TYPE_OAM,
1620+
1621+
/** @DRM_XE_OA_UNIT_TYPE_OAM_SAG: OAM_SAG OA unit */
1622+
DRM_XE_OA_UNIT_TYPE_OAM_SAG,
16201623
};
16211624

16221625
/**
@@ -1638,6 +1641,7 @@ struct drm_xe_oa_unit {
16381641
#define DRM_XE_OA_CAPS_SYNCS (1 << 1)
16391642
#define DRM_XE_OA_CAPS_OA_BUFFER_SIZE (1 << 2)
16401643
#define DRM_XE_OA_CAPS_WAIT_NUM_REPORTS (1 << 3)
1644+
#define DRM_XE_OA_CAPS_OAM (1 << 4)
16411645

16421646
/** @oa_timestamp_freq: OA timestamp freq */
16431647
__u64 oa_timestamp_freq;

0 commit comments

Comments
 (0)