From patchwork Tue Mar 1 20:31:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 8470041 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 05F20C0553 for ; Tue, 1 Mar 2016 20:32:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C45820351 for ; Tue, 1 Mar 2016 20:32:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 446FB2035B for ; Tue, 1 Mar 2016 20:32:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DCA396E69C; Tue, 1 Mar 2016 20:32:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) by gabe.freedesktop.org (Postfix) with ESMTPS id A8A1E6E68E for ; Tue, 1 Mar 2016 20:32:11 +0000 (UTC) Received: by mail-wm0-x22d.google.com with SMTP id p65so52248628wmp.1 for ; Tue, 01 Mar 2016 12:32:11 -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:mime-version :content-transfer-encoding; bh=A6lAhHdXy89Tr2QVLCdPX0MQeAO2btcqZYylFx8AM4E=; b=Vl55yow72R6G+dird1EnPKEi7oj0zTkk8furknOCmzRtdk6zol49TGnnFU2j0DRNeV 50/u68rjJm5xiNcP3jSUtloq5CosBLByPl//6J0G+M+qCL9vGFHTd2iA+Au2lZlrHTOG cVnO1/4vR/rJ43z5wmdyjHrfIyWWtlDJLAAGABfJaFtCnzZWjEFKvorPXcsDJXyXd83U ETF9zmg033qqCWhWZ3TVe5X2cZCN/4OTZbL3BJ/3c1pYOrFqH359vawqgYXz55H9iQVg 8zhSZUtIbEnDhscYMyl5oAskmYDU90PHeP3ch2eXDJsNI6UpMGkwFw26HxFB4urGlqOg hpZA== 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:mime-version :content-transfer-encoding; bh=A6lAhHdXy89Tr2QVLCdPX0MQeAO2btcqZYylFx8AM4E=; b=OJSRy2hQDEDJjw0bSHL3qunv/PJf5vy6+NWp/FgOfGNJ2rGc8GhQ4t5m2W/YqxX/wJ IbwBcv9bcxMnSi1pdiKRYUhiHz19MldsMe0iOVXCSE+ThJsiuvU6re7rBuRTB7Z3Iyzh I2ilbBYjPAqLR1OxhuI9rxsF0QE8Law161qd2lBG6q7Kklqmo7ArgUV3pHvcNOrO4Z6E cI6IAkcnVrniTqBO+6Bgz7pfReW2QXnPWh9qwMh/hb8ggmMitj/p+u4mBbWCN/v4KK0W 1M8PwnN+79bMN/dhZkWboEtE3T5sUk7v/uHIhRc7f0FbYRljPBHHYCudEzfK1I7LDGU7 k+kQ== X-Gm-Message-State: AD7BkJLl49o5928r2zucWlCogiVOSMiN5q6WwCNW8kfxXhOa+ocYIjyUKmh2Pd8leapwog== X-Received: by 10.28.188.195 with SMTP id m186mr883745wmf.64.1456864329981; Tue, 01 Mar 2016 12:32:09 -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 j18sm826245wmd.2.2016.03.01.12.32.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 12:32:08 -0800 (PST) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm/amdgpu: Fix error handling in amdgpu_flip_work_func. Date: Tue, 1 Mar 2016 21:31:16 +0100 Message-Id: <1456864277-9551-1-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Cc: Alex Deucher , =?UTF-8?q?Michel=20D=C3=A4nzer?= , stable@vger.kernel.org, dan.carpenter@oracle.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=-3.1 required=5.0 tests=BAYES_00,BIGNUM_EMAILS, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable 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 The patch e1d09dc0ccc6: "drm/amdgpu: Don't hang in amdgpu_flip_work_func on disabled crtc." from Feb 19, 2016, leads to the following static checker warning, as reported by Dan Carpenter in https://lists.freedesktop.org/archives/dri-devel/2016-February/101987.html drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:127 amdgpu_flip_work_func() warn: should this be 'repcnt == -1' drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:136 amdgpu_flip_work_func() error: double unlock 'spin_lock:&crtc->dev->event_lock' drivers/gpu/drm/amd/amdgpu/amdgpu_display.c:136 amdgpu_flip_work_func() error: double unlock 'irqsave:flags' This patch fixes both reported problems: Change post-decrement of repcnt to pre-decrement, so it can't underflow anymore, but still performs up to three repetitions - three is the maximum one could expect in practice. Move the spin_unlock_irqrestore to where it actually belongs. Reported-by: Dan Carpenter Signed-off-by: Mario Kleiner Cc: # 4.4+ Cc: Michel Dänzer Cc: Alex Deucher Reviewed-by: Michel Dänzer --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 8297bc3..1846d65 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -96,7 +96,7 @@ static void amdgpu_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. */ - while (amdgpuCrtc->enabled && repcnt--) { + while (amdgpuCrtc->enabled && --repcnt) { /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank * start in hpos, and to the "fudged earlier" vblank start in * vpos. @@ -112,13 +112,13 @@ static void amdgpu_flip_work_func(struct work_struct *__work) break; /* 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; } + spin_unlock_irqrestore(&crtc->dev->event_lock, flags); usleep_range(min_udelay, 2 * min_udelay); spin_lock_irqsave(&crtc->dev->event_lock, flags); };