From: Daniel Vetter <daniel@ffwll.ch>
To: Keith Packard <keithp@keithp.com>
Cc: Dave Airlie <airlied@redhat.com>,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 18/21] drm/i915: Disable eDP VDD in a delayed work proc instead of synchronously
Date: Fri, 30 Sep 2011 20:47:00 +0200 [thread overview]
Message-ID: <20110930184700.GV2859@phenom.ffwll.local> (raw)
In-Reply-To: <1317344993-24945-19-git-send-email-keithp@keithp.com>
On Thu, Sep 29, 2011 at 06:09:50PM -0700, Keith Packard wrote:
> There's no good reason to turn off the eDP force VDD bit synchronously
> while probing devices; that just sticks a huge delay into all mode
> setting paths. Instead, queue a delayed work proc to disable the VDD
> force bit and then remember when that fires to ensure that the
> appropriate delay is respected before trying to turn it back on.
>
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
> drivers/gpu/drm/i915/intel_dp.c | 121 +++++++++++++++++++++++++++++++--------
> 1 files changed, 97 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index c7ccb46..08817b0 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -62,6 +62,9 @@ struct intel_dp {
> int panel_power_up_delay;
> int panel_power_down_delay;
> struct drm_display_mode *panel_fixed_mode; /* for eDP */
> + struct delayed_work panel_vdd_work;
> + bool want_panel_vdd;
> + unsigned long panel_off_jiffies;
> };
>
> /**
> @@ -611,7 +614,7 @@ intel_dp_i2c_aux_ch(struct i2c_adapter *adapter, int mode,
> }
>
> static void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp);
> -static void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp);
> +static void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync);
>
> static int
> intel_dp_i2c_init(struct intel_dp *intel_dp,
> @@ -634,7 +637,7 @@ intel_dp_i2c_init(struct intel_dp *intel_dp,
>
> ironlake_edp_panel_vdd_on(intel_dp);
> ret = i2c_dp_aux_add_bus(&intel_dp->adapter);
> - ironlake_edp_panel_vdd_off(intel_dp);
> + ironlake_edp_panel_vdd_off(intel_dp, false);
> return ret;
> }
>
> @@ -848,6 +851,23 @@ intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
> }
> }
>
> +static void ironlake_wait_panel_off(struct intel_dp *intel_dp)
> +{
> + unsigned long off_time;
> + unsigned long delay;
> + DRM_DEBUG_KMS("Wait for panel power off time\n");
> + off_time = intel_dp->panel_off_jiffies + msecs_to_jiffies(intel_dp->panel_power_down_delay);
> + if (time_after(jiffies, off_time)) {
> + DRM_DEBUG_KMS("Time already passed");
> + return;
> + }
> + delay = jiffies_to_msecs(off_time - jiffies);
> + if (delay > intel_dp->panel_power_down_delay)
> + delay = intel_dp->panel_power_down_delay;
> + DRM_DEBUG_KMS("Waiting an additional %ld ms\n", delay);
> + msleep(delay);
> +}
A cancel_work might be good here, not point in waking up the cpu for no
reason. And can you add "panel off timer: " to the deboug output?
> +
> static void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp)
> {
> struct drm_device *dev = intel_dp->base.base.dev;
> @@ -858,6 +878,16 @@ static void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp)
> return;
> DRM_DEBUG_KMS("Turn eDP VDD on\n");
>
> + WARN(intel_dp->want_panel_vdd,
> + "eDP VDD already requested on\n");
> +
> + intel_dp->want_panel_vdd = true;
> + if (ironlake_edp_have_panel_vdd(intel_dp)) {
> + DRM_DEBUG_KMS("eDP VDD already on\n");
> + return;
> + }
> +
> + ironlake_wait_panel_off(intel_dp);
> pp = I915_READ(PCH_PP_CONTROL);
> pp &= ~PANEL_UNLOCK_MASK;
> pp |= PANEL_UNLOCK_REGS;
> @@ -871,31 +901,64 @@ static void ironlake_edp_panel_vdd_on(struct intel_dp *intel_dp)
> * If the panel wasn't on, delay before accessing aux channel
> */
> if (!ironlake_edp_have_panel_power(intel_dp)) {
> + DRM_DEBUG_KMS("eDP was not running\n");
> msleep(intel_dp->panel_power_up_delay);
> - DRM_DEBUG_KMS("eDP VDD was not on\n");
> }
> }
>
> -static void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp)
> +static void ironlake_panel_vdd_off_sync(struct intel_dp *intel_dp)
> {
> struct drm_device *dev = intel_dp->base.base.dev;
> struct drm_i915_private *dev_priv = dev->dev_private;
> u32 pp;
>
> + if (!intel_dp->want_panel_vdd && ironlake_edp_have_panel_vdd(intel_dp)) {
> + pp = I915_READ(PCH_PP_CONTROL);
> + pp &= ~PANEL_UNLOCK_MASK;
> + pp |= PANEL_UNLOCK_REGS;
> + pp &= ~EDP_FORCE_VDD;
> + I915_WRITE(PCH_PP_CONTROL, pp);
> + POSTING_READ(PCH_PP_CONTROL);
> +
> + /* Make sure sequencer is idle before allowing subsequent activity */
> + DRM_DEBUG_KMS("PCH_PP_STATUS: 0x%08x PCH_PP_CONTROL: 0x%08x\n",
> + I915_READ(PCH_PP_STATUS), I915_READ(PCH_PP_CONTROL));
> + intel_dp->panel_off_jiffies = jiffies;
> + }
> +}
> +
> +static void ironlake_panel_vdd_work(struct work_struct *__work)
> +{
> + struct intel_dp *intel_dp = container_of(to_delayed_work(__work),
> + struct intel_dp, panel_vdd_work);
> + struct drm_device *dev = intel_dp->base.base.dev;
> +
> + mutex_lock(&dev->struct_mutex);
> + ironlake_panel_vdd_off_sync(intel_dp);
> + mutex_unlock(&dev->struct_mutex);
> +}
Like Chris already mentioned, s/struct_mutex/mode_config.mutex/ Maybe also
move the intel_dp->want_panel_vdd check in here - we need it only here to
avoid a race with vdd_on. I've almost overlooked it and already started to
write the complaint about the race ;-)
> +
> +static void ironlake_edp_panel_vdd_off(struct intel_dp *intel_dp, bool sync)
> +{
> if (!is_edp(intel_dp))
> return;
> - DRM_DEBUG_KMS("Turn eDP VDD off\n");
> - pp = I915_READ(PCH_PP_CONTROL);
> - pp &= ~PANEL_UNLOCK_MASK;
> - pp |= PANEL_UNLOCK_REGS;
> - pp &= ~EDP_FORCE_VDD;
> - I915_WRITE(PCH_PP_CONTROL, pp);
> - POSTING_READ(PCH_PP_CONTROL);
>
> - /* Make sure sequencer is idle before allowing subsequent activity */
> - DRM_DEBUG_KMS("PCH_PP_STATUS: 0x%08x PCH_PP_CONTROL: 0x%08x\n",
> - I915_READ(PCH_PP_STATUS), I915_READ(PCH_PP_CONTROL));
> - msleep(intel_dp->panel_power_down_delay);
> + DRM_DEBUG_KMS("Turn eDP VDD off %d\n", intel_dp->want_panel_vdd);
> + WARN(!intel_dp->want_panel_vdd, "eDP VDD not forced on");
> +
> + intel_dp->want_panel_vdd = false;
> +
> + if (sync) {
> + ironlake_panel_vdd_off_sync(intel_dp);
> + } else {
> + /*
> + * Queue the timer to fire a long
> + * time from now (relative to the power down delay)
> + * to keep the panel power up across a sequence of operations
> + */
> + schedule_delayed_work(&intel_dp->panel_vdd_work,
> + msecs_to_jiffies(intel_dp->panel_power_down_delay * 5));
> + }
> }
>
> /* Returns true if the panel was already on when called */
> @@ -908,6 +971,7 @@ static void ironlake_edp_panel_on (struct intel_dp *intel_dp)
> if (ironlake_edp_have_panel_power(intel_dp))
> return;
>
> + ironlake_wait_panel_off(intel_dp);
> pp = I915_READ(PCH_PP_CONTROL);
> pp &= ~PANEL_UNLOCK_MASK;
> pp |= PANEL_UNLOCK_REGS;
> @@ -951,7 +1015,6 @@ static void ironlake_edp_panel_off(struct drm_encoder *encoder)
> pp &= ~POWER_TARGET_ON;
> I915_WRITE(PCH_PP_CONTROL, pp);
> POSTING_READ(PCH_PP_CONTROL);
> - msleep(intel_dp->panel_power_down_delay);
>
> if (wait_for((I915_READ(PCH_PP_STATUS) & idle_off_mask) == 0, 5000))
> DRM_ERROR("panel off wait timed out: 0x%08x\n",
> @@ -960,6 +1023,7 @@ static void ironlake_edp_panel_off(struct drm_encoder *encoder)
> pp |= PANEL_POWER_RESET; /* restore panel reset bit */
> I915_WRITE(PCH_PP_CONTROL, pp);
> POSTING_READ(PCH_PP_CONTROL);
> + intel_dp->panel_off_jiffies = jiffies;
> }
>
> static void ironlake_edp_backlight_on (struct drm_device *dev)
> @@ -1053,7 +1117,7 @@ static void intel_dp_prepare(struct drm_encoder *encoder)
> /* Wake up the sink first */
> ironlake_edp_panel_vdd_on(intel_dp);
> intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> - ironlake_edp_panel_vdd_off(intel_dp);
> + ironlake_edp_panel_vdd_off(intel_dp, false);
>
> if (is_edp(intel_dp)) {
> ironlake_edp_backlight_off(dev);
> @@ -1077,7 +1141,7 @@ static void intel_dp_commit(struct drm_encoder *encoder)
>
> if (is_edp(intel_dp))
> ironlake_edp_panel_on(intel_dp);
> - ironlake_edp_panel_vdd_off(intel_dp);
> + ironlake_edp_panel_vdd_off(intel_dp, true);
>
> intel_dp_complete_link_train(intel_dp);
>
> @@ -1111,10 +1175,10 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode)
> intel_dp_start_link_train(intel_dp);
> if (is_edp(intel_dp))
> ironlake_edp_panel_on(intel_dp);
> - ironlake_edp_panel_vdd_off(intel_dp);
> + ironlake_edp_panel_vdd_off(intel_dp, true);
> intel_dp_complete_link_train(intel_dp);
> } else
> - ironlake_edp_panel_vdd_off(intel_dp);
> + ironlake_edp_panel_vdd_off(intel_dp, false);
Any reason why one vdd_off is sync while the other isn't?
> if (is_edp(intel_dp))
> ironlake_edp_backlight_on(dev);
> }
> @@ -1752,7 +1816,7 @@ intel_dp_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter)
>
> ironlake_edp_panel_vdd_on(intel_dp);
> edid = drm_get_edid(connector, adapter);
> - ironlake_edp_panel_vdd_off(intel_dp);
> + ironlake_edp_panel_vdd_off(intel_dp, false);
> return edid;
> }
>
> @@ -1764,7 +1828,7 @@ intel_dp_get_edid_modes(struct drm_connector *connector, struct i2c_adapter *ada
>
> ironlake_edp_panel_vdd_on(intel_dp);
> ret = intel_ddc_get_modes(connector, adapter);
> - ironlake_edp_panel_vdd_off(intel_dp);
> + ironlake_edp_panel_vdd_off(intel_dp, false);
> return ret;
> }
>
> @@ -1951,6 +2015,10 @@ static void intel_dp_encoder_destroy(struct drm_encoder *encoder)
>
> i2c_del_adapter(&intel_dp->adapter);
> drm_encoder_cleanup(encoder);
> + if (is_edp(intel_dp)) {
> + cancel_delayed_work_sync(&intel_dp->panel_vdd_work);
> + ironlake_panel_vdd_off_sync(intel_dp);
> + }
> kfree(intel_dp);
> }
>
> @@ -2087,8 +2155,11 @@ intel_dp_init(struct drm_device *dev, int output_reg)
> else if (output_reg == DP_D || output_reg == PCH_DP_D)
> intel_encoder->clone_mask = (1 << INTEL_DP_D_CLONE_BIT);
>
> - if (is_edp(intel_dp))
> + if (is_edp(intel_dp)) {
> intel_encoder->clone_mask = (1 << INTEL_EDP_CLONE_BIT);
> + INIT_DELAYED_WORK(&intel_dp->panel_vdd_work,
> + ironlake_panel_vdd_work);
> + }
>
> intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
> connector->interlace_allowed = true;
> @@ -2163,9 +2234,11 @@ intel_dp_init(struct drm_device *dev, int output_reg)
> DRM_DEBUG_KMS("panel power up delay %d, power down delay %d\n",
> intel_dp->panel_power_up_delay, intel_dp->panel_power_down_delay);
>
> + intel_dp->panel_off_jiffies = jiffies - intel_dp->panel_power_down_delay;
> +
> ironlake_edp_panel_vdd_on(intel_dp);
> ret = intel_dp_get_dpcd(intel_dp);
> - ironlake_edp_panel_vdd_off(intel_dp);
> + ironlake_edp_panel_vdd_off(intel_dp, false);
> if (ret) {
> if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11)
> dev_priv->no_aux_handshake =
> --
> 1.7.6.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Mail: daniel@ffwll.ch
Mobile: +41 (0)79 365 57 48
next prev parent reply other threads:[~2011-09-30 18:46 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-19 22:21 drm/i915: eDP cleanup patch series -- fixes SNB MacBook Air Keith Packard
2011-09-19 22:21 ` [PATCH 1/9] drm/i915: Enable digital port hotplug on PCH systems Keith Packard
2011-09-19 22:21 ` [PATCH 2/9] drm/i915: Remove extra 300ms delay during eDP mode setting Keith Packard
2011-09-19 22:21 ` [PATCH 3/9] drm/i915: Only use VBT panel mode on eDP if no EDID is found Keith Packard
2011-09-19 22:21 ` [PATCH 4/9] drm/i915: Check eDP power when doing aux channel communications Keith Packard
2011-09-19 22:21 ` [PATCH 5/9] drm/i915: Unlock PCH_PP_CONTROL always Keith Packard
2011-09-19 22:22 ` [PATCH 6/9] drm/i915: Make sure eDP power is on before using aux channel Keith Packard
2011-09-21 3:50 ` [Intel-gfx] " Jesse Barnes
2011-09-21 4:45 ` Keith Packard
2011-09-23 2:55 ` Jesse Barnes
2011-09-23 5:07 ` Keith Packard
2011-09-19 22:22 ` [PATCH 7/9] drm/i915: Correct eDP panel power sequencing delay computations Keith Packard
2011-09-19 22:22 ` [PATCH 8/9] drm/i915: Move eDP panel fixed mode from dev_priv to intel_dp Keith Packard
2011-09-19 22:22 ` [PATCH 9/9] drm/i915: Disable eDP VDD in a delayed work proc instead of synchronously Keith Packard
2011-09-21 4:17 ` [Intel-gfx] " Jesse Barnes
2011-09-21 4:51 ` Keith Packard
2011-09-23 3:22 ` Jesse Barnes
2011-09-30 1:09 ` [PATCH 00/24] MacBook Air patch sequence (v2) Keith Packard
2011-09-30 1:09 ` [PATCH 01/21] drm/i915: Enable digital port hotplug on PCH systems Keith Packard
2011-09-30 16:17 ` [Intel-gfx] " Daniel Vetter
2011-10-03 20:34 ` Jesse Barnes
2011-09-30 1:09 ` [PATCH 02/21] drm/i915: Shut down PCH interrupts during irq_uninstall Keith Packard
2011-09-30 16:20 ` Daniel Vetter
2011-09-30 17:44 ` Keith Packard
2011-09-30 17:56 ` Daniel Vetter
2011-09-30 1:09 ` [PATCH 03/21] drm/i915: Remove extra 300ms delay during eDP mode setting Keith Packard
2011-09-30 16:27 ` Daniel Vetter
2011-09-30 17:50 ` Keith Packard
2011-09-30 17:58 ` Daniel Vetter
2011-09-30 18:09 ` Daniel Vetter
2011-09-30 18:28 ` Keith Packard
2011-09-30 1:09 ` [PATCH 04/21] drm/i915: Only use VBT panel mode on eDP if no EDID is found Keith Packard
2011-09-30 16:32 ` Daniel Vetter
2011-09-30 17:58 ` Keith Packard
2011-10-03 20:42 ` [Intel-gfx] " Jesse Barnes
2011-09-30 1:09 ` [PATCH 05/21] drm/i915: Check eDP power when doing aux channel communications Keith Packard
2011-09-30 17:02 ` [Intel-gfx] " Daniel Vetter
2011-09-30 18:01 ` Keith Packard
2011-09-30 18:11 ` Daniel Vetter
2011-09-30 18:23 ` Chris Wilson
2011-10-03 20:48 ` Jesse Barnes
2011-09-30 1:09 ` [PATCH 06/21] drm/i915: Unlock PCH_PP_CONTROL always Keith Packard
2011-09-30 17:09 ` [Intel-gfx] " Daniel Vetter
2011-09-30 18:01 ` Keith Packard
2011-09-30 23:14 ` Keith Packard
2011-10-01 9:35 ` Daniel Vetter
2011-09-30 1:09 ` [PATCH 07/21] drm/i915: Check for eDP inside intel_edp_panel_vdd_on/off Keith Packard
2011-09-30 17:13 ` [Intel-gfx] " Daniel Vetter
2011-09-30 18:02 ` Keith Packard
2011-09-30 1:09 ` [PATCH 08/21] drm/i915: Turn force VDD back off when panel running in intel_dp_dpms Keith Packard
2011-09-30 17:15 ` [Intel-gfx] " Daniel Vetter
2011-09-30 1:09 ` [PATCH 09/21] drm/i915: Delay DP i2c initialization until panel power timings are computed Keith Packard
2011-09-30 17:25 ` [Intel-gfx] " Daniel Vetter
2011-09-30 1:09 ` [PATCH 10/21] drm/i915: Wrap DP EDID fetch functions to enable eDP panel power Keith Packard
2011-09-30 17:32 ` Daniel Vetter
2011-10-03 20:59 ` [Intel-gfx] " Jesse Barnes
2011-09-30 1:09 ` [PATCH 11/21] drm/i915: Enable eDP panel power during I2C initialization sequence Keith Packard
2011-09-30 17:26 ` Daniel Vetter
2011-09-30 1:09 ` [PATCH 12/21] drm/i915: Ensure eDP powered up during DP_SET_POWER operation in dp_prepare Keith Packard
2011-09-30 17:45 ` Daniel Vetter
2011-09-30 18:30 ` Keith Packard
2011-09-30 1:09 ` [PATCH 13/21] drm/i915: Place long delays after each eDP VDD operation Keith Packard
2011-09-30 18:01 ` [Intel-gfx] " Daniel Vetter
2011-09-30 18:31 ` Keith Packard
2011-09-30 1:09 ` [PATCH 14/21] drm/i915: Correct eDP panel power sequencing delay computations Keith Packard
2011-09-30 18:16 ` Daniel Vetter
2011-09-30 18:33 ` Keith Packard
2011-10-01 3:31 ` Keith Packard
2011-10-01 9:59 ` Daniel Vetter
2011-10-01 19:01 ` Keith Packard
2011-10-03 10:10 ` Daniel Vetter
2011-09-30 1:09 ` [PATCH 15/21] drm/i915: Move eDP panel fixed mode from dev_priv to intel_dp Keith Packard
2011-09-30 18:20 ` [Intel-gfx] " Daniel Vetter
2011-09-30 1:09 ` [PATCH 16/21] drm/i915: edp_panel_on does not need to return a bool Keith Packard
2011-09-30 18:21 ` Daniel Vetter
2011-10-03 21:03 ` [Intel-gfx] " Jesse Barnes
2011-09-30 1:09 ` [PATCH 17/21] drm/i915: Create helper functions to determine eDP power state Keith Packard
2011-09-30 18:26 ` [Intel-gfx] " Daniel Vetter
2011-09-30 1:09 ` [PATCH 18/21] drm/i915: Disable eDP VDD in a delayed work proc instead of synchronously Keith Packard
2011-09-30 10:31 ` Chris Wilson
2011-09-30 18:06 ` Keith Packard
2011-09-30 18:47 ` Daniel Vetter [this message]
2011-09-30 20:56 ` Keith Packard
2011-09-30 22:01 ` Daniel Vetter
2011-09-30 1:09 ` [PATCH 19/21] drm/i915: Asynchronous eDP panel power off Keith Packard
2011-09-30 18:55 ` Daniel Vetter
2011-09-30 20:57 ` Keith Packard
2011-10-12 14:41 ` Dave Airlie
2011-10-12 16:43 ` Keith Packard
2011-09-30 1:09 ` [PATCH 20/21] drm/i915: Restrict ILK-specific eDP power hack to ILK Keith Packard
2011-09-30 18:57 ` Daniel Vetter
2011-09-30 1:09 ` [PATCH 21/21] drm/i915: No need to wait for eDP power off delay if panel is on Keith Packard
2011-09-30 19:01 ` Daniel Vetter
2011-09-30 3:33 ` [PATCH 00/24] MacBook Air patch sequence (v2) Greg KH
2011-09-30 8:58 ` Keith Packard
2011-09-30 13:57 ` Greg KH
2011-09-30 18:10 ` Keith Packard
2011-09-30 13:20 ` Ted Ts'o
2011-09-30 18:17 ` Keith Packard
2011-10-03 21:06 ` [Intel-gfx] " Jesse Barnes
2011-10-11 8:04 ` Chris Wilson
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=20110930184700.GV2859@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=keithp@keithp.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome