Work around media 52-bit limitation on CRI
Subsystems (2)
cover Work around media 52-bit limitation on CRI
Note this is somewhat of an RFC right now to get early feedback. I'm planning a follow up to clean some of this up shortly.
This is a combination of two series I have on the list now, [1] and [2]. I've already gotten some feedback from Rodrigo and Sashiko on both of these I'm planning to incorporate. Apologies those updates didn't make it in to this series yet. I'm also planning on reviewing at least [1] separately since this likely needs more discussion anyway and isn't strictly related/required to the current series.
The main two patches I'm interested in getting feedback in the meantime are:
drm/xe: Add enable_media module parameter
drm/xe: Work around media 52-bit limitation on CRI
The latter is the crux of the workaround here. The first sets up the module parameter which will be used to disable media by default.
The reason to include a module parameter here is we have some customers who are planning many CRI devices on a single host. The request from those customers is to have a way to configure all of the cards on that host at one time rather than having to loop through each device separately (i.e. module parameter instead of configfs). We do already have a configfs that allows media to be disabled (gt_types_allowed = 'primary'), but this is both meant for developer debug, not production configuration, and it requires that per-device configuration.
The workaround details are provided in that last patch in the series so I won't duplicate all of that here, but at a high level, media is now disabled by default and in order to maintain performance for compute when media is enabled on a system that supports 52-bit addressing, PCIe level address translation is supported, but an internal configuration of address translation for the media GAM is disabled. Again, the details of how this is done are in that last patch.
Again, I'm not planning on merging these as-is, but just to clarify,
[1] is attempting to separate the primary and media GT. This is mostly for debug but also used to refactor for that last patch. Likely in the repost I'll just drop this for now and review it completely separately, skipping this refactor unless it's deemed particularly interesting.
[2] is adding a few fixes and refactors in preparation for the actual workaround so I'll be keeping these in the repost. Two of the three patches there have been reviewed (with some feedback) already. The third I'm planning to drop after feedback from Rodrigo.
v2:
- Again, no plan to merge as-is. To facilitate some testing of different GFSP versions, temporarily downgrade the error handling for the media defeature command. See that last patch for details.
[1] https://patchwork.freedesktop.org/series/178247/
[2] https://patchwork.freedesktop.org/series/177792/
Stuart Summers (17):
drm/xe/sysctrl: Use preallocated mailbox staging buffers drm/xe: Process device OOB workarounds during early info init drm/xe/sysctrl: Restore the SoC remapper on every runtime resume drm/xe: Add enable_media module parameter
drm/xe: Detect each GMD_ID IP in a loop
drm/xe: Tolerate a missing graphics IP in xe_info_init() drm/xe: Verify IP presence against GU_CNTL
drm/xe: Guard per-tile primary GT accesses
drm/xe: Stop assuming the root tile has a primary GT drm/xe: Do not claim flat CCS without a graphics IP drm/xe: Run page table updates on the media GT when there is no
primary
drm/xe: Document that gt_types_allowed=media now probes drm/xe: Fall back to CPU copies when the tile cannot blit drm/xe: Require a fully visible VRAM BAR without a primary GT drm/xe: Allow probe without a primary GT
drm/xe: Work around media 52-bit limitation on CRI drm/xe: Don't error on failed media defeature
drivers/gpu/drm/xe/regs/xe_regs.h | 2 + drivers/gpu/drm/xe/xe_bo.c | 43 +++- drivers/gpu/drm/xe/xe_configfs.c | 10 +- drivers/gpu/drm/xe/xe_defaults.h | 1 + drivers/gpu/drm/xe/xe_device.c | 27 +- drivers/gpu/drm/xe/xe_device.h | 17 ++ drivers/gpu/drm/xe/xe_device_types.h | 2 + drivers/gpu/drm/xe/xe_device_wa_oob.rules | 1 + drivers/gpu/drm/xe/xe_exec_queue.c | 5 +- drivers/gpu/drm/xe/xe_gt.c | 11 +- drivers/gpu/drm/xe/xe_memirq.c | 3 +- drivers/gpu/drm/xe/xe_migrate.c | 45 +++- drivers/gpu/drm/xe/xe_migrate.h | 2 + drivers/gpu/drm/xe/xe_module.c | 7 + drivers/gpu/drm/xe/xe_module.h | 1 + drivers/gpu/drm/xe/xe_oa.c | 24 +- drivers/gpu/drm/xe/xe_pagefault.c | 4 +- drivers/gpu/drm/xe/xe_pci.c | 241 ++++++++++++++---- drivers/gpu/drm/xe/xe_pm.c | 13 +- drivers/gpu/drm/xe/xe_query.c | 3 +- drivers/gpu/drm/xe/xe_ras.c | 18 +- drivers/gpu/drm/xe/xe_sysctrl.c | 195 +++++++++++++- drivers/gpu/drm/xe/xe_sysctrl.h | 2 + drivers/gpu/drm/xe/xe_sysctrl_debugfs.c | 6 +- drivers/gpu/drm/xe/xe_sysctrl_event.c | 2 +- drivers/gpu/drm/xe/xe_sysctrl_mailbox.c | 81 +++--- drivers/gpu/drm/xe/xe_sysctrl_mailbox.h | 3 +- drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 34 +++ drivers/gpu/drm/xe/xe_sysctrl_types.h | 17 ++ drivers/gpu/drm/xe/xe_tile.h | 32 +++ drivers/gpu/drm/xe/xe_tlb_inval.c | 20 +- drivers/gpu/drm/xe/xe_vm.c | 2 +- drivers/gpu/drm/xe/xe_vram.c | 15 ++ 33 files changed, 710 insertions(+), 179 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/17 drm/xe/sysctrl: Use preallocated mailbox staging buffers
Every mailbox command stages its request and response through a buffer allocated with GFP_KERNEL. Both are bounded by the maximum mailbox message size and the command mutex already serialises every sender, so embed them in struct xe_sysctrl and drop the per-command allocation.
This removes the only failure mode from sysctrl_prepare_command(), so return the command size directly, and allows commands to be sent from contexts where a GFP_KERNEL allocation is not possible - such as the runtime resume path, which gains a sender later in this series.
--- drivers/gpu/drm/xe/xe_sysctrl_mailbox.c | 56 +++++++++---------------- drivers/gpu/drm/xe/xe_sysctrl_types.h | 11 +++++ 2 files changed, 31 insertions(+), 36 deletions(-)
drivers/gpu/drm/xe/xe_sysctrl_mailbox.c +20 -36
@@ -6,7 +6,6 @@#include <linux/bitfield.h> #include <linux/cleanup.h> #include <linux/minmax.h> -#include <linux/slab.h> #include <linux/sprintf.h> #include <linux/string.h>
@@ -103,36 +102,27 @@ static void sysctrl_clear_response(struct xe_sysctrl *sc)xe_mmio_rmw32 (sc->mmio,SYSCTRL_MB_CTRL ,SYSCTRL_MB_CTRL_RUN_BUSY_OUT ,0 ); } -static int sysctrl_prepare_command (struct xe_device *xe, -u8 group_id,u8 command, -const void *data_in,size_t data_in_len, -u8 **mbox_cmd,size_t *cmd_size) +static size_t sysctrl_prepare_command (struct xe_sysctrl *sc, +u8 group_id,u8 command, +const void *data_in,size_t data_in_len) {struct xe_sysctrl_mailbox_msg_hdr *hdr; -size_t size; -u8 *buffer; +struct xe_device *xe =sc_to_xe (sc); + +lockdep_assert_held (&sc->cmd_lock);xe_assert (xe, command <=SYSCTRL_HDR_COMMAND_MAX );xe_assert (xe, data_in_len <=XE_SYSCTRL_MB_MAX_MESSAGE_SIZE -sizeof (*hdr)); - size =sizeof (*hdr) + data_in_len; - - buffer =kmalloc (size,GFP_KERNEL ); -if (!buffer) -return -ENOMEM ; - - hdr = (struct xe_sysctrl_mailbox_msg_hdr *)buffer; + hdr = (struct xe_sysctrl_mailbox_msg_hdr *)sc->cmd_buf; hdr->data =REG_FIELD_PREP (SYSCTRL_HDR_GROUP_ID_MASK , group_id) |REG_FIELD_PREP (SYSCTRL_HDR_COMMAND_MASK , command);if (data_in && data_in_len) -memcpy (buffer +sizeof (*hdr), data_in, data_in_len); - - *mbox_cmd = buffer; - *cmd_size = size; +memcpy (sc->cmd_buf +sizeof (*hdr), data_in, data_in_len); -return 0 ; +return sizeof (*hdr) + data_in_len; } static int sysctrl_send_frames(struct xe_sysctrl *sc,
@@ -231,14 +221,17 @@ static int sysctrl_receive_frames(struct xe_sysctrl *sc,struct xe_sysctrl_mailbox_msg_hdr *hdr;struct xe_device *xe =sc_to_xe (sc);size_t remain =sizeof (*hdr) + data_out_len; - u8 *buffer __free(kfree) = kzalloc(remain, GFP_KERNEL); +u8 *buffer = sc->resp_buf;size_t frame_size;bool done = false;int ret =0 ;u8 *out; -if (!buffer) -return -ENOMEM ; +lockdep_assert_held (&sc->cmd_lock); + +xe_assert (xe, data_out_len <=XE_SYSCTRL_MB_MAX_MESSAGE_SIZE -sizeof (*hdr)); + +memset (buffer,0 , remain); out = buffer;while (!done && remain) {
@@ -360,8 +353,7 @@ int xe_sysctrl_send_command(struct xe_sysctrl *sc, {struct xe_device *xe =sc_to_xe (sc);u8 group_id, command_code; -u8 *mbox_cmd =NULL ; -size_t cmd_size =0 ; +size_t cmd_size;unsigned int timeout_ms;int ret;
@@ -380,25 +372,17 @@ int xe_sysctrl_send_command(struct xe_sysctrl *sc,might_sleep (); - ret =sysctrl_prepare_command (xe, group_id, command_code, - cmd->data_in, cmd->data_in_len, - &mbox_cmd, &cmd_size); -if (ret) { -xe_log_err (xe,SYSCTRL , ret,"Failed to prepare command %#x.%#x\n" , - group_id, command_code); -return ret; - } -guard (mutex)(&sc->cmd_lock); - ret =sysctrl_send_command (sc, mbox_cmd, cmd_size, + cmd_size =sysctrl_prepare_command (sc, group_id, command_code, + cmd->data_in, cmd->data_in_len); + + ret =sysctrl_send_command (sc, sc->cmd_buf, cmd_size, cmd->data_out, cmd->data_out_len, rdata_len, timeout_ms);if (ret)xe_log_err (xe,SYSCTRL , ret,"Mailbox command failed to send %#x.%#x\n" , group_id, command_code); -kfree (mbox_cmd); -return ret; }
drivers/gpu/drm/xe/xe_sysctrl_types.h +11 -0
@@ -58,6 +58,17 @@ struct xe_sysctrl {/** @cmd_lock: Mutex protecting mailbox command operations */ struct mutex cmd_lock; +/** +* @cmd_buf: Request staging buffer, sized to the maximum mailbox +* message. Preallocated because commands are sent from the runtime +* resume path, which may be entered from reclaim. Protected by +* @cmd_lock. +*/ +u8 cmd_buf[XE_SYSCTRL_MB_MAX_MESSAGE_SIZE ]; + +/** @resp_buf: Response staging buffer, see @cmd_buf */ +u8 resp_buf[XE_SYSCTRL_MB_MAX_MESSAGE_SIZE ]; +/** @work: Pending events worker */ struct work_struct work;
Signature · 1 line
2.43.0
PATCH 2/17 drm/xe: Process device OOB workarounds during early info init
In reply to Stuart SummersDevice OOB workarounds only match on platform, subplatform and platform step, all of which are known once xe_info_init_early() has copied them out of the device descriptor. Processing them there instead of in xe_device_probe_early() makes XE_DEVICE_WA() usable for the rest of early probe, which runs before xe_device_probe_early().
While moving the call, check the return value of xe_wa_device_init(), which the old call site silently dropped.
--- drivers/gpu/drm/xe/xe_device.c | 3 --- drivers/gpu/drm/xe/xe_pci.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_device.c +0 -3
@@ -715,9 +715,6 @@ int xe_device_probe_early(struct xe_device *xe) {int err; -xe_wa_device_init (xe); -xe_wa_process_device_oob (xe); - err =xe_mmio_probe_early (xe);if (err)return err;
drivers/gpu/drm/xe/xe_pci.c +14 -0
@@ -15,6 +15,8 @@#include <drm/drm_drv.h> #include <drm/intel/pciids.h> +#include <generated/xe_device_wa_oob.h> +#include "display/xe_display.h" #include "regs/xe_gt_regs.h" #include "regs/xe_regs.h"
@@ -40,6 +42,7 @@#include "xe_tile.h" #include "xe_tile_printk.h" #include "xe_wedge.h" +#include "xe_wa.h" enum toggle_d3cold {D3COLD_DISABLE ,
@@ -795,6 +798,17 @@ static int xe_info_init_early(struct xe_device *xe, xe->info.subplatform = subplatform_desc ? subplatform_desc->subplatform :XE_SUBPLATFORM_NONE ; +/* +* Device OOB workarounds only match on platform, subplatform and +* platform step, which are all known by now, so process them here and +* make XE_DEVICE_WA() usable for the remainder of early probe. +*/ + err =xe_wa_device_init (xe); +if (err) +return err; + +xe_wa_process_device_oob (xe); + xe->info.dma_mask_size = desc->dma_mask_size; xe->info.va_bits = desc->va_bits; xe->info.vm_max_level = desc->vm_max_level;
Signature · 1 line
2.43.0
PATCH 3/17 drm/xe/sysctrl: Restore the SoC remapper on every runtime resume
In reply to Stuart SummersThe SoC remapper configuration is lost whenever the device loses power, and @d3cold.allowed only records the state xe asked the PCI core for. The platform can still drop power behind our back when the bridge above us runtime suspends, which leaves the remapper unprogrammed and any later System Controller access pointed at nothing.
Restore it on every runtime resume instead.
--- drivers/gpu/drm/xe/xe_pm.c | 9 +++++++-- drivers/gpu/drm/xe/xe_sysctrl.c | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_pm.c +7 -2
@@ -654,8 +654,13 @@ int xe_pm_runtime_resume(struct xe_device *xe)xe_i2c_pm_resume (xe, xe->d3cold.allowed); -if (xe->d3cold.allowed) -xe_sysctrl_pm_resume (xe); +/* +* Done unconditionally: @d3cold.allowed is only the state xe asked the +* PCI core for, the platform can still drop power when the bridge +* above us runtime suspends, taking the SoC remapper configuration +* with it. +*/ +xe_sysctrl_pm_resume (xe);xe_display_pm_runtime_resume_early (xe);
drivers/gpu/drm/xe/xe_sysctrl.c +4 -2
@@ -129,8 +129,10 @@ void xe_sysctrl_irq_handler(struct xe_device *xe, u32 master_ctl)* xe_sysctrl_pm_resume() - System Controller resume handler * @xe: xe device instance * -* Invoked during system resume (S3/S4 to S0) and runtime resume from D3cold. -* Restores SoC remapper configuration. +* Invoked during system resume (S3/S4 to S0) and on every runtime resume. +* Restores SoC remapper configuration, which is lost whenever the device +* loses power - including when the platform drops power behind our back +* because the bridge above us runtime suspended. */ void xe_sysctrl_pm_resume (struct xe_device *xe) {
Signature · 1 line
2.43.0
PATCH 4/17 drm/xe: Add enable_media module parameter
In reply to Stuart SummersThe gt_types_allowed configfs attribute is intended for debug only, so provide a supported way to disable the media GT in production. The modparam takes precedence over configfs so a single knob is enough to guarantee the media GT is left alone.
The parameter is tri-state so that -1 can leave the decision to the driver, which currently enables media wherever it is present.
Both inputs are writable while the driver runs, so latch the result into xe->info.media_allowed during early probe and read it back through xe_device_media_allowed(). That keeps the decision fixed for the lifetime of the device and makes it available outside xe_pci.c.
--- drivers/gpu/drm/xe/xe_configfs.c | 3 +++ drivers/gpu/drm/xe/xe_defaults.h | 1 + drivers/gpu/drm/xe/xe_device.c | 14 ++++++++++++++ drivers/gpu/drm/xe/xe_device.h | 1 + drivers/gpu/drm/xe/xe_device_types.h | 2 ++ drivers/gpu/drm/xe/xe_module.c | 7 +++++++ drivers/gpu/drm/xe/xe_module.h | 1 + drivers/gpu/drm/xe/xe_pci.c | 21 ++++++++++++++++++--- 8 files changed, 47 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_configfs.c +3 -0
@@ -96,6 +96,9 @@* will always return one GT type per line. "primary" and "media" are the * GT type names supported by this interface. * +* Note that the ``enable_media=0`` module parameter takes precedence over +* this attribute: it disables the media GT even if "media" is listed here. +* * This attribute can only be set before binding to the device. * * Examples:
drivers/gpu/drm/xe/xe_defaults.h +1 -0
@@ -13,6 +13,7 @@#define XE_DEFAULT_GUC_LOG_LEVEL 1#endif +#define XE_DEFAULT_ENABLE_MEDIA -1#define XE_DEFAULT_PROBE_DISPLAY IS_ENABLED(CONFIG_DRM_XE_DISPLAY)#define XE_DEFAULT_VRAM_BAR_SIZE 0#define XE_DEFAULT_FORCE_PROBE CONFIG_DRM_XE_FORCE_PROBE
drivers/gpu/drm/xe/xe_device.c +14 -0
@@ -377,6 +377,20 @@ bool xe_device_is_admin_only(const struct xe_device *xe) }#endif +/** +* xe_device_media_allowed() - Check whether the media IP may be used. +* @xe: the &xe_device to check +* +* Returns the decision latched during early probe, see +* @xe_device.info.media_allowed. +* +* Return: true if media may be used, false otherwise. +*/ +bool xe_device_media_allowed (struct xe_device *xe) +{ +return xe->info.media_allowed; +} +/* Number of allocated struct xe_device */ static atomic_t xe_device_count;
drivers/gpu/drm/xe/xe_device.h +1 -0
@@ -279,6 +279,7 @@ static inline bool xe_device_is_admin_only(const struct xe_device *xe) }#endif +bool xe_device_media_allowed (struct xe_device *xe);void xe_device_exit (void );/*
drivers/gpu/drm/xe/xe_device_types.h +2 -0
@@ -226,6 +226,8 @@ struct xe_device { u8 has_pt_mirror:1;/** @info.is_dgfx: is discrete device */ u8 is_dgfx:1; +/** @info.media_allowed: Media IP may be used */ + u8 media_allowed:1;/** @info.needs_scratch: needs scratch page for oob prefetch to work */ u8 needs_scratch:1;/**
drivers/gpu/drm/xe/xe_module.c +7 -0
@@ -22,6 +22,7 @@#include "xe_sched_job.h" struct xe_modparam xe_modparam = { + .enable_media =XE_DEFAULT_ENABLE_MEDIA , .probe_display =XE_DEFAULT_PROBE_DISPLAY , .guc_log_level =XE_DEFAULT_GUC_LOG_LEVEL , .force_probe =XE_DEFAULT_FORCE_PROBE ,
@@ -38,6 +39,12 @@ module_param_named(svm_notifier_size, xe_modparam.svm_notifier_size, uint, 0600) MODULE_PARM_DESC(svm_notifier_size, "Set the svm notifier size in MiB, must be power of 2 " "[default=" __stringify(XE_DEFAULT_SVM_NOTIFIER_SIZE) "]"); +module_param_named (enable_media, xe_modparam.enable_media, int,0444 ); +MODULE_PARM_DESC (enable_media,"Enable the media GT, when present (-1=auto, 0=disable, 1=enable). " +"Disabling overrides any media GT selected via the gt_types_allowed " +"configfs attribute " + "[default=" __stringify(XE_DEFAULT_ENABLE_MEDIA) "])"); +#if IS_ENABLED (CONFIG_DRM_XE_DISPLAY )module_param_named (probe_display, xe_modparam.probe_display, bool,0444 ); MODULE_PARM_DESC(probe_display, "Probe display HW, otherwise it's left untouched "
drivers/gpu/drm/xe/xe_module.h +1 -0
@@ -12,6 +12,7 @@ struct work_struct;/* Module modprobe variables */ struct xe_modparam { +int enable_media;bool probe_display;int force_vram_bar_size;int guc_log_level;
drivers/gpu/drm/xe/xe_pci.c +18 -3
@@ -641,7 +641,7 @@ static int read_gmdid(struct xe_device *xe, enum xe_gmdid_type type, u32 *ver, uint err;/* Don't try to read media ver if media GT is not allowed */ -if (type ==GMDID_MEDIA && !xe_configfs_media_gt_allowed (to_pci_dev (xe->drm.dev))) { +if (type ==GMDID_MEDIA && !xe_device_media_allowed (xe)) { *ver = *revid =0 ;return 0 ; }
@@ -778,6 +778,18 @@ static int xe_probe_info_early(struct xe_device *xe,return 0 ; } +/* +* Whether the user wants media at all. The default (-1) leaves the decision +* to the driver. +*/ +static bool media_wanted (struct xe_device *xe) +{ +if (xe_modparam.enable_media <0 ) +return true; + +return xe_modparam.enable_media; +} +/* * Initialize device info content that only depends on static driver_data * passed to the driver at probe time from PCI ID table.
@@ -809,6 +821,9 @@ static int xe_info_init_early(struct xe_device *xe,xe_wa_process_device_oob (xe); + xe->info.media_allowed =media_wanted (xe) && +xe_configfs_media_gt_allowed (to_pci_dev (xe->drm.dev)); + xe->info.dma_mask_size = desc->dma_mask_size; xe->info.va_bits = desc->va_bits; xe->info.vm_max_level = desc->vm_max_level;
@@ -952,8 +967,8 @@ static struct xe_gt *alloc_media_gt(struct xe_tile *tile,struct xe_device *xe =tile_to_xe (tile);struct xe_gt *gt; -if (!xe_configfs_media_gt_allowed (to_pci_dev (xe->drm.dev))) { -xe_tile_info (tile,"Media GT disabled via configfs\n" ); +if (!xe_device_media_allowed (xe)) { +xe_tile_info (tile,"Media GT disabled\n" );return NULL ; }
Signature · 1 line
2.43.0
PATCH 5/17 drm/xe: Detect each GMD_ID IP in a loop
In reply to Stuart Summershandle_gmdid() open coded the graphics and media detection twice, with the two copies subtly disagreeing: a missing media IP was tolerated, while graphics reporting version 0 was reported as an unknown version.
Describe the per IP differences in a small table and walk it, so both IPs are detected the same way and an absent IP of either kind simply leaves its descriptor NULL. Deciding whether the resulting combination is usable is left to the caller, which is unchanged in still demanding a graphics IP.
--- drivers/gpu/drm/xe/xe_pci.c | 70 ++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 28 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +42 -28
@@ -708,9 +708,21 @@ static const struct xe_ip *find_media_ip(unsigned int verx100)return NULL ; } +static const struct xe_gmdid_desc { +const char *name; +const struct xe_ip *(*find_ip)(unsigned int verx100); +} gmdid_descs[] = { + [GMDID_GRAPHICS ] = {"graphics" , find_graphics_ip }, + [GMDID_MEDIA ] = {"media" , find_media_ip }, +}; +/* * Read IP version from hardware and select graphics/media IP descriptors * based on the result. +* +* Each IP is detected independently and any of them may legitimately be fused +* off or otherwise absent, in which case its descriptor is left NULL. Deciding +* whether the resulting combination is usable is up to the caller. */ static int handle_gmdid(struct xe_device *xe, const struct xe_ip **graphics_ip,
@@ -718,36 +730,38 @@ static int handle_gmdid(struct xe_device *xe, u32 *graphics_revid, u32 *media_revid) { -u32 ver; -int ret; - - *graphics_ip =NULL ; - *media_ip =NULL ; - - ret =read_gmdid (xe,GMDID_GRAPHICS , &ver, graphics_revid); -if (ret) -return ret; - - *graphics_ip =find_graphics_ip (ver); -if (!*graphics_ip) { -xe_log_err (xe,REGS , -EINVAL , -"Hardware reports unknown graphics version %u.%02u\n" , - ver /100 , ver %100 ); - } - - ret =read_gmdid (xe,GMDID_MEDIA , &ver, media_revid); -if (ret) -return ret; +const struct xe_ip **ips[] = { + [GMDID_GRAPHICS ] = graphics_ip, + [GMDID_MEDIA ] = media_ip, + }; +u32 *revids[] = { + [GMDID_GRAPHICS ] = graphics_revid, + [GMDID_MEDIA ] = media_revid, + }; + +for (enum xe_gmdid_type type =0 ; type <ARRAY_SIZE (gmdid_descs); type++) { +const struct xe_gmdid_desc *desc = &gmdid_descs[type]; +u32 ver; +int ret; + + *ips[type] =NULL ; + *revids[type] =0 ; + + ret =read_gmdid (xe, type, &ver, revids[type]); +if (ret) +return ret; -/* Media may legitimately be fused off / not present */ -if (ver ==0 ) -return 0 ; +/* The IP may legitimately be fused off / not present */ +if (!ver) { + *revids[type] =0 ; +continue ; + } - *media_ip =find_media_ip (ver); -if (!*media_ip) { -xe_log_err (xe,REGS , -EINVAL , -"Hardware reports unknown media version %u.%02u\n" , - ver /100 , ver %100 ); + *ips[type] = desc->find_ip (ver); +if (!*ips[type]) +xe_log_err (xe,REGS , -EINVAL , +"Hardware reports unknown %s version %u.%02u\n" , + desc->name, ver /100 , ver %100 ); }return 0 ;
Signature · 1 line
2.43.0
PATCH 6/17 drm/xe: Tolerate a missing graphics IP in xe_info_init()
In reply to Stuart SummersA device without a graphics IP is still rejected a few lines further down, but handle_gmdid() can already hand back a NULL graphics_ip, so stop dereferencing it unconditionally and mirror what is done for media instead. alloc_primary_gt() gets the same treatment, since it reads the descriptor for every field it fills in.
No functional change: the graphics IP is still required.
--- drivers/gpu/drm/xe/xe_pci.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +21 -10
@@ -933,6 +933,9 @@ static struct xe_gt *alloc_primary_gt(struct xe_tile *tile,struct xe_device *xe =tile_to_xe (tile);struct xe_gt *gt; +if (!graphics_desc) +return NULL ; +if (!xe_configfs_primary_gt_allowed (to_pci_dev (xe->drm.dev))) {xe_tile_info (tile,"Primary GT disabled via configfs\n" );return NULL ;
@@ -1085,9 +1088,14 @@ static int xe_info_init(struct xe_device *xe, xe->info.step.graphics = probed_info->step.graphics; xe->info.step.media = probed_info->step.media; - xe->info.graphics_verx100 = graphics_ip->verx100; - xe->info.graphics_name = graphics_ip->name; - graphics_desc = graphics_ip->desc; +if (graphics_ip) { + xe->info.graphics_verx100 = graphics_ip->verx100; + xe->info.graphics_name = graphics_ip->name; + graphics_desc = graphics_ip->desc; + }else { + xe->info.graphics_name ="none" ; + graphics_desc =NULL ; + }if (media_ip) { xe->info.media_verx100 = media_ip->verx100;
@@ -1098,16 +1106,19 @@ static int xe_info_init(struct xe_device *xe, media_desc =NULL ; } - xe->info.has_access_counter = graphics_desc->has_access_counter; - xe->info.has_asid = graphics_desc->has_asid; - xe->info.has_atomic_enable_pte_bit = graphics_desc->has_atomic_enable_pte_bit; +if (graphics_desc) { + xe->info.has_access_counter = graphics_desc->has_access_counter; + xe->info.has_asid = graphics_desc->has_asid; + xe->info.has_atomic_enable_pte_bit = graphics_desc->has_atomic_enable_pte_bit; + xe->info.has_range_tlb_inval = graphics_desc->has_range_tlb_inval; + xe->info.has_ctx_tlb_inval = graphics_desc->has_ctx_tlb_inval; + xe->info.has_usm = graphics_desc->has_usm; + xe->info.has_64bit_timestamp = graphics_desc->has_64bit_timestamp; + } +if (xe->info.platform !=XE_PVC ) xe->info.has_device_atomics_on_smem =1 ; - xe->info.has_range_tlb_inval = graphics_desc->has_range_tlb_inval; - xe->info.has_ctx_tlb_inval = graphics_desc->has_ctx_tlb_inval; - xe->info.has_usm = graphics_desc->has_usm; - xe->info.has_64bit_timestamp = graphics_desc->has_64bit_timestamp; xe->info.has_mem_copy_instr =GRAPHICS_VER (xe) >=20 ;if (IS_SRIOV_VF (xe)) {
Signature · 1 line
2.43.0
PATCH 7/17 drm/xe: Verify IP presence against GU_CNTL
In reply to Stuart SummersGMD_ID is the only thing consulted today to decide whether the graphics and media IPs exist. Hardware also fuses presence bits into GU_CNTL_PROTECTED, so check GTPresent and IMPresent as a second level of verification and leave an IP alone when the two disagree.
Either IP can be dropped this way without failing driver load: an IP hardware says is absent is simply not detected, which is the same state as it reporting version 0, and probe then applies the usual rule that at least one IP has to be left.
VFs have no access to the register, so they keep going by GMD_ID alone.
--- drivers/gpu/drm/xe/regs/xe_regs.h | 2 ++ drivers/gpu/drm/xe/xe_pci.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/regs/xe_regs.h +2 -0
@@ -12,6 +12,8 @@#define SOC_BASE 0x280000#define GU_CNTL_PROTECTED XE_REG(0x10100C) +#define GT_PRESENT REG_BIT(8) +#define IM_PRESENT REG_BIT(10)#define DRIVERINT_FLR_DIS REG_BIT(31)#define GU_CNTL XE_REG(0x101010)
drivers/gpu/drm/xe/xe_pci.c +26 -2
@@ -710,12 +710,28 @@ static const struct xe_ip *find_media_ip(unsigned int verx100)static const struct xe_gmdid_desc {const char *name; +u32 present;const struct xe_ip *(*find_ip)(unsigned int verx100); } gmdid_descs[] = { - [GMDID_GRAPHICS ] = {"graphics" , find_graphics_ip }, - [GMDID_MEDIA ] = {"media" , find_media_ip }, + [GMDID_GRAPHICS ] = {"graphics" ,GT_PRESENT , find_graphics_ip }, + [GMDID_MEDIA ] = {"media" ,IM_PRESENT , find_media_ip }, }; +/* +* Besides the IP version in GMD_ID, hardware reports whether an IP is present +* at all through the fuse backed presence bits in GU_CNTL_PROTECTED. Use +* those as a second level of verification, so an IP hardware says is not there +* is left alone whatever GMD_ID claims. +*/ +static bool gt_fused (struct xe_device *xe,u32 present) +{ +/* VFs have no access to GU_CNTL_PROTECTED, so go by GMD_ID alone */ +if (IS_SRIOV_VF (xe)) +return false; + +return !(xe_mmio_read32 (xe_root_tile_mmio (xe),GU_CNTL_PROTECTED ) & present); +} +/* * Read IP version from hardware and select graphics/media IP descriptors * based on the result.
@@ -757,6 +773,14 @@ static int handle_gmdid(struct xe_device *xe,continue ; } +if (gt_fused (xe, desc->present)) { +xe_log_info (xe,REGS , +"Hardware reports the %s IP is not present, ignoring version %u.%02u\n" , + desc->name, ver /100 , ver %100 ); + *revids[type] =0 ; +continue ; + } + *ips[type] = desc->find_ip (ver);if (!*ips[type]) xe_log_err(xe, REGS, -EINVAL,
Signature · 1 line
2.43.0
PATCH 8/17 drm/xe: Guard per-tile primary GT accesses
In reply to Stuart SummersA tile's primary GT is now optional, just like its media GT already was. The TLB invalidation and memory interrupt paths walk both GTs of a tile but only test the media one for presence, so they would dereference NULL on a device whose graphics IP is absent. Mirror the existing media checks for the primary GT.
--- drivers/gpu/drm/xe/xe_memirq.c | 3 ++- drivers/gpu/drm/xe/xe_tlb_inval.c | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-)
drivers/gpu/drm/xe/xe_memirq.c +2 -1
@@ -578,7 +578,8 @@ void xe_memirq_handler(struct xe_memirq *memirq)/* GuC and media GuC (if present) must be checked separately */ -if (memirq_received (memirq, &memirq->source,ilog2 (INTR_GUC ),"SRC" )) { +if (tile->primary_gt && +memirq_received (memirq, &memirq->source,ilog2 (INTR_GUC ),"SRC" )) { map =IOSYS_MAP_INIT_OFFSET (&memirq->bo->vmap,XE_MEMIRQ_VECTOR_OFFSET (0 ,ilog2 (INTR_GUC )));memirq_dispatch_guc (memirq, &map, &tile->primary_gt->uc.guc);
drivers/gpu/drm/xe/xe_tlb_inval.c +11 -9
@@ -624,15 +624,17 @@ int xe_tlb_inval_range_tilemask_submit(struct xe_device *xe, u32 asid,if (!(tile_mask &BIT (id)))continue ; -xe_tlb_inval_fence_init (&tile->primary_gt->tlb_inval, - &fence[fence_id], true); - - err =xe_tlb_inval_range (&tile->primary_gt->tlb_inval, - &fence[fence_id], start, end, - asid,NULL ); -if (err) - goto wait; - ++fence_id; +if (tile->primary_gt) { +xe_tlb_inval_fence_init (&tile->primary_gt->tlb_inval, + &fence[fence_id], true); + + err =xe_tlb_inval_range (&tile->primary_gt->tlb_inval, + &fence[fence_id], start, end, + asid,NULL ); +if (err) + goto wait; + ++fence_id; + }if (!tile->media_gt)continue ;
Signature · 1 line
2.43.0
PATCH 9/17 drm/xe: Stop assuming the root tile has a primary GT
In reply to Stuart SummersA handful of device level consumers reach for xe_root_mmio_gt() to get at state that merely happens to be hung off a GT - the GuC firmware version, GT stats counters and the default OA unit - and dereference it without a NULL check. None of them touch MMIO, so none of them actually need the primary GT; they just need some GT.
Add xe_device_any_gt(), which falls back to the root tile's media GT, and use it in those places. For OA, walk the GTs instead so the default unit is the first one that exists, which keeps it OA unit 0 as the uapi promises.
--- drivers/gpu/drm/xe/xe_device.h | 16 ++++++++++++++++ drivers/gpu/drm/xe/xe_oa.c | 24 ++++++++++++++++++++++-- drivers/gpu/drm/xe/xe_pagefault.c | 4 ++-- drivers/gpu/drm/xe/xe_query.c | 3 ++- drivers/gpu/drm/xe/xe_vm.c | 2 +- 5 files changed, 43 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/xe_device.h +16 -0
@@ -111,6 +111,22 @@ static inline struct xe_gt *xe_root_mmio_gt(struct xe_device *xe)return xe_device_get_root_tile (xe)->primary_gt; } +/* +* Provide a GT structure for device level state that happens to be hung off a +* GT but is not specific to one, such as GuC firmware versions or OA units. +* Unlike xe_root_mmio_gt(), this never returns NULL: the root tile always has +* at least one GT, even when the graphics IP is absent. It must not be used +* for MMIO, since the media GT needs GSI offset translation. +* +* Returns the primary GT of the root tile, or its media GT if there is none. +*/ +static inline struct xe_gt *xe_device_any_gt (struct xe_device *xe) +{ +struct xe_tile *tile =xe_device_get_root_tile (xe); + +return tile->primary_gt ?: tile->media_gt; +} +static inline struct xe_mmio *xe_root_tile_mmio (struct xe_device *xe) {return &xe->tiles[0 ].mmio;
drivers/gpu/drm/xe/xe_oa.c +22 -2
@@ -2041,6 +2041,23 @@ static int xe_oa_assign_hwe(struct xe_oa *oa, struct xe_oa_open_param *param)return ret; } +/* +* OA unit IDs are handed out in GT iteration order, so the first unit of the +* first GT that has one is OA unit 0. The primary GT may be absent, in which +* case unit 0 lives on the media GT. +*/ +static struct xe_oa_unit *xe_oa_first_unit (struct xe_device *xe) +{ +struct xe_gt *gt; +u8 id; + +for_each_gt (gt, xe, id) +if (gt->oa.num_oa_units) +return >->oa.oa_unit[0 ]; + +return NULL ; +} +/** * xe_oa_stream_open_ioctl - Opens an OA stream * @dev: @drm_device
@@ -2073,8 +2090,11 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *freturn ret;/* If not provided, OA unit defaults to OA unit 0 as per uapi */ -if (!param.oa_unit) - param.oa_unit = &xe_root_mmio_gt (oa->xe)->oa.oa_unit[0 ]; +if (!param.oa_unit) { + param.oa_unit =xe_oa_first_unit (oa->xe); +if (XE_IOCTL_DBG (xe, !param.oa_unit)) +return -ENODEV ; + }if (param.exec_queue_id >0 ) {/* An exec_queue is only needed for OAR/OAC functionality on OAG */
drivers/gpu/drm/xe/xe_pagefault.c +2 -2
@@ -547,7 +547,7 @@ static bool xe_pagefault_queue_pop(struct xe_pagefault_queue *pf_queue,continue ;if (cache_start !=XE_PAGEFAULT_CACHE_START_INVALID ) { -xe_gt_stats_incr (xe_root_mmio_gt (xe), +xe_gt_stats_incr (xe_device_any_gt (xe),XE_GT_STATS_ID_PARALLEL_PAGEFAULT_COUNT ,1 );break ;
@@ -759,7 +759,7 @@ static void xe_pagefault_queue_work(struct work_struct *w) }#undef USM_QUEUE_MAX_RUNTIME_MS -xe_gt_stats_incr (xe_root_mmio_gt (xe),XE_GT_STATS_ID_PAGEFAULT_US , +xe_gt_stats_incr (xe_device_any_gt (xe),XE_GT_STATS_ID_PAGEFAULT_US ,xe_gt_stats_ktime_us_delta (start)); }
drivers/gpu/drm/xe/xe_query.c +2 -1
@@ -592,7 +592,8 @@ query_uc_fw_version(struct xe_device *xe, struct drm_xe_device_query *query)switch (resp.uc_type) {case XE_QUERY_UC_TYPE_GUC_SUBMISSION : { -struct xe_guc *guc = &xe->tiles[0 ].primary_gt->uc.guc; +struct xe_gt *gt =xe_device_any_gt (xe); +struct xe_guc *guc = >->uc.guc; version = &guc->fw.versions.found[XE_UC_FW_VER_COMPATIBILITY ];break ;
drivers/gpu/drm/xe/xe_vm.c +1 -1
@@ -1706,7 +1706,7 @@ static void xe_vm_init_prove_locking(struct xe_device *xe, struct xe_vm *vm)fs_reclaim_release (GFP_KERNEL );down_read (&vm->exec_queues.lock); -might_lock (&xe_root_mmio_gt (xe)->uc.guc.ct.lock); +might_lock (&xe_device_any_gt (xe)->uc.guc.ct.lock);up_read (&vm->exec_queues.lock); }
Signature · 1 line
2.43.0
PATCH 10/17 drm/xe: Do not claim flat CCS without a graphics IP
In reply to Stuart Summershas_flat_ccs comes from the device descriptor rather than from the graphics IP, so it survives a device whose graphics IP is absent. It is a graphics feature though, and probe_has_flat_ccs() reads its layout back through the primary GT, which is not there.
Clear the flag along with the rest of the graphics feature bits.
--- drivers/gpu/drm/xe/xe_pci.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/xe/xe_pci.c +8 -0
@@ -1138,6 +1138,14 @@ static int xe_info_init(struct xe_device *xe, xe->info.has_ctx_tlb_inval = graphics_desc->has_ctx_tlb_inval; xe->info.has_usm = graphics_desc->has_usm; xe->info.has_64bit_timestamp = graphics_desc->has_64bit_timestamp; + }else { +/* +* Flat CCS comes from the device descriptor rather than from +* the graphics IP, but it is still a graphics feature: its +* layout is read back through the primary GT, which is not +* there to be read. +*/ + xe->info.has_flat_ccs =0 ; }if (xe->info.platform !=XE_PVC )
Signature · 1 line
2.43.0
PATCH 11/17 drm/xe: Run page table updates on the media GT when there is no primary
In reply to Stuart SummersThe tile's migration context, and the bind exec queues built on top of it, are hard wired to the primary GT and its copy engine. On a device with no graphics IP that GT is NULL, and xe_migrate_init() is never called at all, so probe dies in xe_cpu_bind_init() on an uninitialised tile->migrate.
Page table updates are plain memory writes, so any GT can issue them. Add xe_tile_pt_gt() and xe_tile_pt_class(), which name the primary GT and its copy engine as before but fall back to the media GT and a video decode engine, and use them for the migration context, the bind queues and the place xe_gt_init() decides to set migration up.
Note this only makes page table updates work. The blit based copy and clear paths now target a video engine rather than NULL on such a device, which stops them oopsing, but they are still not functional there.
--- drivers/gpu/drm/xe/xe_exec_queue.c | 5 +++-- drivers/gpu/drm/xe/xe_gt.c | 11 ++++++---- drivers/gpu/drm/xe/xe_migrate.c | 29 ++++++++++++++------------- drivers/gpu/drm/xe/xe_tile.h | 32 ++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 20 deletions(-)
drivers/gpu/drm/xe/xe_exec_queue.c +3 -2
@@ -28,6 +28,7 @@#include "xe_macros.h" #include "xe_migrate.h" #include "xe_pm.h" +#include "xe_tile.h" #include "xe_trace.h" #include "xe_uc_fw.h" #include "xe_vm.h"
@@ -627,7 +628,7 @@ struct xe_exec_queue *xe_exec_queue_create_bind(struct xe_device *xe,struct xe_vm *user_vm, u32 flags, u64 extensions) { - struct xe_gt *gt = tile->primary_gt; + struct xe_gt *gt = xe_tile_pt_gt(tile);struct xe_exec_queue *q;struct xe_vm *migrate_vm;
@@ -645,7 +646,7 @@ struct xe_exec_queue *xe_exec_queue_create_bind(struct xe_device *xe, flags, extensions); }else { q =xe_exec_queue_create_class (xe, gt, migrate_vm, -XE_ENGINE_CLASS_COPY , flags, +xe_tile_pt_class (tile), flags, extensions); }xe_vm_put (migrate_vm);
drivers/gpu/drm/xe/xe_gt.c +7 -4
@@ -61,6 +61,7 @@#include "xe_sa.h" #include "xe_sched_job.h" #include "xe_sriov.h" +#include "xe_tile.h" #include "xe_tlb_inval.h" #include "xe_tuning.h" #include "xe_uc.h"
@@ -657,10 +658,12 @@ static int gt_init_with_all_forcewake(struct xe_gt *gt) } } -if (xe_gt_is_main_type (gt)) { -struct xe_tile *tile =gt_to_tile (gt); - - err =xe_migrate_init (tile->migrate); +/* +* Normally the migration context runs on the primary GT, but a tile +* with no graphics IP has only its media GT to run it on. +*/ +if (gt ==xe_tile_pt_gt (gt_to_tile (gt))) { + err =xe_migrate_init (gt_to_tile (gt)->migrate);if (err)return err; }
drivers/gpu/drm/xe/xe_migrate.c +15 -14
@@ -43,6 +43,7 @@#include "xe_sriov_vf_ccs.h" #include "xe_svm.h" #include "xe_sync.h" +#include "xe_tile.h" #include "xe_trace_bo.h" #include "xe_ttm_stolen_mgr.h" #include "xe_validation.h"
@@ -485,7 +486,7 @@ static void xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m,if (xe->info.has_usm) {xe_tile_assert (tile,xe_bo_size (batch) ==SZ_1M ); - batch = tile->primary_gt->usm.bb_pool->bo; + batch =xe_tile_pt_gt (tile)->usm.bb_pool->bo; m->usm_batch_base_ofs = m->batch_base_ofs +SZ_1M ;xe_tile_assert (tile,xe_bo_size (batch) ==SZ_512K );
@@ -506,7 +507,7 @@ static void xe_migrate_prepare_vm(struct xe_tile *tile, struct xe_migrate *m, m->batch_base_ofs =xe_migrate_vram_ofs (xe, batch_addr, false);if (xe->info.has_usm) { - batch = tile->primary_gt->usm.bb_pool->bo; + batch =xe_tile_pt_gt (tile)->usm.bb_pool->bo; batch_addr =xe_bo_addr (batch,0 ,XE_PAGE_SIZE ); m->usm_batch_base_ofs =xe_migrate_vram_ofs (xe, batch_addr, false); }
@@ -830,7 +831,7 @@ int xe_migrate_reinit(struct xe_migrate *m)int xe_migrate_init (struct xe_migrate *m) {struct xe_tile *tile = m->tile; -struct xe_gt *primary_gt = tile->primary_gt; +struct xe_gt *gt =xe_tile_pt_gt (tile);struct xe_device *xe =tile_to_xe (tile);struct xe_vm *vm;int err;
@@ -846,8 +847,8 @@ int xe_migrate_init(struct xe_migrate *m) goto err_out;if (xe->info.has_usm) { -struct xe_hw_engine *hwe0 = primary_gt->usm.paging_hwe0; -u32 logical_mask = primary_gt->usm.paging_logical_mask; +struct xe_hw_engine *hwe0 = gt->usm.paging_hwe0; +u32 logical_mask = gt->usm.paging_logical_mask;if (!hwe0 || !logical_mask) { err = -EINVAL ;
@@ -864,8 +865,8 @@ int xe_migrate_init(struct xe_migrate *m)EXEC_QUEUE_FLAG_MIGRATE | EXEC_QUEUE_FLAG_LOW_LATENCY, 0); }else { - m->q =xe_exec_queue_create_class (xe, primary_gt, vm, -XE_ENGINE_CLASS_COPY , + m->q =xe_exec_queue_create_class (xe, gt, vm, +xe_tile_pt_class (tile),EXEC_QUEUE_FLAG_KERNEL |EXEC_QUEUE_FLAG_MIGRATE ,0 ); }
@@ -1214,7 +1215,7 @@ static u32 xe_migrate_ccs_copy(struct xe_migrate *m, u64 dst_ofs, bool dst_is_indirect, u32 dst_size, u64 ccs_ofs, bool copy_ccs) { - struct xe_gt *gt = m->tile->primary_gt; + struct xe_gt *gt = xe_tile_pt_gt(m->tile);u32 flush_flags =0 ;if (!copy_ccs && dst_is_indirect) {
@@ -1276,7 +1277,7 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, bool copy_only_ccs, bool is_vram_resolve) { -struct xe_gt *gt = m->tile->primary_gt; +struct xe_gt *gt =xe_tile_pt_gt (m->tile);struct xe_device *xe =gt_to_xe (gt);struct dma_fence *fence =NULL ;u64 size =xe_bo_size (src_bo);
@@ -1574,7 +1575,7 @@ int xe_migrate_ccs_rw_copy(struct xe_tile *tile, struct xe_exec_queue *q,bool dst_is_pltt = read_write ==XE_SRIOV_VF_CCS_WRITE_CTX ;struct ttm_resource *src = new_mem;struct xe_migrate *m = tile->migrate; -struct xe_gt *gt = tile->primary_gt; +struct xe_gt *gt =xe_tile_pt_gt (tile);u32 batch_size, batch_size_allocated;struct xe_device *xe =gt_to_xe (gt);struct xe_res_cursor src_it, ccs_it;
@@ -1776,7 +1777,7 @@ struct dma_fence *xe_migrate_vram_copy_chunk(struct xe_bo *vram_bo, u64 vram_off {struct xe_device *xe =xe_bo_device (vram_bo);struct xe_tile *tile = vram_bo->tile; -struct xe_gt *gt = tile->primary_gt; +struct xe_gt *gt =xe_tile_pt_gt (tile);struct xe_migrate *m = tile->migrate;struct dma_fence *fence =NULL ;struct ttm_resource *vram = vram_bo->ttm.resource;
@@ -1992,7 +1993,7 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,bool clear_vram =is_devmem (bo, dst);bool clear_bo_data =XE_MIGRATE_CLEAR_FLAG_BO_DATA & clear_flags;bool clear_ccs =XE_MIGRATE_CLEAR_FLAG_CCS_DATA & clear_flags; -struct xe_gt *gt = m->tile->primary_gt; +struct xe_gt *gt =xe_tile_pt_gt (m->tile);struct xe_device *xe =gt_to_xe (gt);bool clear_only_system_ccs = false;struct dma_fence *fence =NULL ;
@@ -2357,7 +2358,7 @@ static struct dma_fence *xe_migrate_vram(struct xe_migrate *m,struct dma_fence *deps, const enum xe_migrate_copy_dir dir) { - struct xe_gt *gt = m->tile->primary_gt; + struct xe_gt *gt = xe_tile_pt_gt(m->tile);struct xe_device *xe =gt_to_xe (gt);bool use_usm_batch = xe->info.has_usm;struct dma_fence *fence =NULL ;
@@ -2785,7 +2786,7 @@ int xe_migrate_debug_ccs_overlap(struct xe_migrate *m, bool write_to_ccs) {struct xe_device *xe =tile_to_xe (m->tile); -struct xe_gt *gt = m->tile->primary_gt; +struct xe_gt *gt =xe_tile_pt_gt (m->tile);struct dma_fence *fence;struct xe_bb *bb;struct xe_sched_job *job;
drivers/gpu/drm/xe/xe_tile.h +32 -0
@@ -6,6 +6,7 @@#ifndef _XE_TILE_H_#define _XE_TILE_H_ +#include "xe_hw_engine_types.h" #include "xe_tile_types.h" struct xe_device ;
@@ -24,6 +25,37 @@ static inline bool xe_tile_is_root(struct xe_tile *tile)return tile->id ==0 ; } +/** +* xe_tile_pt_gt() - GT used to run a tile's page table update jobs +* @tile: Pointer to the struct xe_tile. +* +* Page table updates, and the migration context they are submitted through, +* normally run on the primary GT. A device whose graphics IP is absent has +* no primary GT, but its media GT can write page tables just as well. +* +* Return: The tile's primary GT, or its media GT if it has no primary GT. +*/ +static inline struct xe_gt *xe_tile_pt_gt (struct xe_tile *tile) +{ +return tile->primary_gt ?: tile->media_gt; +} + +/** +* xe_tile_pt_class() - Engine class to run a tile's page table update jobs on +* @tile: Pointer to the struct xe_tile. +* +* The engine class to pair with xe_tile_pt_gt(). The copy engine is the usual +* choice, but it lives on the primary GT; when there is none, fall back to a +* video decode engine on the media GT. +* +* Return: The engine class to create the tile's page table exec queue with. +*/ +static inline enum xe_engine_class xe_tile_pt_class (struct xe_tile *tile) +{ +return tile->primary_gt ?XE_ENGINE_CLASS_COPY : +XE_ENGINE_CLASS_VIDEO_DECODE ; +} +/** * xe_tile_to_vr() - Return the struct xe_vram_region pointer from a * struct xe_tile pointer
Signature · 1 line
2.43.0
PATCH 12/17 drm/xe: Document that gt_types_allowed=media now probes
In reply to Stuart SummersThe media only configuration no longer fails probe, so drop the warning that said it would.
--- drivers/gpu/drm/xe/xe_configfs.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/gpu/drm/xe/xe_configfs.c +3 -4
@@ -114,15 +114,14 @@* # echo 'primary' > /sys/kernel/config/xe/0000:03:00.0/gt_types_allowed * * Allow only the media GT of each tile to be initialized and used, -* effectively disabling the primary GT. **This configuration will cause -* device probe failure on all current platforms, but may be allowed on -* igpu platforms in the future**:: +* effectively disabling the primary GT. Note that only media workloads +* are usable in this configuration:: * * # echo 'media' > /sys/kernel/config/xe/0000:03:00.0/gt_types_allowed * * Disable all GTs. Only other GPU IP (such as display) is potentially usable. * **This configuration will cause device probe failure on all current -* platforms, but may be allowed on igpu platforms in the future**:: +* platforms**:: * * # echo '' > /sys/kernel/config/xe/0000:03:00.0/gt_types_allowed *
Signature · 1 line
2.43.0
PATCH 13/17 drm/xe: Fall back to CPU copies when the tile cannot blit
In reply to Stuart Summersxe_migrate_copy() and xe_migrate_clear() emit blitter commands, and the copy engine they need lives on the primary GT. A tile without one can still run the migration context for page table updates, but it has no way to move data.
On an integrated device this never comes up, since every move either ends in ttm_bo_move_null() or needs no clear. With VRAM it does, so let xe_bo_move() hand the work to ttm_bo_move_memcpy(), which reaches VRAM through the BAR mapping xe already sets up in xe_ttm_io_mem_reserve(), and which covers the clear case by way of an unpopulated source. The pinned save and restore paths grow the same check, falling back to the vmap and memcpy branch they already have.
Reads come back over PCIe uncached and are correspondingly slow, so this is only meant to keep a media only device working, not to perform.
--- drivers/gpu/drm/xe/xe_bo.c | 43 ++++++++++++++++++++++----------- drivers/gpu/drm/xe/xe_migrate.c | 16 ++++++++++++ drivers/gpu/drm/xe/xe_migrate.h | 2 ++ 3 files changed, 47 insertions(+), 14 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +29 -14
@@ -1277,6 +1277,19 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,xe_pm_runtime_get_noresume (xe); } +/* +* A tile with no copy engine cannot blit, so move the data with the +* CPU instead. For VRAM that means going over the PCIe BAR, which is +* slow, but a device with no graphics IP offers no alternative. +* ttm_bo_move_memcpy() covers the clear case too, by way of an +* unpopulated source. +*/ +if (!xe_migrate_can_blit (migrate)) { + ret =ttm_bo_move_memcpy (ttm_bo, ctx, new_mem); +xe_pm_runtime_put (xe); + goto out; + } +/* * Attach CCS BBs before submitting the copy job below so a VF * migration racing the copy sees valid, up to date attach state.
@@ -1578,17 +1591,18 @@ int xe_bo_notifier_unprepare_pinned(struct xe_bo *bo)static int xe_bo_evict_pinned_copy (struct xe_bo *bo,struct xe_bo *backup) {struct xe_device *xe =xe_bo_device (bo); +struct xe_migrate *migrate;bool unmap = false;int ret =0 ; -if (xe_bo_is_user (bo) || (bo->flags &XE_BO_FLAG_PINNED_LATE_RESTORE )) { -struct xe_migrate *migrate; -struct dma_fence *fence; +if (bo->tile) + migrate = bo->tile->migrate; +else + migrate =mem_type_to_migrate (xe, bo->ttm.resource->mem_type); -if (bo->tile) - migrate = bo->tile->migrate; -else - migrate =mem_type_to_migrate (xe, bo->ttm.resource->mem_type); +if ((xe_bo_is_user (bo) || (bo->flags &XE_BO_FLAG_PINNED_LATE_RESTORE )) && +xe_migrate_can_blit (migrate)) { +struct dma_fence *fence;xe_assert (xe, bo->ttm.base.resv == backup->ttm.base.resv); ret =dma_resv_reserve_fences (bo->ttm.base.resv,1 );
@@ -1717,6 +1731,7 @@ int xe_bo_restore_pinned(struct xe_bo *bo) };struct xe_device *xe =ttm_to_xe_device (bo->ttm.bdev);struct xe_bo *backup = bo->backup_obj; +struct xe_migrate *migrate;bool unmap = false;int ret;
@@ -1731,14 +1746,14 @@ int xe_bo_restore_pinned(struct xe_bo *bo) goto out_unlock_bo; } -if (xe_bo_is_user (bo) || (bo->flags &XE_BO_FLAG_PINNED_LATE_RESTORE )) { -struct xe_migrate *migrate; -struct dma_fence *fence; +if (bo->tile) + migrate = bo->tile->migrate; +else + migrate =mem_type_to_migrate (xe, bo->ttm.resource->mem_type); -if (bo->tile) - migrate = bo->tile->migrate; -else - migrate =mem_type_to_migrate (xe, bo->ttm.resource->mem_type); +if ((xe_bo_is_user (bo) || (bo->flags &XE_BO_FLAG_PINNED_LATE_RESTORE )) && +xe_migrate_can_blit (migrate)) { +struct dma_fence *fence; ret =dma_resv_reserve_fences (bo->ttm.base.resv,1 );if (ret)
drivers/gpu/drm/xe/xe_migrate.c +16 -0
@@ -2155,6 +2155,22 @@ void xe_migrate_wait(struct xe_migrate *m)dma_fence_wait (m->fence, false); } +/** +* xe_migrate_can_blit() - Whether a migration context can issue blits +* @m: The migration context +* +* xe_migrate_copy() and xe_migrate_clear() emit blitter commands, which only +* the copy engine understands, and the copy engine lives on the primary GT. +* A tile without one can still update page tables, so its migration context +* is usable, but callers that want to move data have to do it themselves. +* +* Return: true if blit based copy and clear are available on @m. +*/ +bool xe_migrate_can_blit (struct xe_migrate *m) +{ +return m->tile->primary_gt; +} +static u32 pte_update_cmd_size (u64 size) {u32 num_dword;
drivers/gpu/drm/xe/xe_migrate.h +2 -0
@@ -93,6 +93,8 @@ struct xe_vm *xe_migrate_get_vm(struct xe_migrate *m);void xe_migrate_wait (struct xe_migrate *m); +bool xe_migrate_can_blit (struct xe_migrate *m); +#if IS_ENABLED (CONFIG_DRM_XE_DEBUG_MEM ) int xe_migrate_debug_ccs_overlap(struct xe_migrate *m, struct xe_bo *scratch_bo,
Signature · 1 line
2.43.0
PATCH 14/17 drm/xe: Require a fully visible VRAM BAR without a primary GT
In reply to Stuart SummersCPU copies can only reach VRAM that the BAR maps: xe_ttm_io_mem_reserve() rejects any resource that is not entirely CPU visible. With no primary GT there is no copy engine to fall back on, so a small BAR would leave most of VRAM unreachable.
Refuse to probe such a device rather than fail later on the first move.
--- drivers/gpu/drm/xe/xe_vram.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpu/drm/xe/xe_vram.c +15 -0
@@ -23,6 +23,7 @@#include "xe_mmio.h" #include "xe_sriov.h" #include "xe_tile.h" +#include "xe_tile_printk.h" #include "xe_tile_sriov_vf.h" #include "xe_ttm_vram_mgr.h" #include "xe_vram.h"
@@ -346,6 +347,20 @@ int xe_vram_probe(struct xe_device *xe)if (err)return err; +/* +* Without a primary GT there is no copy engine, so VRAM is +* moved with the CPU through the BAR. That only works if the +* BAR covers all of it. +*/ +if (!tile->primary_gt && + tile->mem.vram->io_size < tile->mem.vram->usable_size) { +xe_tile_err (tile, +"VRAM is not fully CPU visible (%pa of %pa); a resizable BAR is required without a primary GT\n" , + &tile->mem.vram->io_size, + &tile->mem.vram->usable_size); +return -ENODEV ; + } +if (total_size > lmem_bar.io_size) { xe_log_info(xe, VRAM, "Total size %#llx is larger than resource %#llx\n",
Signature · 1 line
2.43.0
PATCH 15/17 drm/xe: Allow probe without a primary GT
In reply to Stuart SummersProbe required a graphics IP and a primary GT, so the media only combination the gt_types_allowed configfs attribute can ask for was rejected outright.
Require instead that something is left to drive: at least one of the two IPs has to be detected, and every tile has to end up with at least one GT. The dgpu concern the old comment raised is covered by VRAM being a graphics IP property, so a device without one has no VRAM to manage.
--- drivers/gpu/drm/xe/xe_pci.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/gpu/drm/xe/xe_pci.c +9 -16
@@ -1060,11 +1060,11 @@ static int xe_probe_ips(struct xe_device *xe, }/* -* If we couldn't detect the graphics IP, that's considered a fatal -* error and we should abort driver load. Failing to detect media -* IP is non-fatal; we'll just proceed without enabling media support. +* Either IP on its own is enough to go on with. Only a device where +* neither could be detected is a fatal error, since there would be +* nothing left to drive. */ -if (!probed_info->graphics_ip) +if (!probed_info->graphics_ip && !probed_info->media_ip)return -ENODEV ;return 0 ;
@@ -1179,21 +1179,14 @@ static int xe_info_init(struct xe_device *xe,if (IS_ERR (tile->primary_gt))return PTR_ERR (tile->primary_gt); -/* -* It's not currently possible to probe a device with the -* primary GT disabled. With some work, this may be future in -* the possible for igpu platforms (although probably not for -* dgpu's since access to the primary GT's BCS engines is -* required for VRAM management). -*/ -if (!tile->primary_gt) { -drm_err (&xe->drm,"Cannot probe device with without a primary GT\n" ); -return -ENODEV ; - } - tile->media_gt =alloc_media_gt (tile, media_desc);if (IS_ERR (tile->media_gt))return PTR_ERR (tile->media_gt); + +if (!tile->primary_gt && !tile->media_gt) { +xe_tile_err (tile,"Cannot probe tile without any GT\n" ); +return -ENODEV ; + } }/*
Signature · 1 line
2.43.0
PATCH 16/17 drm/xe: Work around media 52-bit limitation on CRI
In reply to Stuart SummersCRI media only supports 46-bit GPA. With the IOMMU handing out IOVAs above 46 bits this shows up as ATS translation errors and a media GuC load failure.
The workaround for this is broken into a couple of parts:
1) Media is now disabled by default on CRI.
2) When media is enabled, implement certain workarounds to ensure compute performance remains optimal and media accesses do not result in the above mentioned translation errors.
The first part of the workaround means for the customers who are not interested in using media, they can retain the full 52-bit GPA range for a broader PCIe installation without worrying about any specific limitation to support the media workloads on this device.
Additionally, to ensure power is not consumed by media in this configuration, a new interfaces is added between the KMD and the GFSP firmware to bring media down into a low power state.
The second part of the workaround again is broken down into a few parts:
1) The whole device is restricted to 46-bit GPA.
2) Disable address translation in the media block alone to allow faster translation for compute workloads with PCIe level address translation enabled while ensuring host accesses beyond 46-bits (e.g. coming from another 52-bit supporting device) are still limited to 46-bits for the CRI media.
Media needs every device DMA address to stay within 46 bits. With the IOMMU translating device DMA that is guaranteed by the IOVA allocator honoring the clamped mask. Without it, DMA addresses are host physical addresses, so media stays enabled only when host memory fits in 46 bits. Beyond that the host can hand out an address media cannot reach, so disable media.
In order to disable address translation for media, a certain register programming which is not accessible from the host must be engaged. To facilitate this, an additional new interface is added between the KMD and the GFSP firmware to do this programming.
HSDES: 14028632488
--- drivers/gpu/drm/xe/xe_device.c | 10 + drivers/gpu/drm/xe/xe_device_wa_oob.rules | 1 + drivers/gpu/drm/xe/xe_pci.c | 54 ++++- drivers/gpu/drm/xe/xe_pm.c | 4 + drivers/gpu/drm/xe/xe_sysctrl.c | 185 ++++++++++++++++++ drivers/gpu/drm/xe/xe_sysctrl.h | 2 + drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 34 ++++ drivers/gpu/drm/xe/xe_sysctrl_types.h | 6 + 8 files changed, 294 insertions(+), 2 deletions(-)
drivers/gpu/drm/xe/xe_device.c +10 -0
@@ -994,6 +994,12 @@ int xe_device_probe(struct xe_device *xe)if (err)return err; +/* +* Let the System Controller know how media is configured as early as +* the mailbox allows, before any media GT is brought up. +*/ +xe_sysctrl_media_probe (xe); + err =xe_ras_init (xe);if (err)return err;
@@ -1518,6 +1524,10 @@ int xe_device_resume(struct xe_device *xe, bool flr)xe_sysctrl_pm_resume (xe); + err =xe_sysctrl_media_defeature (xe); +if (err) +return err; +xe_irq_resume (xe);for_each_gt (gt, xe, id) {
drivers/gpu/drm/xe/xe_device_wa_oob.rules +1 -0
@@ -8,3 +8,4 @@ 14026779378 PLATFORM(CRESCENTISLAND) 14028586678 PLATFORM(CRESCENTISLAND) 14028434957 PLATFORM(CRESCENTISLAND) +14028632488 PLATFORM(CRESCENTISLAND)
drivers/gpu/drm/xe/xe_pci.c +52 -2
80 lines not on this page · raw message
drivers/gpu/drm/xe/xe_pm.c +4 -0
@@ -662,6 +662,10 @@ int xe_pm_runtime_resume(struct xe_device *xe)*/ xe_sysctrl_pm_resume (xe); + err =xe_sysctrl_media_defeature (xe); +if (err) + goto out; +xe_display_pm_runtime_resume_early (xe);xe_irq_resume (xe);
drivers/gpu/drm/xe/xe_sysctrl.c +185 -0
212 lines not on this page · raw message
drivers/gpu/drm/xe/xe_sysctrl.h +2 -0
@@ -18,6 +18,8 @@ static inline struct xe_device *sc_to_xe(struct xe_sysctrl *sc)void xe_sysctrl_event (struct xe_sysctrl *sc);int xe_sysctrl_init (struct xe_device *xe); +int xe_sysctrl_media_defeature (struct xe_device *xe); +void xe_sysctrl_media_probe (struct xe_device *xe);void xe_sysctrl_irq_handler (struct xe_device *xe,u32 master_ctl);void xe_sysctrl_pm_resume (struct xe_device *xe);bool xe_sysctrl_is_oobmsm_fw_ready (struct xe_device *xe);
drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h +34 -0
@@ -15,11 +15,13 @@* * @XE_SYSCTRL_GROUP_GFSP: GFSP group * @XE_SYSCTRL_GROUP_DIAG: Diag group +* @XE_SYSCTRL_GROUP_RUNTIME: Runtime group * @XE_SYSCTRL_GROUP_CORE: Core group */ enum xe_sysctrl_group {XE_SYSCTRL_GROUP_GFSP =0x01 ,XE_SYSCTRL_GROUP_DIAG =0x02 , +XE_SYSCTRL_GROUP_RUNTIME =0x31 ,XE_SYSCTRL_GROUP_CORE =0xFF , };
@@ -94,6 +96,38 @@ struct xe_sysctrl_diag_ras_err_inj_req {u32 params; } __packed; +/** +* enum xe_sysctrl_runtime_cmd - Commands supported by Runtime group +* +* @XE_SYSCTRL_CMD_MEDIA_DEFEATURE: Disable feature in media +*/ +enum xe_sysctrl_runtime_cmd { +XE_SYSCTRL_CMD_MEDIA_DEFEATURE =0x11 , +}; + +#define XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE 0x01 +#define XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE 0x02 + +/** +* struct xe_sysctrl_media_defeature_req - Media defeature request +* +* @feature: Media feature to defeature, one of +* XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE or +* XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE +*/ +struct xe_sysctrl_media_defeature_req { +u8 feature; +} __packed; + +/** +* struct xe_sysctrl_media_defeature_resp - Media defeature response +* +* @flags: Firmware status flags +*/ +struct xe_sysctrl_media_defeature_resp { +u32 flags; +} __packed; +/** * struct xe_sysctrl_app_status_req - Get application status request *
drivers/gpu/drm/xe/xe_sysctrl_types.h +6 -0
@@ -75,6 +75,12 @@ struct xe_sysctrl {/** @event_lock: Mutex protecting pending events */ struct mutex event_lock; +/** +* @has_media_feature_disable: The System Controller accepts media +* defeature requests. +*/ +bool has_media_feature_disable; +/** @debugfs: Debugfs entries */ struct {/** @debugfs.root: Root debugfs directory */
Signature · 1 line
2.43.0
PATCH 17/17 drm/xe: Don't error on failed media defeature
In reply to Stuart SummersRight now there isn't an easy way to get the version of the GFSP firmware that will be replying to this command. For testing purposes, don't print an error to avoid flagging CI for some early testing.
Note this patch is not intended to be merged...
--- drivers/gpu/drm/xe/xe_ras.c | 18 +++++++++--------- drivers/gpu/drm/xe/xe_sysctrl.c | 10 +++++----- drivers/gpu/drm/xe/xe_sysctrl_debugfs.c | 6 +++--- drivers/gpu/drm/xe/xe_sysctrl_event.c | 2 +- drivers/gpu/drm/xe/xe_sysctrl_mailbox.c | 25 +++++++++++++++---------- drivers/gpu/drm/xe/xe_sysctrl_mailbox.h | 3 ++- 6 files changed, 35 insertions(+), 29 deletions(-)
drivers/gpu/drm/xe/xe_ras.c +9 -9
@@ -282,7 +282,7 @@ static int send_page_offline_cmd(struct xe_device *xe, u64 page_address,xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_PAGE_OFFLINE , &request,sizeof (request), &response,sizeof (response)); - ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen, true);if (ret) {xe_log_err (xe,SYSCTRL , ret,"failed to send page offline command\n" );return ret;
@@ -435,7 +435,7 @@ static void process_offline_pages(struct xe_device *xe, u32 cmd, void *req, sizeif (list_req) list_req->index = count; - ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen, true);if (ret) {xe_log_err (xe,SYSCTRL , ret,"failed to get page offline data, cmd=%#x\n" , cmd);
@@ -792,7 +792,7 @@ int xe_ras_get_counter_response(struct xe_device *xe, const struct xe_ras_error_xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_GET_COUNTER , &request,sizeof (request), response,sizeof (*response)); - ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen, true);if (ret) {xe_err (xe,"sysctrl: failed to get counter %d\n" , ret);return ret;
@@ -860,7 +860,7 @@ enum xe_ras_recovery_action xe_ras_process_errors(struct xe_device *xe) do { memset(&response, 0, sizeof(response)); - ret = xe_sysctrl_send_command(&xe->sc, &command, &rlen); + ret = xe_sysctrl_send_command(&xe->sc, &command, &rlen, true); if (ret) { xe_err(xe, "sysctrl: failed to get soc error %d\n", ret); goto err;
@@ -983,7 +983,7 @@ int xe_ras_clear_counter(struct xe_device *xe, u8 severity, u8 component) &request, sizeof(request), &response, sizeof(response));guard (xe_pm_runtime)(xe); - ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen, true);if (ret) {xe_err (xe,"sysctrl: failed to clear counter %d\n" , ret);return ret;
@@ -1042,7 +1042,7 @@ int xe_ras_get_threshold(struct xe_device *xe, u8 severity, u8 component, u32 *t &request, sizeof(request), &response, sizeof(response));guard (xe_pm_runtime)(xe); - ret =xe_sysctrl_send_command (&xe->sc, &command, &len); + ret =xe_sysctrl_send_command (&xe->sc, &command, &len, true);if (ret) {xe_err (xe,"sysctrl: failed to get threshold %d\n" , ret);return ret;
@@ -1095,7 +1095,7 @@ int xe_ras_set_threshold(struct xe_device *xe, u8 severity, u8 component, u32 th &request, sizeof(request), &response, sizeof(response));guard (xe_pm_runtime)(xe); - ret =xe_sysctrl_send_command (&xe->sc, &command, &len); + ret =xe_sysctrl_send_command (&xe->sc, &command, &len, true);if (ret) {xe_err (xe,"sysctrl: failed to set threshold %d\n" , ret);return ret;
@@ -1137,7 +1137,7 @@ static ssize_t gpu_health_show(struct device *dev, struct device_attribute *attrxe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_GET_HEALTH , &request,sizeof (request), &response,sizeof (response));guard (xe_pm_runtime)(xe); - ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen, true);if (ret) {xe_err (xe,"sysctrl: failed to get health %d\n" , ret);return ret;
@@ -1182,7 +1182,7 @@ static ssize_t gpu_health_store(struct device *dev, struct device_attribute *attxe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_SET_HEALTH , &request,sizeof (request), &response,sizeof (response));guard (xe_pm_runtime)(xe); - ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen); + ret =xe_sysctrl_send_command (&xe->sc, &command, &rlen, true);if (ret) {xe_err (xe,"sysctrl: failed to set health %d\n" , ret);return ret;
drivers/gpu/drm/xe/xe_sysctrl.c +5 -5
@@ -166,7 +166,7 @@ xe_sysctrl_check_app_status(struct xe_device *xe, enum xe_sysctrl_app_id app_id)xe_sysctrl_create_command (&cmd,XE_SYSCTRL_GROUP_CORE ,XE_SYSCTRL_CMD_GET_APP_STATUS_BY_ID , &req,sizeof (req), &resp,sizeof (resp)); - ret =xe_sysctrl_send_command (&xe->sc, &cmd, &out_len); + ret =xe_sysctrl_send_command (&xe->sc, &cmd, &out_len, true);if (ret)return XE_SYSCTRL_FIRMWARE_COMM_FAILURE ;
@@ -243,7 +243,7 @@ int xe_sysctrl_sdk_api_version(struct xe_device *xe, u16 *version)xe_sysctrl_create_command (&cmd,XE_SYSCTRL_GROUP_CORE ,XE_SYSCTRL_CMD_SDK_API_VERSION ,0 ,0 , &resp,sizeof (resp)); - ret =xe_sysctrl_send_command (&xe->sc, &cmd, &out_len); + ret =xe_sysctrl_send_command (&xe->sc, &cmd, &out_len, true);if (ret)return ret;
@@ -270,7 +270,7 @@ static int sysctrl_media_defeature(struct xe_device *xe, u8 feature)XE_SYSCTRL_CMD_MEDIA_DEFEATURE , &req, sizeof(req), &resp, sizeof(resp)); - ret =xe_sysctrl_send_command (&xe->sc, &cmd, &out_len); + ret =xe_sysctrl_send_command (&xe->sc, &cmd, &out_len, false);if (ret)return ret;
@@ -308,8 +308,8 @@ static int sysctrl_media_defeature_send(struct xe_device *xe, u8 feature) ret =sysctrl_media_defeature (xe, feature);if (ret) { -xe_err (xe,"sysctrl: failed to defeature media (0x%02x): %pe\n" , - feature,ERR_PTR (ret)); +xe_info (xe,"sysctrl: failed to defeature media (0x%02x): %pe\n" , + feature,ERR_PTR (ret));return ret; }
drivers/gpu/drm/xe/xe_sysctrl_debugfs.c +3 -3
@@ -85,7 +85,7 @@ static ssize_t xe_sysctrl_loopback_write(struct file *file, const char __user *u scoped_guard(mutex, &entry->lock) {guard (xe_pm_runtime)(xe); - entry->status =xe_sysctrl_send_command (entry->sc, &cmd, &out_len); + entry->status =xe_sysctrl_send_command (entry->sc, &cmd, &out_len, true); entry->response_len = entry->status ?0 : out_len; status = entry->status; }
@@ -227,7 +227,7 @@ static ssize_t xe_sysctrl_ras_error_inject_write(struct file *file, const char _ scoped_guard(mutex, &entry->lock) {guard (xe_pm_runtime)(xe); - status =xe_sysctrl_send_command (entry->sc, &cmd, &out_len); + status =xe_sysctrl_send_command (entry->sc, &cmd, &out_len, true); entry->status = status; }
@@ -420,7 +420,7 @@ static ssize_t xe_sysctrl_mailbox_write(struct file *file, const char __user *ub cmd.timeout_ms = timeout_ms;guard (xe_pm_runtime)(xe); - status =xe_sysctrl_send_command (entry->sc, &cmd, &out_len); + status =xe_sysctrl_send_command (entry->sc, &cmd, &out_len, true); entry->status = status; entry->response_len = status ?0 : out_len; }
drivers/gpu/drm/xe/xe_sysctrl_event.c +1 -1
@@ -24,7 +24,7 @@ static void get_pending_event(struct xe_sysctrl *sc, struct xe_sysctrl_mailbox_c do { memset(response, 0, sizeof(*response)); - ret = xe_sysctrl_send_command(sc, command, &len); + ret = xe_sysctrl_send_command(sc, command, &len, true); if (ret) { xe_log_err(xe, SYSCTRL, ret, "Failed to get pending event\n"); return;
drivers/gpu/drm/xe/xe_sysctrl_mailbox.c +15 -10
@@ -216,7 +216,8 @@ static int sysctrl_process_frame(struct xe_sysctrl *sc,static int sysctrl_receive_frames (struct xe_sysctrl *sc,const struct xe_sysctrl_mailbox_msg_hdr *req,void *data_out,size_t data_out_len, -size_t *rdata_len,unsigned int timeout_ms) +size_t *rdata_len,unsigned int timeout_ms, +bool print_on_error) {struct xe_sysctrl_mailbox_msg_hdr *hdr;struct xe_device *xe =sc_to_xe (sc);
@@ -248,16 +249,17 @@ static int sysctrl_receive_frames(struct xe_sysctrl *sc, hdr = (struct xe_sysctrl_mailbox_msg_hdr *)buffer; -if (!XE_SYSCTRL_HDR_IS_RESPONSE (hdr) || -XE_SYSCTRL_HDR_GROUP_ID (hdr) !=XE_SYSCTRL_HDR_GROUP_ID (req) || -XE_SYSCTRL_HDR_COMMAND (hdr) !=XE_SYSCTRL_HDR_COMMAND (req)) { +if ((!XE_SYSCTRL_HDR_IS_RESPONSE (hdr) || +XE_SYSCTRL_HDR_GROUP_ID (hdr) !=XE_SYSCTRL_HDR_GROUP_ID (req) || +XE_SYSCTRL_HDR_COMMAND (hdr) !=XE_SYSCTRL_HDR_COMMAND (req)) && + print_on_error) {xe_log_err (xe,SYSCTRL , -EPROTO ,"Response header mismatch: %#x != %#x\n" , hdr->data, req->data);return -EPROTO ; } -if (XE_SYSCTRL_HDR_RESULT (hdr) !=0 ) { +if (XE_SYSCTRL_HDR_RESULT (hdr) !=0 && print_on_error) {xe_log_err (xe,SYSCTRL , -EIO ,"Firmware error: %#04x %#x.%#x\n" ,XE_SYSCTRL_HDR_RESULT (hdr),XE_SYSCTRL_HDR_GROUP_ID (req),XE_SYSCTRL_HDR_COMMAND (req));
@@ -273,7 +275,8 @@ static int sysctrl_receive_frames(struct xe_sysctrl *sc,static int sysctrl_send_command (struct xe_sysctrl *sc,const u8 *mbox_cmd,size_t cmd_size,void *data_out,size_t data_out_len, -size_t *rdata_len,unsigned int timeout_ms) +size_t *rdata_len,unsigned int timeout_ms, +bool print_on_error) {const struct xe_sysctrl_mailbox_msg_hdr *hdr;size_t received;
@@ -289,7 +292,8 @@ static int sysctrl_send_command(struct xe_sysctrl *sc, hdr = (const struct xe_sysctrl_mailbox_msg_hdr *)mbox_cmd; ret =sysctrl_receive_frames (sc, hdr, data_out, data_out_len, - &received, timeout_ms); + &received, timeout_ms, + print_on_error);if (ret)return ret;
@@ -349,7 +353,8 @@ void xe_sysctrl_create_command(struct xe_sysctrl_mailbox_command *command, u8 gr*/ int xe_sysctrl_send_command (struct xe_sysctrl *sc,struct xe_sysctrl_mailbox_command *cmd, -size_t *rdata_len) +size_t *rdata_len, +bool print_on_error) {struct xe_device *xe =sc_to_xe (sc);u8 group_id, command_code;
@@ -379,8 +384,8 @@ int xe_sysctrl_send_command(struct xe_sysctrl *sc, ret =sysctrl_send_command (sc, sc->cmd_buf, cmd_size, cmd->data_out, cmd->data_out_len, rdata_len, - timeout_ms); -if (ret) + timeout_ms, print_on_error); +if (ret && print_on_error)xe_log_err (xe,SYSCTRL , ret,"Mailbox command failed to send %#x.%#x\n" , group_id, command_code);
drivers/gpu/drm/xe/xe_sysctrl_mailbox.h +2 -1
@@ -28,6 +28,7 @@ void xe_sysctrl_create_command(struct xe_sysctrl_mailbox_command *command, u8 gr size_t response_len);int xe_sysctrl_send_command (struct xe_sysctrl *sc,struct xe_sysctrl_mailbox_command *cmd, -size_t *rdata_len); +size_t *rdata_len, +bool print_on_error);#endif
Signature · 1 line
2.43.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 17/17] drm/xe: Don't error on failed media defeature
Quoted 74 lines · On Sat, 2026-11-21 at 18:36 +0000, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [High] drm/xe:sysctrl_receive_frames()drops errors whenprint_on_erroris false
- [Low] drm/xe: missing @print_on_error kernel-doc inxe_sysctrl_send_command()
--commit
d140787dfb99bcff2934127956d759603bd3096c
Author: Stuart Summers <[email protected]>drm/xe: Don't error on failed media defeature
This commit adds a
print_on_errorparameter toxe_sysctrl_send_command()
and downgrades the media defeature failure message fromxe_err()toxe_info().Quoted 42 lines
drivers/gpu/drm/xe/xe_sysctrl_mailbox.c +0
-0@@ -216,7 +216,8 @@ static int sysctrl_process_frame(struct xe_sysctrl *sc, static int sysctrl_receive_frames(struct xe_sysctrl *sc,const struct
xe_sysctrl_mailbox_msg_hdr*req,
void*data_out,size_tdata_out_len,
-size_t*rdata_len, unsigned inttimeout_ms)
+size_t*rdata_len, unsigned inttimeout_ms,
+ boolprint_on_error) {
structxe_sysctrl_mailbox_msg_hdr*hdr;
structxe_device*xe =sc_to_xe(sc);drivers/gpu/drm/xe/xe_sysctrl_mailbox.c +0
-0@@ -248,16 +249,17 @@ static int sysctrl_receive_frames(struct xe_sysctrl *sc,
hdr = (structxe_sysctrl_mailbox_msg_hdr*)buffer;
- if (!XE_SYSCTRL_HDR_IS_RESPONSE(hdr) ||
-XE_SYSCTRL_HDR_GROUP_ID(hdr)!=XE_SYSCTRL_HDR_GROUP_ID(req)||
-XE_SYSCTRL_HDR_COMMAND(hdr)!=XE_SYSCTRL_HDR_COMMAND(req)) {
+ if ((!XE_SYSCTRL_HDR_IS_RESPONSE(hdr) ||
+XE_SYSCTRL_HDR_GROUP_ID(hdr)!=XE_SYSCTRL_HDR_GROUP_ID(req)||
+XE_SYSCTRL_HDR_COMMAND(hdr)!=XE_SYSCTRL_HDR_COMMAND(req)) &&
+print_on_error) {
xe_log_err(xe, SYSCTRL,-EPROTO, "Response header mismatch: %#x != %#x\n",
hdr->data,req->data); return-EPROTO;
}Quoted 8 lines
- if (XE_SYSCTRL_HDR_RESULT(hdr)!= 0) {
+ if (XE_SYSCTRL_HDR_RESULT(hdr)!= 0 &&print_on_error) { xe_log_err(xe, SYSCTRL,-EIO, "Firmware error:
%#04x %#x.%#x\n",
XE_SYSCTRL_HDR_RESULT(hdr),XE_SYSCTRL_HDR_GROUP_ID(req),XE_SYSCTRL_HDR_COMMAND(req));[Severity: High]
Does gating these conditions onprint_on_errorcausesysctrl_receive_frames()to drop-EPROTOand-EIOand return 0 whenprint_on_erroris false?
Quoted 6 lines
When
sysctrl_media_defeature()passes false and the firmware rejectsXE_SYSCTRL_CMD_MEDIA_DEFEATURE, the call succeeds instead of failing:xe_sysctrl_media_defeature()leavesxe->sc.has_media_feature_disableset,
andxe_sysctrl_media_probe()returns early without callingsysctrl_media_drop().
This was intentional... Again, no plan to merge this.
-Stuart
Quoted 16 lines
[ ... ]
Quoted 8 lines
drivers/gpu/drm/xe/xe_sysctrl_mailbox.c +0
-0@@ -349,7 +353,8 @@ void xe_sysctrl_create_command(struct
xe_sysctrl_mailbox_command*command, u8 gr
*/
int xe_sysctrl_send_command(structxe_sysctrl*sc, structxe_sysctrl_mailbox_command*cmd, -size_t*rdata_len)
+size_t*rdata_len,
+ boolprint_on_error)[Severity: Low]
The kernel-doc comment abovexe_sysctrl_send_command()is missing a description for @print_on_error.