[Intel-gfx] [PATCH 4/6] drm/i915: Use to_i915() instead of guc_to_i915()

Chris Wilson chris at chris-wilson.co.uk
Fri Apr 15 17:46:03 UTC 2016


The convenience of saving a few characters by using a consistent
interface to obtain our drm_i915_private struct from intel_guc.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.h            |  5 ++++-
 drivers/gpu/drm/i915/i915_guc_submission.c | 17 +++++++----------
 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 282d89d097ae..76eeb47c9c15 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2014,7 +2014,8 @@ static inline struct drm_i915_private *dev_to_i915(const struct device *dev)
 	return __to_i915(dev_get_drvdata(dev));
 }
 
-static inline struct drm_i915_private *guc_to_i915(struct intel_guc *guc)
+static inline struct drm_i915_private *
+__guc_to_i915(const struct intel_guc *guc)
 {
 	return container_of(guc, struct drm_i915_private, guc);
 }
@@ -2506,6 +2507,8 @@ struct drm_i915_cmd_table {
 		__p = __to_i915((struct drm_device *)p); \
 	else if (__builtin_types_compatible_p(typeof(*p), struct drm_i915_gem_object)) \
 		__p = __obj_to_i915((struct drm_i915_gem_object *)p); \
+	else if (__builtin_types_compatible_p(typeof(*p), struct intel_guc)) \
+		__p = __guc_to_i915((struct intel_guc *)p); \
 	else \
 		BUILD_BUG(); \
 	__p; \
diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index da86bdbba275..c10cb13d0fc9 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -77,7 +77,7 @@ static inline bool host2guc_action_response(struct drm_i915_private *dev_priv,
 
 static int host2guc_action(struct intel_guc *guc, u32 *data, u32 len)
 {
-	struct drm_i915_private *dev_priv = guc_to_i915(guc);
+	struct drm_i915_private *dev_priv = to_i915(guc);
 	u32 status;
 	int i;
 	int ret;
@@ -152,7 +152,7 @@ static int host2guc_release_doorbell(struct intel_guc *guc,
 static int host2guc_sample_forcewake(struct intel_guc *guc,
 				     struct i915_guc_client *client)
 {
-	struct drm_i915_private *dev_priv = guc_to_i915(guc);
+	struct drm_i915_private *dev_priv = to_i915(guc);
 	struct drm_device *dev = dev_priv->dev;
 	u32 data[2];
 
@@ -254,7 +254,7 @@ static int guc_ring_doorbell(struct i915_guc_client *gc)
 static void guc_disable_doorbell(struct intel_guc *guc,
 				 struct i915_guc_client *client)
 {
-	struct drm_i915_private *dev_priv = guc_to_i915(guc);
+	struct drm_i915_private *dev_priv = to_i915(guc);
 	struct guc_doorbell_info *doorbell;
 	void *base;
 	i915_reg_t drbreg = GEN8_DRBREGL(client->doorbell_id);
@@ -376,7 +376,6 @@ static void guc_init_proc_desc(struct intel_guc *guc,
 static void guc_init_ctx_desc(struct intel_guc *guc,
 			      struct i915_guc_client *client)
 {
-	struct drm_i915_private *dev_priv = guc_to_i915(guc);
 	struct intel_engine_cs *engine;
 	struct intel_context *ctx = client->owner;
 	struct guc_context_desc desc;
@@ -390,7 +389,7 @@ static void guc_init_ctx_desc(struct intel_guc *guc,
 	desc.priority = client->priority;
 	desc.db_id = client->doorbell_id;
 
-	for_each_engine_id(engine, dev_priv, id) {
+	for_each_engine_id(engine, guc, id) {
 		struct guc_execlist_context *lrc = &desc.lrc[engine->guc_id];
 		struct drm_i915_gem_object *obj;
 		uint64_t ctx_desc;
@@ -772,7 +771,6 @@ err:
 
 static void guc_create_log(struct intel_guc *guc)
 {
-	struct drm_i915_private *dev_priv = guc_to_i915(guc);
 	struct drm_i915_gem_object *obj;
 	unsigned long offset;
 	uint32_t size, flags;
@@ -791,7 +789,7 @@ static void guc_create_log(struct intel_guc *guc)
 
 	obj = guc->log_obj;
 	if (!obj) {
-		obj = gem_allocate_guc_obj(dev_priv->dev, size);
+		obj = gem_allocate_guc_obj(to_i915(guc)->dev, size);
 		if (!obj) {
 			/* logging will be off */
 			i915.guc_log_level = -1;
@@ -835,7 +833,7 @@ static void init_guc_policies(struct guc_policies *policies)
 
 static void guc_create_ads(struct intel_guc *guc)
 {
-	struct drm_i915_private *dev_priv = guc_to_i915(guc);
+	struct drm_i915_private *dev_priv = to_i915(guc);
 	struct drm_i915_gem_object *obj;
 	struct guc_ads *ads;
 	struct guc_policies *policies;
@@ -868,8 +866,7 @@ static void guc_create_ads(struct intel_guc *guc)
 	 * so its address won't change after we've told the GuC where
 	 * to find it.
 	 */
-	engine = &dev_priv->engine[RCS];
-	ads->golden_context_lrca = engine->status_page.gfx_addr;
+	ads->golden_context_lrca = dev_priv->engine[RCS].status_page.gfx_addr;
 
 	for_each_engine(engine, dev_priv)
 		ads->eng_state_size[engine->guc_id] = intel_lr_context_size(engine);
-- 
2.8.0.rc3



More information about the Intel-gfx mailing list