From patchwork Tue Mar 1 20:31:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 8470051 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 5CBAB9F8A8 for ; Tue, 1 Mar 2016 20:32:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D11C20351 for ; Tue, 1 Mar 2016 20:32:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 189CC2034B for ; Tue, 1 Mar 2016 20:32:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C0086E6A3; Tue, 1 Mar 2016 20:32:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com [IPv6:2a00:1450:400c:c09::22a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 915DA6E68E for ; Tue, 1 Mar 2016 20:32:16 +0000 (UTC) Received: by mail-wm0-x22a.google.com with SMTP id p65so50269503wmp.0 for ; Tue, 01 Mar 2016 12:32:16 -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=zxLG5IWTxKu1nFx2/NZR/fk88PXVQ08RnpoP2DYoT18=; b=dXO7wnXXk8nrL0g8Qn4qmngIgOhBzP+4I2MLaxgHlVffDyNBxFkPFkdf1MiCUCMZwS 7X6Mj3VKbPoUZa2g/6vPTLK4NcfAGuC22NVqt+48GwoBrRoKQe7eDDEyQ8MPMK8MAHI5 1EHA5i+ZJui9VSxUfUEV9bV7OxkqYI6T5OsN0icIVo15wo1DV/IS2KraEYgAB1FGz33p iVo2g7JvioK7Lgliut+DeWXrIzWoMBLhFeeju5SM7LURQIQYgjJURF/TQyr9vDcnE8gm WqQQ2RFPd5Nt3ytm5jTq3dcM0wwV4hxz9gMNgaVe/egmE6XO96jYQpiwMF8MH1ihE7P8 jdlg== 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=zxLG5IWTxKu1nFx2/NZR/fk88PXVQ08RnpoP2DYoT18=; b=GarizQyYTaGs/TtxfIceyNIva7nJo+y01l29sSPcJl774jKWJ1abYDiFSBfse3cM/N EzH1y9DUEwyuynMW/oS/C7Ajotg1Mpo22/qK66rfNOrEMrV1x9WEYnUhfbJ/ktNRFeLZ C61e6t03/E6ytWRZacY6/ezGRqD/7itWxhYGZmGwNyPlQ2UhyZrIPIpI7QHvsdjGRUJF OEyoW3DFSiq8RjNrUlidJLcpeuzCDYtTu5Tz1gTlOyG68y9gJeaO4tsZwlKBSM7vCZwk ZFlcaX5lUKMYKiYQPZLtUVaSTxpKM+n0ubtxE6GEztPV2J4jsTR8VAC2PGH9t5I6gKLe C4Hg== X-Gm-Message-State: AD7BkJKeXAg+oqMhpD0m97sJqdk8ihOAGihI8DM6ElV6VixVFDfJlGe+LPuRT5kj+8r+9A== X-Received: by 10.28.17.198 with SMTP id 189mr863456wmr.47.1456864335137; Tue, 01 Mar 2016 12:32:15 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 12:32:14 -0800 (PST) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/radeon: Fix error handling in radeon_flip_work_func. Date: Tue, 1 Mar 2016 21:31:17 +0100 Message-Id: <1456864277-9551-2-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456864277-9551-1-git-send-email-mario.kleiner.de@gmail.com> References: <1456864277-9551-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, 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=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 is a port of the patch "drm/amdgpu: Fix error handling in amdgpu_flip_work_func." to fix the following problem for radeon as well which was reported against amdgpu: 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 --- drivers/gpu/drm/radeon/radeon_display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 1fab4b9..bfcef4d 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c @@ -455,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. */ - while (radeon_crtc->enabled && repcnt--) { + 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. @@ -471,13 +471,13 @@ static void radeon_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); };