Skip to content

Commit

Permalink
Merge tag 'topic/i915-gem-next-2021-03-26' of ssh://git.freedesktop.o…
Browse files Browse the repository at this point in the history
…rg/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 <airlied@redhat.com>

From: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/YF24MHoOSjpKFEXA@phenom.ffwll.local
  • Loading branch information
Dave Airlie committed Mar 31, 2021
2 parents fe8a057 + e1a5e6a commit 2f835b5
Show file tree
Hide file tree
Showing 117 changed files with 2,749 additions and 2,165 deletions.
1 change: 1 addition & 0 deletions Documentation/gpu/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Linux GPU Driver Developer's Guide
vga-switcheroo
vgaarbiter
todo
rfc/index

.. only:: subproject and html

Expand Down
17 changes: 17 additions & 0 deletions Documentation/gpu/rfc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
===============
GPU RFC Section
===============

For complex work, especially new uapi, it is often good to nail the high level
design issues before getting lost in the code details. This section is meant to
host such documentation:

* Each RFC should be a section in this file, explaining the goal and main design
considerations. Especially for uapi make sure you Cc: all relevant project
mailing lists and involved people outside of dri-devel.

* For uapi structures add a file to this directory with and then pull the
kerneldoc in like with real uapi headers.

* Once the code has landed move all the documentation to the right places in
the main core, helper or driver sections.
14 changes: 14 additions & 0 deletions drivers/gpu/drm/i915/Kconfig.profile
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
config DRM_I915_REQUEST_TIMEOUT
int "Default timeout for requests (ms)"
default 20000 # milliseconds
help
Configures the default timeout after which any user submissions will
be forcefully terminated.

Beware setting this value lower, or close to heartbeat interval
rounded to whole seconds times three, in order to avoid allowing
misbehaving applications causing total rendering failure in unrelated
clients.

May be 0 to disable the timeout.

config DRM_I915_FENCE_TIMEOUT
int "Timeout for unsignaled foreign fences (ms, jiffy granularity)"
default 10000 # milliseconds
Expand Down
1 change: 0 additions & 1 deletion drivers/gpu/drm/i915/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ gem-y += \
gem/i915_gem_dmabuf.o \
gem/i915_gem_domain.o \
gem/i915_gem_execbuffer.o \
gem/i915_gem_fence.o \
gem/i915_gem_internal.o \
gem/i915_gem_object.o \
gem/i915_gem_object_blt.o \
Expand Down
41 changes: 41 additions & 0 deletions drivers/gpu/drm/i915/TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
gem/gt TODO items
-----------------

- For discrete memory manager, merge enough dg1 to be able to refactor it to
TTM. Then land pci ids (just in case that turns up an uapi problem). TTM has
improved a lot the past 2 years, there's no reason anymore not to use it.

- Come up with a plan what to do with drm/scheduler and how to get there.

- Roll out dma_fence critical section annotations.

- There's a lot of complexity added past few years to make relocations faster.
That doesn't make sense given hw and gpu apis moved away from this model years
ago:
1. Land a modern pre-bound uapi like VM_BIND
2. Any complexity added in this area past few years which can't be justified
with VM_BIND using userspace should be removed. Looking at amdgpu dma_resv on
the bo and vm, plus some lru locks is all that needed. No complex rcu,
refcounts, caching, ... on everything.
This is the matching task on the vm side compared to ttm/dma_resv on the
backing storage side.

- i915_sw_fence seems to be the main structure for the i915-gem dma_fence model.
How-to-dma_fence is core and drivers really shouldn't build their own world
here, treating everything else as a fixed platform. i915_sw_fence concepts
should be moved to dma_fence, drm/scheduler or atomic commit helpers. Or
removed if dri-devel consensus is that it's not a good idea. Once that's done
maybe even remove it if there's nothing left.

Smaller things:
- i915_utils.h needs to be moved to the right places.

- dma_fence_work should be in drivers/dma-buf

- i915_mm.c should be moved to the right places. Some of the helpers also look a
bit fishy:

https://lore.kernel.org/linux-mm/20210301083320.943079-1-hch@lst.de/

- tasklet helpers in i915_gem.h also look a bit misplaced and should
probably be moved to tasklet headers.
71 changes: 44 additions & 27 deletions drivers/gpu/drm/i915/display/intel_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,7 @@ static bool intel_plane_uses_fence(const struct intel_plane_state *plane_state)

struct i915_vma *
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
bool phys_cursor,
const struct i915_ggtt_view *view,
bool uses_fence,
unsigned long *out_flags)
Expand All @@ -1099,14 +1100,19 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
struct drm_i915_private *dev_priv = to_i915(dev);
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
intel_wakeref_t wakeref;
struct i915_gem_ww_ctx ww;
struct i915_vma *vma;
unsigned int pinctl;
u32 alignment;
int ret;

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

alignment = intel_surf_alignment(fb, 0);
if (phys_cursor)
alignment = intel_cursor_alignment(dev_priv);
else
alignment = intel_surf_alignment(fb, 0);
if (drm_WARN_ON(dev, alignment && !is_power_of_2(alignment)))
return ERR_PTR(-EINVAL);

Expand Down Expand Up @@ -1141,14 +1147,26 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
if (HAS_GMCH(dev_priv))
pinctl |= PIN_MAPPABLE;

vma = i915_gem_object_pin_to_display_plane(obj,
alignment, view, pinctl);
if (IS_ERR(vma))
i915_gem_ww_ctx_init(&ww, true);
retry:
ret = i915_gem_object_lock(obj, &ww);
if (!ret && phys_cursor)
ret = i915_gem_object_attach_phys(obj, alignment);
if (!ret)
ret = i915_gem_object_pin_pages(obj);
if (ret)
goto err;

if (uses_fence && i915_vma_is_map_and_fenceable(vma)) {
int ret;
if (!ret) {
vma = i915_gem_object_pin_to_display_plane(obj, &ww, alignment,
view, pinctl);
if (IS_ERR(vma)) {
ret = PTR_ERR(vma);
goto err_unpin;
}
}

if (uses_fence && i915_vma_is_map_and_fenceable(vma)) {
/*
* Install a fence for tiled scan-out. Pre-i965 always needs a
* fence, whereas 965+ only requires a fence if using
Expand All @@ -1169,16 +1187,28 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
ret = i915_vma_pin_fence(vma);
if (ret != 0 && INTEL_GEN(dev_priv) < 4) {
i915_vma_unpin(vma);
vma = ERR_PTR(ret);
goto err;
goto err_unpin;
}
ret = 0;

if (ret == 0 && vma->fence)
if (vma->fence)
*out_flags |= PLANE_HAS_FENCE;
}

i915_vma_get(vma);

err_unpin:
i915_gem_object_unpin_pages(obj);
err:
if (ret == -EDEADLK) {
ret = i915_gem_ww_ctx_backoff(&ww);
if (!ret)
goto retry;
}
i915_gem_ww_ctx_fini(&ww);
if (ret)
vma = ERR_PTR(ret);

atomic_dec(&dev_priv->gpu_error.pending_fb_pin);
intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
return vma;
Expand Down Expand Up @@ -11333,19 +11363,11 @@ int intel_plane_pin_fb(struct intel_plane_state *plane_state)
struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
struct drm_framebuffer *fb = plane_state->hw.fb;
struct i915_vma *vma;
bool phys_cursor =
plane->id == PLANE_CURSOR &&
INTEL_INFO(dev_priv)->display.cursor_needs_physical;

if (plane->id == PLANE_CURSOR &&
INTEL_INFO(dev_priv)->display.cursor_needs_physical) {
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
const int align = intel_cursor_alignment(dev_priv);
int err;

err = i915_gem_object_attach_phys(obj, align);
if (err)
return err;
}

vma = intel_pin_and_fence_fb_obj(fb,
vma = intel_pin_and_fence_fb_obj(fb, phys_cursor,
&plane_state->view,
intel_plane_uses_fence(plane_state),
&plane_state->flags);
Expand Down Expand Up @@ -11437,13 +11459,8 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
if (!obj)
return 0;

ret = i915_gem_object_pin_pages(obj);
if (ret)
return ret;

ret = intel_plane_pin_fb(new_plane_state);

i915_gem_object_unpin_pages(obj);
if (ret)
return ret;

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

if (obj->userptr.mm) {
if (i915_gem_object_is_userptr(obj)) {
drm_dbg(&i915->drm,
"attempting to use a userptr for a framebuffer, denied\n");
return -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/display/intel_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ void intel_release_load_detect_pipe(struct drm_connector *connector,
struct intel_load_detect_pipe *old,
struct drm_modeset_acquire_ctx *ctx);
struct i915_vma *
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb, bool phys_cursor,
const struct i915_ggtt_view *view,
bool uses_fence,
unsigned long *out_flags);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/display/intel_dsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void intel_dsb_prepare(struct intel_crtc_state *crtc_state)
goto out;
}

buf = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
buf = i915_gem_object_pin_map_unlocked(vma->obj, I915_MAP_WC);
if (IS_ERR(buf)) {
drm_err(&i915->drm, "Command buffer creation failed\n");
i915_vma_unpin_and_release(&vma, I915_VMA_RELEASE_MAP);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/display/intel_fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
* This also validates that any existing fb inherited from the
* BIOS is suitable for own access.
*/
vma = intel_pin_and_fence_fb_obj(&ifbdev->fb->base,
vma = intel_pin_and_fence_fb_obj(&ifbdev->fb->base, false,
&view, false, &flags);
if (IS_ERR(vma)) {
ret = PTR_ERR(vma);
Expand Down
34 changes: 29 additions & 5 deletions drivers/gpu/drm/i915/display/intel_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,32 @@ static u32 overlay_cmd_reg(struct drm_intel_overlay_put_image *params)
return cmd;
}

static struct i915_vma *intel_overlay_pin_fb(struct drm_i915_gem_object *new_bo)
{
struct i915_gem_ww_ctx ww;
struct i915_vma *vma;
int ret;

i915_gem_ww_ctx_init(&ww, true);
retry:
ret = i915_gem_object_lock(new_bo, &ww);
if (!ret) {
vma = i915_gem_object_pin_to_display_plane(new_bo, &ww, 0,
NULL, PIN_MAPPABLE);
ret = PTR_ERR_OR_ZERO(vma);
}
if (ret == -EDEADLK) {
ret = i915_gem_ww_ctx_backoff(&ww);
if (!ret)
goto retry;
}
i915_gem_ww_ctx_fini(&ww);
if (ret)
return ERR_PTR(ret);

return vma;
}

static int intel_overlay_do_put_image(struct intel_overlay *overlay,
struct drm_i915_gem_object *new_bo,
struct drm_intel_overlay_put_image *params)
Expand All @@ -776,12 +802,10 @@ static int intel_overlay_do_put_image(struct intel_overlay *overlay,

atomic_inc(&dev_priv->gpu_error.pending_fb_pin);

vma = i915_gem_object_pin_to_display_plane(new_bo,
0, NULL, PIN_MAPPABLE);
if (IS_ERR(vma)) {
ret = PTR_ERR(vma);
vma = intel_overlay_pin_fb(new_bo);
if (IS_ERR(vma))
goto out_pin_section;
}

i915_gem_object_flush_frontbuffer(new_bo, ORIGIN_DIRTYFB);

if (!overlay->active) {
Expand Down
15 changes: 7 additions & 8 deletions drivers/gpu/drm/i915/gem/i915_gem_clflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ static void __do_clflush(struct drm_i915_gem_object *obj)
static int clflush_work(struct dma_fence_work *base)
{
struct clflush *clflush = container_of(base, typeof(*clflush), base);
struct drm_i915_gem_object *obj = clflush->obj;
int err;

err = i915_gem_object_pin_pages(obj);
if (err)
return err;

__do_clflush(obj);
i915_gem_object_unpin_pages(obj);
__do_clflush(clflush->obj);

return 0;
}
Expand All @@ -44,6 +37,7 @@ static void clflush_release(struct dma_fence_work *base)
{
struct clflush *clflush = container_of(base, typeof(*clflush), base);

i915_gem_object_unpin_pages(clflush->obj);
i915_gem_object_put(clflush->obj);
}

Expand All @@ -63,6 +57,11 @@ static struct clflush *clflush_work_create(struct drm_i915_gem_object *obj)
if (!clflush)
return NULL;

if (__i915_gem_object_get_pages(obj) < 0) {
kfree(clflush);
return NULL;
}

dma_fence_work_init(&clflush->base, &clflush_ops);
clflush->obj = i915_gem_object_get(obj); /* obj <-> clflush cycle */

Expand Down
Loading

0 comments on commit 2f835b5

Please sign in to comment.