public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] improve handling of the driver's default (kernel) context
@ 2016-01-19 19:02 Dave Gordon
  2016-01-19 19:02 ` [PATCH v4 1/3] drm/i915: simplify allocation of driver-internal requests Dave Gordon
                   ` (5 more replies)
  0 siblings, 6 replies; 26+ messages in thread
From: Dave Gordon @ 2016-01-19 19:02 UTC (permalink / raw)
  To: intel-gfx

During startup, the driver creates a unique "intel_context" that will
provide a home for orphan requests (i.e. those generated by the driver
internally, not associated with user batchbuffers).

However, one of the infelicities of the current code is that the driver
keeps a per-engine pointer to the default context for that engine (this
is probably from a decision made early in execlists implementation,
when it was thought that a context was engine-specific, and not revised
when it was decided that an "intel_context" represents a multiplex of
engine-level contexts). All these per-engine pointers actually end up
pointing to the same unique object.

To compound this, the refcounting is bogus; the driver holds just one
reference to the default context, even though there are multiple pointers
to it (RCS is considered to hold this "on behalf of" the other engines,
but this can lead to problems during unload as it makes the code sensitive
to the order of engine teardown -- RCS should be done last, but it isn't).

Also, some of the execlists batch submission code treats the default
context differently from any other; testing for it by comparing against
the per-engine pointer is quite clumsy, especially in debugfs where
contexts are enumerated from a global list and therefore not automatically
known to be associated with a particular engine.

Therefore, we should replace the per-engine pointers with a single
driver-wide reference, which will make the refcounting sane and simplify
the code that uses this context for non-user-related requests.

THIS patchset does NOT address the execlists code's special handling of
the default context, but it will simplify the planned future cleanup of
that code.

v3: don't flag the context created during startup (and fully instantiated
on all engines) for driver-internal purposes as "is_global_default",
1448630935-27377-1-git-send-email-chris@chris-wilson.co.uk notwithstanding.
(We now call it "the kernel context", and compare against the device-wide
pointer).  [Chris Wilson] 

v4: Rebased

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 26+ messages in thread
* [PATCH] Fix pointer tests in error-handling paths
@ 2016-01-28 10:48 Tvrtko Ursulin
  2016-01-28 10:49 ` Tvrtko Ursulin
  0 siblings, 1 reply; 26+ messages in thread
From: Tvrtko Ursulin @ 2016-01-28 10:48 UTC (permalink / raw)
  To: Intel-gfx

From: Dave Gordon <david.s.gordon@intel.com>

In the error-handling paths of i915_gem_do_execbuffer() and
intel_crtc_page_flip(), the local pointer-to-request variables
were expected to be either valid pointers or NULL. Since

  2682708 drm/i915: simplify allocation of driver-internal requests

they could also be ERR_PTR() values, so the tests need to be
updated to accommodate this case.

Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Dave Gordon <david.s.gordon@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
 drivers/gpu/drm/i915/intel_display.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 5cb57f642ac1..8fd00d279447 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1655,7 +1655,7 @@ err:
 	 * must be freed again. If it was submitted then it is being tracked
 	 * on the active request list and no clean up is required here.
 	 */
-	if (ret && req)
+	if (ret && !IS_ERR_OR_NULL(req))
 		i915_gem_request_cancel(req);
 
 	mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 8104511ad302..b88cdac747eb 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11726,7 +11726,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 cleanup_unpin:
 	intel_unpin_fb_obj(fb, crtc->primary->state);
 cleanup_pending:
-	if (request)
+	if (!IS_ERR_OR_NULL(request))
 		i915_gem_request_cancel(request);
 	atomic_dec(&intel_crtc->unpin_work_count);
 	mutex_unlock(&dev->struct_mutex);
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2016-01-28 10:49 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-19 19:02 [PATCH v4 0/3] improve handling of the driver's default (kernel) context Dave Gordon
2016-01-19 19:02 ` [PATCH v4 1/3] drm/i915: simplify allocation of driver-internal requests Dave Gordon
2016-01-20  9:56   ` Tvrtko Ursulin
2016-01-20 10:20     ` Chris Wilson
2016-01-22 11:12   ` Tvrtko Ursulin
2016-01-22 12:19     ` [PATCH] Fix pointer tests in error-handling paths Dave Gordon
2016-01-22 13:01       ` Chris Wilson
2016-01-22 13:17         ` Tvrtko Ursulin
2016-01-22 13:34           ` Chris Wilson
2016-01-25 17:54             ` Dave Gordon
2016-01-22 13:07       ` Tvrtko Ursulin
2016-01-25 16:28         ` Daniel Vetter
2016-01-25 17:07           ` Tvrtko Ursulin
2016-01-25 17:57       ` [PATCH v2] " Dave Gordon
2016-01-27 12:33         ` Maarten Lankhorst
2016-01-27 12:41           ` Tvrtko Ursulin
2016-01-27 13:45             ` Maarten Lankhorst
2016-01-19 19:02 ` [PATCH v4 2/3] drm/i915: abolish separate per-ring default_context pointers Dave Gordon
2016-01-19 19:02 ` [PATCH v4 3/3] drm/i915: tidy up a few leftovers Dave Gordon
2016-01-20  7:49 ` ✗ Fi.CI.BAT: warning for improve handling of the driver's default (kernel) context Patchwork
2016-01-20 17:31   ` Dave Gordon
2016-01-21  8:19     ` Daniel Vetter
2016-01-21  8:21 ` [PATCH v4 0/3] " Daniel Vetter
2016-01-27 15:43 ` ✓ Fi.CI.BAT: success for improve handling of the driver's default (kernel) context (rev3) Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2016-01-28 10:48 [PATCH] Fix pointer tests in error-handling paths Tvrtko Ursulin
2016-01-28 10:49 ` Tvrtko Ursulin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox