Skip to content

Commit 7fa68b9

Browse files
committed
Merge tag 'drm-xe-fixes-2025-02-06' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
UAPI Changes: - OA uAPI related fixes (Ashutosh) Driver Changes: - Fix SRIOV migration initialization (Michal) - Restore devcoredump to a sane state (Lucas) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/Z6S9rI1ScT_5Aw6_@intel.com
2 parents e92e11b + a9ab659 commit 7fa68b9

File tree

9 files changed

+61
-39
lines changed

9 files changed

+61
-39
lines changed

drivers/gpu/drm/xe/regs/xe_oa_regs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151
/* Common to all OA units */
5252
#define OA_OACONTROL_REPORT_BC_MASK REG_GENMASK(9, 9)
5353
#define OA_OACONTROL_COUNTER_SIZE_MASK REG_GENMASK(8, 8)
54+
#define OAG_OACONTROL_USED_BITS \
55+
(OAG_OACONTROL_OA_PES_DISAG_EN | OAG_OACONTROL_OA_CCS_SELECT_MASK | \
56+
OAG_OACONTROL_OA_COUNTER_SEL_MASK | OAG_OACONTROL_OA_COUNTER_ENABLE | \
57+
OA_OACONTROL_REPORT_BC_MASK | OA_OACONTROL_COUNTER_SIZE_MASK)
5458

5559
#define OAG_OA_DEBUG XE_REG(0xdaf8, XE_REG_OPTION_MASKED)
5660
#define OAG_OA_DEBUG_DISABLE_MMIO_TRG REG_BIT(14)
@@ -78,6 +82,8 @@
7882
#define OAM_CONTEXT_CONTROL_OFFSET (0x1bc)
7983
#define OAM_CONTROL_OFFSET (0x194)
8084
#define OAM_CONTROL_COUNTER_SEL_MASK REG_GENMASK(3, 1)
85+
#define OAM_OACONTROL_USED_BITS \
86+
(OAM_CONTROL_COUNTER_SEL_MASK | OAG_OACONTROL_OA_COUNTER_ENABLE)
8187
#define OAM_DEBUG_OFFSET (0x198)
8288
#define OAM_STATUS_OFFSET (0x19c)
8389
#define OAM_MMIO_TRG_OFFSET (0x1d0)

drivers/gpu/drm/xe/xe_devcoredump.c

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ static ssize_t __xe_devcoredump_read(char *buffer, size_t count,
119119
drm_puts(&p, "\n**** GuC CT ****\n");
120120
xe_guc_ct_snapshot_print(ss->guc.ct, &p);
121121

122-
/*
123-
* Don't add a new section header here because the mesa debug decoder
124-
* tool expects the context information to be in the 'GuC CT' section.
125-
*/
126-
/* drm_puts(&p, "\n**** Contexts ****\n"); */
122+
drm_puts(&p, "\n**** Contexts ****\n");
127123
xe_guc_exec_queue_snapshot_print(ss->ge, &p);
128124

129125
drm_puts(&p, "\n**** Job ****\n");
@@ -395,42 +391,34 @@ int xe_devcoredump_init(struct xe_device *xe)
395391
/**
396392
* xe_print_blob_ascii85 - print a BLOB to some useful location in ASCII85
397393
*
398-
* The output is split to multiple lines because some print targets, e.g. dmesg
399-
* cannot handle arbitrarily long lines. Note also that printing to dmesg in
400-
* piece-meal fashion is not possible, each separate call to drm_puts() has a
401-
* line-feed automatically added! Therefore, the entire output line must be
402-
* constructed in a local buffer first, then printed in one atomic output call.
394+
* The output is split into multiple calls to drm_puts() because some print
395+
* targets, e.g. dmesg, cannot handle arbitrarily long lines. These targets may
396+
* add newlines, as is the case with dmesg: each drm_puts() call creates a
397+
* separate line.
403398
*
404399
* There is also a scheduler yield call to prevent the 'task has been stuck for
405400
* 120s' kernel hang check feature from firing when printing to a slow target
406401
* such as dmesg over a serial port.
407402
*
408-
* TODO: Add compression prior to the ASCII85 encoding to shrink huge buffers down.
409-
*
410403
* @p: the printer object to output to
411404
* @prefix: optional prefix to add to output string
405+
* @suffix: optional suffix to add at the end. 0 disables it and is
406+
* not added to the output, which is useful when using multiple calls
407+
* to dump data to @p
412408
* @blob: the Binary Large OBject to dump out
413409
* @offset: offset in bytes to skip from the front of the BLOB, must be a multiple of sizeof(u32)
414410
* @size: the size in bytes of the BLOB, must be a multiple of sizeof(u32)
415411
*/
416-
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
412+
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix, char suffix,
417413
const void *blob, size_t offset, size_t size)
418414
{
419415
const u32 *blob32 = (const u32 *)blob;
420416
char buff[ASCII85_BUFSZ], *line_buff;
421417
size_t line_pos = 0;
422418

423-
/*
424-
* Splitting blobs across multiple lines is not compatible with the mesa
425-
* debug decoder tool. Note that even dropping the explicit '\n' below
426-
* doesn't help because the GuC log is so big some underlying implementation
427-
* still splits the lines at 512K characters. So just bail completely for
428-
* the moment.
429-
*/
430-
return;
431-
432419
#define DMESG_MAX_LINE_LEN 800
433-
#define MIN_SPACE (ASCII85_BUFSZ + 2) /* 85 + "\n\0" */
420+
/* Always leave space for the suffix char and the \0 */
421+
#define MIN_SPACE (ASCII85_BUFSZ + 2) /* 85 + "<suffix>\0" */
434422

435423
if (size & 3)
436424
drm_printf(p, "Size not word aligned: %zu", size);
@@ -462,7 +450,6 @@ void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
462450
line_pos += strlen(line_buff + line_pos);
463451

464452
if ((line_pos + MIN_SPACE) >= DMESG_MAX_LINE_LEN) {
465-
line_buff[line_pos++] = '\n';
466453
line_buff[line_pos++] = 0;
467454

468455
drm_puts(p, line_buff);
@@ -474,10 +461,11 @@ void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
474461
}
475462
}
476463

464+
if (suffix)
465+
line_buff[line_pos++] = suffix;
466+
477467
if (line_pos) {
478-
line_buff[line_pos++] = '\n';
479468
line_buff[line_pos++] = 0;
480-
481469
drm_puts(p, line_buff);
482470
}
483471

drivers/gpu/drm/xe/xe_devcoredump.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static inline int xe_devcoredump_init(struct xe_device *xe)
2929
}
3030
#endif
3131

32-
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix,
32+
void xe_print_blob_ascii85(struct drm_printer *p, const char *prefix, char suffix,
3333
const void *blob, size_t offset, size_t size);
3434

3535
#endif

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,10 @@ static int all_fw_domain_init(struct xe_gt *gt)
532532
if (IS_SRIOV_PF(gt_to_xe(gt)) && !xe_gt_is_media_type(gt))
533533
xe_lmtt_init_hw(&gt_to_tile(gt)->sriov.pf.lmtt);
534534

535-
if (IS_SRIOV_PF(gt_to_xe(gt)))
535+
if (IS_SRIOV_PF(gt_to_xe(gt))) {
536+
xe_gt_sriov_pf_init(gt);
536537
xe_gt_sriov_pf_init_hw(gt);
538+
}
537539

538540
xe_force_wake_put(gt_to_fw(gt), fw_ref);
539541

drivers/gpu/drm/xe/xe_gt_sriov_pf.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
6868
return 0;
6969
}
7070

71+
/**
72+
* xe_gt_sriov_pf_init - Prepare SR-IOV PF data structures on PF.
73+
* @gt: the &xe_gt to initialize
74+
*
75+
* Late one-time initialization of the PF data.
76+
*
77+
* Return: 0 on success or a negative error code on failure.
78+
*/
79+
int xe_gt_sriov_pf_init(struct xe_gt *gt)
80+
{
81+
return xe_gt_sriov_pf_migration_init(gt);
82+
}
83+
7184
static bool pf_needs_enable_ggtt_guest_update(struct xe_device *xe)
7285
{
7386
return GRAPHICS_VERx100(xe) == 1200;
@@ -90,7 +103,6 @@ void xe_gt_sriov_pf_init_hw(struct xe_gt *gt)
90103
pf_enable_ggtt_guest_update(gt);
91104

92105
xe_gt_sriov_pf_service_update(gt);
93-
xe_gt_sriov_pf_migration_init(gt);
94106
}
95107

96108
static u32 pf_get_vf_regs_stride(struct xe_device *xe)

drivers/gpu/drm/xe/xe_gt_sriov_pf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct xe_gt;
1010

1111
#ifdef CONFIG_PCI_IOV
1212
int xe_gt_sriov_pf_init_early(struct xe_gt *gt);
13+
int xe_gt_sriov_pf_init(struct xe_gt *gt);
1314
void xe_gt_sriov_pf_init_hw(struct xe_gt *gt);
1415
void xe_gt_sriov_pf_sanitize_hw(struct xe_gt *gt, unsigned int vfid);
1516
void xe_gt_sriov_pf_restart(struct xe_gt *gt);
@@ -19,6 +20,11 @@ static inline int xe_gt_sriov_pf_init_early(struct xe_gt *gt)
1920
return 0;
2021
}
2122

23+
static inline int xe_gt_sriov_pf_init(struct xe_gt *gt)
24+
{
25+
return 0;
26+
}
27+
2228
static inline void xe_gt_sriov_pf_init_hw(struct xe_gt *gt)
2329
{
2430
}

drivers/gpu/drm/xe/xe_guc_ct.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,8 @@ void xe_guc_ct_snapshot_print(struct xe_guc_ct_snapshot *snapshot,
17241724
snapshot->g2h_outstanding);
17251725

17261726
if (snapshot->ctb)
1727-
xe_print_blob_ascii85(p, "CTB data", snapshot->ctb, 0, snapshot->ctb_size);
1727+
xe_print_blob_ascii85(p, "CTB data", '\n',
1728+
snapshot->ctb, 0, snapshot->ctb_size);
17281729
} else {
17291730
drm_puts(p, "CT disabled\n");
17301731
}

drivers/gpu/drm/xe/xe_guc_log.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ void xe_guc_log_snapshot_print(struct xe_guc_log_snapshot *snapshot, struct drm_
211211
remain = snapshot->size;
212212
for (i = 0; i < snapshot->num_chunks; i++) {
213213
size_t size = min(GUC_LOG_CHUNK_SIZE, remain);
214+
const char *prefix = i ? NULL : "Log data";
215+
char suffix = i == snapshot->num_chunks - 1 ? '\n' : 0;
214216

215-
xe_print_blob_ascii85(p, i ? NULL : "Log data", snapshot->copy[i], 0, size);
217+
xe_print_blob_ascii85(p, prefix, suffix, snapshot->copy[i], 0, size);
216218
remain -= size;
217219
}
218220
}

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
237237
u32 tail, hw_tail, partial_report_size, available;
238238
int report_size = stream->oa_buffer.format->size;
239239
unsigned long flags;
240-
bool pollin;
241240

242241
spin_lock_irqsave(&stream->oa_buffer.ptr_lock, flags);
243242

@@ -282,22 +281,20 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
282281
stream->oa_buffer.tail = tail;
283282

284283
available = xe_oa_circ_diff(stream, stream->oa_buffer.tail, stream->oa_buffer.head);
285-
pollin = available >= stream->wait_num_reports * report_size;
284+
stream->pollin = available >= stream->wait_num_reports * report_size;
286285

287286
spin_unlock_irqrestore(&stream->oa_buffer.ptr_lock, flags);
288287

289-
return pollin;
288+
return stream->pollin;
290289
}
291290

292291
static enum hrtimer_restart xe_oa_poll_check_timer_cb(struct hrtimer *hrtimer)
293292
{
294293
struct xe_oa_stream *stream =
295294
container_of(hrtimer, typeof(*stream), poll_check_timer);
296295

297-
if (xe_oa_buffer_check_unlocked(stream)) {
298-
stream->pollin = true;
296+
if (xe_oa_buffer_check_unlocked(stream))
299297
wake_up(&stream->poll_wq);
300-
}
301298

302299
hrtimer_forward_now(hrtimer, ns_to_ktime(stream->poll_period_ns));
303300

@@ -452,6 +449,12 @@ static u32 __oa_ccs_select(struct xe_oa_stream *stream)
452449
return val;
453450
}
454451

452+
static u32 __oactrl_used_bits(struct xe_oa_stream *stream)
453+
{
454+
return stream->hwe->oa_unit->type == DRM_XE_OA_UNIT_TYPE_OAG ?
455+
OAG_OACONTROL_USED_BITS : OAM_OACONTROL_USED_BITS;
456+
}
457+
455458
static void xe_oa_enable(struct xe_oa_stream *stream)
456459
{
457460
const struct xe_oa_format *format = stream->oa_buffer.format;
@@ -472,14 +475,14 @@ static void xe_oa_enable(struct xe_oa_stream *stream)
472475
stream->hwe->oa_unit->type == DRM_XE_OA_UNIT_TYPE_OAG)
473476
val |= OAG_OACONTROL_OA_PES_DISAG_EN;
474477

475-
xe_mmio_write32(&stream->gt->mmio, regs->oa_ctrl, val);
478+
xe_mmio_rmw32(&stream->gt->mmio, regs->oa_ctrl, __oactrl_used_bits(stream), val);
476479
}
477480

478481
static void xe_oa_disable(struct xe_oa_stream *stream)
479482
{
480483
struct xe_mmio *mmio = &stream->gt->mmio;
481484

482-
xe_mmio_write32(mmio, __oa_regs(stream)->oa_ctrl, 0);
485+
xe_mmio_rmw32(mmio, __oa_regs(stream)->oa_ctrl, __oactrl_used_bits(stream), 0);
483486
if (xe_mmio_wait32(mmio, __oa_regs(stream)->oa_ctrl,
484487
OAG_OACONTROL_OA_COUNTER_ENABLE, 0, 50000, NULL, false))
485488
drm_err(&stream->oa->xe->drm,
@@ -2534,6 +2537,8 @@ static void __xe_oa_init_oa_units(struct xe_gt *gt)
25342537
u->type = DRM_XE_OA_UNIT_TYPE_OAM;
25352538
}
25362539

2540+
xe_mmio_write32(&gt->mmio, u->regs.oa_ctrl, 0);
2541+
25372542
/* Ensure MMIO trigger remains disabled till there is a stream */
25382543
xe_mmio_write32(&gt->mmio, u->regs.oa_debug,
25392544
oag_configure_mmio_trigger(NULL, false));

0 commit comments

Comments
 (0)