From patchwork Fri Feb 19 01:06:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 8355231 Return-Path: X-Original-To: patchwork-dri-devel@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 5C2C9C0553 for ; Fri, 19 Feb 2016 01:07:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 657CC2038D for ; Fri, 19 Feb 2016 01:07:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 67A57203B1 for ; Fri, 19 Feb 2016 01:07:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9FECE6E3DF; Fri, 19 Feb 2016 01:07:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) by gabe.freedesktop.org (Postfix) with ESMTPS id BD12E6E3DF for ; Fri, 19 Feb 2016 01:06:59 +0000 (UTC) Received: by mail-wm0-x22e.google.com with SMTP id a4so49938490wme.1 for ; Thu, 18 Feb 2016 17:06:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yaFEOhgwtSi6WeKTg44ty0fLMnrwjRlrdOHJBO3MiLQ=; b=aUoXrtBLJRchYWK8sKCUWbDPWTaZ7E33rlGthXF36W34GBYY+sBh/HRDbxJFSgdQeo 0h9M9mwd6hTp6l7VqgD5EGejB3LcRn9jBiBIB4OpCdXlSQGAXkSXWhH26hM/nTz+vFNP 8QHdyxRV9H1VrWFGqVmt3bTrzvMiYWiODwCXYF6uFED6+oGPkRvgmNrsDxkvIEhD2deS csgi3Er/Nw8X0oTlVTZCmCndohlHKx9qL58HUSE3qou88M2oxvw0hQxsbSiMter3bZ3q d2/ly9M5UypvR5y+4nR7ilLeFCgDAAGMwB7JiT9R07zB94xh2dEnNWm0/b84Lz6XGL3g zZAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yaFEOhgwtSi6WeKTg44ty0fLMnrwjRlrdOHJBO3MiLQ=; b=fRxr/h6U36i1HI2lKMW6aurO+RIWESTH338hQwuhlvwCDmQFJB8P2LvQBGXd33ZF3N ec/qV98yXQE92o2oYekoRLQlezUIaK5paAp0Su2MfxrtOJkeX5d95NbKBSEMVi/k+8w1 vJ73B0lVDhS9u84r93q3JFkVvPL2t7Fgu5XCiLa4nrI7+LaSRpaxHfs+f+t7W0Vtvmqx fKekQy+WS+O/0UmAqr8BiEQxwI2nlVT8M4S0Hx1Ak20ApfxQAk+vi2W4Vaxfp3VwSCD8 dIGOIDNcjsf56v4drKiwy95bZOh4a4Nz7VBVlqdvxmx84uaZeoY1K932n6ZFxTIjbTjX HDkA== X-Gm-Message-State: AG10YOSRT7y4QZu9oLZfJvLk7jDVsOrXw3u4lkRTZqPUUQZmPI+FNDLbvBk8I9w2yO8nVg== X-Received: by 10.28.12.9 with SMTP id 9mr6247990wmm.76.1455844018485; Thu, 18 Feb 2016 17:06:58 -0800 (PST) Received: from twisty.cin.medizin.uni-tuebingen.de (cin-11.medizin.uni-tuebingen.de. [134.2.118.242]) by smtp.gmail.com with ESMTPSA id ka4sm8880313wjc.47.2016.02.18.17.06.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Feb 2016 17:06:57 -0800 (PST) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/radeon: Don't hang in radeon_flip_work_func on disabled crtc. (v2) Date: Fri, 19 Feb 2016 02:06:38 +0100 Message-Id: <1455843999-19179-2-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455843999-19179-1-git-send-email-mario.kleiner.de@gmail.com> References: <1455843999-19179-1-git-send-email-mario.kleiner.de@gmail.com> MIME-Version: 1.0 Cc: Alex Deucher , =?UTF-8?q?Michel=20D=C3=A4nzer?= , stable@vger.kernel.org, =mario.kleiner.de@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 This fixes a regression introduced in Linux 4.4. Limit the amount of time radeon_flip_work_func can delay programming a page flip, by both limiting the maximum amount of time per wait cycle and the maximum number of wait cycles. Continue the flip if the limit is exceeded, even if that may result in a visual or timing glitch. This is to prevent a hang of page flips, as reported in fdo bug #93746: Disconnecting a DisplayPort display in parallel to a kms pageflip getting queued can cause the following hang of page flips and thereby an unusable desktop: 1. kms pageflip ioctl() queues pageflip -> queues execution of radeon_flip_work_func. 2. Hotunplug of display causes the driver to DPMS OFF the unplugged display. Display engine shuts down, scanout no longer moves, but stays at its resting position at start line of vblank. 3. radeon_flip_work_func executes while crtc is off, and due to the non-moving scanout position, the new flip delay code introduced into Linux 4.4 by commit 5b5561b3660d ("drm/radeon: Fixup hw vblank counter/ts..") enters an infinite wait loop. 4. After reconnecting the display, the pageflip continues to hang in 3. and the display doesn't update its view of the desktop. This patch fixes the Linux 4.4 regression from fdo bug #93746 v2: Skip wait immediately if !radeon_crtc->enabled, as suggested by Michel. Reported-by: Bernd Steinhauser Signed-off-by: Mario Kleiner Tested-by: Bernd Steinhauser Cc: # 4.4+ Cc: Michel Dänzer Cc: Alex Deucher Reviewed-by: Michel Dänzer --- drivers/gpu/drm/radeon/radeon_display.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index b3bb923..1fab4b9 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c @@ -403,7 +403,8 @@ static void radeon_flip_work_func(struct work_struct *__work) struct drm_crtc *crtc = &radeon_crtc->base; unsigned long flags; int r; - int vpos, hpos, stat, min_udelay; + int vpos, hpos, stat, min_udelay = 0; + unsigned repcnt = 4; struct drm_vblank_crtc *vblank = &crtc->dev->vblank[work->crtc_id]; down_read(&rdev->exclusive_lock); @@ -454,7 +455,7 @@ static void radeon_flip_work_func(struct work_struct *__work) * In practice this won't execute very often unless on very fast * machines because the time window for this to happen is very small. */ - for (;;) { + while (radeon_crtc->enabled && repcnt--) { /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank * start in hpos, and to the "fudged earlier" vblank start in * vpos. @@ -472,10 +473,22 @@ static void radeon_flip_work_func(struct work_struct *__work) /* Sleep at least until estimated real start of hw vblank */ spin_unlock_irqrestore(&crtc->dev->event_lock, flags); min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5); + if (min_udelay > vblank->framedur_ns / 2000) { + /* Don't wait ridiculously long - something is wrong */ + repcnt = 0; + break; + } usleep_range(min_udelay, 2 * min_udelay); spin_lock_irqsave(&crtc->dev->event_lock, flags); }; + if (!repcnt) + DRM_DEBUG_DRIVER("Delay problem on crtc %d: min_udelay %d, " + "framedur %d, linedur %d, stat %d, vpos %d, " + "hpos %d\n", work->crtc_id, min_udelay, + vblank->framedur_ns / 1000, + vblank->linedur_ns / 1000, stat, vpos, hpos); + /* do the flip (mmio) */ radeon_page_flip(rdev, radeon_crtc->crtc_id, work->base);