diff mbox series

[RFC,4/4] drm/i915/uc: Add sanitize to to intel_uc_ops

Message ID 20191210204744.65276-5-michal.wajdeczko@intel.com (mailing list archive)
State New, archived
Headers show
Series Add ops to intel_uc | expand

Commit Message

Michal Wajdeczko Dec. 10, 2019, 8:47 p.m. UTC
uC sanitization is only meaningful if we are running with uC present
or enabled. Make this function part of the uc_ops.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 drivers/gpu/drm/i915/gt/uc/intel_uc.c | 10 ++--------
 drivers/gpu/drm/i915/gt/uc/intel_uc.h |  9 ++++++++-
 2 files changed, 10 insertions(+), 9 deletions(-)

Comments

Chris Wilson Dec. 10, 2019, 9 p.m. UTC | #1
Quoting Michal Wajdeczko (2019-12-10 20:47:44)
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
> index 2bd8326130f1..3410d35f8b0c 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
> @@ -19,6 +19,7 @@ struct intel_uc_ops {
>         void (*fini)(struct intel_uc *uc);
>         int (*init_hw)(struct intel_uc *uc);
>         void (*fini_hw)(struct intel_uc *uc);
> +       int (*sanitize)(struct intel_uc *uc);

In the order of ops, first?

The series looks sane. Looks a bit overkill, but if you can convince
Daniele of your vision, fine by me.
-Chris
Daniele Ceraolo Spurio Dec. 12, 2019, 12:13 a.m. UTC | #2
On 12/10/19 1:00 PM, Chris Wilson wrote:
> Quoting Michal Wajdeczko (2019-12-10 20:47:44)
>> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
>> index 2bd8326130f1..3410d35f8b0c 100644
>> --- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h
>> +++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
>> @@ -19,6 +19,7 @@ struct intel_uc_ops {
>>          void (*fini)(struct intel_uc *uc);
>>          int (*init_hw)(struct intel_uc *uc);
>>          void (*fini_hw)(struct intel_uc *uc);
>> +       int (*sanitize)(struct intel_uc *uc);
> 
> In the order of ops, first?
> 
> The series looks sane. Looks a bit overkill, but if you can convince
> Daniele of your vision, fine by me.
> -Chris
> 

I've had a quick chat with Michal about this and, when also considering 
some of the upcoming stuff, it does definitely make sense to me to 
switch to ops.

Daniele
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.c b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
index c8b399d61166..634ef2fa34f1 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.c
@@ -349,14 +349,6 @@  static int __uc_sanitize(struct intel_uc *uc)
 	return __intel_uc_reset_hw(uc);
 }
 
-void intel_uc_sanitize(struct intel_uc *uc)
-{
-	if (!intel_uc_supports_guc(uc))
-		return;
-
-	__uc_sanitize(uc);
-}
-
 /* Initialize and verify the uC regs related to uC positioning in WOPCM */
 static int uc_init_wopcm(struct intel_uc *uc)
 {
@@ -652,10 +644,12 @@  const struct intel_uc_ops uc_ops_none = {
 };
 
 const struct intel_uc_ops uc_ops_off = {
+	.sanitize = __intel_uc_reset_hw,
 	.init_hw = __uc_check_hw,
 };
 
 const struct intel_uc_ops uc_ops_on = {
+	.sanitize = __uc_sanitize,
 	.init_fw = __uc_fetch_firmwares,
 	.fini_fw = __uc_cleanup_firmwares,
 	.init = __uc_init,
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc.h b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
index 2bd8326130f1..3410d35f8b0c 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc.h
@@ -19,6 +19,7 @@  struct intel_uc_ops {
 	void (*fini)(struct intel_uc *uc);
 	int (*init_hw)(struct intel_uc *uc);
 	void (*fini_hw)(struct intel_uc *uc);
+	int (*sanitize)(struct intel_uc *uc);
 };
 
 struct intel_uc {
@@ -33,7 +34,6 @@  struct intel_uc {
 void intel_uc_init_early(struct intel_uc *uc);
 void intel_uc_driver_late_release(struct intel_uc *uc);
 void intel_uc_init_mmio(struct intel_uc *uc);
-void intel_uc_sanitize(struct intel_uc *uc);
 void intel_uc_reset_prepare(struct intel_uc *uc);
 void intel_uc_suspend(struct intel_uc *uc);
 void intel_uc_runtime_suspend(struct intel_uc *uc);
@@ -107,4 +107,11 @@  static inline void intel_uc_fini_hw(struct intel_uc *uc)
 		uc->ops->fini_hw(uc);
 }
 
+static inline int intel_uc_sanitize(struct intel_uc *uc)
+{
+	if (uc->ops->sanitize)
+		return uc->ops->sanitize(uc);
+	return 0;
+}
+
 #endif