Skip to content

Commit 11a5c64

Browse files
committed
Merge tag 'drm-xe-next-2025-03-07' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-next
UAPI Changes: - Expose per-engine activity via perf pmu (Riana, Lucas, Umesh) - Add support for EU stall sampling (Harish, Ashutosh) - Allow userspace to provide low latency hint for submission (Tejas) - GPU SVM and Xe SVM implementation (Matthew Brost) Cross-subsystem Changes: - devres handling for component drivers (Lucas) - Backmege drm-next to allow cross dependent change with i915 - GPU SVM and Xe SVM implementation (Matthew Brost) Core Changes: Driver Changes: - Fixes to userptr and missing validations (Matthew Auld, Thomas Hellström, Matthew Brost) - devcoredump typos and error handling improvement (Shuicheng) - Allow oa_exponent value of 0 (Umesh) - Finish moving device probe to devm (Lucas) - Fix race between submission restart and scheduled being freed (Tejas) - Fix counter overflows in gt_stats (Francois) - Refactor and add missing workarounds and tunings for pre-Xe2 platforms (Aradhya, Tvrtko) - Fix PXP locks interaction with exec queues being killed (Daniele) - Eliminate TIMESTAMP_OVERRIDE from xe (Matt Roper) - Change xe_gen_wa_oob to allow building on MacOS (Daniel Gomez) - New workarounds for Panther Lake (Tejas) - Fix VF resume errors (Satyanarayana) - Fix workaround infra skipping some workarounds dependent on engine initialization (Tvrtko) - Improve per-IP descriptors (Gustavo) - Add more error injections to probe sequence (Francois) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/ilc5jvtyaoyi6woyhght5a6sw5jcluiojjueorcyxbynrcpcjp@mw2mi6rd6a7l
2 parents c8cd03e + 45f5a1e commit 11a5c64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+8210
-791
lines changed

Documentation/gpu/rfc/gpusvm.rst

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
.. SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2+
3+
===============
4+
GPU SVM Section
5+
===============
6+
7+
Agreed upon design principles
8+
=============================
9+
10+
* migrate_to_ram path
11+
* Rely only on core MM concepts (migration PTEs, page references, and
12+
page locking).
13+
* No driver specific locks other than locks for hardware interaction in
14+
this path. These are not required and generally a bad idea to
15+
invent driver defined locks to seal core MM races.
16+
* An example of a driver-specific lock causing issues occurred before
17+
fixing do_swap_page to lock the faulting page. A driver-exclusive lock
18+
in migrate_to_ram produced a stable livelock if enough threads read
19+
the faulting page.
20+
* Partial migration is supported (i.e., a subset of pages attempting to
21+
migrate can actually migrate, with only the faulting page guaranteed
22+
to migrate).
23+
* Driver handles mixed migrations via retry loops rather than locking.
24+
* Eviction
25+
* Eviction is defined as migrating data from the GPU back to the
26+
CPU without a virtual address to free up GPU memory.
27+
* Only looking at physical memory data structures and locks as opposed to
28+
looking at virtual memory data structures and locks.
29+
* No looking at mm/vma structs or relying on those being locked.
30+
* The rationale for the above two points is that CPU virtual addresses
31+
can change at any moment, while the physical pages remain stable.
32+
* GPU page table invalidation, which requires a GPU virtual address, is
33+
handled via the notifier that has access to the GPU virtual address.
34+
* GPU fault side
35+
* mmap_read only used around core MM functions which require this lock
36+
and should strive to take mmap_read lock only in GPU SVM layer.
37+
* Big retry loop to handle all races with the mmu notifier under the gpu
38+
pagetable locks/mmu notifier range lock/whatever we end up calling
39+
those.
40+
* Races (especially against concurrent eviction or migrate_to_ram)
41+
should not be handled on the fault side by trying to hold locks;
42+
rather, they should be handled using retry loops. One possible
43+
exception is holding a BO's dma-resv lock during the initial migration
44+
to VRAM, as this is a well-defined lock that can be taken underneath
45+
the mmap_read lock.
46+
* One possible issue with the above approach is if a driver has a strict
47+
migration policy requiring GPU access to occur in GPU memory.
48+
Concurrent CPU access could cause a livelock due to endless retries.
49+
While no current user (Xe) of GPU SVM has such a policy, it is likely
50+
to be added in the future. Ideally, this should be resolved on the
51+
core-MM side rather than through a driver-side lock.
52+
* Physical memory to virtual backpointer
53+
* This does not work, as no pointers from physical memory to virtual
54+
memory should exist. mremap() is an example of the core MM updating
55+
the virtual address without notifying the driver of address
56+
change rather the driver only receiving the invalidation notifier.
57+
* The physical memory backpointer (page->zone_device_data) should remain
58+
stable from allocation to page free. Safely updating this against a
59+
concurrent user would be very difficult unless the page is free.
60+
* GPU pagetable locking
61+
* Notifier lock only protects range tree, pages valid state for a range
62+
(rather than seqno due to wider notifiers), pagetable entries, and
63+
mmu notifier seqno tracking, it is not a global lock to protect
64+
against races.
65+
* All races handled with big retry as mentioned above.
66+
67+
Overview of baseline design
68+
===========================
69+
70+
Baseline design is simple as possible to get a working basline in which can be
71+
built upon.
72+
73+
.. kernel-doc:: drivers/gpu/drm/xe/drm_gpusvm.c
74+
:doc: Overview
75+
:doc: Locking
76+
:doc: Migrataion
77+
:doc: Partial Unmapping of Ranges
78+
:doc: Examples
79+
80+
Possible future design features
81+
===============================
82+
83+
* Concurrent GPU faults
84+
* CPU faults are concurrent so makes sense to have concurrent GPU
85+
faults.
86+
* Should be possible with fined grained locking in the driver GPU
87+
fault handler.
88+
* No expected GPU SVM changes required.
89+
* Ranges with mixed system and device pages
90+
* Can be added if required to drm_gpusvm_get_pages fairly easily.
91+
* Multi-GPU support
92+
* Work in progress and patches expected after initially landing on GPU
93+
SVM.
94+
* Ideally can be done with little to no changes to GPU SVM.
95+
* Drop ranges in favor of radix tree
96+
* May be desirable for faster notifiers.
97+
* Compound device pages
98+
* Nvidia, AMD, and Intel all have agreed expensive core MM functions in
99+
migrate device layer are a performance bottleneck, having compound
100+
device pages should help increase performance by reducing the number
101+
of these expensive calls.
102+
* Higher order dma mapping for migration
103+
* 4k dma mapping adversely affects migration performance on Intel
104+
hardware, higher order (2M) dma mapping should help here.
105+
* Build common userptr implementation on top of GPU SVM
106+
* Driver side madvise implementation and migration policies
107+
* Pull in pending dma-mapping API changes from Leon / Nvidia when these land

Documentation/gpu/rfc/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ host such documentation:
1616
* Once the code has landed move all the documentation to the right places in
1717
the main core, helper or driver sections.
1818

19+
.. toctree::
20+
21+
gpusvm.rst
22+
1923
.. toctree::
2024

2125
i915_gem_lmem.rst

drivers/base/component.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@ static void component_unbind(struct component *component,
588588
{
589589
WARN_ON(!component->bound);
590590

591+
dev_dbg(adev->parent, "unbinding %s component %p (ops %ps)\n",
592+
dev_name(component->dev), component, component->ops);
593+
591594
if (component->ops && component->ops->unbind)
592595
component->ops->unbind(component->dev, adev->parent, data);
593596
component->bound = false;

drivers/base/devres.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,10 @@ void *devres_open_group(struct device *dev, void *id, gfp_t gfp)
576576
}
577577
EXPORT_SYMBOL_GPL(devres_open_group);
578578

579-
/* Find devres group with ID @id. If @id is NULL, look for the latest. */
579+
/*
580+
* Find devres group with ID @id. If @id is NULL, look for the latest open
581+
* group.
582+
*/
580583
static struct devres_group *find_group(struct device *dev, void *id)
581584
{
582585
struct devres_node *node;
@@ -687,6 +690,13 @@ int devres_release_group(struct device *dev, void *id)
687690
spin_unlock_irqrestore(&dev->devres_lock, flags);
688691

689692
release_nodes(dev, &todo);
693+
} else if (list_empty(&dev->devres_head)) {
694+
/*
695+
* dev is probably dying via devres_release_all(): groups
696+
* have already been removed and are on the process of
697+
* being released - don't touch and don't warn.
698+
*/
699+
spin_unlock_irqrestore(&dev->devres_lock, flags);
690700
} else {
691701
WARN_ON(1);
692702
spin_unlock_irqrestore(&dev->devres_lock, flags);

drivers/gpu/drm/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ config DRM_GPUVM
278278
GPU-VM representation providing helpers to manage a GPUs virtual
279279
address space
280280

281+
config DRM_GPUSVM
282+
tristate
283+
depends on DRM && DEVICE_PRIVATE
284+
select HMM_MIRROR
285+
select MMU_NOTIFIER
286+
help
287+
GPU-SVM representation providing helpers to manage a GPUs shared
288+
virtual memory
289+
281290
config DRM_BUDDY
282291
tristate
283292
depends on DRM

drivers/gpu/drm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ obj-$(CONFIG_DRM_PANEL_BACKLIGHT_QUIRKS) += drm_panel_backlight_quirks.o
104104
#
105105
obj-$(CONFIG_DRM_EXEC) += drm_exec.o
106106
obj-$(CONFIG_DRM_GPUVM) += drm_gpuvm.o
107+
obj-$(CONFIG_DRM_GPUSVM) += drm_gpusvm.o
107108

108109
obj-$(CONFIG_DRM_BUDDY) += drm_buddy.o
109110

0 commit comments

Comments
 (0)