Skip to content

Commit 2f835b5

Browse files
committed
Merge tag 'topic/i915-gem-next-2021-03-26' of ssh://git.freedesktop.org/git/drm/drm into drm-next
special i915-gem-next pull as requested - Conversion to dma_resv_locking, obj->mm.lock is gone (Maarten, with help from Thomas Hellström) - watchdog (Tvrtko, one patch to cancel individual request from Chris) - legacy ioctl cleanup (Jason+Ashutosh) - i915-gem TODO and RFC process doc (me) - i915_ prefix for vma_lookup (Liam Howlett) just because I spotted it and put it in here too Signed-off-by: Dave Airlie <[email protected]> From: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents fe8a057 + e1a5e6a commit 2f835b5

File tree

117 files changed

+2749
-2165
lines changed

Some content is hidden

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

117 files changed

+2749
-2165
lines changed

Documentation/gpu/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Linux GPU Driver Developer's Guide
1616
vga-switcheroo
1717
vgaarbiter
1818
todo
19+
rfc/index
1920

2021
.. only:: subproject and html
2122

Documentation/gpu/rfc/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
===============
2+
GPU RFC Section
3+
===============
4+
5+
For complex work, especially new uapi, it is often good to nail the high level
6+
design issues before getting lost in the code details. This section is meant to
7+
host such documentation:
8+
9+
* Each RFC should be a section in this file, explaining the goal and main design
10+
considerations. Especially for uapi make sure you Cc: all relevant project
11+
mailing lists and involved people outside of dri-devel.
12+
13+
* For uapi structures add a file to this directory with and then pull the
14+
kerneldoc in like with real uapi headers.
15+
16+
* Once the code has landed move all the documentation to the right places in
17+
the main core, helper or driver sections.

drivers/gpu/drm/i915/Kconfig.profile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
config DRM_I915_REQUEST_TIMEOUT
2+
int "Default timeout for requests (ms)"
3+
default 20000 # milliseconds
4+
help
5+
Configures the default timeout after which any user submissions will
6+
be forcefully terminated.
7+
8+
Beware setting this value lower, or close to heartbeat interval
9+
rounded to whole seconds times three, in order to avoid allowing
10+
misbehaving applications causing total rendering failure in unrelated
11+
clients.
12+
13+
May be 0 to disable the timeout.
14+
115
config DRM_I915_FENCE_TIMEOUT
216
int "Timeout for unsignaled foreign fences (ms, jiffy granularity)"
317
default 10000 # milliseconds

drivers/gpu/drm/i915/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ gem-y += \
139139
gem/i915_gem_dmabuf.o \
140140
gem/i915_gem_domain.o \
141141
gem/i915_gem_execbuffer.o \
142-
gem/i915_gem_fence.o \
143142
gem/i915_gem_internal.o \
144143
gem/i915_gem_object.o \
145144
gem/i915_gem_object_blt.o \

drivers/gpu/drm/i915/TODO.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
gem/gt TODO items
2+
-----------------
3+
4+
- For discrete memory manager, merge enough dg1 to be able to refactor it to
5+
TTM. Then land pci ids (just in case that turns up an uapi problem). TTM has
6+
improved a lot the past 2 years, there's no reason anymore not to use it.
7+
8+
- Come up with a plan what to do with drm/scheduler and how to get there.
9+
10+
- Roll out dma_fence critical section annotations.
11+
12+
- There's a lot of complexity added past few years to make relocations faster.
13+
That doesn't make sense given hw and gpu apis moved away from this model years
14+
ago:
15+
1. Land a modern pre-bound uapi like VM_BIND
16+
2. Any complexity added in this area past few years which can't be justified
17+
with VM_BIND using userspace should be removed. Looking at amdgpu dma_resv on
18+
the bo and vm, plus some lru locks is all that needed. No complex rcu,
19+
refcounts, caching, ... on everything.
20+
This is the matching task on the vm side compared to ttm/dma_resv on the
21+
backing storage side.
22+
23+
- i915_sw_fence seems to be the main structure for the i915-gem dma_fence model.
24+
How-to-dma_fence is core and drivers really shouldn't build their own world
25+
here, treating everything else as a fixed platform. i915_sw_fence concepts
26+
should be moved to dma_fence, drm/scheduler or atomic commit helpers. Or
27+
removed if dri-devel consensus is that it's not a good idea. Once that's done
28+
maybe even remove it if there's nothing left.
29+
30+
Smaller things:
31+
- i915_utils.h needs to be moved to the right places.
32+
33+
- dma_fence_work should be in drivers/dma-buf
34+
35+
- i915_mm.c should be moved to the right places. Some of the helpers also look a
36+
bit fishy:
37+
38+
https://lore.kernel.org/linux-mm/[email protected]/
39+
40+
- tasklet helpers in i915_gem.h also look a bit misplaced and should
41+
probably be moved to tasklet headers.

drivers/gpu/drm/i915/display/intel_display.c

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,7 @@ static bool intel_plane_uses_fence(const struct intel_plane_state *plane_state)
10911091

10921092
struct i915_vma *
10931093
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
1094+
bool phys_cursor,
10941095
const struct i915_ggtt_view *view,
10951096
bool uses_fence,
10961097
unsigned long *out_flags)
@@ -1099,14 +1100,19 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
10991100
struct drm_i915_private *dev_priv = to_i915(dev);
11001101
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
11011102
intel_wakeref_t wakeref;
1103+
struct i915_gem_ww_ctx ww;
11021104
struct i915_vma *vma;
11031105
unsigned int pinctl;
11041106
u32 alignment;
1107+
int ret;
11051108

11061109
if (drm_WARN_ON(dev, !i915_gem_object_is_framebuffer(obj)))
11071110
return ERR_PTR(-EINVAL);
11081111

1109-
alignment = intel_surf_alignment(fb, 0);
1112+
if (phys_cursor)
1113+
alignment = intel_cursor_alignment(dev_priv);
1114+
else
1115+
alignment = intel_surf_alignment(fb, 0);
11101116
if (drm_WARN_ON(dev, alignment && !is_power_of_2(alignment)))
11111117
return ERR_PTR(-EINVAL);
11121118

@@ -1141,14 +1147,26 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
11411147
if (HAS_GMCH(dev_priv))
11421148
pinctl |= PIN_MAPPABLE;
11431149

1144-
vma = i915_gem_object_pin_to_display_plane(obj,
1145-
alignment, view, pinctl);
1146-
if (IS_ERR(vma))
1150+
i915_gem_ww_ctx_init(&ww, true);
1151+
retry:
1152+
ret = i915_gem_object_lock(obj, &ww);
1153+
if (!ret && phys_cursor)
1154+
ret = i915_gem_object_attach_phys(obj, alignment);
1155+
if (!ret)
1156+
ret = i915_gem_object_pin_pages(obj);
1157+
if (ret)
11471158
goto err;
11481159

1149-
if (uses_fence && i915_vma_is_map_and_fenceable(vma)) {
1150-
int ret;
1160+
if (!ret) {
1161+
vma = i915_gem_object_pin_to_display_plane(obj, &ww, alignment,
1162+
view, pinctl);
1163+
if (IS_ERR(vma)) {
1164+
ret = PTR_ERR(vma);
1165+
goto err_unpin;
1166+
}
1167+
}
11511168

1169+
if (uses_fence && i915_vma_is_map_and_fenceable(vma)) {
11521170
/*
11531171
* Install a fence for tiled scan-out. Pre-i965 always needs a
11541172
* fence, whereas 965+ only requires a fence if using
@@ -1169,16 +1187,28 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
11691187
ret = i915_vma_pin_fence(vma);
11701188
if (ret != 0 && INTEL_GEN(dev_priv) < 4) {
11711189
i915_vma_unpin(vma);
1172-
vma = ERR_PTR(ret);
1173-
goto err;
1190+
goto err_unpin;
11741191
}
1192+
ret = 0;
11751193

1176-
if (ret == 0 && vma->fence)
1194+
if (vma->fence)
11771195
*out_flags |= PLANE_HAS_FENCE;
11781196
}
11791197

11801198
i915_vma_get(vma);
1199+
1200+
err_unpin:
1201+
i915_gem_object_unpin_pages(obj);
11811202
err:
1203+
if (ret == -EDEADLK) {
1204+
ret = i915_gem_ww_ctx_backoff(&ww);
1205+
if (!ret)
1206+
goto retry;
1207+
}
1208+
i915_gem_ww_ctx_fini(&ww);
1209+
if (ret)
1210+
vma = ERR_PTR(ret);
1211+
11821212
atomic_dec(&dev_priv->gpu_error.pending_fb_pin);
11831213
intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
11841214
return vma;
@@ -11333,19 +11363,11 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state)
1133311363
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
1133411364
struct drm_framebuffer *fb = plane_state->hw.fb;
1133511365
struct i915_vma *vma;
11366+
bool phys_cursor =
11367+
plane->id == PLANE_CURSOR &&
11368+
INTEL_INFO(dev_priv)->display.cursor_needs_physical;
1133611369

11337-
if (plane->id == PLANE_CURSOR &&
11338-
INTEL_INFO(dev_priv)->display.cursor_needs_physical) {
11339-
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
11340-
const int align = intel_cursor_alignment(dev_priv);
11341-
int err;
11342-
11343-
err = i915_gem_object_attach_phys(obj, align);
11344-
if (err)
11345-
return err;
11346-
}
11347-
11348-
vma = intel_pin_and_fence_fb_obj(fb,
11370+
vma = intel_pin_and_fence_fb_obj(fb, phys_cursor,
1134911371
&plane_state->view,
1135011372
intel_plane_uses_fence(plane_state),
1135111373
&plane_state->flags);
@@ -11437,13 +11459,8 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
1143711459
if (!obj)
1143811460
return 0;
1143911461

11440-
ret = i915_gem_object_pin_pages(obj);
11441-
if (ret)
11442-
return ret;
1144311462

1144411463
ret = intel_plane_pin_fb(new_plane_state);
11445-
11446-
i915_gem_object_unpin_pages(obj);
1144711464
if (ret)
1144811465
return ret;
1144911466

@@ -11905,7 +11922,7 @@ static int intel_user_framebuffer_create_handle(struct drm_framebuffer *fb,
1190511922
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
1190611923
struct drm_i915_private *i915 = to_i915(obj->base.dev);
1190711924

11908-
if (obj->userptr.mm) {
11925+
if (i915_gem_object_is_userptr(obj)) {
1190911926
drm_dbg(&i915->drm,
1191011927
"attempting to use a userptr for a framebuffer, denied\n");
1191111928
return -EINVAL;

drivers/gpu/drm/i915/display/intel_display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
573573
struct intel_load_detect_pipe *old,
574574
struct drm_modeset_acquire_ctx *ctx);
575575
struct i915_vma *
576-
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
576+
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, bool phys_cursor,
577577
const struct i915_ggtt_view *view,
578578
bool uses_fence,
579579
unsigned long *out_flags);

drivers/gpu/drm/i915/display/intel_dsb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void intel_dsb_prepare(struct intel_crtc_state *crtc_state)
293293
goto out;
294294
}
295295

296-
buf = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
296+
buf = i915_gem_object_pin_map_unlocked(vma->obj, I915_MAP_WC);
297297
if (IS_ERR(buf)) {
298298
drm_err(&i915->drm, "Command buffer creation failed\n");
299299
i915_vma_unpin_and_release(&vma, I915_VMA_RELEASE_MAP);

drivers/gpu/drm/i915/display/intel_fbdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
211211
* This also validates that any existing fb inherited from the
212212
* BIOS is suitable for own access.
213213
*/
214-
vma = intel_pin_and_fence_fb_obj(&ifbdev->fb->base,
214+
vma = intel_pin_and_fence_fb_obj(&ifbdev->fb->base, false,
215215
&view, false, &flags);
216216
if (IS_ERR(vma)) {
217217
ret = PTR_ERR(vma);

drivers/gpu/drm/i915/display/intel_overlay.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,32 @@ static u32 overlay_cmd_reg(struct drm_intel_overlay_put_image *params)
755755
return cmd;
756756
}
757757

758+
static struct i915_vma *intel_overlay_pin_fb(struct drm_i915_gem_object *new_bo)
759+
{
760+
struct i915_gem_ww_ctx ww;
761+
struct i915_vma *vma;
762+
int ret;
763+
764+
i915_gem_ww_ctx_init(&ww, true);
765+
retry:
766+
ret = i915_gem_object_lock(new_bo, &ww);
767+
if (!ret) {
768+
vma = i915_gem_object_pin_to_display_plane(new_bo, &ww, 0,
769+
NULL, PIN_MAPPABLE);
770+
ret = PTR_ERR_OR_ZERO(vma);
771+
}
772+
if (ret == -EDEADLK) {
773+
ret = i915_gem_ww_ctx_backoff(&ww);
774+
if (!ret)
775+
goto retry;
776+
}
777+
i915_gem_ww_ctx_fini(&ww);
778+
if (ret)
779+
return ERR_PTR(ret);
780+
781+
return vma;
782+
}
783+
758784
static int intel_overlay_do_put_image(struct intel_overlay *overlay,
759785
struct drm_i915_gem_object *new_bo,
760786
struct drm_intel_overlay_put_image *params)
@@ -776,12 +802,10 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,
776802

777803
atomic_inc(&dev_priv->gpu_error.pending_fb_pin);
778804

779-
vma = i915_gem_object_pin_to_display_plane(new_bo,
780-
0, NULL, PIN_MAPPABLE);
781-
if (IS_ERR(vma)) {
782-
ret = PTR_ERR(vma);
805+
vma = intel_overlay_pin_fb(new_bo);
806+
if (IS_ERR(vma))
783807
goto out_pin_section;
784-
}
808+
785809
i915_gem_object_flush_frontbuffer(new_bo, ORIGIN_DIRTYFB);
786810

787811
if (!overlay->active) {

0 commit comments

Comments
 (0)