drm/xe: Create and use XE_DEVICE_WA infrastructure
Subsystems (2)
v2 cover drm/xe: Create and use XE_DEVICE_WA infrastructure
There currently is not a way to apply and track workarounds that are needed ahead of GT init. This series adds a bit field to the xe_device structure similar to those in the GT structures to apply and track workarounds applied at runtime (oobs).
Device workarounds in this new infrastructure are tracked in the existing sysfs entries in gtX/workarounds.
Currently 15015404425 is the only workaround like this, so move it to using this new infrastructure.
PTL A0 is impacted by 15015404425, but only applies to Compute Die A0 stepping. The reality of modern platforms is that we're a Multi Chip Package with logic spread acress multiple dies. This information not being readily available during PCI probe without a read makes this more complicated.
Apply 15015404425 to PTL unconditionally during PCI probe (and GT init). After GT init use the Media GT stepping to determine if we can disable this workaround.
v2: Change naming from SoC to device, address styling issues, update commit messages
Matt Atwood (5):
drm/xe: add xe_device_wa infrastructure
drm/xe: Add infrastructure for Device OOB workarounds drm/xe: Move Wa_15015404425 to use the new EX_DEVICE_WA macro drm/xe: extend Wa_15015404425 to apply to PTL drm/xe: disable wa_15015404425 for PTL B0
drivers/gpu/drm/xe/Makefile | 11 +++++- drivers/gpu/drm/xe/xe_device_types.h | 9 +++++ drivers/gpu/drm/xe/xe_device_wa_oob.rules | 2 + drivers/gpu/drm/xe/xe_gen_wa_oob.c | 27 +++++++++---- drivers/gpu/drm/xe/xe_mmio.c | 10 ++--- drivers/gpu/drm/xe/xe_pci.c | 11 ++++++ drivers/gpu/drm/xe/xe_rtp.c | 5 +++ drivers/gpu/drm/xe/xe_rtp.h | 3 +- drivers/gpu/drm/xe/xe_rtp_types.h | 2 + drivers/gpu/drm/xe/xe_wa.c | 46 +++++++++++++++++++++++ drivers/gpu/drm/xe/xe_wa.h | 18 +++++++-- drivers/gpu/drm/xe/xe_wa_oob.rules | 1 + 12 files changed, 127 insertions(+), 18 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_device_wa_oob.rules
Signature · 1 line
2.49.0
PATCH v2 1/5 drm/xe: add xe_device_wa infrastructure
There are some workarounds that must be applied before gt init, wa_150154044425 for example. Instead of sprinkling them conditionally throughout the driver as we did for i915 generate an oob.rules file reusing the RTP infrastructure to make these easier to track.
v2: rename xe_soc_wa to xe_device_wa
--- drivers/gpu/drm/xe/Makefile | 11 ++++++++- drivers/gpu/drm/xe/xe_device_wa_oob.rules | 0 drivers/gpu/drm/xe/xe_gen_wa_oob.c | 27 ++++++++++++++++------- 3 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_device_wa_oob.rules
drivers/gpu/drm/xe/Makefile +10 -1
@@ -21,6 +21,15 @@ $(obj)/generated/%_wa_oob.c $(obj)/generated/%_wa_oob.h: $(obj)/xe_gen_wa_oob \ $(src)/xe_wa_oob.rules $(call cmd,wa_oob) +generated_device_oob := $(obj)/generated/xe_device_wa_oob.c $(obj)/generated/xe_device_wa_oob.h +quiet_cmd_device_wa_oob = GEN $(notdir $(generated_device_oob)) + cmd_device_wa_oob = mkdir -p $(@D); $^ $(generated_device_oob) +$(obj)/generated/%_device_wa_oob.c $(obj)/generated/%_device_wa_oob.h: $(obj)/xe_gen_wa_oob \ + $(src)/xe_device_wa_oob.rules + $(call cmd,device_wa_oob) + + + # Please keep these build lists sorted! # core driver code
@@ -339,4 +348,4 @@ $(obj)/%.hdrtest: $(src)/%.h FORCE $(call if_changed_dep,hdrtest) uses_generated_oob := $(addprefix $(obj)/, $(xe-y)) -$(uses_generated_oob): $(obj)/generated/xe_wa_oob.h +$(uses_generated_oob): $(obj)/generated/xe_wa_oob.h $(obj)/generated/xe_device_wa_oob.h
drivers/gpu/drm/xe/xe_device_wa_oob.rules new file +0 -0
drivers/gpu/drm/xe/xe_gen_wa_oob.c +19 -8
@@ -18,8 +18,8 @@" *\n" \" * This file was generated from rules: %s\n" \" */\n" \ -"#ifndef _GENERATED_XE_WA_OOB_\n" \ -"#define _GENERATED_XE_WA_OOB_\n" \ +"#ifndef _GENERATED_%s_\n" \ +"#define _GENERATED_%s_\n" \"\n" \"enum {\n"
@@ -52,7 +52,7 @@ static char *strip(char *line, size_t linelen) }#define MAX_LINE_LEN 4096 -static int parse (FILE *input,FILE *csource,FILE *cheader) +static int parse (FILE *input,FILE *csource,FILE *cheader,bool device) {char line[MAX_LINE_LEN +1 ];char *name, *prev_name =NULL , *rules;
@@ -96,7 +96,10 @@ static int parse(FILE *input, FILE *csource, FILE *cheader) }if (name) { -fprintf (cheader,"\tXE_WA_OOB_%s = %u,\n" , name, idx); +if (device == false) +fprintf (cheader,"\tXE_WA_OOB_%s = %u,\n" , name, idx); +else +fprintf (cheader,"\tXE_DEVICE_WA_OOB_%s = %u,\n" , name, idx);/* Close previous entry before starting a new one */ if (idx)
@@ -117,8 +120,10 @@ static int parse(FILE *input, FILE *csource, FILE *cheader)/* Close last entry */ if (idx)fprintf (csource,") },\n" ); - -fprintf (cheader,"\t_XE_WA_OOB_COUNT = %u\n" , idx); +if (device == false) +fprintf (cheader,"\t_XE_WA_OOB_COUNT = %u\n" , idx); +else +fprintf (cheader,"\t_XE_DEVICE_WA_OOB_COUNT = %u\n" , idx);return 0 ; }
@@ -157,9 +162,15 @@ int main(int argc, const char *argv[]) } } -fprintf (args[ARGS_CHEADER ].f,HEADER , args[ARGS_INPUT ].fn); +char *device =strstr (args[ARGS_CHEADER ].fn,"device_" ); +if (device ==NULL ) +fprintf (args[ARGS_CHEADER ].f,HEADER , args[ARGS_INPUT ].fn,"XE_WA_OOB" ,"XE_WA_OOB" ); +else +fprintf (args[ARGS_CHEADER ].f,HEADER , args[ARGS_INPUT ].fn,"XE_DEVICE_WA_OOB" ,"XE_DEVICE_WA_OOB" ); + +bool prefix = device !=NULL ? true : false; ret =parse (args[ARGS_INPUT ].f, args[ARGS_CSOURCE ].f, - args[ARGS_CHEADER ].f); + args[ARGS_CHEADER ].f, prefix);if (!ret)fprintf (args[ARGS_CHEADER ].f,FOOTER );
Signature · 1 line
2.49.0
PATCH v2 2/5 drm/xe: Add infrastructure for Device OOB workarounds
In reply to Matt AtwoodSome workarounds need to be able to be applied ahead of any GT initialization for example 15015404425. This patch creates XE_DEVICE_WA macro, in the same vein as XE_WA. This macro can be used ahead of GT initialization, and can be tracked in sysfs. This should alleviate some of the complexities that exist in i915.
v2: name change SoC to Device, address style issues
--- drivers/gpu/drm/xe/xe_device_types.h | 9 ++++++ drivers/gpu/drm/xe/xe_pci.c | 4 +++ drivers/gpu/drm/xe/xe_rtp.c | 5 +++ drivers/gpu/drm/xe/xe_rtp.h | 3 +- drivers/gpu/drm/xe/xe_rtp_types.h | 2 ++ drivers/gpu/drm/xe/xe_wa.c | 46 ++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_wa.h | 18 +++++++++-- 7 files changed, 83 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_device_types.h +9 -0
@@ -360,6 +360,15 @@ struct xe_device { u8 skip_pcode:1; } info; +/** @xe_active.oob: bitmap with active OOB workarounds */ +unsigned long *oob; +/** +* @xe_active.oob_initialized: mark oob as initialized to help +* detecting misuse of XE_SOC_WA() - it can only be called on +* initialization after SOC OOB WAs have been processed +*/ +bool oob_initialized; +/** @survivability: survivability information for device */ struct xe_survivability survivability;
drivers/gpu/drm/xe/xe_pci.c +4 -0
@@ -32,6 +32,7 @@#include "xe_step.h" #include "xe_survivability_mode.h" #include "xe_tile.h" +#include "xe_wa.h" enum toggle_d3cold {D3COLD_DISABLE ,
@@ -832,6 +833,9 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)if (err)return err; +xe_device_wa_init (xe); +xe_device_wa_process_oob (xe); + err =xe_device_probe_early (xe);/* * In Boot Survivability mode, no drm card is exposed and driver
drivers/gpu/drm/xe/xe_rtp.c +5 -0
@@ -196,6 +196,11 @@ static void rtp_get_context(struct xe_rtp_process_ctx *ctx, *gt = (*hwe)->gt; *xe =gt_to_xe (*gt);break ; +case XE_RTP_PROCESS_TYPE_DEVICE : + *hwe =NULL ; + *gt =NULL ; + *xe = ctx->xe; +break ; } }
drivers/gpu/drm/xe/xe_rtp.h +2 -1
@@ -422,7 +422,8 @@ struct xe_reg_sr;#define XE_RTP_PROCESS_CTX_INITIALIZER (arg__) _Generic((arg__), \ struct xe_hw_engine * : (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_ENGINE }, \ - struct xe_gt * : (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT }) + struct xe_gt * : (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_GT }, \ + struct xe_device * : (struct xe_rtp_process_ctx){ { (void *)(arg__) }, XE_RTP_PROCESS_TYPE_DEVICE }) void xe_rtp_process_ctx_enable_active_tracking(struct xe_rtp_process_ctx *ctx, unsigned long *active_entries,
drivers/gpu/drm/xe/xe_rtp_types.h +2 -0
@@ -112,12 +112,14 @@ struct xe_rtp_entry {enum xe_rtp_process_type {XE_RTP_PROCESS_TYPE_GT ,XE_RTP_PROCESS_TYPE_ENGINE , +XE_RTP_PROCESS_TYPE_DEVICE , };struct xe_rtp_process_ctx {union {struct xe_gt *gt;struct xe_hw_engine *hwe; +struct xe_device *xe; };enum xe_rtp_process_type type;unsigned long *active_entries;
drivers/gpu/drm/xe/xe_wa.c +46 -0
70 lines not on this page · raw message
drivers/gpu/drm/xe/xe_wa.h +15 -3
@@ -14,7 +14,9 @@ struct xe_hw_engine;struct xe_tile ;int xe_wa_init (struct xe_gt *gt); +int xe_device_wa_init (struct xe_device *xe);void xe_wa_process_oob (struct xe_gt *gt); +void xe_device_wa_process_oob (struct xe_device *xe);void xe_wa_process_gt (struct xe_gt *gt);void xe_wa_process_engine (struct xe_hw_engine *hwe);void xe_wa_process_lrc (struct xe_hw_engine *hwe);
@@ -22,14 +24,24 @@ void xe_wa_apply_tile_workarounds(struct xe_tile *tile);void xe_wa_dump (struct xe_gt *gt,struct drm_printer *p);/** -* XE_WA - Out-of-band workarounds, that don't fit the lifecycle any -* other more specific type +* XE_WA - Out-of-band GT workarounds, that don't fit the lifecycle any +* other more specific type, * @gt__: gt instance -* @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h +* @id__: XE_WA_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h */ #define XE_WA (gt__, id__) ({ \ xe_gt_assert(gt__, (gt__)->wa_active.oob_initialized); \ test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob); \ }) +/** +* XE_DEVICE_WA - Out-of-band Device workarounds, that don't fit the lifecycle any +* other more specific type +* @xe__: xe_device +* @id__: XE_SOC_WA_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h +*/ +#define XE_DEVICE_WA (xe__, id__) ({ \ + xe_assert(xe__, (xe__)->oob_initialized); \ + test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->oob); \ +})#endif
Signature · 1 line
2.49.0
PATCH v2 3/5 drm/xe: Move Wa_15015404425 to use the new EX_DEVICE_WA macro
In reply to Matt AtwoodMove Wa_15015404425 to use the new implemented OOB macro XE_DEVICE_WA()
v2: rename from SoC to Device
--- drivers/gpu/drm/xe/xe_device_wa_oob.rules | 1 + drivers/gpu/drm/xe/xe_mmio.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_device_wa_oob.rules +1 -0
@@ -0,0 +1 @@ +15015404425 PLATFORM(LUNARLAKE)
drivers/gpu/drm/xe/xe_mmio.c +5 -5
@@ -22,6 +22,9 @@#include "xe_macros.h" #include "xe_sriov.h" #include "xe_trace.h" +#include "xe_wa.h" + +#include "generated/xe_soc_wa_oob.h" static void tiles_fini (void *arg) {
@@ -163,9 +166,6 @@ static void mmio_flush_pending_writes(struct xe_mmio *mmio)#define DUMMY_REG_OFFSET 0x130030int i; -if (mmio->tile->xe->info.platform !=XE_LUNARLAKE ) -return ; -/* 4 dummy writes */ for (i =0 ; i <4 ; i++)writel (0 , mmio->regs +DUMMY_REG_OFFSET );
@@ -176,8 +176,8 @@ u8 xe_mmio_read8(struct xe_mmio *mmio, struct xe_reg reg)u32 addr =xe_mmio_adjusted_addr (mmio, reg.addr);u8 val; -/* Wa_15015404425 */ -mmio_flush_pending_writes (mmio); +if (XE_DEVICE_WA (mmio->tile->xe,15015404425 )) +mmio_flush_pending_writes (mmio); val =readb (mmio->regs + addr);trace_xe_reg_rw (mmio, false, addr, val,sizeof (val));
Signature · 1 line
2.49.0
PATCH v2 4/5 drm/xe: extend Wa_15015404425 to apply to PTL
In reply to Matt AtwoodWa_15015404425 needs to be applied to PTL A0 to B0, a subsequent patch will address the complexity required to do this. For now apply to PTL as a whole.
--- drivers/gpu/drm/xe/xe_device_wa_oob.rules | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/xe/xe_device_wa_oob.rules +1 -0
@@ -1 +1,2 @@ 15015404425 PLATFORM(LUNARLAKE) + PLATFORM(PANTHERLAKE)
Signature · 1 line
2.49.0
PATCH v2 5/5 drm/xe: disable wa_15015404425 for PTL B0
In reply to Matt AtwoodThis workaround only applies to PTL Compute Die A0. The reality of modern platforms is we're Multi Chip Packages with logic spread across multiple dies. Because this information is not available during PCI probe it becomes a bit more complicated.
This workaround needs to be applied on PTL until we prove that we are not Compute Die A0 stepping without reading any MMIOs. So use the new XE_DEVICE_WA infrastructure to apply early, until we can determine our stepping.
There are at least two ways to determine Compute Die stepping. This patch uses the Media GT stepping to map to Compute Die stepping, in this case Compute and Media dies step synchronously.
Since we're using the Media GT information to determine Compute Die stepping, use the XE_WA and the oob infrastructure to come back and toggle the workaround off when we know its safe, and after GT init.
v2: rename SoC to device, avoid null pointer dereference, update commit message.
--- drivers/gpu/drm/xe/xe_pci.c | 7 +++++++ drivers/gpu/drm/xe/xe_wa_oob.rules | 1 + 2 files changed, 8 insertions(+)
drivers/gpu/drm/xe/xe_pci.c +7 -0
@@ -34,6 +34,9 @@#include "xe_tile.h" #include "xe_wa.h" +#include "generated/xe_wa_oob.h" +#include "generated/xe_device_wa_oob.h" +enum toggle_d3cold {D3COLD_DISABLE ,D3COLD_ENABLE ,
@@ -896,6 +899,10 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)drm_dbg (&xe->drm,"d3cold: capable=%s\n" ,str_yes_no (xe->d3cold.capable)); +if (xe->tiles->media_gt !=NULL && + XE_WA(xe->tiles->media_gt, 15015404425_disable)) + xe->oob[XE_DEVICE_WA_OOB_15015404425 ] =0 ; +return 0 ; err_driver_cleanup:
drivers/gpu/drm/xe/xe_wa_oob.rules +1 -0
@@ -71,3 +71,4 @@ no_media_l3 MEDIA_VERSION(3000) # primary GT GMDID 14022085890 GRAPHICS_VERSION(2001) 16026007364 MEDIA_VERSION(3000) +15015404425_disable PLATFORM(PANTHERLAKE), MEDIA_STEP(B0, FOREVER)
Signature · 1 line
2.49.0