From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: [PATCH v2] drm/xe: Enable ATS if enabled on the PCI side
Date: Sun, 8 Jun 2025 19:36:19 +0200 [thread overview]
Message-ID: <20250608173619.200247-1-thomas.hellstrom@linux.intel.com> (raw)
If IOMMU and device supports ATS, enable it in an effort to offload
IOMMU TLB.
v2:
- Set the FORCE_FAULT PTE flag when clearing a PTE for faulting VM. (CI)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
drivers/gpu/drm/xe/regs/xe_gtt_defs.h | 1 +
drivers/gpu/drm/xe/xe_lrc.c | 5 +++++
drivers/gpu/drm/xe/xe_pt.c | 4 ++--
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/xe/regs/xe_gtt_defs.h b/drivers/gpu/drm/xe/regs/xe_gtt_defs.h
index 4389e5a76f89..c6b32516b008 100644
--- a/drivers/gpu/drm/xe/regs/xe_gtt_defs.h
+++ b/drivers/gpu/drm/xe/regs/xe_gtt_defs.h
@@ -33,5 +33,6 @@
#define XE_PAGE_PRESENT BIT_ULL(0)
#define XE_PAGE_RW BIT_ULL(1)
+#define XE_PAGE_FORCE_FAULT BIT_ULL(2)
#endif
diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
index 61a2e87990a9..085f7e0568e9 100644
--- a/drivers/gpu/drm/xe/xe_lrc.c
+++ b/drivers/gpu/drm/xe/xe_lrc.c
@@ -976,6 +976,7 @@ static void xe_lrc_setup_utilization(struct xe_lrc *lrc)
#define PVC_CTX_ASID (0x2e + 1)
#define PVC_CTX_ACC_CTR_THOLD (0x2a + 1)
+#define XE_CTX_PASID (0x2c + 1)
static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
struct xe_vm *vm, u32 ring_size, u16 msix_vec,
@@ -1104,6 +1105,10 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
if (xe->info.has_asid && vm)
xe_lrc_write_ctx_reg(lrc, PVC_CTX_ASID, vm->usm.asid);
+ /* If possible, enable ATS to offload the IOMMU TLB */
+ if (to_pci_dev(xe->drm.dev)->ats_enabled)
+ xe_lrc_write_ctx_reg(lrc, XE_CTX_PASID, (1 << 31));
+
lrc->desc = LRC_VALID;
lrc->desc |= FIELD_PREP(LRC_ADDRESSING_MODE, LRC_LEGACY_64B_CONTEXT);
/* TODO: Priority */
diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
index c9c41fbe125c..15e87be0e491 100644
--- a/drivers/gpu/drm/xe/xe_pt.c
+++ b/drivers/gpu/drm/xe/xe_pt.c
@@ -65,7 +65,7 @@ static u64 __xe_pt_empty_pte(struct xe_tile *tile, struct xe_vm *vm,
u8 id = tile->id;
if (!xe_vm_has_scratch(vm))
- return 0;
+ return XE_PAGE_FORCE_FAULT;
if (level > MAX_HUGEPTE_LEVEL)
return vm->pt_ops->pde_encode_bo(vm->scratch_pt[id][level - 1]->bo,
@@ -535,7 +535,7 @@ xe_pt_stage_bind_entry(struct xe_ptw *parent, pgoff_t offset,
XE_WARN_ON(xe_walk->va_curs_start != addr);
if (xe_walk->clear_pt) {
- pte = 0;
+ pte = XE_PAGE_FORCE_FAULT;
} else {
pte = vm->pt_ops->pte_encode_vma(is_null ? 0 :
xe_res_dma(curs) +
--
2.49.0
next reply other threads:[~2025-06-08 17:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-08 17:36 Thomas Hellström [this message]
2025-06-08 17:42 ` ✓ CI.Patch_applied: success for drm/xe: Enable ATS if enabled on the PCI side (rev2) Patchwork
2025-06-08 17:42 ` ✓ CI.checkpatch: " Patchwork
2025-06-08 17:43 ` ✓ CI.KUnit: " Patchwork
2025-06-08 17:54 ` ✓ CI.Build: " Patchwork
2025-06-08 17:58 ` ✓ CI.Hooks: " Patchwork
2025-06-08 17:59 ` ✓ CI.checksparse: " Patchwork
2025-06-08 18:46 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-06-09 7:52 ` ✗ Xe.CI.Full: " Patchwork
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=20250608173619.200247-1-thomas.hellstrom@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
/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