From patchwork Tue Mar 1 23:55:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8472991 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 019729F8A8 for ; Wed, 2 Mar 2016 00:24:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0905A20260 for ; Wed, 2 Mar 2016 00:24:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ACA9C200DC for ; Wed, 2 Mar 2016 00:24:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11EB96E10B; Wed, 2 Mar 2016 00:24:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 901 seconds by postgrey-1.35 at gabe; Wed, 02 Mar 2016 00:24:51 UTC Received: from mail333.us4.mandrillapp.com (mail333.us4.mandrillapp.com [205.201.137.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 30C406E20C for ; Wed, 2 Mar 2016 00:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; s=mandrill; d=linuxfoundation.org; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; i=gregkh@linuxfoundation.org; bh=d/9bo3Hxx5rDD9lQiAu1CF5s0WA=; b=aEC6aiZbiZN2bk/t/YALN+RfAH8cZOmVkuNP3i72lIih+UbI9JXZZyQezqnfONk0FNEb6xyMfjjI omYf0ivASZ0tyaqqU4oSfOGavVaKoQdo0/n3AmG7fSPMlurfyYFyAFCHqDn+it6zba45QC73EL0P AGLmy+r95uQt8QZz75Q= DomainKey-Signature: a=rsa-sha1; c=nofws; q=dns; s=mandrill; d=linuxfoundation.org; b=jrtN0bU3lKS98hinVkiz/5o7O1VFmkTD9aHD883QSt18dLY5KvCs+a9mO66xM0e4SATGNsE4KSUG /tilQ0La9cc6DgNNIhSftC7RPNbHQjadYGDissKitV4fth2RJpTwN7kRuld/VYW1AQhF95bA04uz 8PoAIZaxMnZkaekmOJk=; Received: from pmta03.dal05.mailchimp.com (127.0.0.1) by mail333.us4.mandrillapp.com id hqopd6174noc for ; Tue, 1 Mar 2016 23:55:17 +0000 (envelope-from ) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; i=@mandrillapp.com; q=dns/txt; s=mandrill; t=1456876516; h=From : Subject : To : Cc : Message-Id : In-Reply-To : References : Date : MIME-Version : Content-Type : Content-Transfer-Encoding : From : Subject : Date : X-Mandrill-User : List-Unsubscribe; bh=Ifw+CNdlMHVZvYIEB93UWVSSIAOEzdQDpl+Q6qtLPRk=; b=BFBH5yaVf0HeAlOuIdisXtbuvJHMP8ZxUv2AEZvdVk7gymFSjH0c1SwBy1caJrrnJbmkqy Fk+a3AiNdIO12HwsFIM4D6LQzwCAvXyNDZRVCh0nrCqHwrpgMTjZ9Lywp7RpAEA75jtG9l6Z 03ZznSFDiybRscGj+D7vfwOVnesKs= From: Greg Kroah-Hartman Subject: [PATCH 4.4 231/342] drm: Fix drm_vblank_pre/post_modeset regression from Linux 4.4 Received: from [50.170.35.168] by mandrillapp.com id fd52ab99f4514aa59d99016a94875c9a; Tue, 01 Mar 2016 23:55:16 +0000 X-Mailer: git-send-email 2.7.2 To: Message-Id: <20160301234535.388741812@linuxfoundation.org> In-Reply-To: <20160301234527.990448862@linuxfoundation.org> References: <20160301234527.990448862@linuxfoundation.org> X-Report-Abuse: Please forward a copy of this message, including all headers, to abuse@mandrill.com X-Report-Abuse: You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.fd52ab99f4514aa59d99016a94875c9a X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:55:16 +0000 MIME-Version: 1.0 Cc: dri-devel@lists.freedesktop.org, Greg Kroah-Hartman , michel@daenzer.net, stable@vger.kernel.org, Daniel Vetter , alexander.deucher@amd.com, Dave Airlie , christian.koenig@amd.com, Vlastimil Babka 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=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY, URIBL_GREY 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mario Kleiner commit c61934ed9a0e3911a9935df26858726a7ec35ec0 upstream. Changes to drm_update_vblank_count() in Linux 4.4 broke the behaviour of the pre/post modeset functions as the new update code doesn't deal with hw vblank counter resets inbetween calls to drm_vblank_pre_modeset an drm_vblank_post_modeset, as it should. This causes mistreatment of such hw counter resets as counter wraparound, and thereby large forward jumps of the software vblank counter which in turn cause vblank event dispatching and vblank waits to fail/hang --> userspace clients hang. This symptom was reported on radeon-kms to cause a infinite hang of KDE Plasma 5 shell's login procedure, preventing users from logging in. Fix this by detecting when drm_update_vblank_count() is called inside a pre->post modeset interval. If so, clamp valid vblank increments to the safe values 0 and 1, pretty much restoring the update behavior of the old update code of Linux 4.3 and earlier. Also reset the last recorded hw vblank count at call to drm_vblank_post_modeset() to be safe against hw that after modesetting, dpms on etc. only fires its first vblank irq after drm_vblank_post_modeset() was already called. Reported-by: Vlastimil Babka Signed-off-by: Mario Kleiner Reviewed-by: Daniel Vetter Tested-by: Vlastimil Babka Cc: michel@daenzer.net Cc: vbabka@suse.cz Cc: ville.syrjala@linux.intel.com Cc: daniel.vetter@ffwll.ch Cc: dri-devel@lists.freedesktop.org Cc: alexander.deucher@amd.com Cc: christian.koenig@amd.com Signed-off-by: Dave Airlie Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_irq.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -222,6 +222,21 @@ static void drm_update_vblank_count(stru } /* + * Within a drm_vblank_pre_modeset - drm_vblank_post_modeset + * interval? If so then vblank irqs keep running and it will likely + * happen that the hardware vblank counter is not trustworthy as it + * might reset at some point in that interval and vblank timestamps + * are not trustworthy either in that interval. Iow. this can result + * in a bogus diff >> 1 which must be avoided as it would cause + * random large forward jumps of the software vblank counter. + */ + if (diff > 1 && (vblank->inmodeset & 0x2)) { + DRM_DEBUG_VBL("clamping vblank bump to 1 on crtc %u: diffr=%u" + " due to pre-modeset.\n", pipe, diff); + diff = 1; + } + + /* * FIMXE: Need to replace this hack with proper seqlocks. * * Restrict the bump of the software vblank counter to a safe maximum @@ -1575,6 +1590,7 @@ void drm_vblank_post_modeset(struct drm_ if (vblank->inmodeset) { spin_lock_irqsave(&dev->vbl_lock, irqflags); dev->vblank_disable_allowed = true; + drm_reset_vblank_timestamp(dev, pipe); spin_unlock_irqrestore(&dev->vbl_lock, irqflags); if (vblank->inmodeset & 0x2)