drm/xe/guc: Add GuC based register capture for error capture
Subsystems (2)
v3 cover drm/xe/guc: Add GuC based register capture for error capture
Port GuC based register capture for error capture from i915 to Xe.
There are 3 parts in this commit:
. Prepare for capture registers
There is a bo create at guc ads init time, that is very early and engine map is not ready, make it hard to calculate the capture buffer size, new function created for worst case size caluation. Other than that, this part basically follows the i915 design.
. Process capture notification message
Basically follows i915 design
. Sysfs command process.
Xe switched to devcoredump, adopted command line process with captured node list.
Zhanjun Dong (9):
drm/xe/guc: Add register defines for GuC based register capture drm/xe/guc: Expose dss per group for GuC error capture drm/xe/guc: Update GuC ADS size for error capture drm/xe/guc: Add XE_LP steered register lists drm/xe/guc: Add capture size check in GuC log buffer drm/xe/guc: Check sizing of guc_capture output drm/xe/guc: Extract GuC error capture lists on G2H notification drm/xe/guc: Pre-allocate output nodes for extraction drm/xe/guc: Plumb GuC-capture into dev coredump
drivers/gpu/drm/xe/Kconfig | 11 + drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/abi/guc_actions_abi.h | 7 + drivers/gpu/drm/xe/regs/xe_engine_regs.h | 12 + drivers/gpu/drm/xe/regs/xe_gt_regs.h | 20 + drivers/gpu/drm/xe/xe_gt_mcr.c | 2 +- drivers/gpu/drm/xe/xe_gt_mcr.h | 3 + drivers/gpu/drm/xe/xe_gt_printk.h | 3 + drivers/gpu/drm/xe/xe_gt_topology.c | 3 - drivers/gpu/drm/xe/xe_guc.c | 6 + drivers/gpu/drm/xe/xe_guc_ads.c | 222 +++- drivers/gpu/drm/xe/xe_guc_ads_types.h | 2 + drivers/gpu/drm/xe/xe_guc_capture.c | 1386 ++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 21 + drivers/gpu/drm/xe/xe_guc_capture_fwif.h | 222 ++++ drivers/gpu/drm/xe/xe_guc_ct.c | 2 + drivers/gpu/drm/xe/xe_guc_fwif.h | 68 ++ drivers/gpu/drm/xe/xe_guc_log.c | 179 +++ drivers/gpu/drm/xe/xe_guc_log.h | 15 + drivers/gpu/drm/xe/xe_guc_log_types.h | 26 + drivers/gpu/drm/xe/xe_guc_submit.c | 22 +- drivers/gpu/drm/xe/xe_guc_submit.h | 3 + drivers/gpu/drm/xe/xe_guc_types.h | 2 + drivers/gpu/drm/xe/xe_hw_engine.c | 172 ++- drivers/gpu/drm/xe/xe_hw_engine.h | 4 + drivers/gpu/drm/xe/xe_hw_engine_types.h | 111 +- 26 files changed, 2421 insertions(+), 104 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.c create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.h create mode 100644 drivers/gpu/drm/xe/xe_guc_capture_fwif.h
Signature · 1 line
2.34.1
PATCH v3 1/9 drm/xe/guc: Add register defines for GuC based register capture
Add registers defines and list of registers for GuC based error state capture.
--- drivers/gpu/drm/xe/Kconfig | 11 +++ drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_engine_regs.h | 12 +++ drivers/gpu/drm/xe/regs/xe_gt_regs.h | 20 +++++ drivers/gpu/drm/xe/xe_guc.c | 5 ++ drivers/gpu/drm/xe/xe_guc_capture.c | 108 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 15 ++++ 7 files changed, 172 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.c create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.h
drivers/gpu/drm/xe/Kconfig +11 -0
@@ -83,6 +83,17 @@ config DRM_XE_FORCE_PROBE Use "!*" to block the probe of the driver for all known devices. +config DRM_XE_CAPTURE_ERROR + bool "Enable capturing GPU state following a hang" + depends on DRM_XE + default y + help + This option enables capturing the GPU state when a hang is detected. + This information is vital for triaging hangs and assists in debugging. + Please report any hang to your Intel representative to help with triaging. + + If in doubt, say "Y". + menu "drm/Xe Debugging" depends on DRM_XE depends on EXPERT
drivers/gpu/drm/xe/Makefile +1 -0
@@ -92,6 +92,7 @@ xe-y += xe_bb.o \ xe_gt_topology.o \ xe_guc.o \ xe_guc_ads.o \ + xe_guc_capture.o \ xe_guc_ct.o \ xe_guc_db_mgr.o \ xe_guc_debugfs.o \
drivers/gpu/drm/xe/regs/xe_engine_regs.h +12 -0
@@ -64,10 +64,16 @@#define RING_ACTHD_UDW (base) XE_REG((base) + 0x5c)#define RING_DMA_FADD_UDW (base) XE_REG((base) + 0x60) +#define RING_IPEIR (base) XE_REG((base) + 0x64)#define RING_IPEHR (base) XE_REG((base) + 0x68) +#define RING_INSTDONE (base) XE_REG((base) + 0x6c) +#define RING_INSTPS (base) XE_REG((base) + 0x70) +#define RING_ACTHD (base) XE_REG((base) + 0x74)#define RING_DMA_FADD (base) XE_REG((base) + 0x78)#define RING_HWS_PGA (base) XE_REG((base) + 0x80) +#define IPEIR (base) XE_REG((base) + 0x88) +#define RING_HWSTAM (base) XE_REG((base) + 0x98)#define RING_MI_MODE (base) XE_REG((base) + 0x9c)#define RING_NOPID (base) XE_REG((base) + 0x94)
@@ -111,9 +117,12 @@#define FF_DOP_CLOCK_GATE_DISABLE REG_BIT(1)#define REPLAY_MODE_GRANULARITY REG_BIT(0) +#define RING_BBSTATE (base) XE_REG((base) + 0x110)#define RING_BBADDR (base) XE_REG((base) + 0x140)#define RING_BBADDR_UDW (base) XE_REG((base) + 0x168) +#define CCID (base) XE_REG((base) + 0x180) +#define BCS_SWCTRL (base) XE_REG((base) + 0x200, XE_REG_OPTION_MASKED)#define BCS_SWCTRL_DISABLE_256B REG_BIT(2)
@@ -129,6 +138,9 @@#define CTX_CTRL_INHIBIT_SYN_CTX_SWITCH REG_BIT(3)#define CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT REG_BIT(0) +#define RING_PDP_UDW (base, n) XE_REG((base) + 0x270 + (n) * 8 + 4) +#define RING_PDP_LDW (base, n) XE_REG((base) + 0x270 + (n) * 8) +#define RING_MODE (base) XE_REG((base) + 0x29c)#define GFX_DISABLE_LEGACY_MODE REG_BIT(3)
drivers/gpu/drm/xe/regs/xe_gt_regs.h +20 -0
@@ -67,6 +67,8 @@#define VE1_AUX_INV XE_REG(0x42b8)#define AUX_INV REG_BIT(0) +#define AUX_ERR_DBG XE_REG(0x43f4) +#define XEHP_TILE_ADDR_RANGE (_idx) XE_REG_MCR(0x4900 + (_idx) * 4)#define XEHP_FLAT_CCS_BASE_ADDR XE_REG_MCR(0x4910)
@@ -94,6 +96,8 @@#define FF_MODE2_TDS_TIMER_MASK REG_GENMASK(23, 16)#define FF_MODE2_TDS_TIMER_128 REG_FIELD_PREP(FF_MODE2_TDS_TIMER_MASK, 4) +#define XEHPG_INSTDONE_GEOM_SVG XE_REG_MCR(0x666c) +#define CACHE_MODE_1 XE_REG(0x7004, XE_REG_OPTION_MASKED)#define MSAA_OPTIMIZATION_REDUC_DISABLE REG_BIT(11)
@@ -110,6 +114,10 @@#define FLSH_IGNORES_PSD REG_BIT(10)#define FD_END_COLLECT REG_BIT(5) +#define SC_INSTDONE XE_REG(0x7100) +#define SC_INSTDONE_EXTRA XE_REG(0x7104) +#define SC_INSTDONE_EXTRA2 XE_REG(0x7108) +#define COMMON_SLICE_CHICKEN4 XE_REG(0x7300, XE_REG_OPTION_MASKED)#define DISABLE_TDC_LOAD_BALANCING_CALC REG_BIT(6)
@@ -299,6 +307,11 @@#define XE2LPM_L3SQCREG5 XE_REG_MCR(0xb658) +#define FAULT_TLB_DATA0 XE_REG(0xceb8) +#define FAULT_TLB_DATA1 XE_REG(0xcebc) + +#define RING_FAULT_REG XE_REG(0xcec4) +#define XEHP_MERT_MOD_CTRL XE_REG_MCR(0xcf28)#define RENDER_MOD_CTRL XE_REG_MCR(0xcf2c)#define COMP_MOD_CTRL XE_REG_MCR(0xcf30)
@@ -317,6 +330,11 @@#define INVALIDATION_BROADCAST_MODE_DIS REG_BIT(12)#define GLOBAL_INVALIDATION_MODE REG_BIT(2) +#define GAM_DONE XE_REG(0xcf68) + +#define SAMPLER_INSTDONE XE_REG_MCR(0xe160) +#define ROW_INSTDONE XE_REG_MCR(0xe164) +#define HALF_SLICE_CHICKEN5 XE_REG_MCR(0xe188, XE_REG_OPTION_MASKED)#define DISABLE_SAMPLE_G_PERFORMANCE REG_BIT(0)
@@ -484,6 +502,8 @@#define GT_CS_MASTER_ERROR_INTERRUPT REG_BIT(3)#define GT_RENDER_USER_INTERRUPT REG_BIT(0) +#define SFC_DONE (n) XE_REG(0x1cc000 + (n) * 0x1000) +#define PVC_GT0_PACKAGE_ENERGY_STATUS XE_REG(0x281004)#define PVC_GT0_PACKAGE_RAPL_LIMIT XE_REG(0x281008)#define PVC_GT0_PACKAGE_POWER_SKU_UNIT XE_REG(0x281068)
drivers/gpu/drm/xe/xe_guc.c +5 -0
@@ -17,6 +17,7 @@#include "xe_force_wake.h" #include "xe_gt.h" #include "xe_guc_ads.h" +#include "xe_guc_capture.h" #include "xe_guc_ct.h" #include "xe_guc_hwconfig.h" #include "xe_guc_log.h"
@@ -290,6 +291,10 @@ int xe_guc_init(struct xe_guc *guc)if (ret) goto out; + ret =xe_guc_capture_init (guc); +if (ret) + goto out; + ret =xe_guc_ads_init (&guc->ads);if (ret) goto out;
drivers/gpu/drm/xe/xe_guc_capture.c new file +108 -0
108 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_capture.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2021-2021 Intel Corporation +*/ + +#ifndef _XE_GUC_CAPTURE_H +#define _XE_GUC_CAPTURE_H + +#include <linux/types.h> + +struct xe_guc ; + +int xe_guc_capture_init (struct xe_guc *guc); + +#endif /* _XE_GUC_CAPTURE_H */
Signature · 1 line
2.34.1
Re: [PATCH v3 1/9] drm/xe/guc: Add register defines for GuC based register capture
Quoted 24 lines · Zhanjun Dong
Add registers defines and list of registers for GuC based error state capture.
Signed-off-by Zhanjun Dong <[email protected]>--- drivers/gpu/drm/xe/Kconfig | 11 +++ drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_engine_regs.h | 12 +++ drivers/gpu/drm/xe/regs/xe_gt_regs.h | 20 +++++ drivers/gpu/drm/xe/xe_guc.c | 5 ++ drivers/gpu/drm/xe/xe_guc_capture.c | 108 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 15 ++++ 7 files changed, 172 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.c create mode 100644 drivers/gpu/drm/xe/xe_guc_capture.hdrivers/gpu/drm/xe/Kconfig +1
-0@@ -83,6 +83,17 @@ config DRM_XE_FORCE_PROBE Use "!*" to block the probe of the driver for all known devices. +config DRM_XE_CAPTURE_ERROR
drivers/gpu/drm/xe/Kconfig config DRM_XE_FORCE_PROBE · line 96
Quoted 10 lines
drivers/gpu/drm/xe/Kconfig +10
-0+ bool "Enable capturing GPU state following a hang" + depends on DRM_XE + default y + help + This option enables capturing the GPU state when a hang is detected. + This information is vital for triaging hangs and assists in debugging. + Please report any hang to your Intel representative to help with triaging. + + If in doubt, say "Y". +
The commit message said that this was just adding register defines, but you're actually adding new files and build options as well. That should probably all happen as a separate patch.
Quoted 20 lines
drivers/gpu/drm/xe/Kconfig +0
-0menu "drm/Xe Debugging" depends on DRM_XE depends on EXPERTdrivers/gpu/drm/xe/Makefile +1
-0@@ -92,6 +92,7 @@ xe-y += xe_bb.o \ xe_gt_topology.o \ xe_guc.o \ xe_guc_ads.o \ + xe_guc_capture.o \ xe_guc_ct.o \ xe_guc_db_mgr.o \ xe_guc_debugfs.o \drivers/gpu/drm/xe/regs/xe_engine_regs.h +0
-0
drivers/gpu/drm/xe/regs/xe_engine_regs.h line 67
Quoted 4 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +1
-0@@ -64,10 +64,16 @@#define RING_ACTHD_UDW (base) XE_REG((base) + 0x5c)#define RING_DMA_FADD_UDW (base) XE_REG((base) + 0x60) +#define RING_IPEIR (base) XE_REG((base) + 0x64)
There's no such register on any platform supported by Xe; BDW (gen8) was the last platform that had this.
As a reminder, i915 dumps a whole bunch of invalid registers and data that don't actually apply to any modern platform. I think cleaning that all up has been on the todo list for a long time. At least with Xe we're starting fresh so we can make sure that we're dumping just the registers that actually exist and are useful for debugging, and make sure that we're dumping them accurately; we don't want to just blindly copy/paste register dump stuff over from i915 since a lot of it is just unwanted bitrot.
drivers/gpu/drm/xe/regs/xe_engine_regs.h line 75
Quoted 8 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +4
-0#define RING_IPEHR (base) XE_REG((base) + 0x68) +#define RING_INSTDONE (base) XE_REG((base) + 0x6c) +#define RING_INSTPS (base) XE_REG((base) + 0x70) +#define RING_ACTHD (base) XE_REG((base) + 0x74)#define RING_DMA_FADD (base) XE_REG((base) + 0x78)#define RING_HWS_PGA (base) XE_REG((base) + 0x80) +#define IPEIR (base) XE_REG((base) + 0x88)
This looks like the same register as above, but a different offset that hasn't existed on any platform documented by the current bspec tools. That means this is probably an old gen3 offset of something; definitely not the kind of thing that we should be putting into Xe.
You also don't use this definition in the tables at the end of this patch either.
Quoted 18 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +4
-0+#define RING_HWSTAM (base) XE_REG((base) + 0x98)#define RING_MI_MODE (base) XE_REG((base) + 0x9c)#define RING_NOPID (base) XE_REG((base) + 0x94)@@ -111,9 +117,12 @@#define FF_DOP_CLOCK_GATE_DISABLE REG_BIT(1)#define REPLAY_MODE_GRANULARITY REG_BIT(0) +#define RING_BBSTATE (base) XE_REG((base) + 0x110)#define RING_BBADDR (base) XE_REG((base) + 0x140)#define RING_BBADDR_UDW (base) XE_REG((base) + 0x168) +#define CCID (base) XE_REG((base) + 0x180) +#define BCS_SWCTRL (base) XE_REG((base) + 0x200, XE_REG_OPTION_MASKED)#define BCS_SWCTRL_DISABLE_256B REG_BIT(2)
drivers/gpu/drm/xe/regs/xe_engine_regs.h line 142
Quoted 5 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +2
-0@@ -129,6 +138,9 @@#define CTX_CTRL_INHIBIT_SYN_CTX_SWITCH REG_BIT(3)#define CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT REG_BIT(0) +#define RING_PDP_UDW (base, n) XE_REG((base) + 0x270 + (n) * 8 + 4) +#define RING_PDP_LDW (base, n) XE_REG((base) + 0x270 + (n) * 8)
What is the goal of dumping these? I don't think they're relevant for modern usage are they?
Quoted 9 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +1
-0+#define RING_MODE (base) XE_REG((base) + 0x29c)#define GFX_DISABLE_LEGACY_MODE REG_BIT(3)drivers/gpu/drm/xe/regs/xe_gt_regs.h +0
-0
drivers/gpu/drm/xe/regs/xe_gt_regs.h line 71
Quoted 5 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2
-0@@ -67,6 +67,8 @@#define VE1_AUX_INV XE_REG(0x42b8)#define AUX_INV REG_BIT(0) +#define AUX_ERR_DBG XE_REG(0x43f4) +
This is a multicast register. Also it doesn't exist anymore on Xe2 and beyond but you have it on a "COMMON" list that implies it would apply to all platforms.
Dumping registers incorrectly (e.g., printing a single value for a multicast register that actually has several different values) is more misleading than not printing the register at all. That's why it's important to make sure each register is being dumped accurately. We also need to justify why we're including various registers; i915 included a bunch of garbage that nobody cared about (which was obvious since we dumped incorrect values for some registers for years and nobody noticed). We should keep the Xe list restricted to just the registers that we and our userspace partners would actually find useful. Adding unwanted registers just increases the maintenance burden and will lead to Xe's error dump turning into the same kind of graveyard i915's became.
Quoted 13 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2
-0#define XEHP_TILE_ADDR_RANGE (_idx) XE_REG_MCR(0x4900 + (_idx) * 4)#define XEHP_FLAT_CCS_BASE_ADDR XE_REG_MCR(0x4910)@@ -94,6 +96,8 @@#define FF_MODE2_TDS_TIMER_MASK REG_GENMASK(23, 16)#define FF_MODE2_TDS_TIMER_128 REG_FIELD_PREP(FF_MODE2_TDS_TIMER_MASK, 4) +#define XEHPG_INSTDONE_GEOM_SVG XE_REG_MCR(0x666c) +#define CACHE_MODE_1 XE_REG(0x7004, XE_REG_OPTION_MASKED)#define MSAA_OPTIMIZATION_REDUC_DISABLE REG_BIT(11)
drivers/gpu/drm/xe/regs/xe_gt_regs.h line 119
Quoted 6 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +3
-0@@ -110,6 +114,10 @@#define FLSH_IGNORES_PSD REG_BIT(10)#define FD_END_COLLECT REG_BIT(5) +#define SC_INSTDONE XE_REG(0x7100) +#define SC_INSTDONE_EXTRA XE_REG(0x7104) +#define SC_INSTDONE_EXTRA2 XE_REG(0x7108)
These are multicast registers too.
drivers/gpu/drm/xe/regs/xe_gt_regs.h line 311
Quoted 10 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +3
-0+#define COMMON_SLICE_CHICKEN4 XE_REG(0x7300, XE_REG_OPTION_MASKED)#define DISABLE_TDC_LOAD_BALANCING_CALC REG_BIT(6)@@ -299,6 +307,11 @@#define XE2LPM_L3SQCREG5 XE_REG_MCR(0xb658) +#define FAULT_TLB_DATA0 XE_REG(0xceb8) +#define FAULT_TLB_DATA1 XE_REG(0xcebc)
Also multicast.
drivers/gpu/drm/xe/regs/xe_gt_regs.h line 313
Quoted 2 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2
-0+ +#define RING_FAULT_REG XE_REG(0xcec4)
Ditto.
drivers/gpu/drm/xe/regs/xe_gt_regs.h line 333
Quoted 9 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2
-0+#define XEHP_MERT_MOD_CTRL XE_REG_MCR(0xcf28)#define RENDER_MOD_CTRL XE_REG_MCR(0xcf2c)#define COMP_MOD_CTRL XE_REG_MCR(0xcf30)@@ -317,6 +330,11 @@#define INVALIDATION_BROADCAST_MODE_DIS REG_BIT(12)#define GLOBAL_INVALIDATION_MODE REG_BIT(2) +#define GAM_DONE XE_REG(0xcf68)
Ditto.
Quoted 70 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +6
-0+ +#define SAMPLER_INSTDONE XE_REG_MCR(0xe160) +#define ROW_INSTDONE XE_REG_MCR(0xe164) +#define HALF_SLICE_CHICKEN5 XE_REG_MCR(0xe188, XE_REG_OPTION_MASKED)#define DISABLE_SAMPLE_G_PERFORMANCE REG_BIT(0)@@ -484,6 +502,8 @@#define GT_CS_MASTER_ERROR_INTERRUPT REG_BIT(3)#define GT_RENDER_USER_INTERRUPT REG_BIT(0) +#define SFC_DONE (n) XE_REG(0x1cc000 + (n) * 0x1000) +#define PVC_GT0_PACKAGE_ENERGY_STATUS XE_REG(0x281004)#define PVC_GT0_PACKAGE_RAPL_LIMIT XE_REG(0x281008)#define PVC_GT0_PACKAGE_POWER_SKU_UNIT XE_REG(0x281068)drivers/gpu/drm/xe/xe_guc.c +5
-0@@ -17,6 +17,7 @@#include "xe_force_wake.h" #include "xe_gt.h" #include "xe_guc_ads.h" +#include "xe_guc_capture.h" #include "xe_guc_ct.h" #include "xe_guc_hwconfig.h" #include "xe_guc_log.h" @@ -290,6 +291,10 @@ int xe_guc_init(struct xe_guc *guc)if (ret) goto out; + ret =xe_guc_capture_init (guc); +if (ret) + goto out; + ret =xe_guc_ads_init (&guc->ads);if (ret) goto out;drivers/gpu/drm/xe/xe_guc_capture.c new file +25
-0@@ -0,0 +1,108 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2021-2022 Intel Corporation +*/ + +#include <linux/types.h> + +#include <drm/drm_print.h> + +#include "abi/guc_actions_abi.h" +#include "regs/xe_regs.h" +#include "regs/xe_engine_regs.h" +#include "regs/xe_gt_regs.h" +#include "regs/xe_guc_regs.h" + +#include "xe_bo.h" +#include "xe_device.h" +#include "xe_exec_queue_types.h" +#include "xe_hw_engine_types.h" +#include "xe_gt.h" +#include "xe_gt_printk.h" +#include "xe_guc.h" +#include "xe_guc_capture.h" +#include "xe_guc_ct.h" +
drivers/gpu/drm/xe/xe_guc_capture.c line 35
Quoted 10 lines
drivers/gpu/drm/xe/xe_guc_capture.c new file +10
-0+#include "xe_guc_log.h" +#include "xe_gt_mcr.h" +#include "xe_guc_submit.h" +#include "xe_macros.h" +#include "xe_map.h" + +#if IS_ENABLED (CONFIG_DRM_XE_CAPTURE_ERROR ) + +/* +* Define all device tables of GuC error capture register lists
The tables below don't really make sense yet because they don't get used anywhere yet and it isn't even clear what the structure is (i.e., the the "0, 0" part doesn't relate to anything else in this patch).
In general it would probably be better to approach this from the other direction --- add the general infrastructure to just dump the registers we already have definitions for first, then follow up with extra patches that add additional registers and include them in the appropriate lists, along with an explanation for why each set of registers is useful to dump.
Matt
Quoted 97 lines
drivers/gpu/drm/xe/xe_guc_capture.c new file +73
-0+* NOTE: For engine-registers, GuC only needs the register offsets +* from the engine-mmio-base +*/ +#define COMMON_XELP_BASE_GLOBAL \ + { FORCEWAKE_GT, 0, 0, "FORCEWAKE" }, \ + { FAULT_TLB_DATA0, 0, 0, "FAULT_TLB_DATA0" }, \ + { FAULT_TLB_DATA1, 0, 0, "FAULT_TLB_DATA1" }, \ + { AUX_ERR_DBG, 0, 0, "AUX_ERR_DBG" }, \ + { GAM_DONE, 0, 0, "GAM_DONE" }, \ + { RING_FAULT_REG, 0, 0, "FAULT_REG" } + +#define COMMON_BASE_ENGINE_INSTANCE \ + { RING_PSMI_CTL(0), 0, 0, "RC PSMI" }, \ + { RING_ESR(0), 0, 0, "ESR" }, \ + { RING_EMR(0), 0, 0, "EMR" }, \ + { RING_EIR(0), 0, 0, "EIR" }, \ + { RING_EXECLIST_STATUS_HI(0), 0, 0, "RING_EXECLIST_STATUS_HI" }, \ + { RING_EXECLIST_STATUS_LO(0), 0, 0, "RING_EXECLIST_STATUS_LO" }, \ + { RING_DMA_FADD(0), 0, 0, "RING_DMA_FADD_LDW" }, \ + { RING_DMA_FADD_UDW(0), 0, 0, "RING_DMA_FADD_UDW" }, \ + { RING_IPEIR(0), 0, 0, "IPEIR" }, \ + { RING_IPEHR(0), 0, 0, "IPEHR" }, \ + { RING_INSTPS(0), 0, 0, "INSTPS" }, \ + { RING_BBADDR(0), 0, 0, "RING_BBADDR_LOW32" }, \ + { RING_BBADDR_UDW(0), 0, 0, "RING_BBADDR_UP32" }, \ + { RING_BBSTATE(0), 0, 0, "BB_STATE" }, \ + { CCID(0), 0, 0, "CCID" }, \ + { RING_ACTHD(0), 0, 0, "ACTHD_LDW" }, \ + { RING_ACTHD_UDW(0), 0, 0, "ACTHD_UDW" }, \ + { INSTPM(0), 0, 0, "INSTPM" }, \ + { RING_INSTDONE(0), 0, 0, "INSTDONE" }, \ + { RING_NOPID(0), 0, 0, "RING_NOPID" }, \ + { RING_START(0), 0, 0, "START" }, \ + { RING_HEAD(0), 0, 0, "HEAD" }, \ + { RING_TAIL(0), 0, 0, "TAIL" }, \ + { RING_CTL(0), 0, 0, "CTL" }, \ + { RING_MI_MODE(0), 0, 0, "MODE" }, \ + { RING_CONTEXT_CONTROL(0), 0, 0, "RING_CONTEXT_CONTROL" }, \ + { RING_HWS_PGA(0), 0, 0, "HWS" }, \ + { RING_MODE(0), 0, 0, "GFX_MODE" }, \ + { RING_PDP_LDW(0, 0), 0, 0, "PDP0_LDW" }, \ + { RING_PDP_UDW(0, 0), 0, 0, "PDP0_UDW" }, \ + { RING_PDP_LDW(0, 1), 0, 0, "PDP1_LDW" }, \ + { RING_PDP_UDW(0, 1), 0, 0, "PDP1_UDW" }, \ + { RING_PDP_LDW(0, 2), 0, 0, "PDP2_LDW" }, \ + { RING_PDP_UDW(0, 2), 0, 0, "PDP2_UDW" }, \ + { RING_PDP_LDW(0, 3), 0, 0, "PDP3_LDW" }, \ + { RING_PDP_UDW(0, 3), 0, 0, "PDP3_UDW" } + +#define COMMON_XELP_BASE_RENDER \ + { SC_INSTDONE, 0, 0, "SC_INSTDONE" }, \ + { SC_INSTDONE_EXTRA, 0, 0, "SC_INSTDONE_EXTRA" }, \ + { SC_INSTDONE_EXTRA2, 0, 0, "SC_INSTDONE_EXTRA2" } + +#define COMMON_XELP_BASE_VEC \ + { SFC_DONE(0), 0, 0, "SFC_DONE[0]" }, \ + { SFC_DONE(1), 0, 0, "SFC_DONE[1]" }, \ + { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ + { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } + +int xe_guc_capture_init (struct xe_guc *guc) +{ +return 0 ; +} + +#else /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ + +int xe_guc_capture_init (struct xe_guc *guc) +{ +return 0 ; +} + +#endif /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ drivers/gpu/drm/xe/xe_guc_capture.h new file +15
-0@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2021-2021 Intel Corporation +*/ + +#ifndef _XE_GUC_CAPTURE_H +#define _XE_GUC_CAPTURE_H + +#include <linux/types.h> + +struct xe_guc ; + +int xe_guc_capture_init (struct xe_guc *guc); + +#endif /* _XE_GUC_CAPTURE_H */ Signature · 1 line
2.34.1
Signature · 4 lines
Matt Roper Graphics Software Engineer Linux GPU Platform Enablement Intel Corporation
Re: [PATCH v3 1/9] drm/xe/guc: Add register defines for GuC based register capture
Thanks for the review.
Yes, I totally agree with you that from i915, there are many registers dumped out on capture, but is for old platforms. We don't need it on Xe. Although I already filted the register list, there are still many registers not needed as you pointed out. Let me review again and reorgnize files to make it more clear.
Regards,
Zhanjun
Quoted 398 lines · Matt Roper
Quoted 24 lines · Zhanjun Dong
Add registers defines and list of registers for GuC based error state capture.
Signed-off-by Zhanjun Dong <[email protected]>--- drivers/gpu/drm/xe/Kconfig | 11 +++ drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_engine_regs.h | 12 +++ drivers/gpu/drm/xe/regs/xe_gt_regs.h | 20 +++++ drivers/gpu/drm/xe/xe_guc.c | 5 ++ drivers/gpu/drm/xe/xe_guc_capture.c | 108 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 15 ++++ 7 files changed, 172 insertions(+)create mode 100644
drivers/gpu/drm/xe/xe_guc_capture.ccreate mode 100644drivers/gpu/drm/xe/xe_guc_capture.hdrivers/gpu/drm/xe/Kconfig +1
-0@@ -83,6 +83,17 @@ config DRM_XE_FORCE_PROBE Use "!*" to block the probe of the driver for all known devices. +config DRM_XE_CAPTURE_ERRORdrivers/gpu/drm/xe/Kconfig config DRM_XE_FORCE_PROBE · line 96
Quoted 10 lines
drivers/gpu/drm/xe/Kconfig +10
-0+ bool "Enable capturing GPU state following a hang" + depends on DRM_XE + default y + help + This option enables capturing the GPU state when a hang is detected. + This information is vital for triaging hangs and assists in debugging. + Please report any hang to your Intel representative to help with triaging. + + If in doubt, say "Y". +The commit message said that this was just adding register defines, but you're actually adding new files and build options as well. That should probably all happen as a separate patch.
Quoted 20 lines
drivers/gpu/drm/xe/Kconfig +0
-0menu "drm/Xe Debugging" depends on DRM_XE depends on EXPERTdrivers/gpu/drm/xe/Makefile +1
-0@@ -92,6 +92,7 @@ xe-y += xe_bb.o \ xe_gt_topology.o \ xe_guc.o \ xe_guc_ads.o \ + xe_guc_capture.o \ xe_guc_ct.o \ xe_guc_db_mgr.o \ xe_guc_debugfs.o \drivers/gpu/drm/xe/regs/xe_engine_regs.h +0
-0drivers/gpu/drm/xe/regs/xe_engine_regs.h line 67
Quoted 4 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +1
-0@@ -64,10 +64,16 @@#define RING_ACTHD_UDW (base) XE_REG((base) + 0x5c)#define RING_DMA_FADD_UDW (base) XE_REG((base) + 0x60) +#define RING_IPEIR (base) XE_REG((base) + 0x64)There's no such register on any platform supported by Xe; BDW (gen8) was the last platform that had this.
As a reminder, i915 dumps a whole bunch of invalid registers and data that don't actually apply to any modern platform. I think cleaning that all up has been on the todo list for a long time. At least with Xe we're starting fresh so we can make sure that we're dumping just the registers that actually exist and are useful for debugging, and make sure that we're dumping them accurately; we don't want to just blindly copy/paste register dump stuff over from i915 since a lot of it is just unwanted bitrot.
drivers/gpu/drm/xe/regs/xe_engine_regs.h line 75
Quoted 8 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +4
-0#define RING_IPEHR (base) XE_REG((base) + 0x68) +#define RING_INSTDONE (base) XE_REG((base) + 0x6c) +#define RING_INSTPS (base) XE_REG((base) + 0x70) +#define RING_ACTHD (base) XE_REG((base) + 0x74)#define RING_DMA_FADD (base) XE_REG((base) + 0x78)#define RING_HWS_PGA (base) XE_REG((base) + 0x80) +#define IPEIR (base) XE_REG((base) + 0x88)This looks like the same register as above, but a different offset that hasn't existed on any platform documented by the current bspec tools. That means this is probably an old gen3 offset of something; definitely not the kind of thing that we should be putting into Xe.
You also don't use this definition in the tables at the end of this patch either.
Quoted 18 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +4
-0+#define RING_HWSTAM (base) XE_REG((base) + 0x98)#define RING_MI_MODE (base) XE_REG((base) + 0x9c)#define RING_NOPID (base) XE_REG((base) + 0x94)@@ -111,9 +117,12 @@#define FF_DOP_CLOCK_GATE_DISABLE REG_BIT(1)#define REPLAY_MODE_GRANULARITY REG_BIT(0) +#define RING_BBSTATE (base) XE_REG((base) + 0x110)#define RING_BBADDR (base) XE_REG((base) + 0x140)#define RING_BBADDR_UDW (base) XE_REG((base) + 0x168) +#define CCID (base) XE_REG((base) + 0x180) +#define BCS_SWCTRL (base) XE_REG((base) + 0x200, XE_REG_OPTION_MASKED)#define BCS_SWCTRL_DISABLE_256B REG_BIT(2)drivers/gpu/drm/xe/regs/xe_engine_regs.h line 142
Quoted 5 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +2
-0@@ -129,6 +138,9 @@#define CTX_CTRL_INHIBIT_SYN_CTX_SWITCH REG_BIT(3)#define CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT REG_BIT(0) +#define RING_PDP_UDW (base, n) XE_REG((base) + 0x270 + (n) * 8 + 4) +#define RING_PDP_LDW (base, n) XE_REG((base) + 0x270 + (n) * 8)What is the goal of dumping these? I don't think they're relevant for modern usage are they?
Quoted 9 lines
drivers/gpu/drm/xe/regs/xe_engine_regs.h +1
-0+#define RING_MODE (base) XE_REG((base) + 0x29c)#define GFX_DISABLE_LEGACY_MODE REG_BIT(3)drivers/gpu/drm/xe/regs/xe_gt_regs.h +0
-0drivers/gpu/drm/xe/regs/xe_gt_regs.h line 71
Quoted 5 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2
-0@@ -67,6 +67,8 @@#define VE1_AUX_INV XE_REG(0x42b8)#define AUX_INV REG_BIT(0) +#define AUX_ERR_DBG XE_REG(0x43f4) +This is a multicast register. Also it doesn't exist anymore on Xe2 and beyond but you have it on a "COMMON" list that implies it would apply to all platforms.
Dumping registers incorrectly (e.g., printing a single value for a multicast register that actually has several different values) is more misleading than not printing the register at all. That's why it's important to make sure each register is being dumped accurately. We also need to justify why we're including various registers; i915 included a bunch of garbage that nobody cared about (which was obvious since we dumped incorrect values for some registers for years and nobody noticed). We should keep the Xe list restricted to just the registers that we and our userspace partners would actually find useful. Adding unwanted registers just increases the maintenance burden and will lead to Xe's error dump turning into the same kind of graveyard i915's became.
Quoted 13 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2
-0#define XEHP_TILE_ADDR_RANGE (_idx) XE_REG_MCR(0x4900 + (_idx) * 4)#define XEHP_FLAT_CCS_BASE_ADDR XE_REG_MCR(0x4910)@@ -94,6 +96,8 @@#define FF_MODE2_TDS_TIMER_MASK REG_GENMASK(23, 16)#define FF_MODE2_TDS_TIMER_128 REG_FIELD_PREP(FF_MODE2_TDS_TIMER_MASK, 4) +#define XEHPG_INSTDONE_GEOM_SVG XE_REG_MCR(0x666c) +#define CACHE_MODE_1 XE_REG(0x7004, XE_REG_OPTION_MASKED)#define MSAA_OPTIMIZATION_REDUC_DISABLE REG_BIT(11)drivers/gpu/drm/xe/regs/xe_gt_regs.h line 119
Quoted 6 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +3
-0@@ -110,6 +114,10 @@#define FLSH_IGNORES_PSD REG_BIT(10)#define FD_END_COLLECT REG_BIT(5) +#define SC_INSTDONE XE_REG(0x7100) +#define SC_INSTDONE_EXTRA XE_REG(0x7104) +#define SC_INSTDONE_EXTRA2 XE_REG(0x7108)These are multicast registers too.
drivers/gpu/drm/xe/regs/xe_gt_regs.h line 311
Quoted 10 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +3
-0+#define COMMON_SLICE_CHICKEN4 XE_REG(0x7300, XE_REG_OPTION_MASKED)#define DISABLE_TDC_LOAD_BALANCING_CALC REG_BIT(6)@@ -299,6 +307,11 @@#define XE2LPM_L3SQCREG5 XE_REG_MCR(0xb658) +#define FAULT_TLB_DATA0 XE_REG(0xceb8) +#define FAULT_TLB_DATA1 XE_REG(0xcebc)Also multicast.
drivers/gpu/drm/xe/regs/xe_gt_regs.h line 313
Quoted 2 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2
-0+ +#define RING_FAULT_REG XE_REG(0xcec4)Ditto.
drivers/gpu/drm/xe/regs/xe_gt_regs.h line 333
Quoted 9 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +2
-0+#define XEHP_MERT_MOD_CTRL XE_REG_MCR(0xcf28)#define RENDER_MOD_CTRL XE_REG_MCR(0xcf2c)#define COMP_MOD_CTRL XE_REG_MCR(0xcf30)@@ -317,6 +330,11 @@#define INVALIDATION_BROADCAST_MODE_DIS REG_BIT(12)#define GLOBAL_INVALIDATION_MODE REG_BIT(2) +#define GAM_DONE XE_REG(0xcf68)Ditto.
Quoted 70 lines
drivers/gpu/drm/xe/regs/xe_gt_regs.h +6
-0+ +#define SAMPLER_INSTDONE XE_REG_MCR(0xe160) +#define ROW_INSTDONE XE_REG_MCR(0xe164) +#define HALF_SLICE_CHICKEN5 XE_REG_MCR(0xe188, XE_REG_OPTION_MASKED)#define DISABLE_SAMPLE_G_PERFORMANCE REG_BIT(0)@@ -484,6 +502,8 @@#define GT_CS_MASTER_ERROR_INTERRUPT REG_BIT(3)#define GT_RENDER_USER_INTERRUPT REG_BIT(0) +#define SFC_DONE (n) XE_REG(0x1cc000 + (n) * 0x1000) +#define PVC_GT0_PACKAGE_ENERGY_STATUS XE_REG(0x281004)#define PVC_GT0_PACKAGE_RAPL_LIMIT XE_REG(0x281008)#define PVC_GT0_PACKAGE_POWER_SKU_UNIT XE_REG(0x281068)drivers/gpu/drm/xe/xe_guc.c +5
-0@@ -17,6 +17,7 @@#include "xe_force_wake.h" #include "xe_gt.h" #include "xe_guc_ads.h" +#include "xe_guc_capture.h" #include "xe_guc_ct.h" #include "xe_guc_hwconfig.h" #include "xe_guc_log.h" @@ -290,6 +291,10 @@ int xe_guc_init(struct xe_guc *guc)if (ret) goto out; + ret =xe_guc_capture_init (guc); +if (ret) + goto out; + ret =xe_guc_ads_init (&guc->ads);if (ret) goto out;drivers/gpu/drm/xe/xe_guc_capture.c new file +25
-0@@ -0,0 +1,108 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright © 2021-2022 Intel Corporation +*/ + +#include <linux/types.h> + +#include <drm/drm_print.h> + +#include "abi/guc_actions_abi.h" +#include "regs/xe_regs.h" +#include "regs/xe_engine_regs.h" +#include "regs/xe_gt_regs.h" +#include "regs/xe_guc_regs.h" + +#include "xe_bo.h" +#include "xe_device.h" +#include "xe_exec_queue_types.h" +#include "xe_hw_engine_types.h" +#include "xe_gt.h" +#include "xe_gt_printk.h" +#include "xe_guc.h" +#include "xe_guc_capture.h" +#include "xe_guc_ct.h" +drivers/gpu/drm/xe/xe_guc_capture.c line 35
Quoted 10 lines
drivers/gpu/drm/xe/xe_guc_capture.c new file +10
-0+#include "xe_guc_log.h" +#include "xe_gt_mcr.h" +#include "xe_guc_submit.h" +#include "xe_macros.h" +#include "xe_map.h" + +#if IS_ENABLED (CONFIG_DRM_XE_CAPTURE_ERROR ) + +/* +* Define all device tables of GuC error capture register lists The tables below don't really make sense yet because they don't get used anywhere yet and it isn't even clear what the structure is (i.e., the the "0, 0" part doesn't relate to anything else in this patch).
In general it would probably be better to approach this from the other direction --- add the general infrastructure to just dump the registers we already have definitions for first, then follow up with extra patches that add additional registers and include them in the appropriate lists, along with an explanation for why each set of registers is useful to dump.
Matt
Quoted 97 lines
drivers/gpu/drm/xe/xe_guc_capture.c new file +73
-0+* NOTE: For engine-registers, GuC only needs the register offsets +* from the engine-mmio-base +*/ +#define COMMON_XELP_BASE_GLOBAL \ + { FORCEWAKE_GT, 0, 0, "FORCEWAKE" }, \ + { FAULT_TLB_DATA0, 0, 0, "FAULT_TLB_DATA0" }, \ + { FAULT_TLB_DATA1, 0, 0, "FAULT_TLB_DATA1" }, \ + { AUX_ERR_DBG, 0, 0, "AUX_ERR_DBG" }, \ + { GAM_DONE, 0, 0, "GAM_DONE" }, \ + { RING_FAULT_REG, 0, 0, "FAULT_REG" } + +#define COMMON_BASE_ENGINE_INSTANCE \ + { RING_PSMI_CTL(0), 0, 0, "RC PSMI" }, \ + { RING_ESR(0), 0, 0, "ESR" }, \ + { RING_EMR(0), 0, 0, "EMR" }, \ + { RING_EIR(0), 0, 0, "EIR" }, \ + { RING_EXECLIST_STATUS_HI(0), 0, 0, "RING_EXECLIST_STATUS_HI" }, \ + { RING_EXECLIST_STATUS_LO(0), 0, 0, "RING_EXECLIST_STATUS_LO" }, \ + { RING_DMA_FADD(0), 0, 0, "RING_DMA_FADD_LDW" }, \ + { RING_DMA_FADD_UDW(0), 0, 0, "RING_DMA_FADD_UDW" }, \ + { RING_IPEIR(0), 0, 0, "IPEIR" }, \ + { RING_IPEHR(0), 0, 0, "IPEHR" }, \ + { RING_INSTPS(0), 0, 0, "INSTPS" }, \ + { RING_BBADDR(0), 0, 0, "RING_BBADDR_LOW32" }, \ + { RING_BBADDR_UDW(0), 0, 0, "RING_BBADDR_UP32" }, \ + { RING_BBSTATE(0), 0, 0, "BB_STATE" }, \ + { CCID(0), 0, 0, "CCID" }, \ + { RING_ACTHD(0), 0, 0, "ACTHD_LDW" }, \ + { RING_ACTHD_UDW(0), 0, 0, "ACTHD_UDW" }, \ + { INSTPM(0), 0, 0, "INSTPM" }, \ + { RING_INSTDONE(0), 0, 0, "INSTDONE" }, \ + { RING_NOPID(0), 0, 0, "RING_NOPID" }, \ + { RING_START(0), 0, 0, "START" }, \ + { RING_HEAD(0), 0, 0, "HEAD" }, \ + { RING_TAIL(0), 0, 0, "TAIL" }, \ + { RING_CTL(0), 0, 0, "CTL" }, \ + { RING_MI_MODE(0), 0, 0, "MODE" }, \ + { RING_CONTEXT_CONTROL(0), 0, 0, "RING_CONTEXT_CONTROL" }, \ + { RING_HWS_PGA(0), 0, 0, "HWS" }, \ + { RING_MODE(0), 0, 0, "GFX_MODE" }, \ + { RING_PDP_LDW(0, 0), 0, 0, "PDP0_LDW" }, \ + { RING_PDP_UDW(0, 0), 0, 0, "PDP0_UDW" }, \ + { RING_PDP_LDW(0, 1), 0, 0, "PDP1_LDW" }, \ + { RING_PDP_UDW(0, 1), 0, 0, "PDP1_UDW" }, \ + { RING_PDP_LDW(0, 2), 0, 0, "PDP2_LDW" }, \ + { RING_PDP_UDW(0, 2), 0, 0, "PDP2_UDW" }, \ + { RING_PDP_LDW(0, 3), 0, 0, "PDP3_LDW" }, \ + { RING_PDP_UDW(0, 3), 0, 0, "PDP3_UDW" } + +#define COMMON_XELP_BASE_RENDER \ + { SC_INSTDONE, 0, 0, "SC_INSTDONE" }, \ + { SC_INSTDONE_EXTRA, 0, 0, "SC_INSTDONE_EXTRA" }, \ + { SC_INSTDONE_EXTRA2, 0, 0, "SC_INSTDONE_EXTRA2" } + +#define COMMON_XELP_BASE_VEC \ + { SFC_DONE(0), 0, 0, "SFC_DONE[0]" }, \ + { SFC_DONE(1), 0, 0, "SFC_DONE[1]" }, \ + { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ + { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } + +int xe_guc_capture_init (struct xe_guc *guc) +{ +return 0 ; +} + +#else /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ + +int xe_guc_capture_init (struct xe_guc *guc) +{ +return 0 ; +} + +#endif /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ drivers/gpu/drm/xe/xe_guc_capture.h new file +15
-0@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2021-2021 Intel Corporation +*/ + +#ifndef _XE_GUC_CAPTURE_H +#define _XE_GUC_CAPTURE_H + +#include <linux/types.h> + +struct xe_guc ; + +int xe_guc_capture_init (struct xe_guc *guc); + +#endif /* _XE_GUC_CAPTURE_H */ Signature · 1 line
2.34.1
PATCH v3 2/9 drm/xe/guc: Expose dss per group for GuC error capture
In reply to Zhanjun DongExpose helper for dss per group of mcr, GuC error capture feature need this info to prepare buffer required.
--- drivers/gpu/drm/xe/xe_gt_mcr.c | 2 +- drivers/gpu/drm/xe/xe_gt_mcr.h | 3 +++ drivers/gpu/drm/xe/xe_gt_topology.c | 3 --- drivers/gpu/drm/xe/xe_guc_capture.c | 29 +++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_hw_engine_types.h | 3 +++ 5 files changed, 36 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_gt_mcr.c +1 -1
@@ -295,7 +295,7 @@ static void init_steering_dss(struct xe_gt *gt) {unsigned int dss =min (xe_dss_mask_group_ffs (gt->fuse_topo.g_dss_mask,0 ,0 ),xe_dss_mask_group_ffs (gt->fuse_topo.c_dss_mask,0 ,0 )); -unsigned int dss_per_grp =gt_to_xe (gt)->info.platform ==XE_PVC ?8 :4 ; +unsigned int dss_per_grp =XE_GT_MCR_DSS_PER_GROUP (gt); gt->steering[DSS ].group_target = dss / dss_per_grp; gt->steering[DSS ].instance_target = dss % dss_per_grp;
drivers/gpu/drm/xe/xe_gt_mcr.h +3 -0
@@ -7,10 +7,13 @@#define _XE_GT_MCR_H_#include "regs/xe_reg_defs.h" +#include "xe_gt_types.h" struct drm_printer ;struct xe_gt ; +#define XE_GT_MCR_DSS_PER_GROUP (gt) (gt_to_xe(gt)->info.platform == XE_PVC ? 8 : 4) +void xe_gt_mcr_init (struct xe_gt *gt);void xe_gt_mcr_set_implicit_defaults (struct xe_gt *gt);
drivers/gpu/drm/xe/xe_gt_topology.c +0 -3
@@ -11,9 +11,6 @@#include "xe_gt.h" #include "xe_mmio.h" -#define XE_MAX_DSS_FUSE_BITS (32 * XE_MAX_DSS_FUSE_REGS) -#define XE_MAX_EU_FUSE_BITS (32 * XE_MAX_EU_FUSE_REGS) -static void load_dss_mask (struct xe_gt *gt,xe_dss_mask_t mask,int numregs, ...) {
drivers/gpu/drm/xe/xe_guc_capture.c +29 -0
@@ -93,6 +93,35 @@ { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } +static void xe_gt_mcr_get_ss_steering (struct xe_gt *gt,unsigned int dss, +unsigned int *group,unsigned int *instance) +{ +int dss_per_grp =XE_GT_MCR_DSS_PER_GROUP (gt); + + *group = dss / dss_per_grp; + *instance = dss % dss_per_grp; +} + +static bool xe_sseu_has_subslice (struct xe_gt *gt,int slice,int subslice) +{ +int dss_per_grp =XE_GT_MCR_DSS_PER_GROUP (gt); +int index = slice * dss_per_grp + subslice; + +return index >=XE_MAX_DSS_FUSE_BITS ? false :test_bit (index, gt->fuse_topo.g_dss_mask); +} + +#define _HAS_SS (ss_, gt_, group_, instance_) xe_sseu_has_subslice(gt_, group_, instance_) + +/* +* Loop over each subslice/DSS and determine the group and instance IDs that +* should be used to steer MCR accesses toward this DSS. +*/ +#define for_each_ss_steering (ss_, gt_, group_, instance_) \ + for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \ + ss_ < XE_MAX_DSS_FUSE_BITS; \ + ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \ + for_each_if(_HAS_SS(ss_, gt_, group_, instance_)) +int xe_guc_capture_init (struct xe_guc *guc) {return 0 ;
drivers/gpu/drm/xe/xe_hw_engine_types.h +3 -0
@@ -65,6 +65,9 @@ struct xe_bo;struct xe_execlist_port ;struct xe_gt ; +#define XE_MAX_DSS_FUSE_BITS (32 * XE_MAX_DSS_FUSE_REGS) +#define XE_MAX_EU_FUSE_BITS (32 * XE_MAX_EU_FUSE_REGS) +/** * struct xe_hw_engine_class_intf - per hw engine class struct interface *
Signature · 1 line
2.34.1
Re: [PATCH v3 2/9] drm/xe/guc: Expose dss per group for GuC error capture
Quoted 30 lines · Zhanjun Dong
Expose helper for dss per group of mcr, GuC error capture feature need this info to prepare buffer required.
Signed-off-by Zhanjun Dong <[email protected]>--- drivers/gpu/drm/xe/xe_gt_mcr.c | 2 +- drivers/gpu/drm/xe/xe_gt_mcr.h | 3 +++ drivers/gpu/drm/xe/xe_gt_topology.c | 3 --- drivers/gpu/drm/xe/xe_guc_capture.c | 29 +++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_hw_engine_types.h | 3 +++ 5 files changed, 36 insertions(+), 4 deletions(-)drivers/gpu/drm/xe/xe_gt_mcr.c +1
-1@@ -295,7 +295,7 @@ static void init_steering_dss(struct xe_gt *gt) {unsigned int dss =min (xe_dss_mask_group_ffs (gt->fuse_topo.g_dss_mask,0 ,0 ),xe_dss_mask_group_ffs (gt->fuse_topo.c_dss_mask,0 ,0 )); -unsigned int dss_per_grp =gt_to_xe (gt)->info.platform ==XE_PVC ?8 :4 ; +unsigned int dss_per_grp =XE_GT_MCR_DSS_PER_GROUP (gt); gt->steering[DSS ].group_target = dss / dss_per_grp; gt->steering[DSS ].instance_target = dss % dss_per_grp;drivers/gpu/drm/xe/xe_gt_mcr.h +0
-0
drivers/gpu/drm/xe/xe_gt_mcr.h line 15
Quoted 9 lines
drivers/gpu/drm/xe/xe_gt_mcr.h +2
-0@@ -7,10 +7,13 @@#define _XE_GT_MCR_H_#include "regs/xe_reg_defs.h" +#include "xe_gt_types.h" struct drm_printer ;struct xe_gt ; +#define XE_GT_MCR_DSS_PER_GROUP (gt) (gt_to_xe(gt)->info.platform == XE_PVC ? 8 : 4)
I'd just go ahead and move this to a real function rather than using a macro. We expect the hardware to expose the proper value here via a fuse register at some point in the future (meaning we'll be able to stop hardcoding magic numbers in the driver), and once that happens we'll want to have a function anyway. That will also allow us to avoid the extra header include.
Quoted 32 lines
drivers/gpu/drm/xe/xe_gt_mcr.h +1
-0+void xe_gt_mcr_init (struct xe_gt *gt);void xe_gt_mcr_set_implicit_defaults (struct xe_gt *gt);drivers/gpu/drm/xe/xe_gt_topology.c +0
-3@@ -11,9 +11,6 @@#include "xe_gt.h" #include "xe_mmio.h" -#define XE_MAX_DSS_FUSE_BITS (32 * XE_MAX_DSS_FUSE_REGS) -#define XE_MAX_EU_FUSE_BITS (32 * XE_MAX_EU_FUSE_REGS) -static void load_dss_mask (struct xe_gt *gt,xe_dss_mask_t mask,int numregs, ...) {drivers/gpu/drm/xe/xe_guc_capture.c +6
-0@@ -93,6 +93,35 @@ { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } +static void xe_gt_mcr_get_ss_steering (struct xe_gt *gt,unsigned int dss, +unsigned int *group,unsigned int *instance) +{ +int dss_per_grp =XE_GT_MCR_DSS_PER_GROUP (gt); + + *group = dss / dss_per_grp;
drivers/gpu/drm/xe/xe_guc_capture.c line 111
Quoted 10 lines
drivers/gpu/drm/xe/xe_guc_capture.c +10
-0+ *instance = dss % dss_per_grp; +} + +static bool xe_sseu_has_subslice (struct xe_gt *gt,int slice,int subslice) +{ +int dss_per_grp =XE_GT_MCR_DSS_PER_GROUP (gt); +int index = slice * dss_per_grp + subslice; + +return index >=XE_MAX_DSS_FUSE_BITS ? false :test_bit (index, gt->fuse_topo.g_dss_mask); +}
It would be better if we could avoid leaking the internal implementation of the topology outside of xe_gt_topology.[ch]; if we ever need to change it in the future it's easier when it's self-contained inside a single file with well-defined interfaces to the rest of the driver. So it might be better to have
bool xe_gt_topology_has_dss(struct xe_gt *gt, int dss_num);
to wrap the test_bit part, and
int xe_gt_mcr_get_steering(struct xe_gt* gt, enum xe_steering_type type,
int instance, int *grp, int *inst);
for looking up the steering targets of a specific instance of an MCR register. Then you can use those two helper functions in the GuC capture code without exposing the internal interface details (and they can be re-used in other parts of the code as well).
BTW, why does your function here only check the g_dss_mask? On a platform like PVC that won't match any DSS (since the geometry mask is empty and only the compute mask is set).
Matt
Quoted 33 lines
drivers/gpu/drm/xe/xe_guc_capture.c +13
-0+ +#define _HAS_SS (ss_, gt_, group_, instance_) xe_sseu_has_subslice(gt_, group_, instance_) + +/* +* Loop over each subslice/DSS and determine the group and instance IDs that +* should be used to steer MCR accesses toward this DSS. +*/ +#define for_each_ss_steering (ss_, gt_, group_, instance_) \ + for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \ + ss_ < XE_MAX_DSS_FUSE_BITS; \ + ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \ + for_each_if(_HAS_SS(ss_, gt_, group_, instance_)) +int xe_guc_capture_init (struct xe_guc *guc) {return 0 ;drivers/gpu/drm/xe/xe_hw_engine_types.h +3
-0@@ -65,6 +65,9 @@ struct xe_bo;struct xe_execlist_port ;struct xe_gt ; +#define XE_MAX_DSS_FUSE_BITS (32 * XE_MAX_DSS_FUSE_REGS) +#define XE_MAX_EU_FUSE_BITS (32 * XE_MAX_EU_FUSE_REGS) +/** * struct xe_hw_engine_class_intf - per hw engine class struct interface * Signature · 1 line
2.34.1
Signature · 4 lines
Matt Roper Graphics Software Engineer Linux GPU Platform Enablement Intel Corporation
Re: [PATCH v3 2/9] drm/xe/guc: Expose dss per group for GuC error capture
Please see my comments below.
Regards,
Zhanjun
Quoted 9 lines · Matt Roper
Quoted 9 lines
drivers/gpu/drm/xe/xe_gt_mcr.h +1
-0@@ -7,10 +7,13 @@#define _XE_GT_MCR_H_#include "regs/xe_reg_defs.h" +#include "xe_gt_types.h" struct drm_printer ;struct xe_gt ;
Quoted 9 lines
drivers/gpu/drm/xe/xe_gt_mcr.h line 15
Quoted 1 line
drivers/gpu/drm/xe/xe_gt_mcr.h +1
-0+#define XE_GT_MCR_DSS_PER_GROUP (gt) (gt_to_xe(gt)->info.platform == XE_PVC ? 8 : 4)I'd just go ahead and move this to a real function rather than using a macro. We expect the hardware to expose the proper value here via a fuse register at some point in the future (meaning we'll be able to stop hardcoding magic numbers in the driver), and once that happens we'll want to have a function anyway. That will also allow us to avoid the extra header include.
Yes, will do that in next rev.
Quoted 63 lines
Quoted 33 lines
drivers/gpu/drm/xe/xe_gt_mcr.h +1
-0+void xe_gt_mcr_init (struct xe_gt *gt);void xe_gt_mcr_set_implicit_defaults (struct xe_gt *gt);drivers/gpu/drm/xe/xe_gt_topology.c +0
-3@@ -11,9 +11,6 @@#include "xe_gt.h" #include "xe_mmio.h" -#define XE_MAX_DSS_FUSE_BITS (32 * XE_MAX_DSS_FUSE_REGS) -#define XE_MAX_EU_FUSE_BITS (32 * XE_MAX_EU_FUSE_REGS) -static void load_dss_mask (struct xe_gt *gt,xe_dss_mask_t mask,int numregs, ...) {drivers/gpu/drm/xe/xe_guc_capture.c +6
-0@@ -93,6 +93,35 @@ { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } +static void xe_gt_mcr_get_ss_steering (struct xe_gt *gt,unsigned int dss, +unsigned int *group,unsigned int *instance) +{ +int dss_per_grp =XE_GT_MCR_DSS_PER_GROUP (gt); + + *group = dss / dss_per_grp;drivers/gpu/drm/xe/xe_guc_capture.c line 111
Quoted 10 lines
drivers/gpu/drm/xe/xe_guc_capture.c +10
-0+ *instance = dss % dss_per_grp; +} + +static bool xe_sseu_has_subslice (struct xe_gt *gt,int slice,int subslice) +{ +int dss_per_grp =XE_GT_MCR_DSS_PER_GROUP (gt); +int index = slice * dss_per_grp + subslice; + +return index >=XE_MAX_DSS_FUSE_BITS ? false :test_bit (index, gt->fuse_topo.g_dss_mask); +}It would be better if we could avoid leaking the internal implementation of the topology outside of xe_gt_topology.[ch]; if we ever need to change it in the future it's easier when it's self-contained inside a single file with well-defined interfaces to the rest of the driver. So it might be better to have
bool xe_gt_topology_has_dss(struct xe_gt *gt, int dss_num);to wrap the
test_bitpart, andint xe_gt_mcr_get_steering(struct xe_gt* gt, enum
xe_steering_typetype,
int instance, int *grp, int *inst);for looking up the steering targets of a specific instance of an MCR register. Then you can use those two helper functions in the GuC capture code without exposing the internal interface details (and they can be re-used in other parts of the code as well).
Quoted 6 lines
BTW, why does your function here only check the
g_dss_mask? On a platform like PVC that won't match any DSS (since the geometry mask is empty and only the compute mask is set).Matt
Good catch!
I will rewrite this part, do some test and get back to you later.
Quoted 35 lines
Quoted 34 lines
drivers/gpu/drm/xe/xe_guc_capture.c +13
-0+ +#define _HAS_SS (ss_, gt_, group_, instance_) xe_sseu_has_subslice(gt_, group_, instance_) + +/* +* Loop over each subslice/DSS and determine the group and instance IDs that +* should be used to steer MCR accesses toward this DSS. +*/ +#define for_each_ss_steering (ss_, gt_, group_, instance_) \ + for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \ + ss_ < XE_MAX_DSS_FUSE_BITS; \ + ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \ + for_each_if(_HAS_SS(ss_, gt_, group_, instance_)) +int xe_guc_capture_init (struct xe_guc *guc) {return 0 ;drivers/gpu/drm/xe/xe_hw_engine_types.h +3
-0@@ -65,6 +65,9 @@ struct xe_bo;struct xe_execlist_port ;struct xe_gt ; +#define XE_MAX_DSS_FUSE_BITS (32 * XE_MAX_DSS_FUSE_REGS) +#define XE_MAX_EU_FUSE_BITS (32 * XE_MAX_EU_FUSE_REGS) +/** * struct xe_hw_engine_class_intf - per hw engine class struct interface * Signature · 1 line
2.34.1
PATCH v3 3/9 drm/xe/guc: Update GuC ADS size for error capture
In reply to Zhanjun DongUpdate GuC ADS size allocation to include space for the lists of error state capture register descriptors.
Then, populate GuC ADS with the lists of registers we want GuC to report back to host on engine reset events. This list should include global, engine-class and engine-instance registers for every engine-class type on the current hardware.
Ensure we allocate a persistent store for the register lists that are populated into ADS so that we don't need to allocate memory during GT resets when GuC is reloaded and ADS population happens again.
--- drivers/gpu/drm/xe/xe_guc_ads.c | 222 ++++++++++++++++++- drivers/gpu/drm/xe/xe_guc_ads_types.h | 2 + drivers/gpu/drm/xe/xe_guc_capture.c | 265 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 5 + drivers/gpu/drm/xe/xe_guc_capture_fwif.h | 177 +++++++++++++++ drivers/gpu/drm/xe/xe_guc_fwif.h | 20 ++ drivers/gpu/drm/xe/xe_guc_types.h | 2 + 7 files changed, 683 insertions(+), 10 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_guc_capture_fwif.h
drivers/gpu/drm/xe/xe_guc_ads.c +212 -10
@@ -14,6 +14,8 @@#include "xe_gt.h" #include "xe_gt_ccs_mode.h" #include "xe_guc.h" +#include "xe_guc_capture.h" +#include "xe_guc_capture_fwif.h" #include "xe_hw_engine.h" #include "xe_lrc.h" #include "xe_map.h"
@@ -117,6 +119,8 @@ struct __guc_ads_blob {#define info_map_read (xe_, map_, field_) \ xe_map_rd_field(xe_, map_, 0, struct guc_gt_system_info, field_) +static int guc_capture_prep_lists (struct xe_guc_ads *ads); +static size_t guc_ads_regset_size (struct xe_guc_ads *ads) {struct xe_device *xe =ads_to_xe (ads);
@@ -133,8 +137,7 @@ static size_t guc_ads_golden_lrc_size(struct xe_guc_ads *ads)static size_t guc_ads_capture_size (struct xe_guc_ads *ads) { -/* FIXME: Allocate a proper capture list */ -return PAGE_ALIGN (PAGE_SIZE ); +return PAGE_ALIGN (ads->capture_size); }static size_t guc_ads_um_queues_size (struct xe_guc_ads *ads)
@@ -260,6 +263,41 @@ static size_t calculate_golden_lrc_size(struct xe_guc_ads *ads)return total_size; } +static size_t calculate_capture_worst_size (struct xe_guc_ads *ads) +{ +#if IS_ENABLED (CONFIG_DRM_XE_CAPTURE_ERROR ) +struct xe_guc *guc =ads_to_guc (ads); +size_t total_size, class_size, instance_size, global_size; +int i, j; + +/* Early calcuate the capture size, to reserve capture size before guc init finished, +* as engine mask is not ready, the calculate here is the worst case size +*/ + total_size =PAGE_SIZE ;/* Pad a page in front for empty lists */ +for (i =0 ; i <GUC_CAPTURE_LIST_INDEX_MAX ; i++) { +for (j =0 ; j <GUC_MAX_ENGINE_CLASSES ; j++) { + class_size =0 ; + instance_size =0 ; +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &class_size); +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &instance_size); + total_size += class_size + instance_size; + } + global_size =0 ; +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , &global_size); + total_size +=PAGE_ALIGN (global_size); + } + +return total_size; + +#else /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ + +return 0 ; + +#endif /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ +} +#define MAX_GOLDEN_LRC_SIZE (SZ_4K * 64)int xe_guc_ads_init (struct xe_guc_ads *ads)
@@ -270,6 +308,7 @@ int xe_guc_ads_init(struct xe_guc_ads *ads)struct xe_bo *bo; ads->golden_lrc_size =calculate_golden_lrc_size (ads); + ads->capture_size =calculate_capture_worst_size (ads); ads->regset_size =calculate_regset_size (gt); bo = xe_managed_bo_create_pin_map(xe, tile, guc_ads_size(ads) + MAX_GOLDEN_LRC_SIZE,
@@ -301,9 +340,11 @@ int xe_guc_ads_init_post_hwconfig(struct xe_guc_ads *ads)xe_gt_assert (gt, ads->bo); ads->golden_lrc_size =calculate_golden_lrc_size (ads); + ads->capture_size =0 ;/* Clear capture_size before run guc_capture_prep_lists */ + ads->capture_size =guc_capture_prep_lists (ads); ads->regset_size =calculate_regset_size (gt); -xe_gt_assert (gt, ads->golden_lrc_size + +xe_gt_assert (gt, ads->golden_lrc_size + ads->capture_size + (ads->regset_size - prev_regset_size) <=MAX_GOLDEN_LRC_SIZE );
@@ -393,22 +434,183 @@ static void guc_mapping_table_init(struct xe_gt *gt, } } -static void guc_capture_list_init (struct xe_guc_ads *ads) +#if IS_ENABLED (CONFIG_DRM_XE_CAPTURE_ERROR ) +static u32 guc_get_capture_engine_mask (struct xe_gt *gt,struct iosys_map *info_map, +u32 capture_class) { +struct xe_device *xe =gt_to_xe (gt); +u32 mask; + +switch (capture_class) { +case GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_RENDER_CLASS ]); + mask |=info_map_read (xe, info_map, engine_enabled_masks[GUC_COMPUTE_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_VIDEO : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_VIDEO_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_VIDEOENHANCE_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_BLITTER : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_BLITTER_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_GSC_OTHER : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_GSC_OTHER_CLASS ]); +break ; + +default : + mask =0 ; + } + +return mask; +} + +static int guc_capture_prep_lists (struct xe_guc_ads *ads) +{ +struct xe_guc *guc =ads_to_guc (ads); +struct xe_gt *gt =ads_to_gt (ads); +u32 ads_ggtt, capture_offset, null_ggtt, total_size =0 ; +struct iosys_map info_map; +bool ads_is_mapped; +size_t size =0 ; +void *ptr;int i, j; -u32 addr =xe_bo_ggtt_addr (ads->bo) +guc_ads_capture_offset (ads); -/* FIXME: Populate a proper capture list */ + ads_is_mapped = ads->capture_size !=0 ; +if (ads_is_mapped) { + capture_offset =guc_ads_capture_offset (ads); + ads_ggtt =xe_bo_ggtt_addr (ads->bo); + info_map =IOSYS_MAP_INIT_OFFSET (ads_to_map (ads), + offsetof(struct __guc_ads_blob , system_info)); + }else { +/* Bail with worst case size calculations */ + total_size =calculate_capture_worst_size (ads); +return total_size; + } + +/* first, set aside the first page for a capture_list with zero descriptors */ + total_size =PAGE_SIZE ; +if (!xe_guc_capture_getnullheader (guc, &ptr, &size)) +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, ptr, size); + + null_ggtt = ads_ggtt + capture_offset; + capture_offset +=PAGE_SIZE ; + +/* Populate capture list : at this point adps is already allocated and mapped to worst case +* size +*/ for (i =0 ; i <GUC_CAPTURE_LIST_INDEX_MAX ; i++) { +bool write_empty_list;for (j =0 ; j <GUC_MAX_ENGINE_CLASSES ; j++) { -ads_blob_write (ads, ads.capture_instance[i][j], addr); -ads_blob_write (ads, ads.capture_class[i][j], addr); +u32 engine_mask =guc_get_capture_engine_mask (gt, &info_map, j); +/* null list if we dont have said engine or list */ +if (!engine_mask) { +ads_blob_write (ads, ads.capture_class[i][j], null_ggtt); +ads_blob_write (ads, ads.capture_instance[i][j], null_ggtt); +continue ; + } +/********************************************************/ +/*** engine exists: start with engine-class registers ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &ptr)) +/* everything checked out, populate! */ + write_empty_list = false; + } +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_class[i][j], + ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, + ptr, size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_class[i][j], null_ggtt); + } + +/********************************************************/ +/*** engine exists: next, engine-instance registers ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &ptr)) +/* everything checked out, populate! */ + write_empty_list = false; + } + +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_instance[i][j], + ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, + ptr, size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_instance[i][j], null_ggtt); + } } -ads_blob_write (ads, ads.capture_global[i], addr); +/********************************************************/ +/*** global registers is last in our PF/VF loops ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , + &ptr)) + write_empty_list = false;/* everything checked out, populate! */ + } +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_global[i], ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, ptr, + size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_global[i], null_ggtt); + } } + +if (ads->capture_size !=PAGE_ALIGN (total_size)) +xe_gt_info (gt,"ADS capture alloc size changed from %d to %d\n" , + ads->capture_size,PAGE_ALIGN (total_size)); +return PAGE_ALIGN (total_size); +} + +#else /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ + +static int guc_capture_prep_lists (struct xe_guc_ads *ads) +{ +return 0 ; } +#endif /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ + static void guc_mmio_regset_write_one(struct xe_guc_ads *ads, struct iosys_map *regset_map, struct xe_reg reg,
@@ -595,7 +797,7 @@ void xe_guc_ads_populate(struct xe_guc_ads *ads)guc_mmio_reg_state_init (ads);guc_prep_golden_lrc_null (ads);guc_mapping_table_init (gt, &info_map); -guc_capture_list_init (ads); +guc_capture_prep_lists (ads);guc_doorbell_init (ads);if (xe->info.has_usm) {
drivers/gpu/drm/xe/xe_guc_ads_types.h +2 -0
@@ -20,6 +20,8 @@ struct xe_guc_ads {size_t golden_lrc_size;/** @regset_size: size of register set passed to GuC for save/restore */ u32 regset_size; +/** @capture_size: size of register set passed to GuC for capture */ + u32 capture_size; };#endif
drivers/gpu/drm/xe/xe_guc_capture.c +265 -0
285 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_capture.h +5 -0
@@ -7,9 +7,14 @@#define _XE_GUC_CAPTURE_H#include <linux/types.h> +#include "xe_exec_queue_types.h" struct xe_guc ; +void xe_guc_capture_process (struct xe_guc *guc); +int xe_guc_capture_getlist (struct xe_guc *guc,u32 owner,u32 type,u32 classid,void **outptr); +int xe_guc_capture_getlistsize (struct xe_guc *guc,u32 owner,u32 type,u32 classid,size_t *size); +int xe_guc_capture_getnullheader (struct xe_guc *guc,void **outptr,size_t *size);int xe_guc_capture_init (struct xe_guc *guc);#endif /* _XE_GUC_CAPTURE_H */
drivers/gpu/drm/xe/xe_guc_capture_fwif.h new file +177 -0
177 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_fwif.h +20 -0
@@ -9,6 +9,7 @@#include <linux/bits.h> #include "abi/guc_klvs_abi.h" +#include "xe_hw_engine_types.h" #define G2H_LEN_DW_SCHED_CONTEXT_MODE_SET 4#define G2H_LEN_DW_DEREGISTER_CONTEXT 3
@@ -164,6 +165,8 @@ struct guc_mmio_reg {#define GUC_REGSET_MASKED BIT(0)#define GUC_REGSET_MASKED_WITH_VALUE BIT(2)#define GUC_REGSET_RESTORE_ONLY BIT(3) +#define GUC_REGSET_STEERING_GROUP GENMASK(15, 12) +#define GUC_REGSET_STEERING_INSTANCE GENMASK(23, 20) } __packed;/* GuC register sets */
@@ -192,6 +195,23 @@ enum { GUC_CAPTURE_LIST_INDEX_MAX = 2, }; +/*Register-types of GuC capture register lists */ +enum guc_capture_type { +GUC_CAPTURE_LIST_TYPE_GLOBAL =0 , +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , +GUC_CAPTURE_LIST_TYPE_MAX , +}; + +/* Class indecies for capture_class and capture_instance arrays */ +enum { +GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE =0 , +GUC_CAPTURE_LIST_CLASS_VIDEO =1 , +GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE =2 , +GUC_CAPTURE_LIST_CLASS_BLITTER =3 , +GUC_CAPTURE_LIST_CLASS_GSC_OTHER =4 , +}; +/* GuC Additional Data Struct */ struct guc_ads {struct guc_mmio_reg_set reg_state_list[GUC_MAX_ENGINE_CLASSES ][GUC_MAX_INSTANCES_PER_CLASS ];
drivers/gpu/drm/xe/xe_guc_types.h +2 -0
@@ -43,6 +43,8 @@ struct xe_guc {struct xe_guc_ads ads;/** @ct: GuC ct */ struct xe_guc_ct ct; +/** @capture: the error-state-capture module's data and objects */ +struct xe_guc_state_capture *capture;/** @pc: GuC Power Conservation */ struct xe_guc_pc pc;/** @dbm: GuC Doorbell Manager */
Signature · 1 line
2.34.1
Re: [PATCH v3 3/9] drm/xe/guc: Update GuC ADS size for error capture
Quoted 510 lines · Zhanjun Dong
Update GuC ADS size allocation to include space for the lists of error state capture register descriptors.
Then, populate GuC ADS with the lists of registers we want GuC to report back to host on engine reset events. This list should include global, engine-class and engine-instance registers for every engine-class type on the current hardware.
Ensure we allocate a persistent store for the register lists that are populated into ADS so that we don't need to allocate memory during GT resets when GuC is reloaded and ADS population happens again.
Signed-off-by Zhanjun Dong <[email protected]>--- drivers/gpu/drm/xe/xe_guc_ads.c | 222 ++++++++++++++++++- drivers/gpu/drm/xe/xe_guc_ads_types.h | 2 + drivers/gpu/drm/xe/xe_guc_capture.c | 265 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 5 + drivers/gpu/drm/xe/xe_guc_capture_fwif.h | 177 +++++++++++++++ drivers/gpu/drm/xe/xe_guc_fwif.h | 20 ++ drivers/gpu/drm/xe/xe_guc_types.h | 2 + 7 files changed, 683 insertions(+), 10 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_guc_capture_fwif.hdrivers/gpu/drm/xe/xe_guc_ads.c +212
-10@@ -14,6 +14,8 @@#include "xe_gt.h" #include "xe_gt_ccs_mode.h" #include "xe_guc.h" +#include "xe_guc_capture.h" +#include "xe_guc_capture_fwif.h" #include "xe_hw_engine.h" #include "xe_lrc.h" #include "xe_map.h" @@ -117,6 +119,8 @@ struct __guc_ads_blob {#define info_map_read (xe_, map_, field_) \ xe_map_rd_field(xe_, map_, 0, struct guc_gt_system_info, field_) +static int guc_capture_prep_lists (struct xe_guc_ads *ads); +static size_t guc_ads_regset_size (struct xe_guc_ads *ads) {struct xe_device *xe =ads_to_xe (ads);@@ -133,8 +137,7 @@ static size_t guc_ads_golden_lrc_size(struct xe_guc_ads *ads)static size_t guc_ads_capture_size (struct xe_guc_ads *ads) { -/* FIXME: Allocate a proper capture list */ -return PAGE_ALIGN (PAGE_SIZE ); +return PAGE_ALIGN (ads->capture_size); }static size_t guc_ads_um_queues_size (struct xe_guc_ads *ads)@@ -260,6 +263,41 @@ static size_t calculate_golden_lrc_size(struct xe_guc_ads *ads)return total_size; } +static size_t calculate_capture_worst_size (struct xe_guc_ads *ads) +{ +#if IS_ENABLED (CONFIG_DRM_XE_CAPTURE_ERROR ) +struct xe_guc *guc =ads_to_guc (ads); +size_t total_size, class_size, instance_size, global_size; +int i, j; + +/* Early calcuate the capture size, to reserve capture size before guc init finished, +* as engine mask is not ready, the calculate here is the worst case size +*/ + total_size =PAGE_SIZE ;/* Pad a page in front for empty lists */ +for (i =0 ; i <GUC_CAPTURE_LIST_INDEX_MAX ; i++) { +for (j =0 ; j <GUC_MAX_ENGINE_CLASSES ; j++) { + class_size =0 ; + instance_size =0 ; +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &class_size); +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &instance_size); + total_size += class_size + instance_size; + } + global_size =0 ; +xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , &global_size); + total_size +=PAGE_ALIGN (global_size); + } + +return total_size; + +#else /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ + +return 0 ; + +#endif /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ +} +#define MAX_GOLDEN_LRC_SIZE (SZ_4K * 64)int xe_guc_ads_init (struct xe_guc_ads *ads)@@ -270,6 +308,7 @@ int xe_guc_ads_init(struct xe_guc_ads *ads)struct xe_bo *bo; ads->golden_lrc_size =calculate_golden_lrc_size (ads); + ads->capture_size =calculate_capture_worst_size (ads); ads->regset_size =calculate_regset_size (gt); bo = xe_managed_bo_create_pin_map(xe, tile, guc_ads_size(ads) + MAX_GOLDEN_LRC_SIZE,@@ -301,9 +340,11 @@ int xe_guc_ads_init_post_hwconfig(struct xe_guc_ads *ads)xe_gt_assert (gt, ads->bo); ads->golden_lrc_size =calculate_golden_lrc_size (ads); + ads->capture_size =0 ;/* Clear capture_size before run guc_capture_prep_lists */ + ads->capture_size =guc_capture_prep_lists (ads); ads->regset_size =calculate_regset_size (gt); -xe_gt_assert (gt, ads->golden_lrc_size + +xe_gt_assert (gt, ads->golden_lrc_size + ads->capture_size + (ads->regset_size - prev_regset_size) <=MAX_GOLDEN_LRC_SIZE );@@ -393,22 +434,183 @@ static void guc_mapping_table_init(struct xe_gt *gt, } } -static void guc_capture_list_init (struct xe_guc_ads *ads) +#if IS_ENABLED (CONFIG_DRM_XE_CAPTURE_ERROR ) +static u32 guc_get_capture_engine_mask (struct xe_gt *gt,struct iosys_map *info_map, +u32 capture_class) { +struct xe_device *xe =gt_to_xe (gt); +u32 mask; + +switch (capture_class) { +case GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_RENDER_CLASS ]); + mask |=info_map_read (xe, info_map, engine_enabled_masks[GUC_COMPUTE_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_VIDEO : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_VIDEO_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_VIDEOENHANCE_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_BLITTER : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_BLITTER_CLASS ]); +break ; + +case GUC_CAPTURE_LIST_CLASS_GSC_OTHER : + mask =info_map_read (xe, info_map, engine_enabled_masks[GUC_GSC_OTHER_CLASS ]); +break ; + +default : + mask =0 ; + } + +return mask; +} + +static int guc_capture_prep_lists (struct xe_guc_ads *ads) +{ +struct xe_guc *guc =ads_to_guc (ads); +struct xe_gt *gt =ads_to_gt (ads); +u32 ads_ggtt, capture_offset, null_ggtt, total_size =0 ; +struct iosys_map info_map; +bool ads_is_mapped; +size_t size =0 ; +void *ptr;int i, j; -u32 addr =xe_bo_ggtt_addr (ads->bo) +guc_ads_capture_offset (ads); -/* FIXME: Populate a proper capture list */ + ads_is_mapped = ads->capture_size !=0 ; +if (ads_is_mapped) { + capture_offset =guc_ads_capture_offset (ads); + ads_ggtt =xe_bo_ggtt_addr (ads->bo); + info_map =IOSYS_MAP_INIT_OFFSET (ads_to_map (ads), + offsetof(struct __guc_ads_blob , system_info)); + }else { +/* Bail with worst case size calculations */ + total_size =calculate_capture_worst_size (ads); +return total_size; + } + +/* first, set aside the first page for a capture_list with zero descriptors */ + total_size =PAGE_SIZE ; +if (!xe_guc_capture_getnullheader (guc, &ptr, &size)) +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, ptr, size); + + null_ggtt = ads_ggtt + capture_offset; + capture_offset +=PAGE_SIZE ; + +/* Populate capture list : at this point adps is already allocated and mapped to worst case +* size +*/ for (i =0 ; i <GUC_CAPTURE_LIST_INDEX_MAX ; i++) { +bool write_empty_list;for (j =0 ; j <GUC_MAX_ENGINE_CLASSES ; j++) { -ads_blob_write (ads, ads.capture_instance[i][j], addr); -ads_blob_write (ads, ads.capture_class[i][j], addr); +u32 engine_mask =guc_get_capture_engine_mask (gt, &info_map, j); +/* null list if we dont have said engine or list */ +if (!engine_mask) { +ads_blob_write (ads, ads.capture_class[i][j], null_ggtt); +ads_blob_write (ads, ads.capture_instance[i][j], null_ggtt); +continue ; + } +/********************************************************/ +/*** engine exists: start with engine-class registers ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + j, &ptr)) +/* everything checked out, populate! */ + write_empty_list = false; + } +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_class[i][j], + ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, + ptr, size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_class[i][j], null_ggtt); + } + +/********************************************************/ +/*** engine exists: next, engine-instance registers ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i, +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + j, &ptr)) +/* everything checked out, populate! */ + write_empty_list = false; + } + +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_instance[i][j], + ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, + ptr, size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_instance[i][j], null_ggtt); + } } -ads_blob_write (ads, ads.capture_global[i], addr); +/********************************************************/ +/*** global registers is last in our PF/VF loops ***/ +/********************************************************/ + write_empty_list = true;/* starting assumption is an empty list */ + size =0 ; +if (!xe_guc_capture_getlistsize (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , &size)) { +if (total_size + size > ads->capture_size) +xe_gt_dbg (gt,"Capture size overflow :%lu vs %d\n" , + total_size + size, ads->capture_size); +else if (!xe_guc_capture_getlist (guc, i,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , + &ptr)) + write_empty_list = false;/* everything checked out, populate! */ + } +if (!write_empty_list) { +ads_blob_write (ads, ads.capture_global[i], ads_ggtt + capture_offset); +xe_map_memcpy_to (ads_to_xe (ads),ads_to_map (ads), capture_offset, ptr, + size); + total_size += size; + capture_offset += size; + }else { +ads_blob_write (ads, ads.capture_global[i], null_ggtt); + } } + +if (ads->capture_size !=PAGE_ALIGN (total_size)) +xe_gt_info (gt,"ADS capture alloc size changed from %d to %d\n" , + ads->capture_size,PAGE_ALIGN (total_size)); +return PAGE_ALIGN (total_size); +} + +#else /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ + +static int guc_capture_prep_lists (struct xe_guc_ads *ads) +{ +return 0 ; } +#endif /* IS_ENABLED(CONFIG_DRM_XE_CAPTURE_ERROR) */ + static void guc_mmio_regset_write_one(struct xe_guc_ads *ads, struct iosys_map *regset_map, struct xe_reg reg,@@ -595,7 +797,7 @@ void xe_guc_ads_populate(struct xe_guc_ads *ads)guc_mmio_reg_state_init (ads);guc_prep_golden_lrc_null (ads);guc_mapping_table_init (gt, &info_map); -guc_capture_list_init (ads); +guc_capture_prep_lists (ads);guc_doorbell_init (ads);if (xe->info.has_usm) {drivers/gpu/drm/xe/xe_guc_ads_types.h +2
-0@@ -20,6 +20,8 @@ struct xe_guc_ads {size_t golden_lrc_size;/** @regset_size: size of register set passed to GuC for save/restore */ u32 regset_size; +/** @capture_size: size of register set passed to GuC for capture */ + u32 capture_size; };#endif drivers/gpu/drm/xe/xe_guc_capture.c +156
-0@@ -21,6 +21,7 @@#include "xe_gt_printk.h" #include "xe_guc.h" #include "xe_guc_capture.h" +#include "xe_guc_capture_fwif.h" #include "xe_guc_ct.h" #include "xe_guc_log.h" @@ -93,6 +94,28 @@ { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } +static const char *const capture_list_type_names[] = { +"Global" , +"Class" , +"Instance" , +"unknown" ,/* Default name, if out of bound */ +}; + +static const char *const capture_engine_class_names[] = { +"Render/Compute" , +"Video" , +"VideoEnhance" , +"Blitter" , +"GSC-Other" , +"unknown" ,/* Default name, if out of bound */ +}; + +/* Get item from array by index. +* The last item is the default value, referenced for index out of bound condition. +*/ +#define get_item_with_default (ar, index) (ar[(index) >= ARRAY_SIZE(ar) ? ARRAY_SIZE(ar) - 1 : \ + (index)]) +static void xe_gt_mcr_get_ss_steering (struct xe_gt *gt,unsigned int dss,unsigned int *group,unsigned int *instance) {@@ -122,8 +145,250 @@ static bool xe_sseu_has_subslice(struct xe_gt *gt, int slice, int subslice) ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \for_each_if (_HAS_SS(ss_ ,gt_ ,group_ ,instance_ )) +static const struct __guc_mmio_reg_descr_group * +guc_capture_get_one_list (const struct __guc_mmio_reg_descr_group *reglists, +u32 owner,u32 type,u32 id) +{ +int i; + +if (!reglists) +return NULL ; + +for (i =0 ; reglists[i].list; ++i) { +if (reglists[i].owner == owner && reglists[i].type == type && + (reglists[i].engine == id || reglists[i].type ==GUC_CAPTURE_LIST_TYPE_GLOBAL )) +return ®lists[i]; + } + +return NULL ; +} + +static struct __guc_mmio_reg_descr_group * +guc_capture_get_one_ext_list (struct __guc_mmio_reg_descr_group *reglists, +u32 owner,u32 type,u32 id) +{ +int i; + +if (!reglists) +return NULL ; + +for (i =0 ; reglists[i].extlist; ++i) { +if (reglists[i].owner == owner && reglists[i].type == type && + (reglists[i].engine == id || reglists[i].type ==GUC_CAPTURE_LIST_TYPE_GLOBAL )) +return ®lists[i]; + } + +return NULL ; +} + +static const struct __guc_mmio_reg_descr_group * +guc_capture_get_device_reglist (struct xe_guc *guc) +{ +//FIXME: add register list +return NULL ; +} + +static int +guc_capture_list_init (struct xe_guc *guc,u32 owner,u32 type,u32 classid, +struct guc_mmio_reg *ptr,u16 num_entries) +{ +u32 i =0 , j =0 ; +const struct __guc_mmio_reg_descr_group *reglists = guc->capture->reglists; +struct __guc_mmio_reg_descr_group *extlists = guc->capture->extlists; +const struct __guc_mmio_reg_descr_group *match; +struct __guc_mmio_reg_descr_group *matchext; + +if (!reglists) +return -ENODEV ; + + match =guc_capture_get_one_list (reglists, owner, type, classid); +if (!match) +return -ENODATA ; + +for (i =0 ; i < num_entries && i < match->num_regs; ++i) { + ptr[i].offset = match->list[i].reg.addr; + ptr[i].value =0xDEADF00D ; + ptr[i].flags = match->list[i].flags; + ptr[i].mask = match->list[i].mask; + } + + matchext =guc_capture_get_one_ext_list (extlists, owner, type, classid); +if (matchext) { +for (i = match->num_regs, j =0 ; i < num_entries && + i < (match->num_regs + matchext->num_regs) && + j < matchext->num_regs; ++i, ++j) { + ptr[i].offset = matchext->extlist[j].reg.addr; + ptr[i].value =0xDEADF00D ; + ptr[i].flags = matchext->extlist[j].flags; + ptr[i].mask = matchext->extlist[j].mask; + } + } +if (i < num_entries) +xe_gt_dbg (guc_to_gt (guc),"Got short capture reglist init: %d out %d.\n" , i, + num_entries); + +return 0 ; +} + +static int +guc_cap_list_num_regs (struct xe_guc_state_capture *gc,u32 owner,u32 type,u32 classid) +{ +const struct __guc_mmio_reg_descr_group *match; +struct __guc_mmio_reg_descr_group *matchext; +int num_regs; + + match =guc_capture_get_one_list (gc->reglists, owner, type, classid); +if (!match) +return 0 ; + + num_regs = match->num_regs; + + matchext =guc_capture_get_one_ext_list (gc->extlists, owner, type, classid); +if (matchext) + num_regs += matchext->num_regs; + +return num_regs; +} + +static int +guc_capture_getlistsize (struct xe_guc *guc,u32 owner,u32 type,u32 classid, +size_t *size,bool is_purpose_est) +{ +struct xe_guc_state_capture *gc = guc->capture; +struct __guc_capture_ads_cache *cache = &gc->ads_cache[owner][type][classid]; +int num_regs; + +if (!gc->reglists) { +xe_gt_warn (guc_to_gt (guc),"No capture reglist for this device\n" ); +return -ENODEV ; + } + +if (cache->is_valid) { + *size = cache->size; +return cache->status; + } + +if (!is_purpose_est && owner ==GUC_CAPTURE_LIST_INDEX_PF && + !guc_capture_get_one_list (gc->reglists, owner, type, classid)) { +if (type ==GUC_CAPTURE_LIST_TYPE_GLOBAL ) +xe_gt_warn (guc_to_gt (guc),"Missing capture reglist: global!\n" ); +else +xe_gt_warn (guc_to_gt (guc),"Missing capture reglist: %s(%u):%s(%u)!\n" , +get_item_with_default (capture_list_type_names, type), type, +get_item_with_default (capture_engine_class_names, classid), + classid); +return -ENODEV ;
drivers/gpu/drm/xe/xe_guc_capture.c static bool xe_sseu_has_subslice(struct xe_gt *gt, int slice, int subslice) · line 290
Quoted 10 lines
drivers/gpu/drm/xe/xe_guc_capture.c +10
-0+ } + + num_regs =guc_cap_list_num_regs (gc, owner, type, classid); +/* intentional empty lists can exist depending on hw config */ +if (!num_regs) +return -ENODATA ; + +if (size) + *size =PAGE_ALIGN ((sizeof (struct guc_debug_capture_list )) + + (num_regs *sizeof (struct guc_mmio_reg )));
For MCR regs, don't you need several independent entries in the list to do unicast reads of each group/instance?
Matt
Quoted 367 lines
drivers/gpu/drm/xe/xe_guc_capture.c +99
-0+ +return 0 ; +} + +int +xe_guc_capture_getlistsize (struct xe_guc *guc,u32 owner,u32 type,u32 classid,size_t *size) +{ +return guc_capture_getlistsize (guc, owner, type, classid, size, false); +} + +int +xe_guc_capture_getlist (struct xe_guc *guc,u32 owner,u32 type,u32 classid,void **outptr) +{ +struct xe_guc_state_capture *gc = guc->capture; +struct __guc_capture_ads_cache *cache = &gc->ads_cache[owner][type][classid]; +struct guc_debug_capture_list *listnode; +int ret, num_regs; +u8 *caplist, *tmp; +size_t size =0 ; + +if (!gc->reglists) +return -ENODEV ; + +if (cache->is_valid) { + *outptr = cache->ptr; +return cache->status; + } + + ret =xe_guc_capture_getlistsize (guc, owner, type, classid, &size); +if (ret) { + cache->is_valid = true; + cache->ptr =NULL ; + cache->size =0 ; + cache->status = ret; +return ret; + } + + caplist =kzalloc (size,GFP_KERNEL ); +if (!caplist) { +xe_gt_dbg (guc_to_gt (guc),"Failed to alloc cached register capture list" ); +return -ENOMEM ; + } + +/* populate capture list header */ + tmp = caplist; + num_regs =guc_cap_list_num_regs (guc->capture, owner, type, classid); + listnode = (struct guc_debug_capture_list *)tmp; + listnode->header.info =FIELD_PREP (GUC_CAPTURELISTHDR_NUMDESCR , (u32 )num_regs); + +/* populate list of register descriptor */ + tmp +=sizeof (struct guc_debug_capture_list ); +guc_capture_list_init (guc, owner, type, classid, (struct guc_mmio_reg *)tmp, num_regs); + +/* cache this list */ + cache->is_valid = true; + cache->ptr = caplist; + cache->size = size; + cache->status =0 ; + + *outptr = caplist; + +return 0 ; +} + +int +xe_guc_capture_getnullheader (struct xe_guc *guc,void **outptr,size_t *size) +{ +struct xe_guc_state_capture *gc = guc->capture; +int tmp =sizeof (u32) *4 ; +void *null_header; + +if (gc->ads_null_cache) { + *outptr = gc->ads_null_cache; + *size = tmp; +return 0 ; + } + + null_header =kzalloc (tmp,GFP_KERNEL ); +if (!null_header) { +xe_gt_dbg (guc_to_gt (guc),"Failed to alloc cached register capture null list" ); +return -ENOMEM ; + } + + gc->ads_null_cache = null_header; + *outptr = null_header; + *size = tmp; + +return 0 ; +} +int xe_guc_capture_init (struct xe_guc *guc) { + guc->capture =kzalloc (sizeof (*guc->capture),GFP_KERNEL ); +if (!guc->capture) +return -ENOMEM ; + + guc->capture->reglists =guc_capture_get_device_reglist (guc); + +INIT_LIST_HEAD (&guc->capture->outlist); +INIT_LIST_HEAD (&guc->capture->cachelist); +return 0 ; }drivers/gpu/drm/xe/xe_guc_capture.h +5
-0@@ -7,9 +7,14 @@#define _XE_GUC_CAPTURE_H#include <linux/types.h> +#include "xe_exec_queue_types.h" struct xe_guc ; +void xe_guc_capture_process (struct xe_guc *guc); +int xe_guc_capture_getlist (struct xe_guc *guc,u32 owner,u32 type,u32 classid,void **outptr); +int xe_guc_capture_getlistsize (struct xe_guc *guc,u32 owner,u32 type,u32 classid,size_t *size); +int xe_guc_capture_getnullheader (struct xe_guc *guc,void **outptr,size_t *size);int xe_guc_capture_init (struct xe_guc *guc);#endif /* _XE_GUC_CAPTURE_H */ drivers/gpu/drm/xe/xe_guc_capture_fwif.h new file +177
-0@@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2021-2022 Intel Corporation +*/ + +#ifndef _XE_GUC_CAPTURE_FWIF_H +#define _XE_GUC_CAPTURE_FWIF_H + +#include <linux/types.h> +#include "regs/xe_reg_defs.h" +#include "xe_guc_fwif.h" + +/* +* struct guc_debug_capture_list_header / struct guc_debug_capture_list +* +* As part of ADS registration, these header structures (followed by +* an array of 'struct guc_mmio_reg' entries) are used to register with +* GuC microkernel the list of registers we want it to dump out prior +* to a engine reset. +*/ +struct guc_debug_capture_list_header { +u32 info; +#define GUC_CAPTURELISTHDR_NUMDESCR GENMASK(15, 0) +} __packed; + +struct guc_debug_capture_list { +struct guc_debug_capture_list_header header; +struct guc_mmio_reg regs[]; +} __packed; + +/* +* struct __guc_mmio_reg_descr / struct __guc_mmio_reg_descr_group +* +* xe_guc_capture module uses these structures to maintain static +* tables (per unique platform) that consists of lists of registers +* (offsets, names, flags,...) that are used at the ADS regisration +* time as well as during runtime processing and reporting of error- +* capture states generated by GuC just prior to engine reset events. +*/ +struct __guc_mmio_reg_descr { +struct xe_reg reg; +u32 flags; +u32 mask; +const char *regname; +}; + +struct __guc_mmio_reg_descr_group { +const struct __guc_mmio_reg_descr *list; +u32 num_regs; +u32 owner;/* see enum guc_capture_owner */ +u32 type;/* see enum guc_capture_type */ +u32 engine;/* as per MAX_ENGINE_CLASS */ +struct __guc_mmio_reg_descr *extlist;/* only used for steered registers */ +}; + +/* +* struct guc_state_capture_header_t / struct guc_state_capture_t / +* guc_state_capture_group_header_t / guc_state_capture_group_t +* +* Prior to resetting engines that have hung or faulted, GuC microkernel +* reports the engine error-state (register values that was read) by +* logging them into the shared GuC log buffer using these hierarchy +* of structures. +*/ +struct guc_state_capture_header_t { +u32 owner; +#define CAP_HDR_CAPTURE_VFID GENMASK(7, 0) +u32 info; +#define CAP_HDR_CAPTURE_TYPE GENMASK(3, 0)/* see enum guc_capture_type */ +#define CAP_HDR_ENGINE_CLASS GENMASK(7, 4)/* see GUC_MAX_ENGINE_CLASSES */ +#define CAP_HDR_ENGINE_INSTANCE GENMASK(11, 8) +u32 lrca;/* if type-instance, LRCA (address) that hung, else set to ~0 */ +u32 guc_id;/* if type-instance, context index of hung context, else set to ~0 */ +u32 num_mmios; +#define CAP_HDR_NUM_MMIOS GENMASK(9, 0) +} __packed; + +struct guc_state_capture_t { +struct guc_state_capture_header_t header; +struct guc_mmio_reg mmio_entries[]; +} __packed; + +enum guc_capture_group_types { +GUC_STATE_CAPTURE_GROUP_TYPE_FULL , +GUC_STATE_CAPTURE_GROUP_TYPE_PARTIAL , +GUC_STATE_CAPTURE_GROUP_TYPE_MAX , +}; + +struct guc_state_capture_group_header_t { +u32 owner; +u32 info; +#define CAP_GRP_HDR_NUM_CAPTURES GENMASK(7, 0) +#define CAP_GRP_HDR_CAPTURE_TYPE GENMASK(15, 8)/* guc_capture_group_types */ +} __packed; + +/* this is the top level structure where an error-capture dump starts */ +struct guc_state_capture_group_t { +struct guc_state_capture_group_header_t grp_header; +struct guc_state_capture_t capture_entries[]; +} __packed; + +/* +* struct __guc_capture_ads_cache +* +* A structure to cache register lists that were populated and registered +* with GuC at startup during ADS registration. This allows much quicker +* GuC resets without re-parsing all the tables for the given gt. +*/ +struct __guc_capture_ads_cache { +bool is_valid; +void *ptr; +size_t size; +int status; +}; + +/** +* struct xe_guc_state_capture +* +* Internal context of the xe_guc_capture module. +*/ +struct xe_guc_state_capture { +/** +* @reglists: static table of register lists used for error-capture state. +*/ +const struct __guc_mmio_reg_descr_group *reglists; + +/** +* @extlists: allocated table of steered register lists used for error-capture state. +* +* NOTE: steered registers have multiple instances depending on the HW configuration +* (slices or dual-sub-slices) and thus depends on HW fuses discovered at startup +*/ +struct __guc_mmio_reg_descr_group *extlists; + +/** +* @ads_cache: cached register lists that is ADS format ready +*/ +struct __guc_capture_ads_cache ads_cache[GUC_CAPTURE_LIST_INDEX_MAX ] + [GUC_CAPTURE_LIST_TYPE_MAX ] + [GUC_MAX_ENGINE_CLASSES ]; + +/** +* @ads_null_cache: ADS null cache. +*/ +void *ads_null_cache; + +/** +* @cachelist: Pool of pre-allocated nodes for error capture output +* +* We need this pool of pre-allocated nodes because we cannot +* dynamically allocate new nodes when receiving the G2H notification +* because the event handlers for all G2H event-processing is called +* by the ct processing worker queue and when that queue is being +* processed, there is no absoluate guarantee that we are not in the +* midst of a GT reset operation (which doesn't allow allocations). +*/ +struct list_head cachelist; +#define PREALLOC_NODES_MAX_COUNT (3 * GUC_MAX_ENGINE_CLASSES * GUC_MAX_INSTANCES_PER_CLASS) +#define PREALLOC_NODES_DEFAULT_NUMREGS 64 + +/** +* @max_mmio_per_node: Max MMIO per node. +*/ +int max_mmio_per_node; + +/** +* @outlist: Pool of pre-allocated nodes for error capture output +* +* A linked list of parsed GuC error-capture output data before +* reporting with formatting via i915_gpu_coredump. Each node in this linked list shall +* contain a single engine-capture including global, engine-class and +* engine-instance register dumps as per guc_capture_parsed_output_node +*/ +struct list_head outlist; +}; + +#endif /* _XE_GUC_CAPTURE_FWIF_H */ drivers/gpu/drm/xe/xe_guc_fwif.h +20
-0@@ -9,6 +9,7 @@#include <linux/bits.h> #include "abi/guc_klvs_abi.h" +#include "xe_hw_engine_types.h" #define G2H_LEN_DW_SCHED_CONTEXT_MODE_SET 4#define G2H_LEN_DW_DEREGISTER_CONTEXT 3@@ -164,6 +165,8 @@ struct guc_mmio_reg {#define GUC_REGSET_MASKED BIT(0)#define GUC_REGSET_MASKED_WITH_VALUE BIT(2)#define GUC_REGSET_RESTORE_ONLY BIT(3) +#define GUC_REGSET_STEERING_GROUP GENMASK(15, 12) +#define GUC_REGSET_STEERING_INSTANCE GENMASK(23, 20) } __packed;/* GuC register sets */ @@ -192,6 +195,23 @@ enum { GUC_CAPTURE_LIST_INDEX_MAX = 2, }; +/*Register-types of GuC capture register lists */ +enum guc_capture_type { +GUC_CAPTURE_LIST_TYPE_GLOBAL =0 , +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , +GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , +GUC_CAPTURE_LIST_TYPE_MAX , +}; + +/* Class indecies for capture_class and capture_instance arrays */ +enum { +GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE =0 , +GUC_CAPTURE_LIST_CLASS_VIDEO =1 , +GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE =2 , +GUC_CAPTURE_LIST_CLASS_BLITTER =3 , +GUC_CAPTURE_LIST_CLASS_GSC_OTHER =4 , +}; +/* GuC Additional Data Struct */ struct guc_ads {struct guc_mmio_reg_set reg_state_list[GUC_MAX_ENGINE_CLASSES ][GUC_MAX_INSTANCES_PER_CLASS ];drivers/gpu/drm/xe/xe_guc_types.h +2
-0@@ -43,6 +43,8 @@ struct xe_guc {struct xe_guc_ads ads;/** @ct: GuC ct */ struct xe_guc_ct ct; +/** @capture: the error-state-capture module's data and objects */ +struct xe_guc_state_capture *capture;/** @pc: GuC Power Conservation */ struct xe_guc_pc pc;/** @dbm: GuC Doorbell Manager */ Signature · 1 line
2.34.1
Signature · 4 lines
Matt Roper Graphics Software Engineer Linux GPU Platform Enablement Intel Corporation
PATCH v3 4/9 drm/xe/guc: Add XE_LP steered register lists
In reply to Zhanjun DongAdd the ability for runtime allocation and freeing of steered register list extentions that depend on the detected HW config fuses.
--- drivers/gpu/drm/xe/xe_guc_capture.c | 187 +++++++++++++++++++++++++++- 1 file changed, 185 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_guc_capture.c +185 -2
@@ -94,6 +94,81 @@ { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \ { SFC_DONE(3), 0, 0, "SFC_DONE[3]" } +/* XE_LP Global */ +static const struct __guc_mmio_reg_descr xe_lp_global_regs[] = { +COMMON_XELP_BASE_GLOBAL , +}; + +/* XE_LP Render / Compute Per-Class */ +static const struct __guc_mmio_reg_descr xe_lp_rc_class_regs[] = { +COMMON_XELP_BASE_RENDER , +}; + +/* Pre-Xe Render / Compute Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr pre_xe_rc_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* Pre-Xe Media Decode/Encode Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr pre_xe_vd_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* XE_LP Video Enhancement Per-Class */ +static const struct __guc_mmio_reg_descr xe_lp_vec_class_regs[] = { +COMMON_XELP_BASE_VEC , +}; + +/* Pre-Xe Video Enhancement Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr pre_xe_vec_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* Pre-Xe Blitter Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr pre_xe_blt_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* XE_LP - GSC Per-Engine-Instance */ +static const struct __guc_mmio_reg_descr xe_lp_gsc_inst_regs[] = { +COMMON_BASE_ENGINE_INSTANCE , +}; + +/* +* Empty list to prevent warnings about unknown class/instance types +* as not all class/instanace types have entries on all platforms. +*/ +static const struct __guc_mmio_reg_descr empty_regs_list[] = { +}; + +#define TO_GCAP_DEF_OWNER (x) (GUC_CAPTURE_LIST_INDEX_##x) +#define TO_GCAP_DEF_TYPE (x) (GUC_CAPTURE_LIST_TYPE_##x) +#define MAKE_REGLIST (regslist, regsowner, regstype, class) \ + { \ + regslist, \ + ARRAY_SIZE(regslist), \ + TO_GCAP_DEF_OWNER(regsowner), \ + TO_GCAP_DEF_TYPE(regstype), \ + class, \ + NULL, \ + } + +/* List of lists */ +static const struct __guc_mmio_reg_descr_group xe_lp_lists[] = { +MAKE_REGLIST (xe_lp_global_regs,PF ,GLOBAL ,0 ), +MAKE_REGLIST (xe_lp_rc_class_regs,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE ), +MAKE_REGLIST (pre_xe_rc_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE ), +MAKE_REGLIST (empty_regs_list,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_VIDEO ), +MAKE_REGLIST (pre_xe_vd_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_VIDEO ), +MAKE_REGLIST (xe_lp_vec_class_regs,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE ), +MAKE_REGLIST (pre_xe_vec_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE ), +MAKE_REGLIST (empty_regs_list,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_BLITTER ), +MAKE_REGLIST (pre_xe_blt_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_BLITTER ), +MAKE_REGLIST (empty_regs_list,PF ,ENGINE_CLASS ,GUC_CAPTURE_LIST_CLASS_GSC_OTHER ), +MAKE_REGLIST (xe_lp_gsc_inst_regs,PF ,ENGINE_INSTANCE ,GUC_CAPTURE_LIST_CLASS_GSC_OTHER ), + {} +}; +static const char *const capture_list_type_names[] = {"Global" ,"Class" ,
@@ -181,11 +256,119 @@ guc_capture_get_one_ext_list(struct __guc_mmio_reg_descr_group *reglists,return NULL ; } +struct __ext_steer_reg { +const char *name; +struct xe_reg_mcr reg; +}; + +static const struct __ext_steer_reg pre_xe_extregs[] = { + {"SAMPLER_INSTDONE" ,SAMPLER_INSTDONE }, + {"ROW_INSTDONE" ,ROW_INSTDONE } +}; + +static const struct __ext_steer_reg xehpg_extregs[] = { + {"XEHPG_INSTDONE_GEOM_SVG" ,XEHPG_INSTDONE_GEOM_SVG } +}; + +static void __fill_ext_reg (struct __guc_mmio_reg_descr *ext, +const struct __ext_steer_reg *extlist, +int slice_id,int subslice_id) +{ + ext->reg =XE_REG (extlist->reg.__reg.addr); + ext->flags =FIELD_PREP (GUC_REGSET_STEERING_GROUP , slice_id); + ext->flags |=FIELD_PREP (GUC_REGSET_STEERING_INSTANCE , subslice_id); + ext->regname = extlist->name; +} + +static int +__alloc_ext_regs (struct __guc_mmio_reg_descr_group *newlist, +const struct __guc_mmio_reg_descr_group *rootlist,int num_regs) +{ +struct __guc_mmio_reg_descr *list; + + list =kcalloc (num_regs,sizeof (struct __guc_mmio_reg_descr ),GFP_KERNEL ); +if (!list) +return -ENOMEM ; + + newlist->extlist = list; + newlist->num_regs = num_regs; + newlist->owner = rootlist->owner; + newlist->engine = rootlist->engine; + newlist->type = rootlist->type; + +return 0 ; +} + +static void +guc_capture_alloc_steered_lists (struct xe_guc *guc,const struct __guc_mmio_reg_descr_group *lists) +{ +struct xe_gt *gt =guc_to_gt (guc); +int slice, subslice, iter, i, num_steer_regs, num_tot_regs =0 ; +const struct __guc_mmio_reg_descr_group *list; +struct __guc_mmio_reg_descr_group *extlists; +struct __guc_mmio_reg_descr *extarray; +bool has_xehpg_extregs; + +/* steered registers currently only exist for the render-class */ + list =guc_capture_get_one_list (lists,GUC_CAPTURE_LIST_INDEX_PF , +GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , +GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE ); +/* skip if extlists was previously allocated */ +if (!list || guc->capture->extlists) +return ; + + has_xehpg_extregs =GRAPHICS_VERx100 (gt_to_xe (gt)) >=1255 ; + + num_steer_regs =ARRAY_SIZE (pre_xe_extregs); +if (has_xehpg_extregs) + num_steer_regs +=ARRAY_SIZE (xehpg_extregs); + + num_tot_regs += num_steer_regs *bitmap_weight (gt->fuse_topo.g_dss_mask, +sizeof (gt->fuse_topo.g_dss_mask) *8 ); +if (!num_tot_regs) +return ; + +/* allocate an extra for an end marker */ + extlists =kcalloc (2 ,sizeof (struct __guc_mmio_reg_descr_group ),GFP_KERNEL ); +if (!extlists) +return ; + +if (__alloc_ext_regs (&extlists[0 ], list, num_tot_regs)) { +kfree (extlists); +return ; + } + + extarray = extlists[0 ].extlist; +for_each_ss_steering (iter, gt, slice, subslice) { +for (i =0 ; i <ARRAY_SIZE (pre_xe_extregs); ++i) { +__fill_ext_reg (extarray, &pre_xe_extregs[i], slice, subslice); + ++extarray; + } + +if (has_xehpg_extregs) { +for (i =0 ; i <ARRAY_SIZE (xehpg_extregs); ++i) { +__fill_ext_reg (extarray, &xehpg_extregs[i], slice, subslice); + ++extarray; + } + } + } + +xe_gt_dbg (guc_to_gt (guc),"capture found %d ext-regs.\n" , num_tot_regs); + guc->capture->extlists = extlists; +} +static const struct __guc_mmio_reg_descr_group *guc_capture_get_device_reglist (struct xe_guc *guc) { -//FIXME: add register list -return NULL ; +/* +* For certain engine classes, there are slice and subslice +* level registers requiring steering. We allocate and populate +* these at init time based on hw config add it as an extension +* list at the end of the pre-populated render list. +*/ +guc_capture_alloc_steered_lists (guc, xe_lp_lists); + +return xe_lp_lists; } static int
Signature · 1 line
2.34.1
PATCH v3 5/9 drm/xe/guc: Add capture size check in GuC log buffer
In reply to Zhanjun DongThe capture-nodes is included in GuC log buffer, add the size check for capture region in the whole GuC log buffer.
--- drivers/gpu/drm/xe/xe_gt_printk.h | 3 + drivers/gpu/drm/xe/xe_guc_fwif.h | 48 +++++++ drivers/gpu/drm/xe/xe_guc_log.c | 179 ++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_log.h | 15 +++ drivers/gpu/drm/xe/xe_guc_log_types.h | 26 ++++ 5 files changed, 271 insertions(+)
drivers/gpu/drm/xe/xe_gt_printk.h +3 -0
@@ -22,6 +22,9 @@#define xe_gt_notice (_gt, _fmt, ...) \ xe_gt_printk((_gt), notice, _fmt, ##__VA_ARGS__) +#define xe_gt_notice_ratelimited (_gt, _fmt, ...) \ + xe_gt_printk((_gt), err_ratelimited, _fmt, ##__VA_ARGS__) +#define xe_gt_info (_gt, _fmt, ...) \ xe_gt_printk((_gt), info, _fmt, ##__VA_ARGS__)
drivers/gpu/drm/xe/xe_guc_fwif.h +48 -0
54 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_log.c +179 -0
191 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_log.h +15 -0
@@ -7,6 +7,7 @@#define _XE_GUC_LOG_H_#include "xe_guc_log_types.h" +#include "xe_guc_types.h" struct drm_printer ;
@@ -36,6 +37,11 @@ struct drm_printer;#define GUC_VERBOSITY_TO_LOG_LEVEL (x) ((x) + 2)#define GUC_LOG_LEVEL_MAX GUC_VERBOSITY_TO_LOG_LEVEL(GUC_LOG_VERBOSITY_MAX) +static inline struct xe_guc *log_to_guc (struct xe_guc_log *log) +{ + return container_of(log, struct xe_guc, log); +} +int xe_guc_log_init (struct xe_guc_log *log);void xe_guc_log_print (struct xe_guc_log *log,struct drm_printer *p);
@@ -45,4 +51,13 @@ xe_guc_log_get_level(struct xe_guc_log *log) return log->level; } +u32 xe_guc_log_section_size_capture (struct xe_guc_log *log); + +bool xe_guc_check_log_buf_overflow (struct xe_guc_log *log, +enum guc_log_buffer_type type, +unsigned int full_cnt); +unsigned int xe_guc_get_log_buffer_size (struct xe_guc_log *log, +enum guc_log_buffer_type type); +size_t xe_guc_get_log_buffer_offset (struct xe_guc_log *log, +enum guc_log_buffer_type type);#endif
drivers/gpu/drm/xe/xe_guc_log_types.h +26 -0
@@ -6,7 +6,17 @@#ifndef _XE_GUC_LOG_TYPES_H_#define _XE_GUC_LOG_TYPES_H_ +#include <linux/mutex.h> #include <linux/types.h> +#include <linux/workqueue.h> +#include "xe_guc_fwif.h" + +enum { +GUC_LOG_SECTIONS_CRASH , +GUC_LOG_SECTIONS_DEBUG , +GUC_LOG_SECTIONS_CAPTURE , +GUC_LOG_SECTIONS_LIMIT +};struct xe_bo ;
@@ -18,6 +28,22 @@ struct xe_guc_log {u32 level;/** @bo: XE BO for GuC log */ struct xe_bo *bo; + +/* Allocation settings */ +struct { +s32 bytes;/* Size in bytes */ +s32 units;/* GuC API units - 1MB or 4KB */ +s32 count;/* Number of API units */ +u32 flag;/* GuC API units flag */ + } sizes[GUC_LOG_SECTIONS_LIMIT ]; +bool sizes_initialised; + +/* logging related stats */ +struct { +u32 sampled_overflow; +u32 overflow; +u32 flush; + } stats[GUC_MAX_LOG_BUFFER]; };#endif
Signature · 1 line
2.34.1
PATCH v3 6/9 drm/xe/guc: Check sizing of guc_capture output
In reply to Zhanjun DongAdd capture output size check function to provide a reasonable minimum size for error capture region before allocating the shared buffer.
Add guc capture data structure definition.
--- drivers/gpu/drm/xe/xe_guc_capture.c | 76 ++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture_fwif.h | 45 ++++++++++++++ 2 files changed, 121 insertions(+)
drivers/gpu/drm/xe/xe_guc_capture.c +76 -0
@@ -561,6 +561,81 @@ xe_guc_capture_getnullheader(struct xe_guc *guc, void **outptr, size_t *size)return 0 ; } +static int +guc_capture_output_min_size_est (struct xe_guc *guc) +{ +struct xe_gt *gt =guc_to_gt (guc); +struct xe_hw_engine *hwe; +enum xe_hw_engine_id id; + +int worst_min_size =0 ; +size_t tmp =0 ; + +if (!guc->capture) +return -ENODEV ; + +/* +* If every single engine-instance suffered a failure in quick succession but +* were all unrelated, then a burst of multiple error-capture events would dump +* registers for every one engine instance, one at a time. In this case, GuC +* would even dump the global-registers repeatedly. +* +* For each engine instance, there would be 1 x guc_state_capture_group_t output +* followed by 3 x guc_state_capture_t lists. The latter is how the register +* dumps are split across different register types (where the '3' are global vs class +* vs instance). +*/ +for_each_hw_engine (hwe, gt, id) { + worst_min_size +=sizeof (struct guc_state_capture_group_header_t ) + + (3 *sizeof (struct guc_state_capture_header_t )); + +if (!guc_capture_getlistsize (guc,0 ,GUC_CAPTURE_LIST_TYPE_GLOBAL ,0 , &tmp, true)) + worst_min_size += tmp; + +if (!guc_capture_getlistsize (guc,0 ,GUC_CAPTURE_LIST_TYPE_ENGINE_CLASS , + hwe->class, &tmp, true)) { + worst_min_size += tmp; + } +if (!guc_capture_getlistsize (guc,0 ,GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE , + hwe->class, &tmp, true)) { + worst_min_size += tmp; + } + } + +return worst_min_size; +} + +/* +* Add on a 3x multiplier to allow for multiple back-to-back captures occurring +* before the i915 can read the data out and process it +*/ +#define GUC_CAPTURE_OVERBUFFER_MULTIPLIER 3 + +static void check_guc_capture_size (struct xe_guc *guc) +{ +int min_size =guc_capture_output_min_size_est (guc); +int spare_size = min_size *GUC_CAPTURE_OVERBUFFER_MULTIPLIER ; +u32 buffer_size =xe_guc_log_section_size_capture (&guc->log); + +/* +* NOTE: min_size is much smaller than the capture region allocation (DG2: <80K vs 1MB) +* Additionally, its based on space needed to fit all engines getting reset at once +* within the same G2H handler task slot. This is very unlikely. However, if GuC really +* does run out of space for whatever reason, we will see an separate warning message +* when processing the G2H event capture-notification, search for: +* xe_guc_STATE_CAPTURE_EVENT_STATUS_NOSPACE. +*/ +if (min_size <0 ) +xe_gt_warn (guc_to_gt (guc),"Failed to calculate error state capture buffer minimum size: %d!\n" , + min_size); +else if (min_size > buffer_size) +xe_gt_warn (guc_to_gt (guc),"Error state capture buffer maybe small: %d < %d\n" , + buffer_size, min_size); +else if (spare_size > buffer_size) +xe_gt_dbg (guc_to_gt (guc),"Error state capture buffer lacks spare size: %d < %d (min = %d)\n" , + buffer_size, spare_size, min_size); +} +int xe_guc_capture_init (struct xe_guc *guc) { guc->capture =kzalloc (sizeof (*guc->capture),GFP_KERNEL );
@@ -572,6 +647,7 @@ int xe_guc_capture_init(struct xe_guc *guc)INIT_LIST_HEAD (&guc->capture->outlist);INIT_LIST_HEAD (&guc->capture->cachelist); +check_guc_capture_size (guc);return 0 ; }
drivers/gpu/drm/xe/xe_guc_capture_fwif.h +45 -0
51 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 7/9 drm/xe/guc: Extract GuC error capture lists on G2H notification
In reply to Zhanjun DongUpon the G2H Notify-Err-Capture event, parse through the GuC Log Buffer (error-capture-subregion) and generate one or more capture-nodes. A single node represents a single "engine- instance-capture-dump" and contains at least 3 register lists:
global, engine-class and engine-instance. An internal link list is maintained to store one or more nodes.
Because the link-list node generation happen before the call to devcoredump, duplicate global and engine-class register lists for each engine-instance register dump if we find dependent-engine resets in a engine-capture-group.
--- drivers/gpu/drm/xe/abi/guc_actions_abi.h | 7 + drivers/gpu/drm/xe/xe_guc_capture.c | 576 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_ct.c | 2 + drivers/gpu/drm/xe/xe_guc_submit.c | 22 +- drivers/gpu/drm/xe/xe_guc_submit.h | 3 + 5 files changed, 609 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/abi/guc_actions_abi.h +7 -0
@@ -182,6 +182,13 @@ enum xe_guc_sleep_state_status {#define GUC_LOG_CONTROL_VERBOSITY_MASK (0xF << GUC_LOG_CONTROL_VERBOSITY_SHIFT)#define GUC_LOG_CONTROL_DEFAULT_LOGGING (1 << 8) +enum intel_guc_state_capture_event_status { +XE_GUC_STATE_CAPTURE_EVENT_STATUS_SUCCESS =0x0 , +XE_GUC_STATE_CAPTURE_EVENT_STATUS_NOSPACE =0x1 , +}; + +#define XE_GUC_STATE_CAPTURE_EVENT_STATUS_MASK 0x000000FF +#define XE_GUC_TLB_INVAL_TYPE_SHIFT 0#define XE_GUC_TLB_INVAL_MODE_SHIFT 8/* Flush PPC or SMRO caches along with TLB invalidation request */
drivers/gpu/drm/xe/xe_guc_capture.c +576 -0
588 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_ct.c +2 -0
@@ -987,6 +987,8 @@ static int process_g2h_msg(struct xe_guc_ct *ct, u32 *msg, u32 len)/* Selftest only at the moment */ break ;case XE_GUC_ACTION_STATE_CAPTURE_NOTIFICATION : + ret =xe_guc_error_capture_handler (guc, payload, adj_len); +break ;case XE_GUC_ACTION_NOTIFY_FLUSH_LOG_BUFFER_TO_FILE :/* FIXME: Handle this */ break ;
drivers/gpu/drm/xe/xe_guc_submit.c +21 -1
@@ -23,7 +23,9 @@#include "xe_force_wake.h" #include "xe_gpu_scheduler.h" #include "xe_gt.h" +#include "xe_gt_printk.h" #include "xe_guc.h" +#include "xe_guc_capture.h" #include "xe_guc_ct.h" #include "xe_guc_exec_queue_types.h" #include "xe_guc_submit_types.h"
@@ -758,7 +760,7 @@ static void guc_exec_queue_free_job(struct drm_sched_job *drm_job)xe_sched_job_put (job); } -static int guc_read_stopped (struct xe_guc *guc) +int guc_read_stopped (struct xe_guc *guc) {return atomic_read (&guc->submission_state.stopped); }
@@ -1679,6 +1681,24 @@ int xe_guc_exec_queue_reset_handler(struct xe_guc *guc, u32 *msg, u32 len)return 0 ; } +int xe_guc_error_capture_handler (struct xe_guc *guc,u32 *msg,u32 len) +{ +u32 status; + +if (unlikely (len !=1 )) { +xe_gt_dbg (guc_to_gt (guc),"Invalid length %u" , len); +return -EPROTO ; + } + + status = msg[0 ] &XE_GUC_STATE_CAPTURE_EVENT_STATUS_MASK ; +if (status ==XE_GUC_STATE_CAPTURE_EVENT_STATUS_NOSPACE ) +xe_gt_warn (guc_to_gt (guc),"G2H-Error capture no space" ); + +xe_guc_capture_process (guc); + +return 0 ; +} +int xe_guc_exec_queue_memory_cat_error_handler (struct xe_guc *guc,u32 *msg,u32 len) {
drivers/gpu/drm/xe/xe_guc_submit.h +3 -0
@@ -19,12 +19,15 @@ void xe_guc_submit_reset_wait(struct xe_guc *guc);int xe_guc_submit_stop (struct xe_guc *guc);int xe_guc_submit_start (struct xe_guc *guc); +int guc_read_stopped (struct xe_guc *guc); +int xe_guc_sched_done_handler (struct xe_guc *guc,u32 *msg,u32 len);int xe_guc_deregister_done_handler (struct xe_guc *guc,u32 *msg,u32 len);int xe_guc_exec_queue_reset_handler (struct xe_guc *guc,u32 *msg,u32 len);int xe_guc_exec_queue_memory_cat_error_handler (struct xe_guc *guc,u32 *msg,u32 len);int xe_guc_exec_queue_reset_failure_handler (struct xe_guc *guc,u32 *msg,u32 len); +int xe_guc_error_capture_handler (struct xe_guc *guc,u32 *msg,u32 len);struct xe_guc_submit_exec_queue_snapshot *xe_guc_exec_queue_snapshot_capture (struct xe_exec_queue *q);
Signature · 1 line
2.34.1
PATCH v3 8/9 drm/xe/guc: Pre-allocate output nodes for extraction
In reply to Zhanjun DongPre-allocate a fixed number of empty nodes up front (at the time of ADS registration) that we can consume from or return to an internal cached list of nodes.
--- drivers/gpu/drm/xe/xe_guc.c | 1 + drivers/gpu/drm/xe/xe_guc_capture.c | 122 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_guc_capture.h | 1 + 3 files changed, 124 insertions(+)
drivers/gpu/drm/xe/xe_guc.c +1 -0
@@ -253,6 +253,7 @@ static void guc_fini(struct drm_device *drm, void *arg)xe_force_wake_get (gt_to_fw (guc_to_gt (guc)),XE_FORCEWAKE_ALL );xe_guc_pc_fini (&guc->pc); +xe_guc_capture_destroy (guc);xe_uc_fini_hw (&guc_to_gt (guc)->uc);xe_force_wake_put (gt_to_fw (guc_to_gt (guc)),XE_FORCEWAKE_ALL ); }
drivers/gpu/drm/xe/xe_guc_capture.c +122 -0
158 lines not on this page · raw message
drivers/gpu/drm/xe/xe_guc_capture.h +1 -0
@@ -15,6 +15,7 @@ void xe_guc_capture_process(struct xe_guc *guc);int xe_guc_capture_getlist (struct xe_guc *guc,u32 owner,u32 type,u32 classid,void **outptr);int xe_guc_capture_getlistsize (struct xe_guc *guc,u32 owner,u32 type,u32 classid,size_t *size);int xe_guc_capture_getnullheader (struct xe_guc *guc,void **outptr,size_t *size); +void xe_guc_capture_destroy (struct xe_guc *guc);int xe_guc_capture_init (struct xe_guc *guc);#endif /* _XE_GUC_CAPTURE_H */
Signature · 1 line
2.34.1
PATCH v3 9/9 drm/xe/guc: Plumb GuC-capture into dev coredump
In reply to Zhanjun DongAdd xe_hw_engine_snapshot_from_capture to take snapshot from capture node list.
Add data struct to map register to a snapshot field, although all field is mapped now, which means the offset could be optimized, while in the future, depends on system configuration, the field might not be consecutive. This is reserved for future.
--- drivers/gpu/drm/xe/xe_guc_capture.c | 27 ++++ drivers/gpu/drm/xe/xe_hw_engine.c | 172 ++++++++++++++++++------ drivers/gpu/drm/xe/xe_hw_engine.h | 4 + drivers/gpu/drm/xe/xe_hw_engine_types.h | 108 ++++++++------- 4 files changed, 222 insertions(+), 89 deletions(-)
drivers/gpu/drm/xe/xe_guc_capture.c +27 -0
@@ -169,6 +169,33 @@ static const struct __guc_mmio_reg_descr_group xe_lp_lists[] = { {} }; +struct __reg_map_descr capture_engine_reg[] = { + {offsetof(struct snap_shot_regs , ring_hwstam),RING_HWSTAM (0 )}, + {offsetof(struct snap_shot_regs , ring_hws_pga),RING_HWS_PGA (0 )}, + {offsetof(struct snap_shot_regs , ring_execlist_status_lo),RING_EXECLIST_STATUS_LO (0 )}, + {offsetof(struct snap_shot_regs , ring_execlist_status_hi),RING_EXECLIST_STATUS_HI (0 )}, + {offsetof(struct snap_shot_regs , ring_execlist_sq_contents_lo),RING_EXECLIST_SQ_CONTENTS_LO (0 )}, + {offsetof(struct snap_shot_regs , ring_execlist_sq_contents_hi),RING_EXECLIST_SQ_CONTENTS_HI (0 )}, + {offsetof(struct snap_shot_regs , ring_start),RING_START (0 )}, + {offsetof(struct snap_shot_regs , ring_head),RING_HEAD (0 )}, + {offsetof(struct snap_shot_regs , ring_tail),RING_TAIL (0 )}, + {offsetof(struct snap_shot_regs , ring_ctl),RING_CTL (0 )}, + {offsetof(struct snap_shot_regs , ring_mi_mode),RING_MI_MODE (0 )}, + {offsetof(struct snap_shot_regs , ring_mode),RING_MODE (0 )}, + {offsetof(struct snap_shot_regs , ring_imr),RING_IMR (0 )}, + {offsetof(struct snap_shot_regs , ring_esr),RING_ESR (0 )}, + {offsetof(struct snap_shot_regs , ring_emr),RING_EMR (0 )}, + {offsetof(struct snap_shot_regs , ring_eir),RING_EIR (0 )}, + {offsetof(struct snap_shot_regs , ring_acthd_udw),RING_ACTHD_UDW (0 )}, + {offsetof(struct snap_shot_regs , ring_acthd),RING_ACTHD (0 )}, + {offsetof(struct snap_shot_regs , ring_bbaddr_udw),RING_BBADDR_UDW (0 )}, + {offsetof(struct snap_shot_regs , ring_bbaddr),RING_BBADDR (0 )}, + {offsetof(struct snap_shot_regs , ring_dma_fadd_udw),RING_DMA_FADD_UDW (0 )}, + {offsetof(struct snap_shot_regs , ring_dma_fadd),RING_DMA_FADD (0 )}, + {offsetof(struct snap_shot_regs , ipehr),RING_IPEHR (0 )}, + {offsetof(struct snap_shot_regs , rcu_mode),RCU_MODE }, +}; +static const char *const capture_list_type_names[] = {"Global" ,"Class" ,
drivers/gpu/drm/xe/xe_hw_engine.c +133 -39
197 lines not on this page · raw message
drivers/gpu/drm/xe/xe_hw_engine.h +4 -0
@@ -62,6 +62,10 @@ void xe_hw_engine_print(struct xe_hw_engine *hwe, struct drm_printer *p);void xe_hw_engine_setup_default_lrc_state (struct xe_hw_engine *hwe);bool xe_hw_engine_is_reserved (struct xe_hw_engine *hwe); +void xe_hw_engine_snapshot_from_engine (struct xe_hw_engine *hwe, +struct xe_hw_engine_snapshot *snapshot); +void xe_hw_engine_snapshot_from_capture (struct xe_hw_engine *hwe, +struct xe_hw_engine_snapshot *snapshot);static inline bool xe_hw_engine_is_valid (struct xe_hw_engine *hwe) {return hwe->name;
drivers/gpu/drm/xe/xe_hw_engine_types.h +58 -50
120 lines not on this page · raw message
Signature · 1 line
2.34.1
Patchwork
CI✓ CI.Patch_applied: success for drm/xe/guc: Add GuC based register capture for error capture (rev2)
In reply to Zhanjun Dong== Series Details ==
== Series Details ==
Series: drm/xe/guc: Add GuC based register capture for error capture (rev2)
URL : https://patchwork.freedesktop.org/series/128077/
State : success
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: ed982e1f2 drm-tip: 2024y-01m-18d-23h-31m-18s UTC integration manifest === git am output follows ===
Applying: drm/xe/guc: Add register defines for GuC based register capture
Applying: drm/xe/guc: Expose dss per group for GuC error capture
Applying: drm/xe/guc: Update GuC ADS size for error capture
Applying: drm/xe/guc: Add XE_LP steered register lists
Applying: drm/xe/guc: Add capture size check in GuC log buffer
Applying: drm/xe/guc: Check sizing of guc_capture output
Applying: drm/xe/guc: Extract GuC error capture lists on G2H notification
Applying: drm/xe/guc: Pre-allocate output nodes for extraction
Applying: drm/xe/guc: Plumb GuC-capture into dev coredump
Patchwork
CI✗ CI.checkpatch: warning for drm/xe/guc: Add GuC based register capture for error capture (rev2)
In reply to Zhanjun Dong== Series Details ==
== Series Details ==
Series: drm/xe/guc: Add GuC based register capture for error capture (rev2)
URL : https://patchwork.freedesktop.org/series/128077/
State : warning
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master e7f730565356938dd6c63cd498218fdc5d6a22b0
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit 2e5e399a9f5fd13e711cbe48f632b77923a7298a
Author: Zhanjun Dong <[email protected]> Date: Thu Jan 18 16:42:03 2024 -0800
drm/xe/guc: Plumb GuC-capture into dev coredump
Add xe_hw_engine_snapshot_from_capture to take snapshot from capture node list.
Add data struct to map register to a snapshot field, although all field is mapped now, which means the offset could be optimized, while in the future, depends on system configuration, the field might not be consecutive. This is reserved for future.
+ /mt/dim checkpatch ed982e1f2709684a702b81cc5a0a0811570ab589 drm-intel43a25c60f drm/xe/guc: Add register defines for GuC based register capture
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:7: WARNING:COMMIT_LOG_LONG_LINE: Prefer a maximum 75 chars per line (possible unwrapped commit description?) #7:
Add registers defines and list of registers for GuC based error state capture.
-:179: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #179:
new file mode 100644
-:222: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #222: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:39:
+#define COMMON_XELP_BASE_GLOBAL \
+ { FORCEWAKE_GT, 0, 0, "FORCEWAKE" }, \
+ { FAULT_TLB_DATA0, 0, 0, "FAULT_TLB_DATA0" }, \
+ { FAULT_TLB_DATA1, 0, 0, "FAULT_TLB_DATA1" }, \+ { AUX_ERR_DBG, 0, 0, "AUX_ERR_DBG" }, \
+ { GAM_DONE, 0, 0, "GAM_DONE" }, \
+ { RING_FAULT_REG, 0, 0, "FAULT_REG" }
-:230: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #230: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:47:
+#define COMMON_BASE_ENGINE_INSTANCE \
+ { RING_PSMI_CTL(0), 0, 0, "RC PSMI" }, \
+ { RING_ESR(0), 0, 0, "ESR" }, \
+ { RING_EMR(0), 0, 0, "EMR" }, \
+ { RING_EIR(0), 0, 0, "EIR" }, \
+ { RING_EXECLIST_STATUS_HI(0), 0, 0, "RING_EXECLIST_STATUS_HI" }, \
+ { RING_EXECLIST_STATUS_LO(0), 0, 0, "RING_EXECLIST_STATUS_LO" }, \
+ { RING_DMA_FADD(0), 0, 0, "RING_DMA_FADD_LDW" }, \
+ { RING_DMA_FADD_UDW(0), 0, 0, "RING_DMA_FADD_UDW" }, \
+ { RING_IPEIR(0), 0, 0, "IPEIR" }, \
+ { RING_IPEHR(0), 0, 0, "IPEHR" }, \
+ { RING_INSTPS(0), 0, 0, "INSTPS" }, \
+ { RING_BBADDR(0), 0, 0, "RING_BBADDR_LOW32" }, \
+ { RING_BBADDR_UDW(0), 0, 0, "RING_BBADDR_UP32" }, \
+ { RING_BBSTATE(0), 0, 0, "BB_STATE" }, \
+ { CCID(0), 0, 0, "CCID" }, \
+ { RING_ACTHD(0), 0, 0, "ACTHD_LDW" }, \
+ { RING_ACTHD_UDW(0), 0, 0, "ACTHD_UDW" }, \
+ { INSTPM(0), 0, 0, "INSTPM" }, \
+ { RING_INSTDONE(0), 0, 0, "INSTDONE" }, \
+ { RING_NOPID(0), 0, 0, "RING_NOPID" }, \
+ { RING_START(0), 0, 0, "START" }, \
+ { RING_HEAD(0), 0, 0, "HEAD" }, \
+ { RING_TAIL(0), 0, 0, "TAIL" }, \
+ { RING_CTL(0), 0, 0, "CTL" }, \
+ { RING_MI_MODE(0), 0, 0, "MODE" }, \
+ { RING_CONTEXT_CONTROL(0), 0, 0, "RING_CONTEXT_CONTROL" }, \
+ { RING_HWS_PGA(0), 0, 0, "HWS" }, \
+ { RING_MODE(0), 0, 0, "GFX_MODE" }, \
+ { RING_PDP_LDW(0, 0), 0, 0, "PDP0_LDW" }, \
+ { RING_PDP_UDW(0, 0), 0, 0, "PDP0_UDW" }, \
+ { RING_PDP_LDW(0, 1), 0, 0, "PDP1_LDW" }, \
+ { RING_PDP_UDW(0, 1), 0, 0, "PDP1_UDW" }, \
+ { RING_PDP_LDW(0, 2), 0, 0, "PDP2_LDW" }, \
+ { RING_PDP_UDW(0, 2), 0, 0, "PDP2_UDW" }, \
+ { RING_PDP_LDW(0, 3), 0, 0, "PDP3_LDW" }, \
+ { RING_PDP_UDW(0, 3), 0, 0, "PDP3_UDW" }-:268: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #268: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:85:
+#define COMMON_XELP_BASE_RENDER \
+ { SC_INSTDONE, 0, 0, "SC_INSTDONE" }, \
+ { SC_INSTDONE_EXTRA, 0, 0, "SC_INSTDONE_EXTRA" }, \
+ { SC_INSTDONE_EXTRA2, 0, 0, "SC_INSTDONE_EXTRA2" }
-:273: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #273: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:90:
+#define COMMON_XELP_BASE_VEC \
+ { SFC_DONE(0), 0, 0, "SFC_DONE[0]" }, \
+ { SFC_DONE(1), 0, 0, "SFC_DONE[1]" }, \
+ { SFC_DONE(2), 0, 0, "SFC_DONE[2]" }, \
+ { SFC_DONE(3), 0, 0, "SFC_DONE[3]" }total: 4 errors, 2 warnings, 0 checks, 257 lines checkededdd19f9a drm/xe/guc: Expose dss per group for GuC error capture -:87: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'ss_' - possible side-effects? #87: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:119:
+#define for_each_ss_steering(ss_, gt_, group_, instance_) \
+ for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \
+ ss_ < XE_MAX_DSS_FUSE_BITS; \
+ ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \
+ for_each_if(_HAS_SS(ss_, gt_, group_, instance_))
-:87: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'gt_' - possible side-effects? #87: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:119:
+#define for_each_ss_steering(ss_, gt_, group_, instance_) \
+ for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \
+ ss_ < XE_MAX_DSS_FUSE_BITS; \
+ ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \
+ for_each_if(_HAS_SS(ss_, gt_, group_, instance_))
-:87: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'group_' - possible side-effects? #87: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:119:
+#define for_each_ss_steering(ss_, gt_, group_, instance_) \
+ for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \
+ ss_ < XE_MAX_DSS_FUSE_BITS; \
+ ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \
+ for_each_if(_HAS_SS(ss_, gt_, group_, instance_))
-:87: CHECK:MACRO_ARG_PRECEDENCE: Macro argument 'group_' may be better as '(group_)' to avoid precedence issues #87: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:119:
+#define for_each_ss_steering(ss_, gt_, group_, instance_) \
+ for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \
+ ss_ < XE_MAX_DSS_FUSE_BITS; \
+ ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \
+ for_each_if(_HAS_SS(ss_, gt_, group_, instance_))
-:87: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'instance_' - possible side-effects? #87: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:119:
+#define for_each_ss_steering(ss_, gt_, group_, instance_) \
+ for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \
+ ss_ < XE_MAX_DSS_FUSE_BITS; \
+ ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \
+ for_each_if(_HAS_SS(ss_, gt_, group_, instance_))
-:87: CHECK:MACRO_ARG_PRECEDENCE: Macro argument 'instance_' may be better as '(instance_)' to avoid precedence issues #87: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:119:
+#define for_each_ss_steering(ss_, gt_, group_, instance_) \
+ for (ss_ = 0, xe_gt_mcr_get_ss_steering(gt_, 0, &group_, &instance_); \
+ ss_ < XE_MAX_DSS_FUSE_BITS; \
+ ss_++, xe_gt_mcr_get_ss_steering(gt_, ss_, &group_, &instance_)) \
+ for_each_if(_HAS_SS(ss_, gt_, group_, instance_))
total: 0 errors, 0 warnings, 6 checks, 74 lines checked 07e1c7c36 drm/xe/guc: Update GuC ADS size for error capture Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:245: WARNING:LONG_LINE: line length of 103 exceeds 100 columns #245: FILE: drivers/gpu/drm/xe/xe_guc_ads.c:557:
+ GUC_CAPTURE_LIST_TYPE_ENGINE_INSTANCE,
-:363: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'ar' - possible side-effects? #363: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:116:
+#define get_item_with_default(ar, index) (ar[(index) >= ARRAY_SIZE(ar) ? ARRAY_SIZE(ar) - 1 : \
+ (index)])
-:363: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'index' - possible side-effects? #363: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:116:
+#define get_item_with_default(ar, index) (ar[(index) >= ARRAY_SIZE(ar) ? ARRAY_SIZE(ar) - 1 : \
+ (index)])
-:555: WARNING:OOM_MESSAGE: Possible unnecessary 'out of memory' message #555: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:330:
+ if (!caplist) {
+ xe_gt_dbg(guc_to_gt(guc), "Failed to alloc cached register capture list");
-:595: WARNING:OOM_MESSAGE: Possible unnecessary 'out of memory' message #595: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:370:
+ if (!null_header) {
+ xe_gt_dbg(guc_to_gt(guc), "Failed to alloc cached register capture null list");
-:640: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #640:
new file mode 100644
total: 0 errors, 4 warnings, 2 checks, 812 lines checked66461d434 drm/xe/guc: Add XE_LP steered register lists
-:69: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'regslist' - possible side-effects? #69: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:146:
+#define MAKE_REGLIST(regslist, regsowner, regstype, class) \
+ { \
+ regslist, \
+ ARRAY_SIZE(regslist), \
+ TO_GCAP_DEF_OWNER(regsowner), \
+ TO_GCAP_DEF_TYPE(regstype), \
+ class, \
+ NULL, \
+ }
-:83: WARNING:LONG_LINE: line length of 102 exceeds 100 columns #83: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:160:
+ MAKE_REGLIST(pre_xe_rc_inst_regs, PF, ENGINE_INSTANCE, GUC_CAPTURE_LIST_CLASS_RENDER_COMPUTE),
-:87: WARNING:LONG_LINE: line length of 101 exceeds 100 columns #87: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:164:
+ MAKE_REGLIST(pre_xe_vec_inst_regs, PF, ENGINE_INSTANCE, GUC_CAPTURE_LIST_CLASS_VIDEOENHANCE),
total: 0 errors, 2 warnings, 1 checks, 202 lines checked 1a1a0b467 drm/xe/guc: Add capture size check in GuC log buffer b6c2a78c0 drm/xe/guc: Check sizing of guc_capture output db85fe6ef drm/xe/guc: Extract GuC error capture lists on G2H notification cb53ee709 drm/xe/guc: Pre-allocate output nodes for extraction 2e5e399a9 drm/xe/guc: Plumb GuC-capture into dev coredump -:28: WARNING:LONG_LINE: line length of 105 exceeds 100 columns #28: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:177:
+ {offsetof(struct snap_shot_regs, ring_execlist_sq_contents_lo), RING_EXECLIST_SQ_CONTENTS_LO(0)},
-:29: WARNING:LONG_LINE: line length of 105 exceeds 100 columns #29: FILE: drivers/gpu/drm/xe/xe_guc_capture.c:178:
+ {offsetof(struct snap_shot_regs, ring_execlist_sq_contents_hi), RING_EXECLIST_SQ_CONTENTS_HI(0)},
-:74: WARNING:LONG_LINE: line length of 105 exceeds 100 columns #74: FILE: drivers/gpu/drm/xe/xe_hw_engine.c:267:
+ {offsetof(struct snap_shot_regs, ring_execlist_sq_contents_lo), RING_EXECLIST_SQ_CONTENTS_LO(0)},
-:75: WARNING:LONG_LINE: line length of 105 exceeds 100 columns #75: FILE: drivers/gpu/drm/xe/xe_hw_engine.c:268:
+ {offsetof(struct snap_shot_regs, ring_execlist_sq_contents_hi), RING_EXECLIST_SQ_CONTENTS_HI(0)},
total: 0 errors, 4 warnings, 0 checks, 360 lines checked
Patchwork
CI✗ CI.KUnit: failure for drm/xe/guc: Add GuC based register capture for error capture (rev2)
In reply to Zhanjun Dong== Series Details ==
== Series Details ==
Series: drm/xe/guc: Add GuC based register capture for error capture (rev2)
URL : https://patchwork.freedesktop.org/series/128077/
State : failure
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
ERROR:root:../drivers/gpu/drm/xe/xe_guc_capture.c: In function ‘xe_guc_capture_destroy’:../drivers/gpu/drm/xe/xe_guc_capture.c:1347:2: error: implicit declaration of function ‘guc_capture_delete_prealloc_nodes’; did you mean ‘guc_capture_create_prealloc_nodes’? [-Werror=implicit-function-declaration]
1347 | guc_capture_delete_prealloc_nodes(guc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| guc_capture_create_prealloc_nodes
../drivers/gpu/drm/xe/xe_guc_capture.c:1349:2: error: implicit declaration of function ‘guc_capture_free_extlists’; did you mean ‘guc_capture_get_one_ext_list’? [-Werror=implicit-function-declaration]
1349 | guc_capture_free_extlists(guc->capture->extlists);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
| guc_capture_get_one_ext_listcc1: some warnings being treated as errors
make[7]: *** [../scripts/Makefile.build:243: drivers/gpu/drm/xe/xe_guc_capture.o] Error 1 make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:480: drivers/gpu/drm/xe] Error 2 make[6]: *** Waiting for unfinished jobs....
make[5]: *** [../scripts/Makefile.build:480: drivers/gpu/drm] Error 2 make[4]: *** [../scripts/Makefile.build:480: drivers/gpu] Error 2
make[3]: *** [../scripts/Makefile.build:480: drivers] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [/kernel/Makefile:1911: .] Error 2
make[1]: *** [/kernel/Makefile:234: __sub-make] Error 2
make: *** [Makefile:234: __sub-make] Error 2
[00:56:08] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig [00:56:13] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make ARCH=um O=.kunit --jobs=48 + cleanup ++ stat -c %u:%g /kernel + chown -R 1003:1003 /kernel