Skip to content

Commit 76650bc

Browse files
committed
drm/xe/lrc: Reduce scope of empty lrc data
The only case in which new lrc data is created from scratch is when it's called prior to recording the default lrc. There's no need to check for NULL init_data since in that case the function already failed: just move the allocation where it's needed. Reviewed-by: Tvrtko Ursulin <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent b533b8e commit 76650bc

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

drivers/gpu/drm/xe/xe_lrc.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,6 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
11571157
struct xe_tile *tile = gt_to_tile(gt);
11581158
struct xe_device *xe = gt_to_xe(gt);
11591159
struct iosys_map map;
1160-
void *init_data = NULL;
11611160
u32 arb_enable;
11621161
u32 bo_flags;
11631162
int err;
@@ -1195,25 +1194,26 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
11951194
xe_hw_fence_ctx_init(&lrc->fence_ctx, hwe->gt,
11961195
hwe->fence_irq, hwe->name);
11971196

1198-
if (!gt->default_lrc[hwe->class]) {
1199-
init_data = empty_lrc_data(hwe);
1200-
if (!init_data) {
1201-
err = -ENOMEM;
1202-
goto err_lrc_finish;
1203-
}
1204-
}
1205-
12061197
/*
12071198
* Init Per-Process of HW status Page, LRC / context state to known
1208-
* values
1199+
* values. If there's already a primed default_lrc, just copy it, otherwise
1200+
* it's the early submission to record the lrc: build a new empty one from
1201+
* scratch.
12091202
*/
12101203
map = __xe_lrc_pphwsp_map(lrc);
1211-
if (!init_data) {
1204+
if (gt->default_lrc[hwe->class]) {
12121205
xe_map_memset(xe, &map, 0, 0, LRC_PPHWSP_SIZE); /* PPHWSP */
12131206
xe_map_memcpy_to(xe, &map, LRC_PPHWSP_SIZE,
12141207
gt->default_lrc[hwe->class] + LRC_PPHWSP_SIZE,
12151208
lrc_size - LRC_PPHWSP_SIZE);
12161209
} else {
1210+
void *init_data = empty_lrc_data(hwe);
1211+
1212+
if (!init_data) {
1213+
err = -ENOMEM;
1214+
goto err_lrc_finish;
1215+
}
1216+
12171217
xe_map_memcpy_to(xe, &map, 0, init_data, lrc_size);
12181218
kfree(init_data);
12191219
}

0 commit comments

Comments
 (0)