From mboxrd@z Thu Jan 1 00:00:00 1970 From: Imre Deak Subject: Re: [PATCH 05/19] drm/i915: add initial Runtime PM functions Date: Mon, 02 Dec 2013 14:23:03 +0200 Message-ID: <1385986983.16543.1.camel@intelbox> References: <1385048853-1579-1-git-send-email-przanoni@gmail.com> <1385048853-1579-6-git-send-email-przanoni@gmail.com> Reply-To: imre.deak@intel.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2079067992==" Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 26A3BFA8DA for ; Mon, 2 Dec 2013 04:23:24 -0800 (PST) In-Reply-To: <1385048853-1579-6-git-send-email-przanoni@gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: Paulo Zanoni Cc: intel-gfx@lists.freedesktop.org, Paulo Zanoni List-Id: intel-gfx@lists.freedesktop.org --===============2079067992== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-1g6Gu034CRZKDusRdUQX" --=-1g6Gu034CRZKDusRdUQX Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2013-11-21 at 13:47 -0200, Paulo Zanoni wrote: > From: Paulo Zanoni >=20 > This patch adds the initial infrastructure to allow a Runtime PM > implementation that sets the device to its D3 state. The patch just > adds the necessary callbacks and the initial infrastructure. >=20 > We still don't have any platform that actually uses this > infrastructure, we still don't call get/put in all the places we need > to, and we don't have any function to save/restore the state of the > registers. This is not a problem since no platform uses the code added > by this patch. We have a few people simultaneously working on runtime > PM, so this initial code could help everybody make their plans. >=20 > V2: - Move some functions to intel_pm.c > - Remove useless pm_runtime_allow() call at init > - Remove useless pm_runtime_mark_last_busy() call at get > - Use pm_runtime_get_sync() instead of 2 calls > - Add a WARN to check if we're really awake >=20 > Signed-off-by: Paulo Zanoni > --- > drivers/gpu/drm/i915/i915_dma.c | 6 ++++ > drivers/gpu/drm/i915/i915_drv.c | 42 ++++++++++++++++++++++++++++ > drivers/gpu/drm/i915/i915_drv.h | 7 +++++ > drivers/gpu/drm/i915/intel_drv.h | 4 +++ > drivers/gpu/drm/i915/intel_pm.c | 56 +++++++++++++++++++++++++++++++= ++++++ > drivers/gpu/drm/i915/intel_uncore.c | 9 ++++++ > 6 files changed, 124 insertions(+) > [...] > diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel= _pm.c > index 6bd0fc6..ef5e274 100644 > --- a/drivers/gpu/drm/i915/intel_pm.c > +++ b/drivers/gpu/drm/i915/intel_pm.c > @@ -31,6 +31,7 @@ > #include "../../../platform/x86/intel_ips.h" > #include > #include > +#include > =20 > /** > * RC6 is a special power stage which allows the GPU to enter an very > @@ -5878,6 +5879,61 @@ void intel_aux_display_runtime_put(struct drm_i915= _private *dev_priv) > hsw_enable_package_c8(dev_priv); > } > =20 > +void intel_runtime_pm_get(struct drm_i915_private *dev_priv) > +{ > + struct drm_device *dev =3D dev_priv->dev; > + struct device *device =3D &dev->pdev->dev; > + > + if (!HAS_RUNTIME_PM(dev)) > + return; > + > + pm_runtime_get_sync(device); > + WARN(dev_priv->pm.suspended, "Device still suspended.\n"); > +} > + > +void intel_runtime_pm_put(struct drm_i915_private *dev_priv) > +{ > + struct drm_device *dev =3D dev_priv->dev; > + struct device *device =3D &dev->pdev->dev; > + > + if (!HAS_RUNTIME_PM(dev)) > + return; > + > + pm_runtime_mark_last_busy(device); > + pm_runtime_put_autosuspend(device); > +} > + > +void intel_init_runtime_pm(struct drm_i915_private *dev_priv) > +{ > + struct drm_device *dev =3D dev_priv->dev; > + struct device *device =3D &dev->pdev->dev; > + > + dev_priv->pm.suspended =3D false; > + > + if (!HAS_RUNTIME_PM(dev)) > + return; > + > + pm_runtime_set_active(device); > + pm_runtime_enable(device); This will generate a warning as you get here with an already enabled state. --Imre > + pm_runtime_set_autosuspend_delay(device, 10000); /* 10s */ > + pm_runtime_mark_last_busy(device); > + pm_runtime_use_autosuspend(device); > +} > + > +void intel_fini_runtime_pm(struct drm_i915_private *dev_priv) > +{ > + struct drm_device *dev =3D dev_priv->dev; > + struct device *device =3D &dev->pdev->dev; > + > + if (!HAS_RUNTIME_PM(dev)) > + return; > + > + /* Make sure we're not suspended first. */ > + pm_runtime_get_sync(device); > + pm_runtime_disable(device); > +} > + > /* Set up chip specific power management-related functions */ > void intel_init_pm(struct drm_device *dev) > { > diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/i= ntel_uncore.c > index eac5661..ddd9084 100644 > --- a/drivers/gpu/drm/i915/intel_uncore.c > +++ b/drivers/gpu/drm/i915/intel_uncore.c > @@ -346,6 +346,13 @@ hsw_unclaimed_reg_check(struct drm_i915_private *dev= _priv, u32 reg) > } > } > =20 > +static void > +assert_device_not_suspended(struct drm_i915_private *dev_priv) > +{ > + WARN(HAS_RUNTIME_PM(dev_priv->dev) && dev_priv->pm.suspended, > + "Device suspended\n"); > +} > + > #define REG_READ_HEADER(x) \ > unsigned long irqflags; \ > u##x val =3D 0; \ > @@ -438,6 +445,7 @@ gen6_write##x(struct drm_i915_private *dev_priv, off_= t reg, u##x val, bool trace > if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ > __fifo_ret =3D __gen6_gt_wait_for_fifo(dev_priv); \ > } \ > + assert_device_not_suspended(dev_priv); \ > __raw_i915_write##x(dev_priv, reg, val); \ > if (unlikely(__fifo_ret)) { \ > gen6_gt_check_fifodbg(dev_priv); \ > @@ -453,6 +461,7 @@ hsw_write##x(struct drm_i915_private *dev_priv, off_t= reg, u##x val, bool trace) > if (NEEDS_FORCE_WAKE((dev_priv), (reg))) { \ > __fifo_ret =3D __gen6_gt_wait_for_fifo(dev_priv); \ > } \ > + assert_device_not_suspended(dev_priv); \ > hsw_unclaimed_reg_clear(dev_priv, reg); \ > __raw_i915_write##x(dev_priv, reg, val); \ > if (unlikely(__fifo_ret)) { \ --=-1g6Gu034CRZKDusRdUQX Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAABAgAGBQJSnHunAAoJEORIIAnNuWDFY/oH/i9yHh15PJZg3rhbHR/bmNhH Y4Fxz4Kb5oDznfWVuSrsFsNL8cp2HvPbpUpxxM+s+P2o2GQ3xvqNvjRl0sAFaS+8 0oeazqfeD9A0MjxckIbZT9ZvPhdg0f4X9TvFSsIV+ATrfmQNfIS61SAP0LEO/keZ c8k436C5Ecri1o5I4Xr6ke6oCwCEncNuSLXox9nSqAxDoagKARY5yidI+tPUS66u ZY9wybaJvszVG3puyfrpaZ5Bf7IkoPlSr7nzrLAxfTnDX3fx9YvT8SF4fd4O/xA7 DzXtwwx/ysJORdICIpsEUxxHcb1sfVGNbwoSVdiVXMRxxySF3z0J1j93JgcBF7I= =KMdD -----END PGP SIGNATURE----- --=-1g6Gu034CRZKDusRdUQX-- --===============2079067992== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============2079067992==--