Skip to content

Commit 10d42ef

Browse files
committed
drm/xe/oa: Assign hwe for OAM_SAG
Because OAM_SAG doesn't have an attached hwe, assign another hwe belonging to the same gt (and different OAM unit) to OAM_SAG. A hwe is needed for batch submissions to program OA HW. v2: Assign an engine with a valid OA unit for OAM_SAG (Umesh) Signed-off-by: Ashutosh Dixit <[email protected]> Reviewed-by: Umesh Nerlige Ramappa <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2d1fcec commit 10d42ef

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,37 +1923,48 @@ u16 xe_oa_unit_id(struct xe_hw_engine *hwe)
19231923
hwe->oa_unit->oa_unit_id : U16_MAX;
19241924
}
19251925

1926+
/* A hwe must be assigned to stream/oa_unit for batch submissions */
19261927
static int xe_oa_assign_hwe(struct xe_oa *oa, struct xe_oa_open_param *param)
19271928
{
1928-
struct xe_gt *gt;
1929-
int i, ret = 0;
1929+
struct xe_hw_engine *hwe;
1930+
enum xe_hw_engine_id id;
1931+
int ret = 0;
1932+
1933+
/* If not provided, OA unit defaults to OA unit 0 as per uapi */
1934+
if (!param->oa_unit)
1935+
param->oa_unit = &xe_device_get_gt(oa->xe, 0)->oa.oa_unit[0];
19301936

1937+
/* When we have an exec_q, get hwe from the exec_q */
19311938
if (param->exec_q) {
1932-
/* When we have an exec_q, get hwe from the exec_q */
19331939
param->hwe = xe_gt_hw_engine(param->exec_q->gt, param->exec_q->class,
19341940
param->engine_instance, true);
1935-
} else {
1936-
struct xe_hw_engine *hwe;
1937-
enum xe_hw_engine_id id;
1938-
1939-
/* Else just get the first hwe attached to the oa unit */
1940-
for_each_gt(gt, oa->xe, i) {
1941-
for_each_hw_engine(hwe, gt, id) {
1942-
if (hwe->oa_unit == param->oa_unit) {
1943-
param->hwe = hwe;
1944-
goto out;
1945-
}
1946-
}
1947-
}
1941+
if (!param->hwe || param->hwe->oa_unit != param->oa_unit)
1942+
goto err;
1943+
goto out;
19481944
}
1949-
out:
1950-
if (!param->hwe || param->hwe->oa_unit != param->oa_unit) {
1951-
drm_dbg(&oa->xe->drm, "Unable to find hwe (%d, %d) for OA unit ID %d\n",
1952-
param->exec_q ? param->exec_q->class : -1,
1953-
param->engine_instance, param->oa_unit->oa_unit_id);
1954-
ret = -EINVAL;
1945+
1946+
/* Else just get the first hwe attached to the oa unit */
1947+
for_each_hw_engine(hwe, param->oa_unit->gt, id) {
1948+
if (hwe->oa_unit == param->oa_unit) {
1949+
param->hwe = hwe;
1950+
goto out;
1951+
}
19551952
}
19561953

1954+
/* If we still didn't find a hwe, just get one with a valid oa_unit from the same gt */
1955+
for_each_hw_engine(hwe, param->oa_unit->gt, id) {
1956+
if (!hwe->oa_unit)
1957+
continue;
1958+
1959+
param->hwe = hwe;
1960+
goto out;
1961+
}
1962+
err:
1963+
drm_dbg(&oa->xe->drm, "Unable to find hwe (%d, %d) for OA unit ID %d\n",
1964+
param->exec_q ? param->exec_q->class : -1,
1965+
param->engine_instance, param->oa_unit->oa_unit_id);
1966+
ret = -EINVAL;
1967+
out:
19571968
return ret;
19581969
}
19591970

@@ -2578,6 +2589,8 @@ static void __xe_oa_init_oa_units(struct xe_gt *gt)
25782589
DRM_XE_OA_UNIT_TYPE_OAM_SAG : DRM_XE_OA_UNIT_TYPE_OAM;
25792590
}
25802591

2592+
u->gt = gt;
2593+
25812594
xe_mmio_write32(&gt->mmio, u->regs.oa_ctrl, 0);
25822595

25832596
/* Ensure MMIO trigger remains disabled till there is a stream */

drivers/gpu/drm/xe/xe_oa_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ struct xe_oa_unit {
9595
/** @oa_unit_id: identifier for the OA unit */
9696
u16 oa_unit_id;
9797

98+
/** @gt: gt associated with the OA unit */
99+
struct xe_gt *gt;
100+
98101
/** @type: Type of OA unit - OAM, OAG etc. */
99102
enum drm_xe_oa_unit_type type;
100103

0 commit comments

Comments
 (0)