Skip to content

Commit 3c435c1

Browse files
committed
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
Pull drm refcounting fixes from Dave Airlie: "Here is the complete set of i915 bug/warn/refcounting fixes" * 'drm-fixes' of git://people.freedesktop.org/~airlied/linux: drm/i915: Fixup legacy plane->crtc link for initial fb config drm/i915: Fix atomic state when reusing the firmware fb drm/i915: Keep ring->active_list and ring->requests_list consistent drm/i915: Don't try to reference the fb in get_initial_plane_config() drm: Fixup racy refcounting in plane_force_disable
2 parents be8a9bc + 9822393 commit 3c435c1

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -525,17 +525,6 @@ void drm_framebuffer_reference(struct drm_framebuffer *fb)
525525
}
526526
EXPORT_SYMBOL(drm_framebuffer_reference);
527527

528-
static void drm_framebuffer_free_bug(struct kref *kref)
529-
{
530-
BUG();
531-
}
532-
533-
static void __drm_framebuffer_unreference(struct drm_framebuffer *fb)
534-
{
535-
DRM_DEBUG("%p: FB ID: %d (%d)\n", fb, fb->base.id, atomic_read(&fb->refcount.refcount));
536-
kref_put(&fb->refcount, drm_framebuffer_free_bug);
537-
}
538-
539528
/**
540529
* drm_framebuffer_unregister_private - unregister a private fb from the lookup idr
541530
* @fb: fb to unregister
@@ -1320,7 +1309,7 @@ void drm_plane_force_disable(struct drm_plane *plane)
13201309
return;
13211310
}
13221311
/* disconnect the plane from the fb and crtc: */
1323-
__drm_framebuffer_unreference(plane->old_fb);
1312+
drm_framebuffer_unreference(plane->old_fb);
13241313
plane->old_fb = NULL;
13251314
plane->fb = NULL;
13261315
plane->crtc = NULL;

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,24 +2737,11 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
27372737

27382738
WARN_ON(i915_verify_lists(ring->dev));
27392739

2740-
/* Move any buffers on the active list that are no longer referenced
2741-
* by the ringbuffer to the flushing/inactive lists as appropriate,
2742-
* before we free the context associated with the requests.
2740+
/* Retire requests first as we use it above for the early return.
2741+
* If we retire requests last, we may use a later seqno and so clear
2742+
* the requests lists without clearing the active list, leading to
2743+
* confusion.
27432744
*/
2744-
while (!list_empty(&ring->active_list)) {
2745-
struct drm_i915_gem_object *obj;
2746-
2747-
obj = list_first_entry(&ring->active_list,
2748-
struct drm_i915_gem_object,
2749-
ring_list);
2750-
2751-
if (!i915_gem_request_completed(obj->last_read_req, true))
2752-
break;
2753-
2754-
i915_gem_object_move_to_inactive(obj);
2755-
}
2756-
2757-
27582745
while (!list_empty(&ring->request_list)) {
27592746
struct drm_i915_gem_request *request;
27602747
struct intel_ringbuffer *ringbuf;
@@ -2789,6 +2776,23 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
27892776
i915_gem_free_request(request);
27902777
}
27912778

2779+
/* Move any buffers on the active list that are no longer referenced
2780+
* by the ringbuffer to the flushing/inactive lists as appropriate,
2781+
* before we free the context associated with the requests.
2782+
*/
2783+
while (!list_empty(&ring->active_list)) {
2784+
struct drm_i915_gem_object *obj;
2785+
2786+
obj = list_first_entry(&ring->active_list,
2787+
struct drm_i915_gem_object,
2788+
ring_list);
2789+
2790+
if (!i915_gem_request_completed(obj->last_read_req, true))
2791+
break;
2792+
2793+
i915_gem_object_move_to_inactive(obj);
2794+
}
2795+
27922796
if (unlikely(ring->trace_irq_req &&
27932797
i915_gem_request_completed(ring->trace_irq_req, true))) {
27942798
ring->irq_put(ring);

drivers/gpu/drm/i915/intel_display.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,8 +2438,15 @@ intel_find_plane_obj(struct intel_crtc *intel_crtc,
24382438
if (!intel_crtc->base.primary->fb)
24392439
return;
24402440

2441-
if (intel_alloc_plane_obj(intel_crtc, plane_config))
2441+
if (intel_alloc_plane_obj(intel_crtc, plane_config)) {
2442+
struct drm_plane *primary = intel_crtc->base.primary;
2443+
2444+
primary->state->crtc = &intel_crtc->base;
2445+
primary->crtc = &intel_crtc->base;
2446+
update_state_fb(primary);
2447+
24422448
return;
2449+
}
24432450

24442451
kfree(intel_crtc->base.primary->fb);
24452452
intel_crtc->base.primary->fb = NULL;
@@ -2462,11 +2469,15 @@ intel_find_plane_obj(struct intel_crtc *intel_crtc,
24622469
continue;
24632470

24642471
if (i915_gem_obj_ggtt_offset(obj) == plane_config->base) {
2472+
struct drm_plane *primary = intel_crtc->base.primary;
2473+
24652474
if (obj->tiling_mode != I915_TILING_NONE)
24662475
dev_priv->preserve_bios_swizzle = true;
24672476

24682477
drm_framebuffer_reference(c->primary->fb);
2469-
intel_crtc->base.primary->fb = c->primary->fb;
2478+
primary->fb = c->primary->fb;
2479+
primary->state->crtc = &intel_crtc->base;
2480+
primary->crtc = &intel_crtc->base;
24702481
obj->frontbuffer_bits |= INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe);
24712482
break;
24722483
}
@@ -6663,7 +6674,6 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
66636674
plane_config->size);
66646675

66656676
crtc->base.primary->fb = fb;
6666-
update_state_fb(crtc->base.primary);
66676677
}
66686678

66696679
static void chv_crtc_clock_get(struct intel_crtc *crtc,
@@ -7704,7 +7714,6 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
77047714
plane_config->size);
77057715

77067716
crtc->base.primary->fb = fb;
7707-
update_state_fb(crtc->base.primary);
77087717
return;
77097718

77107719
error:
@@ -7798,7 +7807,6 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
77987807
plane_config->size);
77997808

78007809
crtc->base.primary->fb = fb;
7801-
update_state_fb(crtc->base.primary);
78027810
}
78037811

78047812
static bool ironlake_get_pipe_config(struct intel_crtc *crtc,

0 commit comments

Comments
 (0)