diff mbox

[v4,04/13] drm/i915/guc: Implement response handling in send_mmio()

Message ID 20180323144728.61548-5-michal.wajdeczko@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michal Wajdeczko March 23, 2018, 2:47 p.m. UTC
We're using data encoded in the status MMIO as return value from send
function, but GuC may also write more data in remaining MMIO regs.
Let's copy content of these registers to the buffer provided by caller.

v2: new line (Michel)
v3: updated commit message

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Oscar Mateo <oscar.mateo@intel.com>
Reviewed-by: Michel Thierry <michel.thierry@intel.com> #2
---
 drivers/gpu/drm/i915/intel_guc.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Michel Thierry March 23, 2018, 9:55 p.m. UTC | #1
On 3/23/2018 7:47 AM, Michal Wajdeczko wrote:
> We're using data encoded in the status MMIO as return value from send
> function, but GuC may also write more data in remaining MMIO regs.
> Let's copy content of these registers to the buffer provided by caller.
> 
> v2: new line (Michel)
> v3: updated commit message
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Oscar Mateo <oscar.mateo@intel.com>
> Reviewed-by: Michel Thierry <michel.thierry@intel.com> #2
> ---
>   drivers/gpu/drm/i915/intel_guc.c | 15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_guc.c b/drivers/gpu/drm/i915/intel_guc.c
> index a533ff8..9ce01e5 100644
> --- a/drivers/gpu/drm/i915/intel_guc.c
> +++ b/drivers/gpu/drm/i915/intel_guc.c
> @@ -368,11 +368,20 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len,
>                                   " ret=%d status=0x%08X response=0x%08X\n",
>                                   action[0], ret, status,
>                                   I915_READ(SOFT_SCRATCH(15)));
> -       } else {
> -               /* Use data from the GuC response as our return value */
> -               ret = INTEL_GUC_MSG_TO_DATA(status);
> +               goto out;
>          }
> 

I'm not a big fan of goto's, so I would have added the response handling 
in the else part.

But it's still correct, so my old r-b still stands.

-Michel

> +       if (response_buf) {
> +               int count = min(response_buf_size, guc->send_regs.count - 1);
> +
> +               for (i = 0; i < count; i++)
> +                       response_buf[i] = I915_READ(guc_send_reg(guc, i + 1));
> +       }
> +
> +       /* Use data from the GuC response as our return value */
> +       ret = INTEL_GUC_MSG_TO_DATA(status);
> +
> +out:
>          intel_uncore_forcewake_put(dev_priv, guc->send_regs.fw_domains);
>          mutex_unlock(&guc->send_mutex);
> 
> --
> 1.9.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
Michal Wajdeczko March 24, 2018, 7:09 a.m. UTC | #2
On Fri, 23 Mar 2018 22:55:09 +0100, Michel Thierry  
<michel.thierry@intel.com> wrote:

> On 3/23/2018 7:47 AM, Michal Wajdeczko wrote:
>> We're using data encoded in the status MMIO as return value from send
>> function, but GuC may also write more data in remaining MMIO regs.
>> Let's copy content of these registers to the buffer provided by caller.
>>  v2: new line (Michel)
>> v3: updated commit message
>>  Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
>> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
>> Cc: Oscar Mateo <oscar.mateo@intel.com>
>> Reviewed-by: Michel Thierry <michel.thierry@intel.com> #2
>> ---
>>   drivers/gpu/drm/i915/intel_guc.c | 15 ++++++++++++---
>>   1 file changed, 12 insertions(+), 3 deletions(-)
>>  diff --git a/drivers/gpu/drm/i915/intel_guc.c  
>> b/drivers/gpu/drm/i915/intel_guc.c
>> index a533ff8..9ce01e5 100644
>> --- a/drivers/gpu/drm/i915/intel_guc.c
>> +++ b/drivers/gpu/drm/i915/intel_guc.c
>> @@ -368,11 +368,20 @@ int intel_guc_send_mmio(struct intel_guc *guc,  
>> const u32 *action, u32 len,
>>                                   " ret=%d status=0x%08X  
>> response=0x%08X\n",
>>                                   action[0], ret, status,
>>                                   I915_READ(SOFT_SCRATCH(15)));
>> -       } else {
>> -               /* Use data from the GuC response as our return value */
>> -               ret = INTEL_GUC_MSG_TO_DATA(status);
>> +               goto out;
>>          }
>>
>
> I'm not a big fan of goto's, so I would have added the response handling  
> in the else part.

me too, but there were too many indents and code was getting less readable
due to 80 column limit

/m

>
> But it's still correct, so my old r-b still stands.
>
> -Michel
>
>> +       if (response_buf) {
>> +               int count = min(response_buf_size, guc->send_regs.count  
>> - 1);
>> +
>> +               for (i = 0; i < count; i++)
>> +                       response_buf[i] = I915_READ(guc_send_reg(guc, i  
>> + 1));
>> +       }
>> +
>> +       /* Use data from the GuC response as our return value */
>> +       ret = INTEL_GUC_MSG_TO_DATA(status);
>> +
>> +out:
>>          intel_uncore_forcewake_put(dev_priv,  
>> guc->send_regs.fw_domains);
>>          mutex_unlock(&guc->send_mutex);
>>  --
>> 1.9.1
>>  _______________________________________________
>> Intel-gfx mailing list
>> Intel-gfx@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_guc.c b/drivers/gpu/drm/i915/intel_guc.c
index a533ff8..9ce01e5 100644
--- a/drivers/gpu/drm/i915/intel_guc.c
+++ b/drivers/gpu/drm/i915/intel_guc.c
@@ -368,11 +368,20 @@  int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len,
 				 " ret=%d status=0x%08X response=0x%08X\n",
 				 action[0], ret, status,
 				 I915_READ(SOFT_SCRATCH(15)));
-	} else {
-		/* Use data from the GuC response as our return value */
-		ret = INTEL_GUC_MSG_TO_DATA(status);
+		goto out;
 	}
 
+	if (response_buf) {
+		int count = min(response_buf_size, guc->send_regs.count - 1);
+
+		for (i = 0; i < count; i++)
+			response_buf[i] = I915_READ(guc_send_reg(guc, i + 1));
+	}
+
+	/* Use data from the GuC response as our return value */
+	ret = INTEL_GUC_MSG_TO_DATA(status);
+
+out:
 	intel_uncore_forcewake_put(dev_priv, guc->send_regs.fw_domains);
 	mutex_unlock(&guc->send_mutex);