Skip to content

Commit 5ee2d63

Browse files
committed
drm/xe/gsc: Add debugfs to print GSC info
This is useful for debug, in case something goes wrong with the GSC. The info includes the version information and the current value of the HECI1 status registers. Signed-off-by: Daniele Ceraolo Spurio <[email protected]> Cc: John Harrison <[email protected]> Cc: Alan Previn <[email protected]> Reviewed-by: Julia Filipchuk <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent f7c2ea6 commit 5ee2d63

File tree

7 files changed

+128
-0
lines changed

7 files changed

+128
-0
lines changed

drivers/gpu/drm/xe/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ xe-y += xe_bb.o \
4040
xe_ggtt.o \
4141
xe_gpu_scheduler.o \
4242
xe_gsc.o \
43+
xe_gsc_debugfs.o \
4344
xe_gsc_proxy.o \
4445
xe_gsc_submit.o \
4546
xe_gt.o \

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
#define HECI1_FWSTS1_CURRENT_STATE_RESET 0
3333
#define HECI1_FWSTS1_PROXY_STATE_NORMAL 5
3434
#define HECI1_FWSTS1_INIT_COMPLETE REG_BIT(9)
35+
#define HECI_FWSTS2(base) XE_REG((base) + 0xc48)
36+
#define HECI_FWSTS3(base) XE_REG((base) + 0xc60)
37+
#define HECI_FWSTS4(base) XE_REG((base) + 0xc64)
3538
#define HECI_FWSTS5(base) XE_REG((base) + 0xc68)
3639
#define HECI1_FWSTS5_HUC_AUTH_DONE REG_BIT(19)
40+
#define HECI_FWSTS6(base) XE_REG((base) + 0xc6c)
3741

3842
#define HECI_H_GS1(base) XE_REG((base) + 0xc4c)
3943
#define HECI_H_GS1_ER_PREP REG_BIT(0)

drivers/gpu/drm/xe/xe_gsc.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/delay.h>
99

1010
#include <drm/drm_managed.h>
11+
#include <drm/drm_print.h>
1112

1213
#include <generated/xe_wa_oob.h>
1314

@@ -587,3 +588,35 @@ void xe_gsc_wa_14015076503(struct xe_gt *gt, bool prep)
587588
msleep(200);
588589
}
589590
}
591+
592+
/**
593+
* xe_gsc_print_info - print info about GSC FW status
594+
* @gsc: the GSC structure
595+
* @p: the printer to be used to print the info
596+
*/
597+
void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p)
598+
{
599+
struct xe_gt *gt = gsc_to_gt(gsc);
600+
int err;
601+
602+
xe_uc_fw_print(&gsc->fw, p);
603+
604+
drm_printf(p, "\tfound security version %u\n", gsc->security_version);
605+
606+
if (!xe_uc_fw_is_enabled(&gsc->fw))
607+
return;
608+
609+
err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC);
610+
if (err)
611+
return;
612+
613+
drm_printf(p, "\nHECI1 FWSTS: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n",
614+
xe_mmio_read32(gt, HECI_FWSTS1(MTL_GSC_HECI1_BASE)),
615+
xe_mmio_read32(gt, HECI_FWSTS2(MTL_GSC_HECI1_BASE)),
616+
xe_mmio_read32(gt, HECI_FWSTS3(MTL_GSC_HECI1_BASE)),
617+
xe_mmio_read32(gt, HECI_FWSTS4(MTL_GSC_HECI1_BASE)),
618+
xe_mmio_read32(gt, HECI_FWSTS5(MTL_GSC_HECI1_BASE)),
619+
xe_mmio_read32(gt, HECI_FWSTS6(MTL_GSC_HECI1_BASE)));
620+
621+
xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC);
622+
}

drivers/gpu/drm/xe/xe_gsc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <linux/types.h>
1010

11+
struct drm_printer;
1112
struct xe_gsc;
1213
struct xe_gt;
1314
struct xe_hw_engine;
@@ -21,4 +22,6 @@ void xe_gsc_hwe_irq_handler(struct xe_hw_engine *hwe, u16 intr_vec);
2122

2223
void xe_gsc_wa_14015076503(struct xe_gt *gt, bool prep);
2324

25+
void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p);
26+
2427
#endif
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// SPDX-License-Identifier: MIT
2+
/*
3+
* Copyright © 2022 Intel Corporation
4+
*/
5+
6+
#include "xe_gsc_debugfs.h"
7+
8+
#include <drm/drm_debugfs.h>
9+
#include <drm/drm_managed.h>
10+
11+
#include "xe_device.h"
12+
#include "xe_gt.h"
13+
#include "xe_gsc.h"
14+
#include "xe_macros.h"
15+
#include "xe_pm.h"
16+
17+
static struct xe_gt *
18+
gsc_to_gt(struct xe_gsc *gsc)
19+
{
20+
return container_of(gsc, struct xe_gt, uc.gsc);
21+
}
22+
23+
static struct xe_device *
24+
gsc_to_xe(struct xe_gsc *gsc)
25+
{
26+
return gt_to_xe(gsc_to_gt(gsc));
27+
}
28+
29+
static struct xe_gsc *node_to_gsc(struct drm_info_node *node)
30+
{
31+
return node->info_ent->data;
32+
}
33+
34+
static int gsc_info(struct seq_file *m, void *data)
35+
{
36+
struct xe_gsc *gsc = node_to_gsc(m->private);
37+
struct xe_device *xe = gsc_to_xe(gsc);
38+
struct drm_printer p = drm_seq_file_printer(m);
39+
40+
xe_pm_runtime_get(xe);
41+
xe_gsc_print_info(gsc, &p);
42+
xe_pm_runtime_put(xe);
43+
44+
return 0;
45+
}
46+
47+
static const struct drm_info_list debugfs_list[] = {
48+
{"gsc_info", gsc_info, 0},
49+
};
50+
51+
void xe_gsc_debugfs_register(struct xe_gsc *gsc, struct dentry *parent)
52+
{
53+
struct drm_minor *minor = gsc_to_xe(gsc)->drm.primary;
54+
struct drm_info_list *local;
55+
int i;
56+
57+
#define DEBUGFS_SIZE (ARRAY_SIZE(debugfs_list) * sizeof(struct drm_info_list))
58+
local = drmm_kmalloc(&gsc_to_xe(gsc)->drm, DEBUGFS_SIZE, GFP_KERNEL);
59+
if (!local)
60+
return;
61+
62+
memcpy(local, debugfs_list, DEBUGFS_SIZE);
63+
#undef DEBUGFS_SIZE
64+
65+
for (i = 0; i < ARRAY_SIZE(debugfs_list); ++i)
66+
local[i].data = gsc;
67+
68+
drm_debugfs_create_files(local,
69+
ARRAY_SIZE(debugfs_list),
70+
parent, minor);
71+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* SPDX-License-Identifier: MIT */
2+
/*
3+
* Copyright © 2024 Intel Corporation
4+
*/
5+
6+
#ifndef _XE_GSC_DEBUGFS_H_
7+
#define _XE_GSC_DEBUGFS_H_
8+
9+
struct dentry;
10+
struct xe_gsc;
11+
12+
void xe_gsc_debugfs_register(struct xe_gsc *gsc, struct dentry *parent);
13+
14+
#endif

drivers/gpu/drm/xe/xe_uc_debugfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <drm/drm_debugfs.h>
99

1010
#include "xe_gt.h"
11+
#include "xe_gsc_debugfs.h"
1112
#include "xe_guc_debugfs.h"
1213
#include "xe_huc_debugfs.h"
1314
#include "xe_macros.h"
@@ -23,6 +24,7 @@ void xe_uc_debugfs_register(struct xe_uc *uc, struct dentry *parent)
2324
return;
2425
}
2526

27+
xe_gsc_debugfs_register(&uc->gsc, root);
2628
xe_guc_debugfs_register(&uc->guc, root);
2729
xe_huc_debugfs_register(&uc->huc, root);
2830
}

0 commit comments

Comments
 (0)