diff mbox

[v2] drm/i915/guc: Make intel_guc_send a function pointer

Message ID 1486459235-16945-1-git-send-email-oscar.mateo@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

oscar.mateo@intel.com Feb. 7, 2017, 9:20 a.m. UTC
From: Michal Wajdeczko <michal.wajdeczko@intel.com>

Prepare for an alternate GuC communication interface.

v2: Make a few functions static and name them correctly while we are at it (Oscar)
v3: Leave an intel_guc_send_mmio interface for users that require old-style communication

Signed-off-by: Michel Thierry <michel.thierry@intel.com>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
---
 drivers/gpu/drm/i915/intel_uc.c | 25 +++++++++++++++----------
 drivers/gpu/drm/i915/intel_uc.h | 10 +++++++++-
 2 files changed, 24 insertions(+), 11 deletions(-)

Comments

Michal Wajdeczko March 1, 2017, 6:33 p.m. UTC | #1
On Tue, Feb 07, 2017 at 01:20:35AM -0800, Oscar Mateo wrote:
> From: Michal Wajdeczko <michal.wajdeczko@intel.com>
> 
> Prepare for an alternate GuC communication interface.
> 
> v2: Make a few functions static and name them correctly while we are at it (Oscar)
> v3: Leave an intel_guc_send_mmio interface for users that require old-style communication
> 
> Signed-off-by: Michel Thierry <michel.thierry@intel.com>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_uc.c | 25 +++++++++++++++----------
>  drivers/gpu/drm/i915/intel_uc.h | 10 +++++++++-
>  2 files changed, 24 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_uc.c b/drivers/gpu/drm/i915/intel_uc.c
> index c46bc85..2fa70a9 100644
> --- a/drivers/gpu/drm/i915/intel_uc.c
> +++ b/drivers/gpu/drm/i915/intel_uc.c

<snip>

> @@ -98,6 +96,14 @@ int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
>  	return ret;
>  }
>  
> +void intel_uc_init_early(struct drm_i915_private *dev_priv)
> +{
> +	struct intel_guc *guc = &dev_priv->guc;
> +
> +	mutex_init(&guc->send_mutex);
> +	guc->send = intel_guc_send_mmio;
> +}
> +

As intel_guc_send_mmio() is again public, there is no need to move
intel_uc_init_early() down to this place, it can stay at the top
of the file.

-Michal
oscar.mateo@intel.com March 3, 2017, 4:38 p.m. UTC | #2
You are totally right. I'll update the patch and include it together 
with all the other GuC patches (less probability of it getting lost in 
the depths of the mailing list that way).
Thanks!

On 03/01/2017 10:33 AM, Michal Wajdeczko wrote:
> On Tue, Feb 07, 2017 at 01:20:35AM -0800, Oscar Mateo wrote:
>> From: Michal Wajdeczko <michal.wajdeczko@intel.com>
>>
>> Prepare for an alternate GuC communication interface.
>>
>> v2: Make a few functions static and name them correctly while we are at it (Oscar)
>> v3: Leave an intel_guc_send_mmio interface for users that require old-style communication
>>
>> Signed-off-by: Michel Thierry <michel.thierry@intel.com>
>> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
>> ---
>>   drivers/gpu/drm/i915/intel_uc.c | 25 +++++++++++++++----------
>>   drivers/gpu/drm/i915/intel_uc.h | 10 +++++++++-
>>   2 files changed, 24 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_uc.c b/drivers/gpu/drm/i915/intel_uc.c
>> index c46bc85..2fa70a9 100644
>> --- a/drivers/gpu/drm/i915/intel_uc.c
>> +++ b/drivers/gpu/drm/i915/intel_uc.c
> <snip>
>
>> @@ -98,6 +96,14 @@ int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
>>   	return ret;
>>   }
>>   
>> +void intel_uc_init_early(struct drm_i915_private *dev_priv)
>> +{
>> +	struct intel_guc *guc = &dev_priv->guc;
>> +
>> +	mutex_init(&guc->send_mutex);
>> +	guc->send = intel_guc_send_mmio;
>> +}
>> +
> As intel_guc_send_mmio() is again public, there is no need to move
> intel_uc_init_early() down to this place, it can stay at the top
> of the file.
>
> -Michal
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_uc.c b/drivers/gpu/drm/i915/intel_uc.c
index c46bc85..2fa70a9 100644
--- a/drivers/gpu/drm/i915/intel_uc.c
+++ b/drivers/gpu/drm/i915/intel_uc.c
@@ -25,16 +25,11 @@ 
 #include "i915_drv.h"
 #include "intel_uc.h"
 
-void intel_uc_init_early(struct drm_i915_private *dev_priv)
-{
-	mutex_init(&dev_priv->guc.send_mutex);
-}
-
 /*
  * Read GuC command/status register (SOFT_SCRATCH_0)
  * Return true if it contains a response rather than a command
  */
-static bool intel_guc_recv(struct intel_guc *guc, u32 *status)
+static bool guc_recv(struct intel_guc *guc, u32 *status)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
 
@@ -43,7 +38,10 @@  static bool intel_guc_recv(struct intel_guc *guc, u32 *status)
 	return INTEL_GUC_RECV_IS_RESPONSE(val);
 }
 
-int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
+/*
+ * This function implements the MMIO based host to GuC interface.
+ */
+int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
 	u32 status;
@@ -71,9 +69,9 @@  int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
 	 * up to that length of time, then switch to a slower sleep-wait loop.
 	 * No inte_guc_send command should ever take longer than 10ms.
 	 */
-	ret = wait_for_us(intel_guc_recv(guc, &status), 10);
+	ret = wait_for_us(guc_recv(guc, &status), 10);
 	if (ret)
-		ret = wait_for(intel_guc_recv(guc, &status), 10);
+		ret = wait_for(guc_recv(guc, &status), 10);
 	if (status != INTEL_GUC_STATUS_SUCCESS) {
 		/*
 		 * Either the GuC explicitly returned an error (which
@@ -98,6 +96,14 @@  int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
 	return ret;
 }
 
+void intel_uc_init_early(struct drm_i915_private *dev_priv)
+{
+	struct intel_guc *guc = &dev_priv->guc;
+
+	mutex_init(&guc->send_mutex);
+	guc->send = intel_guc_send_mmio;
+}
+
 int intel_guc_sample_forcewake(struct intel_guc *guc)
 {
 	struct drm_i915_private *dev_priv = guc_to_i915(guc);
@@ -113,4 +119,3 @@  int intel_guc_sample_forcewake(struct intel_guc *guc)
 
 	return intel_guc_send(guc, action, ARRAY_SIZE(action));
 }
-
diff --git a/drivers/gpu/drm/i915/intel_uc.h b/drivers/gpu/drm/i915/intel_uc.h
index d74f4d3..8a33a46 100644
--- a/drivers/gpu/drm/i915/intel_uc.h
+++ b/drivers/gpu/drm/i915/intel_uc.h
@@ -174,6 +174,9 @@  struct intel_guc {
 
 	/* To serialize the intel_guc_send actions */
 	struct mutex send_mutex;
+
+	/* GuC's FW specific send function */
+	int (*send)(struct intel_guc *guc, const u32 *data, u32 len);
 };
 
 struct intel_huc {
@@ -185,9 +188,14 @@  struct intel_huc {
 
 /* intel_uc.c */
 void intel_uc_init_early(struct drm_i915_private *dev_priv);
-int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len);
 int intel_guc_sample_forcewake(struct intel_guc *guc);
 
+int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len);
+static inline int intel_guc_send(struct intel_guc *guc, const u32 *action, u32 len)
+{
+	return guc->send(guc, action, len);
+}
+
 /* intel_guc_loader.c */
 extern void intel_guc_init(struct drm_i915_private *dev_priv);
 extern int intel_guc_setup(struct drm_i915_private *dev_priv);