Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <daniele.ceraolospurio@intel.com>
Cc: John Harrison <John.C.Harrison@Intel.com>
Cc: Alan Previn <alan.previn.teres.alexis@intel.com>
Reviewed-by: Julia Filipchuk <julia.filipchuk@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240828215158.2743994-5-daniele.ceraolospurio@intel.com

+128
+1
drivers/gpu/drm/xe/Makefile
··· 40 40 xe_ggtt.o \ 41 41 xe_gpu_scheduler.o \ 42 42 xe_gsc.o \ 43 + xe_gsc_debugfs.o \ 43 44 xe_gsc_proxy.o \ 44 45 xe_gsc_submit.o \ 45 46 xe_gt.o \
+4
drivers/gpu/drm/xe/regs/xe_gsc_regs.h
··· 32 32 #define HECI1_FWSTS1_CURRENT_STATE_RESET 0 33 33 #define HECI1_FWSTS1_PROXY_STATE_NORMAL 5 34 34 #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) 35 38 #define HECI_FWSTS5(base) XE_REG((base) + 0xc68) 36 39 #define HECI1_FWSTS5_HUC_AUTH_DONE REG_BIT(19) 40 + #define HECI_FWSTS6(base) XE_REG((base) + 0xc6c) 37 41 38 42 #define HECI_H_GS1(base) XE_REG((base) + 0xc4c) 39 43 #define HECI_H_GS1_ER_PREP REG_BIT(0)
+33
drivers/gpu/drm/xe/xe_gsc.c
··· 8 8 #include <linux/delay.h> 9 9 10 10 #include <drm/drm_managed.h> 11 + #include <drm/drm_print.h> 11 12 12 13 #include <generated/xe_wa_oob.h> 13 14 ··· 587 586 HECI_H_CSR_RST, HECI_H_CSR_IG); 588 587 msleep(200); 589 588 } 589 + } 590 + 591 + /** 592 + * xe_gsc_print_info - print info about GSC FW status 593 + * @gsc: the GSC structure 594 + * @p: the printer to be used to print the info 595 + */ 596 + void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p) 597 + { 598 + struct xe_gt *gt = gsc_to_gt(gsc); 599 + int err; 600 + 601 + xe_uc_fw_print(&gsc->fw, p); 602 + 603 + drm_printf(p, "\tfound security version %u\n", gsc->security_version); 604 + 605 + if (!xe_uc_fw_is_enabled(&gsc->fw)) 606 + return; 607 + 608 + err = xe_force_wake_get(gt_to_fw(gt), XE_FW_GSC); 609 + if (err) 610 + return; 611 + 612 + drm_printf(p, "\nHECI1 FWSTS: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x\n", 613 + xe_mmio_read32(gt, HECI_FWSTS1(MTL_GSC_HECI1_BASE)), 614 + xe_mmio_read32(gt, HECI_FWSTS2(MTL_GSC_HECI1_BASE)), 615 + xe_mmio_read32(gt, HECI_FWSTS3(MTL_GSC_HECI1_BASE)), 616 + xe_mmio_read32(gt, HECI_FWSTS4(MTL_GSC_HECI1_BASE)), 617 + xe_mmio_read32(gt, HECI_FWSTS5(MTL_GSC_HECI1_BASE)), 618 + xe_mmio_read32(gt, HECI_FWSTS6(MTL_GSC_HECI1_BASE))); 619 + 620 + xe_force_wake_put(gt_to_fw(gt), XE_FW_GSC); 590 621 }
+3
drivers/gpu/drm/xe/xe_gsc.h
··· 8 8 9 9 #include <linux/types.h> 10 10 11 + struct drm_printer; 11 12 struct xe_gsc; 12 13 struct xe_gt; 13 14 struct xe_hw_engine; ··· 21 20 void xe_gsc_hwe_irq_handler(struct xe_hw_engine *hwe, u16 intr_vec); 22 21 23 22 void xe_gsc_wa_14015076503(struct xe_gt *gt, bool prep); 23 + 24 + void xe_gsc_print_info(struct xe_gsc *gsc, struct drm_printer *p); 24 25 25 26 #endif
+71
drivers/gpu/drm/xe/xe_gsc_debugfs.c
··· 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 + }
+14
drivers/gpu/drm/xe/xe_gsc_debugfs.h
··· 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
+2
drivers/gpu/drm/xe/xe_uc_debugfs.c
··· 8 8 #include <drm/drm_debugfs.h> 9 9 10 10 #include "xe_gt.h" 11 + #include "xe_gsc_debugfs.h" 11 12 #include "xe_guc_debugfs.h" 12 13 #include "xe_huc_debugfs.h" 13 14 #include "xe_macros.h" ··· 24 23 return; 25 24 } 26 25 26 + xe_gsc_debugfs_register(&uc->gsc, root); 27 27 xe_guc_debugfs_register(&uc->guc, root); 28 28 xe_huc_debugfs_register(&uc->huc, root); 29 29 }