From: sashiko-bot@kernel.org
To: "Stuart Summers" <stuart.summers@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 2/2] drm/xe: Work around media 52-bit limitation on CRI
Date: Fri, 04 Dec 2026 00:03:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-248800@kernel.org> (raw)
In-Reply-To: <20261203232859.321380-6-stuart.summers@intel.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [Medium] drm/xe: xe_sysctrl_media_resume() skips media disable on
reset or power loss
- [Medium] drm/xe: xe_sysctrl_media_resume() omits media_verx100 check
for absent media
- [Medium] drm/xe: host_max_phys_addr() misuses MAX_PHYSMEM_BITS for
46-bit DMA check
- [Medium] drm/xe: sticky media defeature in xe_sysctrl_media_probe()
breaks reload
- [Medium] drm/xe: xe_sysctrl_media_probe() skips media ATS disable for
SR-IOV VFs
- [Medium] drm/xe: sysctrl_media_defeature() ignores resp.flags firmware
status
--
commit 7d17b36bd7bfeabd2f18b1bba4f21be143424af7
Author: Stuart Summers <stuart.summers@intel.com>
drm/xe: Work around media 52-bit limitation on CRI
This commit disables media by default on CRI, clamps the device DMA mask
to 46 bits when media is enabled on systems whose DMA stays within 46
bits, and adds System Controller mailbox commands to power down media or
disable media address translation at probe and resume.
> diff --git a/drivers/gpu/drm/xe/xe_pci.c b/drivers/gpu/drm/xe/xe_pci.c
> index 4e464ba3bbee8..12fd78137beab 100644
> --- a/drivers/gpu/drm/xe/xe_pci.c
> +++ b/drivers/gpu/drm/xe/xe_pci.c
[ ... ]
> @@ -789,6 +792,54 @@ static int xe_probe_info_early(struct xe_device *xe,
> return 0;
> }
>
> +/*
> + * Number of address bits media is able to reach on CRI, where it has no
> + * address translation of its own.
> + */
> +#define XE_CRI_MEDIA_ADDR_BITS 46
> +
> +static bool device_iommu_iova_backed(struct device *dev)
> +{
> + struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
> +
> + return domain && domain->type != IOMMU_DOMAIN_IDENTITY;
> +}
> +
> +/* Highest architectural physical address the host can produce */
> +static u64 host_max_phys_addr(void)
> +{
> +#ifdef MAX_PHYSMEM_BITS
> + return DMA_BIT_MASK(MAX_PHYSMEM_BITS);
> +#else
> + return (phys_addr_t)-1;
> +#endif
> +}
> +
> +/*
> + * Decide whether media can be used on CRI. Media there cannot translate
> + * addresses, so it is only usable if device DMA is guaranteed to stay within
> + * XE_CRI_MEDIA_ADDR_BITS. The IOMMU guarantees that by allocating IOVAs
> + * below the device dma mask. Without it, DMA addresses are host physical
> + * addresses, so media is only usable when the host cannot produce an address
> + * wider than media can reach.
> + */
> +static bool cri_media_addressable(struct xe_device *xe)
> +{
> + u64 host_max_addr = host_max_phys_addr();
> +
> + if (device_iommu_iova_backed(xe->drm.dev))
> + return true;
> +
> + if (host_max_addr <= DMA_BIT_MASK(XE_CRI_MEDIA_ADDR_BITS))
> + return true;
> +
> + drm_info(&xe->drm,
> + "IOMMU is not translating device DMA and the host can produce %u bit physical addresses, media is limited to %u\n",
> + fls64(host_max_addr), XE_CRI_MEDIA_ADDR_BITS);
> +
> + return false;
> +}
[Severity: Medium]
Is MAX_PHYSMEM_BITS a safe proxy for the highest DMA address the host can
produce without a translating IOMMU?
On x86-64 with 4-level paging, MAX_PHYSMEM_BITS is 46 (the direct-map RAM
ceiling) even when boot_cpu_data.x86_phys_bits is 48 or 52, AMD SME places
the encryption bit above bit 46, or dev->dma_range_map applies an offset.
When cri_media_addressable() falsely returns true, xe_info_init_early()
clamps the device DMA mask to 46 bits. On a 4-level paging AMD SME host
without IOMMU translation, force_dma_unencrypted() then returns true and
bounces system-RAM BOs through SWIOTLB, which breaks xe_tt_map_sg()
because xe passes DMA_ATTR_SKIP_CPU_SYNC. Peer MMIO BARs above 46 bits
also fail dma_capable() in dma_direct_map_phys().
Conversely, when CONFIG_SPARSEMEM is disabled (such as 32-bit PAE with
CONFIG_FLATMEM), MAX_PHYSMEM_BITS is undefined and host_max_phys_addr()
falls back to (phys_addr_t)-1, spuriously disabling media. Checking
actual physical and DMA bounds (such as iomem_resource.end, SME
encryption, and dev->dma_range_map) would avoid both issues.
> diff --git a/drivers/gpu/drm/xe/xe_sysctrl.c b/drivers/gpu/drm/xe/xe_sysctrl.c
> index d362e8156fca2..2fc4e35f3e25d 100644
> --- a/drivers/gpu/drm/xe/xe_sysctrl.c
> +++ b/drivers/gpu/drm/xe/xe_sysctrl.c
[ ... ]
> @@ -249,3 +254,162 @@ int xe_sysctrl_sdk_api_version(struct xe_device *xe, u16 *version)
>
> return 0;
> }
> +
> +static int sysctrl_media_defeature(struct xe_device *xe, u8 feature)
> +{
> + struct xe_sysctrl_media_defeature_req req = { .feature = feature };
> + struct xe_sysctrl_media_defeature_resp resp = {};
> + struct xe_sysctrl_mailbox_command cmd = {};
> + size_t out_len = 0;
> + int ret;
> +
> + xe_sysctrl_create_command(&cmd, XE_SYSCTRL_GROUP_RUNTIME,
> + XE_SYSCTRL_CMD_MEDIA_DEFEATURE,
> + &req, sizeof(req), &resp, sizeof(resp));
> +
> + ret = xe_sysctrl_send_command(&xe->sc, &cmd, &out_len);
> + if (ret)
> + return ret;
> +
> + if (out_len != sizeof(resp)) {
> + xe_err(xe, "sysctrl: unexpected media defeature response length %zu (expected %zu)\n",
> + out_len, sizeof(resp));
> + return -EPROTO;
> + }
> +
> + return 0;
> +}
[Severity: Medium]
Should sysctrl_media_defeature() validate resp.flags before returning 0?
struct xe_sysctrl_media_defeature_resp defines u32 flags as firmware
status flags, and sysctrl_receive_frames() only checks the transport
header result (XE_SYSCTRL_HDR_RESULT(hdr) == 0), leaving payload status
fields to callers as xe_sysctrl_check_app_status() and xe_ras.c do.
If firmware reports a command-level failure in resp.flags,
xe_sysctrl_media_probe() skips sysctrl_media_drop() and brings up the
media GT with ATS still enabled.
[ ... ]
> +/* Whether this platform needs the media defeature workaround at all */
> +static bool sysctrl_media_defeature_needed(struct xe_device *xe)
> +{
> + return XE_DEVICE_WA(xe, 14028632488) &&
> + xe->info.has_soc_remapper_sysctrl &&
> + xe->info.has_sysctrl &&
> + xe->sc.has_media_feature_disable;
> +}
[Severity: Medium]
Should sysctrl_media_defeature_needed() (or xe_sysctrl_media_resume())
also check xe->info.media_verx100?
xe_info_init_early() sets xe->info.media_allowed before handle_gmdid()
probes hardware, and xe_info_init() leaves media_allowed true when media
is fused off (media_verx100 == 0). xe_sysctrl_media_probe() returns early
on !xe->info.media_verx100 without checking firmware support or clearing
has_media_feature_disable.
On a CRI SKU with fused-off media, enable_media=1, and ATS enabled,
xe_sysctrl_media_resume() will still send
XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE on resume, and any firmware error
will abort xe_pm_runtime_resume() or xe_device_resume().
> +/**
> + * xe_sysctrl_media_resume() - Restore media address translation defeature
> + * @xe: xe device instance
> + *
> + * The media address translation defeature does not survive a power loss, so
> + * it must be requested again on resume from D3cold or system suspend whenever
> + * media is in use and ATS is enabled. The media defeature sent at probe when
> + * media is not in use persists until a secondary bus reset, which cannot
> + * happen while the driver is bound, so it is not resent here.
> + *
> + * Return: 0 on success, error code on failure
> + */
> +int xe_sysctrl_media_resume(struct xe_device *xe)
> +{
> + if (!sysctrl_media_defeature_needed(xe) ||
> + !xe_device_media_allowed(xe) || !sysctrl_ats_enabled(xe))
> + return 0;
> +
> + return sysctrl_media_defeature_send(xe, XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE);
> +}
[Severity: Medium]
Can a secondary bus reset or full power loss happen while the driver stays
bound, leaving media powered on after resume?
PCI core executes secondary bus resets without unbinding the driver
(pci_reset_function() -> pci_reset_bus_function() -> xe_pci_reset_done()
-> xe_device_resume(xe, true)), and runtime D3cold, S3 suspend, and S4
hibernation also remove power and resume via xe_pm_runtime_resume() or
xe_device_resume() instead of re-running xe_sysctrl_media_probe().
Because xe_sysctrl_media_resume() returns early whenever
!xe_device_media_allowed(xe), XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE is never
re-sent in the default CRI configuration, leaving unused media powered on.
[ ... ]
> +void xe_sysctrl_media_probe(struct xe_device *xe)
> +{
> + bool media_allowed = xe_device_media_allowed(xe);
> + int ret;
> +
> + if (!sysctrl_media_defeature_needed(xe) || !xe->info.media_verx100)
> + return;
> +
> + if (media_allowed) {
> + if (!sysctrl_ats_enabled(xe))
> + return;
> +
> + if (!sysctrl_media_defeature_send(xe, XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE)) {
> + xe_dbg(xe, "sysctrl: media address translation defeatured\n");
> + return;
> + }
> + }
[Severity: Medium]
Can SR-IOV VFs enable ATS while PCI_ATS_CTRL_ENABLE is clear on the PF,
bypassing media ATS disable?
When the PF is attached to an identity IOMMU domain (for example iommu=pt
in Intel VT-d legacy mode or ARM SMMUv3) on a 4-level paging host with
enable_media=1, pci_prepare_ats() programs ats_stu on the PF while leaving
PCI_ATS_CTRL_ENABLE clear, so sysctrl_ats_enabled() returns false in both
xe_sysctrl_media_probe() and xe_sysctrl_media_resume().
VFs created later and attached to translating domains (such as VFIO)
enable ATS via pci_enable_ats(), which only requires the PF's ats_stu to
match. Since xe_info_init() clears has_sysctrl on VFs, they cannot send
XE_SYSCTRL_MEDIA_DEFEATURE_ATS_DISABLE themselves and hit ATS translation
errors and media GuC load failures.
> + ret = sysctrl_media_defeature_send(xe, XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE);
> + if (ret)
> + xe->sc.has_media_feature_disable = false;
> + else
> + xe_dbg(xe, "sysctrl: media defeatured\n");
[Severity: Medium]
Does sending XE_SYSCTRL_MEDIA_DEFEATURE_DISABLE by default break reloading
the driver or rebinding via configfs with media enabled?
Neither xe_pci_remove() nor xe_driver_flr_fini() performs a secondary bus
reset and there is no re-enable command, so media stays defeatured across
unload or unbind.
Reloading with enable_media=1 (or rebinding with
gt_types_allowed=primary,media) then either fails probe on media GT
forcewake in xe_gt_init_early() if GMD_ID still reports media, or silently
probes without media if GMD_ID reads 0 while leaving dma_mask_size clamped
to 46 bits.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203232859.321380-4-stuart.summers@intel.com?part=2
next prev parent reply other threads:[~2026-12-04 0:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 23:28 [PATCH 0/2] Work around 52-bit limitation in CRI media Stuart Summers
2026-12-03 23:28 ` [PATCH 1/2] drm/xe: Add enable_media module parameter Stuart Summers
2026-12-03 23:32 ` Summers, Stuart
2026-12-03 23:58 ` sashiko-bot
2026-12-03 23:29 ` [PATCH 2/2] drm/xe: Work around media 52-bit limitation on CRI Stuart Summers
2026-12-04 0:03 ` sashiko-bot [this message]
2026-12-04 0:52 ` ✗ CI.checkpatch: warning for Work around 52-bit limitation in CRI media (rev2) Patchwork
2026-12-04 0:54 ` ✓ CI.KUnit: success " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2026-12-03 19:09 [PATCH 0/2] Work around 52-bit limitation in CRI media Stuart Summers
2026-12-03 19:09 ` [PATCH 2/2] drm/xe: Work around media 52-bit limitation on CRI Stuart Summers
2026-12-03 19:31 ` sashiko-bot
2026-12-03 19:57 ` Summers, Stuart
2026-12-03 21:37 ` Rodrigo Vivi
2026-12-03 21:41 ` Summers, Stuart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-248800@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=stuart.summers@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox