From patchwork Mon Feb 15 18:41:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 8320041 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 89AF69F2F0 for ; Tue, 16 Feb 2016 00:46:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 688C42039E for ; Tue, 16 Feb 2016 00:46:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 63DC4203C0 for ; Tue, 16 Feb 2016 00:46:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 313716E716; Tue, 16 Feb 2016 00:46:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by gabe.freedesktop.org (Postfix) with ESMTPS id ABD6E6E6C9 for ; Mon, 15 Feb 2016 18:42:16 +0000 (UTC) Received: by mail-wm0-f48.google.com with SMTP id a4so68112584wme.1 for ; Mon, 15 Feb 2016 10:42:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lQQQHMBQFVcNKKIHM3JQTdWvb6WEnNzHS0gvA1nyGsw=; b=LCZz5eLJU4KmeCRveruYA2CB8yaIHne1t2jTpkqkUhxYV+BOXYR8j1okMlAgSS09iS 0ak4VJbykufEpN3Nuxcln2KpYoY4FUYGusI3wmccjwcbrwR/HE+yXR4riHQcP3NQ9AgZ XX0Ca8rDeJTL5IS9S/MT7p5ydeaeEVV0JQZ/U= 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; bh=lQQQHMBQFVcNKKIHM3JQTdWvb6WEnNzHS0gvA1nyGsw=; b=AbNfgLcBjjeIgkiKzVuEblqJoLB9Ap4UHiyCevt0Qo1zJbrEBa/225YGdMLmvVDrlK gK/GhZ1Sok4/9nmo/raXMFVpkAUOulLbMQp1ZhST1w0MUOa8Rqt7u3vpJdX8xFvRhhL1 yj43ecDj5Z+gP8rKSA0yUt0KVhNXg7bsri85HpF3p2kUELt/GoxLnFA7uSjJMHY3BJqm WVlqmWqkYon70NpjXaMPSgB/yVJnu3U4vA0qVN5RCHZ2zyeuHbIWYYIB0yHfAFuTxUCw g9vDLc5Are3dF9I+V9CSQKpRiYc09/6EZ0QuAGuGFws++bUCsyZjyVkZ7IWDxbmP3053 Q7pA== X-Gm-Message-State: AG10YOTRvQ5BwAARXON3Wcfx52L9DSDga157YfPNfGLmn8cjn/Og3M6H77V15j+SnJ10yA== X-Received: by 10.28.12.80 with SMTP id 77mr14208311wmm.19.1455561735503; Mon, 15 Feb 2016 10:42:15 -0800 (PST) Received: from wildmoose.dk (lvps87-230-87-209.dedicated.hosteurope.de. [87.230.87.209]) by smtp.gmail.com with ESMTPSA id l7sm26624463wjx.14.2016.02.15.10.42.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Feb 2016 10:42:15 -0800 (PST) From: Rasmus Villemoes To: David Airlie Subject: [PATCH 2/3] drm/nouveau: use post-decrement in error handling Date: Mon, 15 Feb 2016 19:41:46 +0100 Message-Id: <1455561708-32390-3-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455561708-32390-1-git-send-email-linux@rasmusvillemoes.dk> References: <1455561708-32390-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailman-Approved-At: Tue, 16 Feb 2016 00:46:21 +0000 Cc: Rasmus Villemoes , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org 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: , MIME-Version: 1.0 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_SIGNED, 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 We need to use post-decrement to get the dma_map_page undone also for i==0, and to avoid some very unpleasant behaviour if dma_map_page failed already at i==0. Signed-off-by: Rasmus Villemoes Reviewed-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 78f520d05de9..e3acc35e3805 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -1520,7 +1520,7 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm) DMA_BIDIRECTIONAL); if (dma_mapping_error(pdev, addr)) { - while (--i) { + while (i--) { dma_unmap_page(pdev, ttm_dma->dma_address[i], PAGE_SIZE, DMA_BIDIRECTIONAL); ttm_dma->dma_address[i] = 0;