diff mbox series

[v3,3/6] drm/i915/pxp: Make intel_pxp_is_active implicitly sort PXP-owning-GT

Message ID 20221021173946.366210-4-alan.previn.teres.alexis@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/pxp: Prepare intel_pxp entry points for MTL | expand

Commit Message

Teres Alexis, Alan Previn Oct. 21, 2022, 5:39 p.m. UTC
Make intel_pxp_is_active a global check and implicitly find
the PXP-owning-GT.

As per prior two patches, callers of this function shall now
pass in i915 since PXP is a global GPU feature. Make
intel_pxp_is_active implicitly find the right gt so it's transparent
for global view callers (like display or gem-exec).

However we also need to expose the per-gt variation of this for internal
pxp files to use (like what intel_pxp_is_active was prior) so also expose
a new intel_gtpxp_is_active function for replacement.

Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c  |  2 +-
 drivers/gpu/drm/i915/pxp/intel_pxp.c         | 14 ++++++++++++--
 drivers/gpu/drm/i915/pxp/intel_pxp.h         |  3 ++-
 drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c |  4 ++--
 drivers/gpu/drm/i915/pxp/intel_pxp_irq.c     |  2 +-
 5 files changed, 18 insertions(+), 7 deletions(-)

Comments

Daniele Ceraolo Spurio Nov. 15, 2022, 4:17 a.m. UTC | #1
On 10/21/2022 10:39 AM, Alan Previn wrote:
> Make intel_pxp_is_active a global check and implicitly find
> the PXP-owning-GT.
>
> As per prior two patches, callers of this function shall now
> pass in i915 since PXP is a global GPU feature. Make
> intel_pxp_is_active implicitly find the right gt so it's transparent
> for global view callers (like display or gem-exec).
>
> However we also need to expose the per-gt variation of this for internal
> pxp files to use (like what intel_pxp_is_active was prior) so also expose
> a new intel_gtpxp_is_active function for replacement.
>
> Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
> ---
>   drivers/gpu/drm/i915/gem/i915_gem_context.c  |  2 +-
>   drivers/gpu/drm/i915/pxp/intel_pxp.c         | 14 ++++++++++++--
>   drivers/gpu/drm/i915/pxp/intel_pxp.h         |  3 ++-
>   drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c |  4 ++--
>   drivers/gpu/drm/i915/pxp/intel_pxp_irq.c     |  2 +-
>   5 files changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> index 72f47ebda75f..798e77398acc 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> @@ -271,7 +271,7 @@ static int proto_context_set_protected(struct drm_i915_private *i915,
>   		 */
>   		pc->pxp_wakeref = intel_runtime_pm_get(&i915->runtime_pm);
>   
> -		if (!intel_pxp_is_active(&to_gt(i915)->pxp))
> +		if (!intel_pxp_is_active(i915))
>   			ret = intel_pxp_start(&to_gt(i915)->pxp);
>   	}
>   
> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp.c b/drivers/gpu/drm/i915/pxp/intel_pxp.c
> index f7c909fce97c..15f7983f6da8 100644
> --- a/drivers/gpu/drm/i915/pxp/intel_pxp.c
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp.c
> @@ -97,11 +97,21 @@ bool intel_pxp_is_enabled(struct drm_i915_private *i915)
>   	return intel_gtpxp_is_enabled(&gt->pxp);
>   }
>   
> -bool intel_pxp_is_active(const struct intel_pxp *pxp)
> +bool intel_gtpxp_is_active(const struct intel_pxp *pxp)
>   {
>   	return pxp->arb_is_valid;
>   }
>   
> +bool intel_pxp_is_active(struct drm_i915_private *i915)

again I'd suggest a different name to differentiate the 2 checkers. 
Considering the only calling of this is from outside the PXP code is to 
decide whether to start the arb session or not, maybe rename this to 
intel_pxp_has_started or intel_pxp_is_running and leave the old 
intel_pxp_is_active as-is?

Daniele

> +{
> +	struct intel_gt *gt = _i915_to_pxp_gt(i915);
> +
> +	if (!gt)
> +		return false;
> +
> +	return intel_gtpxp_is_active(&gt->pxp);
> +}
> +
>   /* KCR register definitions */
>   #define KCR_INIT _MMIO(0x320f0)
>   /* Setting KCR Init bit is required after system boot */
> @@ -300,7 +310,7 @@ int intel_pxp_key_check(struct intel_pxp *pxp,
>   			struct drm_i915_gem_object *obj,
>   			bool assign)
>   {
> -	if (!intel_pxp_is_active(pxp))
> +	if (!intel_gtpxp_is_active(pxp))
>   		return -ENODEV;
>   
>   	if (!i915_gem_object_is_protected(obj))
> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp.h b/drivers/gpu/drm/i915/pxp/intel_pxp.h
> index 61472018bc45..70383394adb4 100644
> --- a/drivers/gpu/drm/i915/pxp/intel_pxp.h
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp.h
> @@ -16,9 +16,10 @@ struct drm_i915_private;
>   struct intel_gt *pxp_to_gt(const struct intel_pxp *pxp);
>   bool intel_gtpxp_is_supported(struct intel_pxp *pxp);
>   bool intel_gtpxp_is_enabled(const struct intel_pxp *pxp);
> +bool intel_gtpxp_is_active(const struct intel_pxp *pxp);
>   
>   bool intel_pxp_is_enabled(struct drm_i915_private *i915);
> -bool intel_pxp_is_active(const struct intel_pxp *pxp);
> +bool intel_pxp_is_active(struct drm_i915_private *i915);
>   
>   void intel_pxp_init(struct intel_pxp *pxp);
>   void intel_pxp_fini(struct intel_pxp *pxp);
> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c b/drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c
> index 13f517f94bae..7f304b421633 100644
> --- a/drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c
> @@ -25,7 +25,7 @@ static int pxp_info_show(struct seq_file *m, void *data)
>   		return 0;
>   	}
>   
> -	drm_printf(&p, "active: %s\n", str_yes_no(intel_pxp_is_active(pxp)));
> +	drm_printf(&p, "active: %s\n", str_yes_no(intel_gtpxp_is_active(pxp)));
>   	drm_printf(&p, "instance counter: %u\n", pxp->key_instance);
>   
>   	return 0;
> @@ -43,7 +43,7 @@ static int pxp_terminate_set(void *data, u64 val)
>   	struct intel_pxp *pxp = data;
>   	struct intel_gt *gt = pxp_to_gt(pxp);
>   
> -	if (!intel_pxp_is_active(pxp))
> +	if (!intel_gtpxp_is_active(pxp))
>   		return -ENODEV;
>   
>   	/* simulate a termination interrupt */
> diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c b/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c
> index 8e8e5645e4fc..cd97f8d8cc10 100644
> --- a/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c
> +++ b/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c
> @@ -86,7 +86,7 @@ void intel_pxp_irq_disable(struct intel_pxp *pxp)
>   	 * called in a path were the driver consider the session as valid and
>   	 * doesn't call a termination on restart.
>   	 */
> -	GEM_WARN_ON(intel_pxp_is_active(pxp));
> +	GEM_WARN_ON(intel_gtpxp_is_active(pxp));
>   
>   	spin_lock_irq(gt->irq_lock);
>
Teres Alexis, Alan Previn Nov. 15, 2022, 5:26 a.m. UTC | #2
On Mon, 2022-11-14 at 20:17 -0800, Ceraolo Spurio, Daniele wrote:
> 
> On 10/21/2022 10:39 AM, Alan Previn wrote:
> > Make intel_pxp_is_active a global check and implicitly find
> > the PXP-owning-GT.
> > 
> > As per prior two patches, callers of this function shall now
> > pass in i915 since PXP is a global GPU feature. Make
> > intel_pxp_is_active implicitly find the right gt so it's transparent
> > for global view callers (like display or gem-exec).
> > 
> > However we also need to expose the per-gt variation of this for internal
> > pxp files to use (like what intel_pxp_is_active was prior) so also expose
> > a new intel_gtpxp_is_active function for replacement.
> > 
> > Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
> > ---
> >   drivers/gpu/drm/i915/gem/i915_gem_context.c  |  2 +-
> >   drivers/gpu/drm/i915/pxp/intel_pxp.c         | 14 ++++++++++++--
> >   drivers/gpu/drm/i915/pxp/intel_pxp.h         |  3 ++-
> >   drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c |  4 ++--
> >   drivers/gpu/drm/i915/pxp/intel_pxp_irq.c     |  2 +-
> >   5 files changed, 18 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> > index 72f47ebda75f..798e77398acc 100644
> > --- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
> > +++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
> > @@ -271,7 +271,7 @@ static int proto_context_set_protected(struct drm_i915_private *i915,
> >   		 */
> >   		pc->pxp_wakeref = intel_runtime_pm_get(&i915->runtime_pm);
> >   
> > -		if (!intel_pxp_is_active(&to_gt(i915)->pxp))
> > +		if (!intel_pxp_is_active(i915))
> >   			ret = intel_pxp_start(&to_gt(i915)->pxp);
> >   	}
> >   
> > diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp.c b/drivers/gpu/drm/i915/pxp/intel_pxp.c
> > index f7c909fce97c..15f7983f6da8 100644
> > --- a/drivers/gpu/drm/i915/pxp/intel_pxp.c
> > +++ b/drivers/gpu/drm/i915/pxp/intel_pxp.c
> > @@ -97,11 +97,21 @@ bool intel_pxp_is_enabled(struct drm_i915_private *i915)
> >   	return intel_gtpxp_is_enabled(&gt->pxp);
> >   }
> >   
> > -bool intel_pxp_is_active(const struct intel_pxp *pxp)
> > +bool intel_gtpxp_is_active(const struct intel_pxp *pxp)
> >   {
> >   	return pxp->arb_is_valid;
> >   }
> >   
> > +bool intel_pxp_is_active(struct drm_i915_private *i915)
> 
> again I'd suggest a different name to differentiate the 2 checkers. 
> Considering the only calling of this is from outside the PXP code is to 
> decide whether to start the arb session or not, maybe rename this to 
> intel_pxp_has_started or intel_pxp_is_running and leave the old 
> intel_pxp_is_active as-is?
> 
Again, i humbly disagree - if one is a wrapper around the other, i rather keep the action specific part of the function
name to be exactly consistent. Perhaps like earlier, we can make intel_pxp_is_active as a wrapper round
intel_gt_has_active_pxp. But i want to maintain the "active" key word to enforce that symmetry and not decouple them
(since its a wrapper relationship).

> Daniele
> 
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 72f47ebda75f..798e77398acc 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -271,7 +271,7 @@  static int proto_context_set_protected(struct drm_i915_private *i915,
 		 */
 		pc->pxp_wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
-		if (!intel_pxp_is_active(&to_gt(i915)->pxp))
+		if (!intel_pxp_is_active(i915))
 			ret = intel_pxp_start(&to_gt(i915)->pxp);
 	}
 
diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp.c b/drivers/gpu/drm/i915/pxp/intel_pxp.c
index f7c909fce97c..15f7983f6da8 100644
--- a/drivers/gpu/drm/i915/pxp/intel_pxp.c
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp.c
@@ -97,11 +97,21 @@  bool intel_pxp_is_enabled(struct drm_i915_private *i915)
 	return intel_gtpxp_is_enabled(&gt->pxp);
 }
 
-bool intel_pxp_is_active(const struct intel_pxp *pxp)
+bool intel_gtpxp_is_active(const struct intel_pxp *pxp)
 {
 	return pxp->arb_is_valid;
 }
 
+bool intel_pxp_is_active(struct drm_i915_private *i915)
+{
+	struct intel_gt *gt = _i915_to_pxp_gt(i915);
+
+	if (!gt)
+		return false;
+
+	return intel_gtpxp_is_active(&gt->pxp);
+}
+
 /* KCR register definitions */
 #define KCR_INIT _MMIO(0x320f0)
 /* Setting KCR Init bit is required after system boot */
@@ -300,7 +310,7 @@  int intel_pxp_key_check(struct intel_pxp *pxp,
 			struct drm_i915_gem_object *obj,
 			bool assign)
 {
-	if (!intel_pxp_is_active(pxp))
+	if (!intel_gtpxp_is_active(pxp))
 		return -ENODEV;
 
 	if (!i915_gem_object_is_protected(obj))
diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp.h b/drivers/gpu/drm/i915/pxp/intel_pxp.h
index 61472018bc45..70383394adb4 100644
--- a/drivers/gpu/drm/i915/pxp/intel_pxp.h
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp.h
@@ -16,9 +16,10 @@  struct drm_i915_private;
 struct intel_gt *pxp_to_gt(const struct intel_pxp *pxp);
 bool intel_gtpxp_is_supported(struct intel_pxp *pxp);
 bool intel_gtpxp_is_enabled(const struct intel_pxp *pxp);
+bool intel_gtpxp_is_active(const struct intel_pxp *pxp);
 
 bool intel_pxp_is_enabled(struct drm_i915_private *i915);
-bool intel_pxp_is_active(const struct intel_pxp *pxp);
+bool intel_pxp_is_active(struct drm_i915_private *i915);
 
 void intel_pxp_init(struct intel_pxp *pxp);
 void intel_pxp_fini(struct intel_pxp *pxp);
diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c b/drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c
index 13f517f94bae..7f304b421633 100644
--- a/drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp_debugfs.c
@@ -25,7 +25,7 @@  static int pxp_info_show(struct seq_file *m, void *data)
 		return 0;
 	}
 
-	drm_printf(&p, "active: %s\n", str_yes_no(intel_pxp_is_active(pxp)));
+	drm_printf(&p, "active: %s\n", str_yes_no(intel_gtpxp_is_active(pxp)));
 	drm_printf(&p, "instance counter: %u\n", pxp->key_instance);
 
 	return 0;
@@ -43,7 +43,7 @@  static int pxp_terminate_set(void *data, u64 val)
 	struct intel_pxp *pxp = data;
 	struct intel_gt *gt = pxp_to_gt(pxp);
 
-	if (!intel_pxp_is_active(pxp))
+	if (!intel_gtpxp_is_active(pxp))
 		return -ENODEV;
 
 	/* simulate a termination interrupt */
diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c b/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c
index 8e8e5645e4fc..cd97f8d8cc10 100644
--- a/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp_irq.c
@@ -86,7 +86,7 @@  void intel_pxp_irq_disable(struct intel_pxp *pxp)
 	 * called in a path were the driver consider the session as valid and
 	 * doesn't call a termination on restart.
 	 */
-	GEM_WARN_ON(intel_pxp_is_active(pxp));
+	GEM_WARN_ON(intel_gtpxp_is_active(pxp));
 
 	spin_lock_irq(gt->irq_lock);