All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sagar Arun Kamble <sagar.a.kamble@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Cc: praveen.paneri@intel.com
Subject: Re: [PATCH 15/36] drm/i915: Mark up Ironlake ips with rpm wakerefs
Date: Fri, 16 Mar 2018 10:28:22 +0530	[thread overview]
Message-ID: <1a012df7-2677-4c60-7907-d79b1a6aa0a5@intel.com> (raw)
In-Reply-To: <20180314093748.8541-15-chris@chris-wilson.co.uk>



On 3/14/2018 3:07 PM, Chris Wilson wrote:
> Currently Ironlake operates under the assumption that rpm awake (and its
> error checking is disabled). As such, we have missed a few places where we
> access registers without taking the rpm wakeref and thus trigger
> warnings. intel_ips being one culprit.
>
> As this involved adding a potentially sleeping rpm_get, we have to
> rearrange the spinlocks slightly and so switch to acquiring a device-ref
> under the spinlock rather than hold the spinlock for the whole
> operation. To be consistent, we make the change in pattern common to the
> intel_ips interface even though this adds a few more atomic operations
> than necessary in a few cases.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/i915_drv.c |   3 +
>   drivers/gpu/drm/i915/intel_pm.c | 138 ++++++++++++++++++++--------------------
>   2 files changed, 73 insertions(+), 68 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 3d0b7353fb09..5c28990aab7f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1440,6 +1440,9 @@ void i915_driver_unload(struct drm_device *dev)
>   
>   	i915_driver_unregister(dev_priv);
>   
> +	/* Flush any external code that still may be under the RCU lock */
> +	synchronize_rcu();
> +
Hi Chris,

Will this rcu change be equivalent to

rcu_assign_pointer(i915_mch_dev, dev_priv) in gpu_ips_init
rcu_assign_pointer(i915_mch_dev, NULL) in gpu_ips_teardown

eliminating smp_store_mb from init/teardown and synchronize_rcu here.

Thanks,
Sagar
>   	if (i915_gem_suspend(dev_priv))
>   		DRM_ERROR("failed to idle hardware; continuing to unload!\n");
>   
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 447811c5be35..a2ebf66ff9ed 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -5930,10 +5930,6 @@ void intel_init_ipc(struct drm_i915_private *dev_priv)
>    */
>   DEFINE_SPINLOCK(mchdev_lock);
>   
> -/* Global for IPS driver to get at the current i915 device. Protected by
> - * mchdev_lock. */
> -static struct drm_i915_private *i915_mch_dev;
> -
>   bool ironlake_set_drps(struct drm_i915_private *dev_priv, u8 val)
>   {
>   	u16 rgvswctl;
> @@ -7577,11 +7573,13 @@ unsigned long i915_chipset_val(struct drm_i915_private *dev_priv)
>   	if (!IS_GEN5(dev_priv))
>   		return 0;
>   
> +	intel_runtime_pm_get(dev_priv);
>   	spin_lock_irq(&mchdev_lock);
>   
>   	val = __i915_chipset_val(dev_priv);
>   
>   	spin_unlock_irq(&mchdev_lock);
> +	intel_runtime_pm_put(dev_priv);
>   
>   	return val;
>   }
> @@ -7661,11 +7659,13 @@ void i915_update_gfx_val(struct drm_i915_private *dev_priv)
>   	if (!IS_GEN5(dev_priv))
>   		return;
>   
> +	intel_runtime_pm_get(dev_priv);
>   	spin_lock_irq(&mchdev_lock);
>   
>   	__i915_update_gfx_val(dev_priv);
>   
>   	spin_unlock_irq(&mchdev_lock);
> +	intel_runtime_pm_put(dev_priv);
>   }
>   
>   static unsigned long __i915_gfx_val(struct drm_i915_private *dev_priv)
> @@ -7712,15 +7712,32 @@ unsigned long i915_gfx_val(struct drm_i915_private *dev_priv)
>   	if (!IS_GEN5(dev_priv))
>   		return 0;
>   
> +	intel_runtime_pm_get(dev_priv);
>   	spin_lock_irq(&mchdev_lock);
>   
>   	val = __i915_gfx_val(dev_priv);
>   
>   	spin_unlock_irq(&mchdev_lock);
> +	intel_runtime_pm_put(dev_priv);
>   
>   	return val;
>   }
>   
> +static struct drm_i915_private *i915_mch_dev;
> +
> +static struct drm_i915_private *mchdev_get(void)
> +{
> +	struct drm_i915_private *i915;
> +
> +	rcu_read_lock();
> +	i915 = i915_mch_dev;
> +	if (!kref_get_unless_zero(&i915->drm.ref))
> +		i915 = NULL;
> +	rcu_read_unlock();
> +
> +	return i915;
> +}
> +
>   /**
>    * i915_read_mch_val - return value for IPS use
>    *
> @@ -7729,23 +7746,22 @@ unsigned long i915_gfx_val(struct drm_i915_private *dev_priv)
>    */
>   unsigned long i915_read_mch_val(void)
>   {
> -	struct drm_i915_private *dev_priv;
> -	unsigned long chipset_val, graphics_val, ret = 0;
> -
> -	spin_lock_irq(&mchdev_lock);
> -	if (!i915_mch_dev)
> -		goto out_unlock;
> -	dev_priv = i915_mch_dev;
> -
> -	chipset_val = __i915_chipset_val(dev_priv);
> -	graphics_val = __i915_gfx_val(dev_priv);
> +	struct drm_i915_private *i915;
> +	unsigned long chipset_val, graphics_val;
>   
> -	ret = chipset_val + graphics_val;
> +	i915 = mchdev_get();
> +	if (!i915)
> +		return 0;
>   
> -out_unlock:
> +	intel_runtime_pm_get(i915);
> +	spin_lock_irq(&mchdev_lock);
> +	chipset_val = __i915_chipset_val(i915);
> +	graphics_val = __i915_gfx_val(i915);
>   	spin_unlock_irq(&mchdev_lock);
> +	intel_runtime_pm_put(i915);
>   
> -	return ret;
> +	drm_dev_put(&i915->drm);
> +	return chipset_val + graphics_val;
>   }
>   EXPORT_SYMBOL_GPL(i915_read_mch_val);
>   
> @@ -7756,23 +7772,19 @@ EXPORT_SYMBOL_GPL(i915_read_mch_val);
>    */
>   bool i915_gpu_raise(void)
>   {
> -	struct drm_i915_private *dev_priv;
> -	bool ret = true;
> -
> -	spin_lock_irq(&mchdev_lock);
> -	if (!i915_mch_dev) {
> -		ret = false;
> -		goto out_unlock;
> -	}
> -	dev_priv = i915_mch_dev;
> +	struct drm_i915_private *i915;
>   
> -	if (dev_priv->ips.max_delay > dev_priv->ips.fmax)
> -		dev_priv->ips.max_delay--;
> +	i915 = mchdev_get();
> +	if (!i915)
> +		return false;
>   
> -out_unlock:
> +	spin_lock_irq(&mchdev_lock);
> +	if (i915->ips.max_delay > i915->ips.fmax)
> +		i915->ips.max_delay--;
>   	spin_unlock_irq(&mchdev_lock);
>   
> -	return ret;
> +	drm_dev_put(&i915->drm);
> +	return true;
>   }
>   EXPORT_SYMBOL_GPL(i915_gpu_raise);
>   
> @@ -7784,23 +7796,19 @@ EXPORT_SYMBOL_GPL(i915_gpu_raise);
>    */
>   bool i915_gpu_lower(void)
>   {
> -	struct drm_i915_private *dev_priv;
> -	bool ret = true;
> +	struct drm_i915_private *i915;
>   
> -	spin_lock_irq(&mchdev_lock);
> -	if (!i915_mch_dev) {
> -		ret = false;
> -		goto out_unlock;
> -	}
> -	dev_priv = i915_mch_dev;
> -
> -	if (dev_priv->ips.max_delay < dev_priv->ips.min_delay)
> -		dev_priv->ips.max_delay++;
> +	i915 = mchdev_get();
> +	if (!i915)
> +		return false;
>   
> -out_unlock:
> +	spin_lock_irq(&mchdev_lock);
> +	if (i915->ips.max_delay < i915->ips.min_delay)
> +		i915->ips.max_delay++;
>   	spin_unlock_irq(&mchdev_lock);
>   
> -	return ret;
> +	drm_dev_put(&i915->drm);
> +	return true;
>   }
>   EXPORT_SYMBOL_GPL(i915_gpu_lower);
>   
> @@ -7811,13 +7819,16 @@ EXPORT_SYMBOL_GPL(i915_gpu_lower);
>    */
>   bool i915_gpu_busy(void)
>   {
> -	bool ret = false;
> +	struct drm_i915_private *i915;
> +	bool ret;
>   
> -	spin_lock_irq(&mchdev_lock);
> -	if (i915_mch_dev)
> -		ret = i915_mch_dev->gt.awake;
> -	spin_unlock_irq(&mchdev_lock);
> +	i915 = mchdev_get();
> +	if (!i915)
> +		return false;
> +
> +	ret = i915->gt.awake;
>   
> +	drm_dev_put(&i915->drm);
>   	return ret;
>   }
>   EXPORT_SYMBOL_GPL(i915_gpu_busy);
> @@ -7830,24 +7841,19 @@ EXPORT_SYMBOL_GPL(i915_gpu_busy);
>    */
>   bool i915_gpu_turbo_disable(void)
>   {
> -	struct drm_i915_private *dev_priv;
> -	bool ret = true;
> -
> -	spin_lock_irq(&mchdev_lock);
> -	if (!i915_mch_dev) {
> -		ret = false;
> -		goto out_unlock;
> -	}
> -	dev_priv = i915_mch_dev;
> -
> -	dev_priv->ips.max_delay = dev_priv->ips.fstart;
> +	struct drm_i915_private *i915;
> +	bool ret;
>   
> -	if (!ironlake_set_drps(dev_priv, dev_priv->ips.fstart))
> -		ret = false;
> +	i915 = mchdev_get();
> +	if (!i915)
> +		return false;
>   
> -out_unlock:
> +	spin_lock_irq(&mchdev_lock);
> +	i915->ips.max_delay = i915->ips.fstart;
> +	ret = ironlake_set_drps(i915, i915->ips.fstart);
>   	spin_unlock_irq(&mchdev_lock);
>   
> +	drm_dev_put(&i915->drm);
>   	return ret;
>   }
>   EXPORT_SYMBOL_GPL(i915_gpu_turbo_disable);
> @@ -7876,18 +7882,14 @@ void intel_gpu_ips_init(struct drm_i915_private *dev_priv)
>   {
>   	/* We only register the i915 ips part with intel-ips once everything is
>   	 * set up, to avoid intel-ips sneaking in and reading bogus values. */
> -	spin_lock_irq(&mchdev_lock);
> -	i915_mch_dev = dev_priv;
> -	spin_unlock_irq(&mchdev_lock);
> +	smp_store_mb(i915_mch_dev, dev_priv);
>   
>   	ips_ping_for_i915_load();
>   }
>   
>   void intel_gpu_ips_teardown(void)
>   {
> -	spin_lock_irq(&mchdev_lock);
> -	i915_mch_dev = NULL;
> -	spin_unlock_irq(&mchdev_lock);
> +	smp_store_mb(i915_mch_dev, NULL);
>   }
>   
>   static void intel_init_emon(struct drm_i915_private *dev_priv)

-- 
Thanks,
Sagar

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-03-16  4:58 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14  9:37 [PATCH 01/36] drm/i915/stolen: Switch from DEBUG_KMS to DEBUG_DRIVER Chris Wilson
2018-03-14  9:37 ` [PATCH 02/36] drm/i915/stolen: Checkpatch cleansing Chris Wilson
2018-03-14  9:37 ` [PATCH 03/36] drm/i915/stolen: Deduce base of reserved portion as top-size on vlv Chris Wilson
2018-03-14  9:37 ` [PATCH 04/36] drm/i915: Trim error mask to known engines Chris Wilson
2018-03-14  9:37 ` [PATCH 05/36] drm/i915: Disable preemption and sleeping while using the punit sideband Chris Wilson
2018-03-16 12:18   ` Mika Kuoppala
2018-03-14  9:37 ` [PATCH 06/36] drm/i915: Lift acquiring the vlv punit magic to a common sb-get Chris Wilson
2018-03-14  9:37 ` [PATCH 07/36] drm/i915: Lift sideband locking for vlv_punit_(read|write) Chris Wilson
2018-03-14  9:37 ` [PATCH 08/36] drm/i915: Reduce RPS update frequency on Valleyview/Cherryview Chris Wilson
2018-03-15  9:23   ` Sagar Arun Kamble
2018-04-09 13:51     ` Chris Wilson
2018-03-14  9:37 ` [PATCH 09/36] Revert "drm/i915: Avoid tweaking evaluation thresholds on Baytrail v3" Chris Wilson
2018-03-14  9:37 ` [PATCH 10/36] drm/i915: Replace pcu_lock with sb_lock Chris Wilson
2018-03-15 12:06   ` Sagar Arun Kamble
2018-04-09 13:54     ` Chris Wilson
2018-03-14  9:37 ` [PATCH 11/36] drm/i915: Separate sideband declarations to intel_sideband.h Chris Wilson
2018-03-14  9:37 ` [PATCH 12/36] drm/i915: Merge sbi read/write into a single accessor Chris Wilson
2018-03-16  3:39   ` Sagar Arun Kamble
2018-04-09 14:00     ` Chris Wilson
2018-03-14  9:37 ` [PATCH 13/36] drm/i915: Merge sandybridge_pcode_(read|write) Chris Wilson
2018-03-14 15:20   ` Imre Deak
2018-03-14  9:37 ` [PATCH 14/36] drm/i915: Move sandybride pcode access to intel_sideband.c Chris Wilson
2018-03-14  9:37 ` [PATCH 15/36] drm/i915: Mark up Ironlake ips with rpm wakerefs Chris Wilson
2018-03-16  4:58   ` Sagar Arun Kamble [this message]
2018-04-09 14:07     ` Chris Wilson
2018-03-16  6:04   ` Sagar Arun Kamble
2018-04-09 14:11     ` Chris Wilson
2018-03-14  9:37 ` [PATCH 16/36] drm/i915: Record logical context support in driver caps Chris Wilson
2018-03-14  9:37 ` [PATCH 17/36] drm/i915: Generalize i915_gem_sanitize() to reset contexts Chris Wilson
2018-03-14  9:37 ` [PATCH 18/36] drm/i915: Enable render context support for Ironlake (gen5) Chris Wilson
2018-03-14  9:37 ` [PATCH 19/36] drm/i915: Enable render context support for gen4 (Broadwater to Cantiga) Chris Wilson
2018-03-14  9:37 ` [PATCH 20/36] drm/i915: Remove obsolete min/max freq setters from debugfs Chris Wilson
2018-03-14 16:46   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 21/36] drm/i915: Split GT powermanagement functions to intel_gt_pm.c Chris Wilson
2018-03-16  6:23   ` Sagar Arun Kamble
2018-03-18 13:28   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 22/36] drm/i915: Move rps worker " Chris Wilson
2018-03-16  7:12   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 23/36] drm/i915: Move all the RPS irq handlers to intel_gt_pm Chris Wilson
2018-03-16  7:43   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 24/36] drm/i915: Track HAS_RPS alongside HAS_RC6 in the device info Chris Wilson
2018-03-16  8:10   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 25/36] drm/i915: Remove defunct intel_suspend_gt_powersave() Chris Wilson
2018-03-16  8:12   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 26/36] drm/i915: Reorder GT interface code Chris Wilson
2018-03-16  8:34   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 27/36] drm/i915: Split control of rps and rc6 Chris Wilson
2018-03-16  8:52   ` Sagar Arun Kamble
2018-03-16 13:03     ` Sagar Arun Kamble
2018-04-10 12:36       ` Chris Wilson
2018-03-14  9:37 ` [PATCH 28/36] drm/i915: Enabling rc6 and rps have different requirements, so separate them Chris Wilson
2018-03-16 14:01   ` Sagar Arun Kamble
2018-04-10 12:40     ` Chris Wilson
2018-03-14  9:37 ` [PATCH 29/36] drm/i915: Simplify rc6/rps enabling Chris Wilson
2018-03-16 14:28   ` Sagar Arun Kamble
2018-04-10 12:45     ` Chris Wilson
2018-03-14  9:37 ` [PATCH 30/36] drm/i915: Refactor frequency bounds computation Chris Wilson
2018-03-17 15:10   ` Sagar Arun Kamble
2018-04-10 12:49     ` Chris Wilson
2018-03-14  9:37 ` [PATCH 31/36] drm/i915: Don't fiddle with rps/rc6 across GPU reset Chris Wilson
2018-03-18 12:13   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 32/36] drm/i915: Rename rps min/max frequencies Chris Wilson
2018-03-18 17:13   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 33/36] drm/i915: Pull IPS into RPS Chris Wilson
2018-03-19  5:26   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 34/36] drm/i915, intel_ips: Enable GPU wait-boosting with IPS Chris Wilson
2018-03-14  9:37 ` [PATCH 35/36] drm/i915: Remove unwarranted clamping for hsw/bdw Chris Wilson
2018-03-19  7:32   ` Sagar Arun Kamble
2018-03-14  9:37 ` [PATCH 36/36] drm/i915: Support per-context user requests for GPU frequency control Chris Wilson
2018-03-19  9:51   ` Sagar Arun Kamble
2018-04-10 12:53     ` Chris Wilson
2018-11-09 17:51   ` Lionel Landwerlin
2018-11-16 11:14     ` Joonas Lahtinen
2018-11-16 11:22       ` Lionel Landwerlin
2018-03-14 10:03 ` ✗ Fi.CI.SPARSE: warning for series starting with [01/36] drm/i915/stolen: Switch from DEBUG_KMS to DEBUG_DRIVER Patchwork
2018-03-14 10:06 ` ✓ Fi.CI.BAT: success " Patchwork
2018-03-14 11:44 ` ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a012df7-2677-4c60-7907-d79b1a6aa0a5@intel.com \
    --to=sagar.a.kamble@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=praveen.paneri@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.