[Intel-gfx] [PATCH 24/27] drm/i915/guc: Move fields protected by guc->contexts_lock into sub structure

2021-08-25 Thread Matthew Brost
To make ownership of locking clear move fields (guc_id, guc_id_ref,
guc_id_link) to sub structure guc_id in intel_context.

Reviewed-by: Daniele Ceraolo Spurio 
Signed-off-by: Matthew Brost 
---
 drivers/gpu/drm/i915/gt/intel_context.c   |   4 +-
 drivers/gpu/drm/i915/gt/intel_context_types.h |  18 +--
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c  |   6 +-
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 104 +-
 drivers/gpu/drm/i915/i915_trace.h |   4 +-
 5 files changed, 69 insertions(+), 67 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
b/drivers/gpu/drm/i915/gt/intel_context.c
index 3048267ddc7e..485460a11331 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -398,8 +398,8 @@ intel_context_init(struct intel_context *ce, struct 
intel_engine_cs *engine)
spin_lock_init(>guc_active.lock);
INIT_LIST_HEAD(>guc_active.requests);
 
-   ce->guc_id = GUC_INVALID_LRC_ID;
-   INIT_LIST_HEAD(>guc_id_link);
+   ce->guc_id.id = GUC_INVALID_LRC_ID;
+   INIT_LIST_HEAD(>guc_id.link);
 
/*
 * Initialize fence to be complete as this is expected to be complete
diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h 
b/drivers/gpu/drm/i915/gt/intel_context_types.h
index b56960a781da..0b00d249c884 100644
--- a/drivers/gpu/drm/i915/gt/intel_context_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
@@ -186,16 +186,18 @@ struct intel_context {
u32 prio_count[GUC_CLIENT_PRIORITY_NUM];
} guc_active;
 
-   /* GuC LRC descriptor ID */
-   u16 guc_id;
+   struct {
+   /* GuC LRC descriptor ID */
+   u16 id;
 
-   /* GuC LRC descriptor reference count */
-   atomic_t guc_id_ref;
+   /* GuC LRC descriptor reference count */
+   atomic_t ref;
 
-   /*
-* GuC ID link - in list when unpinned but guc_id still valid in GuC
-*/
-   struct list_head guc_id_link;
+   /*
+* GuC ID link - in list when unpinned but guc_id still valid 
in GuC
+*/
+   struct list_head link;
+   } guc_id;
 
 #ifdef CONFIG_DRM_I915_SELFTEST
/**
diff --git a/drivers/gpu/drm/i915/gt/selftest_hangcheck.c 
b/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
index 2c1ed32ca5ac..e9130fa39616 100644
--- a/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
+++ b/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
@@ -789,7 +789,7 @@ static int __igt_reset_engine(struct intel_gt *gt, bool 
active)
if (err)
pr_err("[%s] Wait for request %lld:%lld 
[0x%04X] failed: %d!\n",
   engine->name, rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id, err);
+  rq->fence.seqno, 
rq->context->guc_id.id, err);
}
 
 skip:
@@ -1098,7 +1098,7 @@ static int __igt_reset_engines(struct intel_gt *gt,
if (err)
pr_err("[%s] Wait for request %lld:%lld 
[0x%04X] failed: %d!\n",
   engine->name, rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id, err);
+  rq->fence.seqno, 
rq->context->guc_id.id, err);
}
 
count++;
@@ -1108,7 +1108,7 @@ static int __igt_reset_engines(struct intel_gt *gt,
pr_err("i915_reset_engine(%s:%s): 
failed to reset request %lld:%lld [0x%04X]\n",
   engine->name, test_name,
   rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id);
+  rq->fence.seqno, 
rq->context->guc_id.id);
i915_request_put(rq);
 
GEM_TRACE_DUMP();
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index bc68c0122be4..044f9dda1397 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -270,12 +270,12 @@ static inline void decr_context_committed_requests(struct 
intel_context *ce)
 
 static inline bool context_guc_id_invalid(struct intel_context *ce)
 {
-   return ce->guc_id == GUC_INVALID_LRC_ID;
+   return ce->guc_id.id == GUC_INVALID_LRC_ID;
 }
 
 static inline void set_context_guc_id_invalid(struct intel_context *ce)
 {
-   ce->guc_id = GUC_INVALID_LRC_ID;
+   ce->guc_id.id = GUC_INVALID_LRC_ID;
 }
 
 static inline struct intel_guc *ce_to_guc(struct 

Re: [Intel-gfx] [PATCH 24/27] drm/i915/guc: Move fields protected by guc->contexts_lock into sub structure

2021-08-24 Thread Daniele Ceraolo Spurio




On 8/18/2021 11:16 PM, Matthew Brost wrote:

To make ownership of locking clear move fields (guc_id, guc_id_ref,
guc_id_link) to sub structure guc_id in intel_context.

Signed-off-by: Matthew Brost 
---
  drivers/gpu/drm/i915/gt/intel_context.c   |   4 +-
  drivers/gpu/drm/i915/gt/intel_context_types.h |  18 +--
  drivers/gpu/drm/i915/gt/selftest_hangcheck.c  |   6 +-
  .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 106 +-
  drivers/gpu/drm/i915/i915_trace.h |   4 +-
  5 files changed, 70 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
b/drivers/gpu/drm/i915/gt/intel_context.c
index 0e48939ec85f..87b84c1d5393 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -398,8 +398,8 @@ intel_context_init(struct intel_context *ce, struct 
intel_engine_cs *engine)
spin_lock_init(>guc_active.lock);
INIT_LIST_HEAD(>guc_active.requests);
  
-	ce->guc_id = GUC_INVALID_LRC_ID;

-   INIT_LIST_HEAD(>guc_id_link);
+   ce->guc_id.id = GUC_INVALID_LRC_ID;
+   INIT_LIST_HEAD(>guc_id.link);
  
  	/*

 * Initialize fence to be complete as this is expected to be complete
diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h 
b/drivers/gpu/drm/i915/gt/intel_context_types.h
index 9fb0480ccf3b..7a1d1537cf67 100644
--- a/drivers/gpu/drm/i915/gt/intel_context_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
@@ -186,16 +186,18 @@ struct intel_context {
u32 prio_count[GUC_CLIENT_PRIORITY_NUM];
} guc_active;
  
-	/* GuC LRC descriptor ID */

-   u16 guc_id;
+   struct {
+   /* GuC LRC descriptor ID */
+   u16 id;
  
-	/* GuC LRC descriptor reference count */

-   atomic_t guc_id_ref;
+   /* GuC LRC descriptor reference count */
+   atomic_t ref;
  
-	/*

-* GuC ID link - in list when unpinned but guc_id still valid in GuC
-*/
-   struct list_head guc_id_link;
+   /*
+* GuC ID link - in list when unpinned but guc_id still valid 
in GuC
+*/
+   struct list_head link;
+   } guc_id;


Maybe add a

/* protected via guc->contexts_lock */

somewhere in the struct doc?

Reviewed-by: Daniele Ceraolo Spurio 

Daniele

  
  #ifdef CONFIG_DRM_I915_SELFTEST

/**
diff --git a/drivers/gpu/drm/i915/gt/selftest_hangcheck.c 
b/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
index 08f011f893b2..bf43bed905db 100644
--- a/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
+++ b/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
@@ -789,7 +789,7 @@ static int __igt_reset_engine(struct intel_gt *gt, bool 
active)
if (err)
pr_err("[%s] Wait for request %lld:%lld 
[0x%04X] failed: %d!\n",
   engine->name, rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id, err);
+  rq->fence.seqno, 
rq->context->guc_id.id, err);
}
  
  skip:

@@ -1098,7 +1098,7 @@ static int __igt_reset_engines(struct intel_gt *gt,
if (err)
pr_err("[%s] Wait for request %lld:%lld 
[0x%04X] failed: %d!\n",
   engine->name, rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id, err);
+  rq->fence.seqno, 
rq->context->guc_id.id, err);
}
  
  			count++;

@@ -1108,7 +1108,7 @@ static int __igt_reset_engines(struct intel_gt *gt,
pr_err("i915_reset_engine(%s:%s): failed to 
reset request %lld:%lld [0x%04X]\n",
   engine->name, test_name,
   rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id);
+  rq->fence.seqno, 
rq->context->guc_id.id);
i915_request_put(rq);
  
  	GEM_TRACE_DUMP();

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index bb90bedb1305..c4c018348ac0 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -269,12 +269,12 @@ static inline void decr_context_committed_requests(struct 
intel_context *ce)
  
  static inline bool context_guc_id_invalid(struct intel_context *ce)

  {
-   return ce->guc_id == GUC_INVALID_LRC_ID;
+   return ce->guc_id.id == GUC_INVALID_LRC_ID;
  }
  
  static inline void set_context_guc_id_invalid(struct intel_context *ce)

  {
-   ce->guc_id = GUC_INVALID_LRC_ID;
+   

[Intel-gfx] [PATCH 24/27] drm/i915/guc: Move fields protected by guc->contexts_lock into sub structure

2021-08-19 Thread Matthew Brost
To make ownership of locking clear move fields (guc_id, guc_id_ref,
guc_id_link) to sub structure guc_id in intel_context.

Signed-off-by: Matthew Brost 
---
 drivers/gpu/drm/i915/gt/intel_context.c   |   4 +-
 drivers/gpu/drm/i915/gt/intel_context_types.h |  18 +--
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c  |   6 +-
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 106 +-
 drivers/gpu/drm/i915/i915_trace.h |   4 +-
 5 files changed, 70 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c 
b/drivers/gpu/drm/i915/gt/intel_context.c
index 0e48939ec85f..87b84c1d5393 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -398,8 +398,8 @@ intel_context_init(struct intel_context *ce, struct 
intel_engine_cs *engine)
spin_lock_init(>guc_active.lock);
INIT_LIST_HEAD(>guc_active.requests);
 
-   ce->guc_id = GUC_INVALID_LRC_ID;
-   INIT_LIST_HEAD(>guc_id_link);
+   ce->guc_id.id = GUC_INVALID_LRC_ID;
+   INIT_LIST_HEAD(>guc_id.link);
 
/*
 * Initialize fence to be complete as this is expected to be complete
diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h 
b/drivers/gpu/drm/i915/gt/intel_context_types.h
index 9fb0480ccf3b..7a1d1537cf67 100644
--- a/drivers/gpu/drm/i915/gt/intel_context_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_context_types.h
@@ -186,16 +186,18 @@ struct intel_context {
u32 prio_count[GUC_CLIENT_PRIORITY_NUM];
} guc_active;
 
-   /* GuC LRC descriptor ID */
-   u16 guc_id;
+   struct {
+   /* GuC LRC descriptor ID */
+   u16 id;
 
-   /* GuC LRC descriptor reference count */
-   atomic_t guc_id_ref;
+   /* GuC LRC descriptor reference count */
+   atomic_t ref;
 
-   /*
-* GuC ID link - in list when unpinned but guc_id still valid in GuC
-*/
-   struct list_head guc_id_link;
+   /*
+* GuC ID link - in list when unpinned but guc_id still valid 
in GuC
+*/
+   struct list_head link;
+   } guc_id;
 
 #ifdef CONFIG_DRM_I915_SELFTEST
/**
diff --git a/drivers/gpu/drm/i915/gt/selftest_hangcheck.c 
b/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
index 08f011f893b2..bf43bed905db 100644
--- a/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
+++ b/drivers/gpu/drm/i915/gt/selftest_hangcheck.c
@@ -789,7 +789,7 @@ static int __igt_reset_engine(struct intel_gt *gt, bool 
active)
if (err)
pr_err("[%s] Wait for request %lld:%lld 
[0x%04X] failed: %d!\n",
   engine->name, rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id, err);
+  rq->fence.seqno, 
rq->context->guc_id.id, err);
}
 
 skip:
@@ -1098,7 +1098,7 @@ static int __igt_reset_engines(struct intel_gt *gt,
if (err)
pr_err("[%s] Wait for request %lld:%lld 
[0x%04X] failed: %d!\n",
   engine->name, rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id, err);
+  rq->fence.seqno, 
rq->context->guc_id.id, err);
}
 
count++;
@@ -1108,7 +1108,7 @@ static int __igt_reset_engines(struct intel_gt *gt,
pr_err("i915_reset_engine(%s:%s): 
failed to reset request %lld:%lld [0x%04X]\n",
   engine->name, test_name,
   rq->fence.context,
-  rq->fence.seqno, 
rq->context->guc_id);
+  rq->fence.seqno, 
rq->context->guc_id.id);
i915_request_put(rq);
 
GEM_TRACE_DUMP();
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c 
b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index bb90bedb1305..c4c018348ac0 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -269,12 +269,12 @@ static inline void decr_context_committed_requests(struct 
intel_context *ce)
 
 static inline bool context_guc_id_invalid(struct intel_context *ce)
 {
-   return ce->guc_id == GUC_INVALID_LRC_ID;
+   return ce->guc_id.id == GUC_INVALID_LRC_ID;
 }
 
 static inline void set_context_guc_id_invalid(struct intel_context *ce)
 {
-   ce->guc_id = GUC_INVALID_LRC_ID;
+   ce->guc_id.id = GUC_INVALID_LRC_ID;
 }
 
 static inline struct intel_guc *ce_to_guc(struct intel_context *ce)
@@ -466,14 +466,14