From mboxrd@z Thu Jan 1 00:00:00 1970 From: Imre Deak Subject: Re: [PATCH 2/3] drm/i915: Generalize drain latency computation Date: Thu, 31 Jul 2014 16:33:09 +0300 Message-ID: <1406813589.18327.30.camel@intelbox> References: <1405515245-14946-1-git-send-email-gajanan.bhat@intel.com> <1405515245-14946-3-git-send-email-gajanan.bhat@intel.com> Reply-To: imre.deak@intel.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0972393570==" Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FB9E6E1FA for ; Thu, 31 Jul 2014 06:34:23 -0700 (PDT) In-Reply-To: <1405515245-14946-3-git-send-email-gajanan.bhat@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Gajanan Bhat Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============0972393570== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-AybCt4DkLYavNxfUKbWG" --=-AybCt4DkLYavNxfUKbWG Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2014-07-16 at 18:24 +0530, Gajanan Bhat wrote: > Modify drain latency computation to use it for any plane. Same function c= an be > used for primary, cursor and sprite planes. >=20 > Signed-off-by: Gajanan Bhat > --- > drivers/gpu/drm/i915/i915_reg.h | 1 + > drivers/gpu/drm/i915/intel_pm.c | 82 ++++++++++++++++++++++-----------= ------ > 2 files changed, 47 insertions(+), 36 deletions(-) >=20 > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_= reg.h > index d2a220b..a1260a2 100644 > --- a/drivers/gpu/drm/i915/i915_reg.h > +++ b/drivers/gpu/drm/i915/i915_reg.h > @@ -3877,6 +3877,7 @@ enum punit_power_well { > #define DDL_PLANE_PRECISION_64 (1<<7) > #define DDL_PLANE_PRECISION_32 (0<<7) > #define DDL_PLANE_SHIFT 0 > +#define DRAIN_LATENCY_MAX 0x7f _MASK is the standard postfix in the driver. > =20 > /* FIFO watermark sizes etc */ > #define G4X_FIFO_LINE_SIZE 64 > diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel= _pm.c > index 90df1e8..f3a3e90 100644 > --- a/drivers/gpu/drm/i915/intel_pm.c > +++ b/drivers/gpu/drm/i915/intel_pm.c > @@ -1268,33 +1268,21 @@ static bool g4x_compute_srwm(struct drm_device *d= ev, > display, cursor); > } > =20 > -static bool vlv_compute_drain_latency(struct drm_device *dev, > - int plane, > - int *plane_prec_mult, > - int *plane_dl, > - int *cursor_prec_mult, > - int *cursor_dl) > +static bool vlv_compute_drain_latency(struct drm_crtc *crtc, > + int pixel_size, > + int *prec_mult, > + int *drain_latency) > { > - struct drm_crtc *crtc; > - int clock, pixel_size; > int entries; > + int clock =3D to_intel_crtc(crtc)->config.adjusted_mode.crtc_clock; > =20 > - crtc =3D intel_get_crtc_for_plane(dev, plane); > - if (!intel_crtc_active(crtc)) > + if (clock =3D=3D 0 || pixel_size =3D=3D 0) This would mean a driver bug, so needs to be wrapped in a WARN(). > return false; > =20 > - clock =3D to_intel_crtc(crtc)->config.adjusted_mode.crtc_clock; > - pixel_size =3D crtc->primary->fb->bits_per_pixel / 8; /* BPP */ > - > - entries =3D (clock / 1000) * pixel_size; > - *plane_prec_mult =3D (entries > 128) ? > - DRAIN_LATENCY_PRECISION_64 : DRAIN_LATENCY_PRECISION_32; > - *plane_dl =3D (64 * (*plane_prec_mult) * 4) / entries; > - > - entries =3D (clock / 1000) * 4; /* BPP is always 4 for cursor */ > - *cursor_prec_mult =3D (entries > 128) ? > - DRAIN_LATENCY_PRECISION_64 : DRAIN_LATENCY_PRECISION_32; > - *cursor_dl =3D (64 * (*cursor_prec_mult) * 4) / entries; > + entries =3D DIV_ROUND_UP(clock, 1000) * pixel_size; > + *prec_mult =3D (entries > 128) ? DRAIN_LATENCY_PRECISION_64 : > + DRAIN_LATENCY_PRECISION_32; > + *drain_latency =3D (64 * (*prec_mult) * 4) / entries; > =20 > return true; > } > @@ -1309,24 +1297,46 @@ static bool vlv_compute_drain_latency(struct drm_= device *dev, > =20 > static void vlv_update_drain_latency(struct drm_crtc *crtc) > { > - struct drm_device *dev =3D crtc->dev; > - struct drm_i915_private *dev_priv =3D dev->dev_private; > + struct drm_i915_private *dev_priv =3D crtc->dev->dev_private; > + int pixel_size; > + int drain_latency; > enum pipe pipe =3D to_intel_crtc(crtc)->pipe; > - int plane_prec, plane_dl; > - int cursor_prec, cursor_dl; > - int plane_prec_mult, cursor_prec_mult; > + int plane_prec, prec_mult, plane_dl; > =20 > - if (vlv_compute_drain_latency(dev, pipe, &plane_prec_mult, &plane_dl, > - &cursor_prec_mult, &cursor_dl)) { > - cursor_prec =3D (cursor_prec_mult =3D=3D DRAIN_LATENCY_PRECISION_64) ? > - DDL_CURSOR_PRECISION_64 : DDL_CURSOR_PRECISION_32; > - plane_prec =3D (plane_prec_mult =3D=3D DRAIN_LATENCY_PRECISION_64) ? > - DDL_PLANE_PRECISION_64 : DDL_PLANE_PRECISION_32; > + plane_dl =3D I915_READ(VLV_DDL(pipe)) & ~DDL_PLANE_PRECISION_64 & > + ~DRAIN_LATENCY_MAX & ~DDL_CURSOR_PRECISION_64 & > + ~(DRAIN_LATENCY_MAX << DDL_CURSOR_SHIFT); A tad simpler and more standard way for masking is ~(X | Y | Z). =20 > - I915_WRITE(VLV_DDL(pipe), cursor_prec | > - (cursor_dl << DDL_CURSOR_SHIFT) | > - plane_prec | (plane_dl << DDL_PLANE_SHIFT)); > + if (!intel_crtc_active(crtc)) { > + I915_WRITE(VLV_DDL(pipe), plane_dl); > + return; > } > + > + /* Primary plane Drain Latency */ > + pixel_size =3D crtc->primary->fb->bits_per_pixel / 8; /* BPP */ > + if (vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, &drain_late= ncy)) { > + plane_prec =3D (prec_mult =3D=3D DRAIN_LATENCY_PRECISION_64) ? > + DDL_PLANE_PRECISION_64 : > + DDL_PLANE_PRECISION_32; > + plane_dl =3D plane_dl | plane_prec | drain_latency; > + } > + > + /* Cursor Drain Latency > + * BPP is always 4 for cursor > + */ > + pixel_size =3D 4; > + > + /* Program cursor DL only if it is enabled */ > + if ((I915_READ(CURCNTR(pipe)) & CURSOR_MODE) && Checking intel_crtc->cursor_base would be cheaper. > + vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, &drain_late= ncy)) { > + plane_prec =3D (prec_mult =3D=3D DRAIN_LATENCY_PRECISION_64) ? > + DDL_CURSOR_PRECISION_64 : > + DDL_CURSOR_PRECISION_32; > + plane_dl =3D plane_dl | plane_prec | > + drain_latency << DDL_CURSOR_SHIFT; This would overwrite the above assignment of plane_dl. > + } > + > + I915_WRITE(VLV_DDL(pipe), plane_dl); > } > =20 > #define single_plane_enabled(mask) is_power_of_2(mask) --=-AybCt4DkLYavNxfUKbWG 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.14 (GNU/Linux) iQEcBAABAgAGBQJT2kWVAAoJEORIIAnNuWDFIyYH/R4zYs5BfYjiJ06SP2/wmQ+7 +H8uQPsXJG5K1aWxbO8kkr67+/A8ZjtN8GT1/r6cvLpqVzlQz7SKJWq0MkvgqrKp aLucZguVlSuYUN0Mm8JJmLCjJ/wfJOO+m/vWBaJ5+cmQmmd1Tieyqk1ocQbPV5Yg 8ObttjFHgbTUGDybU0NkqS+UfDE8RAA4EClRoveDjqeLYFu/hESj1cj+GYEpTXX4 I/cL6kEc2om3P0LiwRNWdvXK2lakAZr2/XKV1GRIHLJoFhtTY1PHpU8dJsgDIwWs /cY8gwOgogyV5BN893nmwh30p6TreRAh6QkWigwDN3MvdEifcQCfBvPeNlf8VAo= =dKR/ -----END PGP SIGNATURE----- --=-AybCt4DkLYavNxfUKbWG-- --===============0972393570== 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 --===============0972393570==--