drm/i915/gt: Check we are the Ironlake IPS provider before deregistering
diff mbox series

Message ID 20191210153620.3929372-1-chris@chris-wilson.co.uk
State New
Headers show
Series
  • drm/i915/gt: Check we are the Ironlake IPS provider before deregistering
Related show

Commit Message

Chris Wilson Dec. 10, 2019, 3:36 p.m. UTC
Check that we own the global pointer before deregistering.

Reported-by: Venkata Sandeep Dhanalakota <venkata.s.dhanalakota@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Venkata Sandeep Dhanalakota <venkata.s.dhanalakota@intel.com>
Cc: Andi Shyti <andi.shyti@intel.com>
---
 drivers/gpu/drm/i915/gt/intel_rps.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Venkata Sandeep Dhanalakota Dec. 10, 2019, 5:09 p.m. UTC | #1
On 19/12/10 03:36, Chris Wilson wrote:
> Check that we own the global pointer before deregistering.
> 
> Reported-by: Venkata Sandeep Dhanalakota <venkata.s.dhanalakota@intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Venkata Sandeep Dhanalakota <venkata.s.dhanalakota@intel.com>
> Cc: Andi Shyti <andi.shyti@intel.com>
> ---
>  drivers/gpu/drm/i915/gt/intel_rps.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/intel_rps.c b/drivers/gpu/drm/i915/gt/intel_rps.c
> index 08a38a3b90b0..fd01e4100fc1 100644
> --- a/drivers/gpu/drm/i915/gt/intel_rps.c
> +++ b/drivers/gpu/drm/i915/gt/intel_rps.c
> @@ -1715,6 +1715,7 @@ void intel_rps_driver_register(struct intel_rps *rps)
>  	 * set up, to avoid intel-ips sneaking in and reading bogus values.
>  	 */
>  	if (IS_GEN(gt->i915, 5)) {
> +		GEM_BUG_ON(ips_mchdev);
>  		rcu_assign_pointer(ips_mchdev, gt->i915);
>  		ips_ping_for_i915_load();
>  	}
> @@ -1722,7 +1723,8 @@ void intel_rps_driver_register(struct intel_rps *rps)
>  
>  void intel_rps_driver_unregister(struct intel_rps *rps)
>  {
> -	rcu_assign_pointer(ips_mchdev, NULL);
> +	if (ips_mchdev == rps_to_i915(rps))
> +		rcu_assign_pointer(ips_mchdev, NULL);
>  }
I think its right thing to do, looks good to me.

Reviewed-by: Venkata Sandeep Dhanalakota <venkata.s.dhanalakota@intel.com>
>  
>  static struct drm_i915_private *mchdev_get(void)
> -- 
> 2.24.0
>

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gt/intel_rps.c b/drivers/gpu/drm/i915/gt/intel_rps.c
index 08a38a3b90b0..fd01e4100fc1 100644
--- a/drivers/gpu/drm/i915/gt/intel_rps.c
+++ b/drivers/gpu/drm/i915/gt/intel_rps.c
@@ -1715,6 +1715,7 @@  void intel_rps_driver_register(struct intel_rps *rps)
 	 * set up, to avoid intel-ips sneaking in and reading bogus values.
 	 */
 	if (IS_GEN(gt->i915, 5)) {
+		GEM_BUG_ON(ips_mchdev);
 		rcu_assign_pointer(ips_mchdev, gt->i915);
 		ips_ping_for_i915_load();
 	}
@@ -1722,7 +1723,8 @@  void intel_rps_driver_register(struct intel_rps *rps)
 
 void intel_rps_driver_unregister(struct intel_rps *rps)
 {
-	rcu_assign_pointer(ips_mchdev, NULL);
+	if (ips_mchdev == rps_to_i915(rps))
+		rcu_assign_pointer(ips_mchdev, NULL);
 }
 
 static struct drm_i915_private *mchdev_get(void)