From patchwork Thu Feb 18 16:56:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 8352251 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0D34BC0553 for ; Thu, 18 Feb 2016 16:56:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B8EB20376 for ; Thu, 18 Feb 2016 16:56:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 140742039E for ; Thu, 18 Feb 2016 16:56:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A7196ECAE; Thu, 18 Feb 2016 16:56:13 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk0-x234.google.com (mail-qk0-x234.google.com [IPv6:2607:f8b0:400d:c09::234]) by gabe.freedesktop.org (Postfix) with ESMTPS id 409046ECAF for ; Thu, 18 Feb 2016 16:56:11 +0000 (UTC) Received: by mail-qk0-x234.google.com with SMTP id s5so20764956qkd.0 for ; Thu, 18 Feb 2016 08:56:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ZkIrANdvUqc6XqrvW+a7bTUFV4pfTOJSC8kSAvQ4icA=; b=sfdGcUR7f/icBYGs+uVY7DQ9xgbDdVu9TDkARB+Ar9Ic+uFdBFsOZ9dPKCLjWT24y8 XNg2PX+l/puWHxUnEj/skO33iMk/8Ms5aj7fDc2AU657z4iUlzDY63OBBmb9U1ihoK+e eGymvmyIY1XZ6xyxB6gNx6zhxb4/2FZZThfyQmkgno4booLnpB04/e/aeF4d6IqgMK18 DHeGYdt+ZH5lFILhHCpkDX7W45tps7ZTi28HHdKbE1/pc/fwZMWKFAgNrHVtumkUFmgV /AELgjD6Fsv9XnflVWfQQxQm7NAMN+Oav5pYdNFBxcYxuJMo4TXRSeesSkgOziAIJB1b ZG1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=ZkIrANdvUqc6XqrvW+a7bTUFV4pfTOJSC8kSAvQ4icA=; b=XDNCx5ME1+jplkLArTdBFIAbm35kODBYLy3X69BWY93O3rJtpoCVFPcFSxkcddCsCS XFdm4ufXuLfokS78dZuGjUs29CsnCTnBJv8olexGkh7/JY11llq4tvRsivZ70ky68oVR BDm0ECLNpbR1ogmqxagKd0N1tD4p0pE/1sCUWGJGin27owPx7woHutnZr2OopK+a7IVx ngttbm4sip9yKujYiXZ+X9aEpmcVclsizlCML46UGSqq9Udvj/oZVOz1+TE4XMaDLm5M 9CE6ZWa/KV+H91MD3vEN9HwdUKK0XM7L8impPndrRnpu/cNQWmkFSFIAB2wNrxAWhsui uKcQ== X-Gm-Message-State: AG10YOQGONAuJVS+p9rsw/Kg3Df+xnLia0m7FZnnfFcqsKpF92KYVs+13knDLcdRmkXNjpeb07oSB7XP81hX5w== MIME-Version: 1.0 X-Received: by 10.55.16.36 with SMTP id a36mr10383699qkh.45.1455814570366; Thu, 18 Feb 2016 08:56:10 -0800 (PST) Received: by 10.140.28.164 with HTTP; Thu, 18 Feb 2016 08:56:10 -0800 (PST) In-Reply-To: References: <1455210047-1574-1-git-send-email-rodrigo.vivi@intel.com> <20160216155013.GO32705@phenom.ffwll.local> Date: Thu, 18 Feb 2016 08:56:10 -0800 Message-ID: From: Rodrigo Vivi To: Imre Deak , patrik.jakobsson@intel.com, intel-gfx Subject: [Intel-gfx] Fwd: [PATCH] drm/i915: Avoid vblank counter for gen9+ X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Imre, Patrik, do you know if I'm missing something or what I'm doing wrong with this power domain handler for vblanks to avoid DC states when we need a reliable frame counter in place. Do you have better ideas? Thanks, Rodrigo. ---------- Forwarded message ---------- From: Rodrigo Vivi Date: Wed, Feb 17, 2016 at 3:14 PM Subject: Re: [Intel-gfx] [PATCH] drm/i915: Avoid vblank counter for gen9+ To: Daniel Vetter , Patrik Jakobsson Cc: Rodrigo Vivi , intel-gfx On Tue, Feb 16, 2016 at 7:50 AM, Daniel Vetter wrote: > On Thu, Feb 11, 2016 at 09:00:47AM -0800, Rodrigo Vivi wrote: >> Framecounter register is read-only so DMC cannot restore it >> after exiting DC5 and DC6. >> >> Easiest way to go is to avoid the counter and use vblank >> interruptions for this platform and for all the following >> ones since DMC came to stay. At least while we can't change >> this register to read-write. >> >> Signed-off-by: Rodrigo Vivi > > Now my comments also in public: > - Do we still get reasonable dc5 residency with this - it means we'll keep > vblank irq running forever. > > - I'm a bit unclear on what exactly this fixes - have you tested that > long-lasting vblank waits are still accurate? Just want to make sure we > don't just paper over the issue and desktops can still get stuck waiting > for a vblank. apparently no... so please just ignore this patch for now... after a while with that patch I was seeing the issue again... > > Just a bit suprised that the only problem is the framecounter, and not > that vblanks stop happening too. > > We need to also know these details for the proper fix, which will involve > grabbing power well references (might need a new one for vblank > interrupts) to make sure. Yeap, I liked this idea... so combining a power domain reference with a vblank count restore once we know the dc off is blocked we could workaround this case... something like: @@ -2796,6 +2799,8 @@ static void gen8_disable_vblank(struct drm_device *dev, unsigned int pipe) spin_lock_irqsave(&dev_priv->irq_lock, irqflags); bdw_disable_pipe_irq(dev_priv, pipe, GEN8_PIPE_VBLANK); spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); + + intel_display_power_put(dev_priv, POWER_DOMAIN_VBLANK); } where POWER_DOMAIN_VBLANK is part of: #define SKL_DISPLAY_DC_OFF_POWER_DOMAINS ( \ BIT(POWER_DOMAIN_VBLANK) | \ However I have my dmesg flooded by: [ 69.025562] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:955 [ 69.025576] in_atomic(): 1, irqs_disabled(): 1, pid: 995, name: Xorg [ 69.025582] Preemption disabled at:[] drm_vblank_get+0x4e/0xd0 [ 69.025619] CPU: 3 PID: 995 Comm: Xorg Tainted: G U W 4.5.0-rc4+ #11 [ 69.025628] Hardware name: Intel Corporation Kabylake Client platform/Skylake U DDR3L RVP7, BIOS KBLSE2R1.R00.X019.B01.1512230743 12/23/2015 [ 69.025637] 0000000000000000 ffff88003f0bfbb0 ffffffff8148e983 0000000000000000 [ 69.025653] ffff880085b04200 ffff88003f0bfbd0 ffffffff81133ece ffffffff81d77f23 [ 69.025667] 00000000000003bb ffff88003f0bfbf8 ffffffff81133f89 ffff88016913a098 [ 69.025680] Call Trace: [ 69.025697] [] dump_stack+0x65/0x92 [ 69.025711] [] ___might_sleep+0x10e/0x180 [ 69.025722] [] __might_sleep+0x49/0x80 [ 69.025739] [] __pm_runtime_resume+0x79/0x80 [ 69.025841] [] intel_runtime_pm_get+0x28/0x90 [i915] [ 69.025924] [] intel_display_power_get+0x19/0x50 [i915] [ 69.025995] [] gen8_enable_vblank+0x34/0xc0 [i915] [ 69.026016] [] drm_vblank_enable+0x76/0xd0 Another thing that I search in the spec was for an Interrupt to know when we came back from DC5 or DC6 or got power well re-enabled, so we would be able to restore the drm last counter... but I couldn't find any... Any other idea? > > Cheers, Daniel > >> --- >> drivers/gpu/drm/i915/i915_irq.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c >> index 25a8937..c294a4b 100644 >> --- a/drivers/gpu/drm/i915/i915_irq.c >> +++ b/drivers/gpu/drm/i915/i915_irq.c >> @@ -4556,7 +4556,10 @@ void intel_irq_init(struct drm_i915_private *dev_priv) >> >> pm_qos_add_request(&dev_priv->pm_qos, PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE); >> >> - if (IS_GEN2(dev_priv)) { >> + if (INTEL_INFO(dev_priv)->gen >= 9) { >> + dev->max_vblank_count = 0; >> + dev->driver->get_vblank_counter = g4x_get_vblank_counter; >> + } else if (IS_GEN2(dev_priv)) { >> dev->max_vblank_count = 0; >> dev->driver->get_vblank_counter = i8xx_get_vblank_counter; >> } else if (IS_G4X(dev_priv) || INTEL_INFO(dev_priv)->gen >= 5) { >> @@ -4572,7 +4575,7 @@ void intel_irq_init(struct drm_i915_private *dev_priv) >> * Gen2 doesn't have a hardware frame counter and so depends on >> * vblank interrupts to produce sane vblank seuquence numbers. >> */ >> - if (!IS_GEN2(dev_priv)) >> + if (!IS_GEN2(dev_priv) && !INTEL_INFO(dev_priv)->gen >= 9) >> dev->vblank_disable_immediate = true; >> >> dev->driver->get_vblank_timestamp = i915_get_vblank_timestamp; >> -- >> 2.4.3 >> >> _______________________________________________ >> Intel-gfx mailing list >> Intel-gfx@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/intel-gfx > > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx --- Rodrigo Vivi Blog: http://blog.vivi.eng.br diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 25a8937..2b18778 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -2743,7 +2743,10 @@ static int gen8_enable_vblank(struct drm_device *dev, unsigned int pipe) struct drm_i915_private *dev_priv = dev->dev_private; unsigned long irqflags; + intel_display_power_get(dev_priv, POWER_DOMAIN_VBLANK); + spin_lock_irqsave(&dev_priv->irq_lock, irqflags); + dev->vblank[pipe].last = g4x_get_vblank_counter(dev, pipe); bdw_enable_pipe_irq(dev_priv, pipe, GEN8_PIPE_VBLANK); spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags);