All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 2/6] drm/i915: Allow passing any known pointer to for_each_engine()
Date: Fri, 15 Apr 2016 18:46:01 +0100	[thread overview]
Message-ID: <1460742365-3646-3-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1460742365-3646-1-git-send-email-chris@chris-wilson.co.uk>

Rather than require the user to grab a drm_i915_private, allow them to
pass anything that we know how to derive such a pointer user to_i915()

Note this fixes a macro bug in for_each_engine_masked() which was not
using its dev_priv__ parameter.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h         | 18 +++++++++---------
 drivers/gpu/drm/i915/i915_gem_context.c |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 6569ebfe8cf1..0a62354ba53d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2020,24 +2020,24 @@ static inline struct drm_i915_private *guc_to_i915(struct intel_guc *guc)
 }
 
 /* Simple iterator over all initialised engines */
-#define for_each_engine(engine__, dev_priv__) \
-	for ((engine__) = &(dev_priv__)->engine[0]; \
-	     (engine__) < &(dev_priv__)->engine[I915_NUM_ENGINES]; \
+#define for_each_engine(engine__, ptr__) \
+	for ((engine__) = &to_i915(ptr__)->engine[0]; \
+	     (engine__) < &to_i915(ptr__)->engine[I915_NUM_ENGINES]; \
 	     (engine__)++) \
 		for_each_if (intel_engine_initialized(engine__))
 
 /* Iterator with engine_id */
-#define for_each_engine_id(engine__, dev_priv__, id__) \
-	for ((engine__) = &(dev_priv__)->engine[0], (id__) = 0; \
-	     (engine__) < &(dev_priv__)->engine[I915_NUM_ENGINES]; \
+#define for_each_engine_id(engine__, ptr__, id__) \
+	for ((engine__) = &to_i915(ptr__)->engine[0], (id__) = 0; \
+	     (engine__) < &to_i915(ptr__)->engine[I915_NUM_ENGINES]; \
 	     (engine__)++) \
 		for_each_if (((id__) = (engine__)->id, \
 			      intel_engine_initialized(engine__)))
 
 /* Iterator over subset of engines selected by mask */
-#define for_each_engine_masked(engine__, dev_priv__, mask__) \
-	for ((engine__) = &(dev_priv__)->engine[0]; \
-	     (engine__) < &(dev_priv__)->engine[I915_NUM_ENGINES]; \
+#define for_each_engine_masked(engine__, ptr__, mask__) \
+	for ((engine__) = &to_i915(ptr__)->engine[0]; \
+	     (engine__) < &to_i915(ptr__)->engine[I915_NUM_ENGINES]; \
 	     (engine__)++) \
 		for_each_if (((mask__) & intel_engine_flag(engine__)) && \
 			     intel_engine_initialized(engine__))
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index e5acc3916f75..b8439971c9bb 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -553,7 +553,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
 
 			intel_ring_emit(engine,
 					MI_LOAD_REGISTER_IMM(num_rings));
-			for_each_engine(signaller, to_i915(engine->dev)) {
+			for_each_engine(signaller, engine->dev) {
 				if (signaller == engine)
 					continue;
 
@@ -583,7 +583,7 @@ mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
 
 			intel_ring_emit(engine,
 					MI_LOAD_REGISTER_IMM(num_rings));
-			for_each_engine(signaller, to_i915(engine->dev)) {
+			for_each_engine(signaller, engine->dev) {
 				if (signaller == engine)
 					continue;
 
-- 
2.8.0.rc3

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

  parent reply	other threads:[~2016-04-15 17:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15 17:45 Polymorphic to_i915() Chris Wilson
2016-04-15 17:46 ` [PATCH 1/6] drm/i915: Rename the magic polymorphic macro __I915__ Chris Wilson
2016-04-20 14:27   ` Dave Gordon
2016-04-15 17:46 ` Chris Wilson [this message]
2016-04-15 17:46 ` [PATCH 3/6] drm/i915: Extend magic to_i915() to work with drm_i915_gem_object Chris Wilson
2016-04-15 17:46 ` [PATCH 4/6] drm/i915: Use to_i915() instead of guc_to_i915() Chris Wilson
2016-04-15 17:46 ` [PATCH 5/6] drm/i915: Teach to_i915() how to extract drm_i915_private from requests Chris Wilson
2016-04-15 17:46 ` [PATCH 6/6] drm/i915: Teach to_i915() how to extract drm_i915_private from engines Chris Wilson
2016-04-18  9:18 ` Polymorphic to_i915() Jani Nikula
2016-04-18 11:11   ` Dave Gordon
2016-04-18 11:49     ` Jani Nikula
2016-04-18 12:09       ` Chris Wilson
2016-04-20 12:57   ` Daniel Vetter
2016-04-20 14:29     ` Dave Gordon
2016-04-20 15:26     ` Mika Kuoppala
  -- strict thread matches above, loose matches on Subject: below --
2016-03-18 21:16 [PATCH 1/6] drm/i915: Rename the magic polymorphic macro __I915__ Chris Wilson
2016-03-18 21:16 ` [PATCH 2/6] drm/i915: Allow passing any known pointer to for_each_engine() Chris Wilson
2016-03-21 15:44   ` Dave Gordon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1460742365-3646-3-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.