From patchwork Mon Feb 15 18:41:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 8320051 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 AD6369FD0B for ; Tue, 16 Feb 2016 00:46:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 813D3203C3 for ; Tue, 16 Feb 2016 00:46:26 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 923E5203B8 for ; Tue, 16 Feb 2016 00:46:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 722146E71D; 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 813E86E6C6 for ; Mon, 15 Feb 2016 18:42:15 +0000 (UTC) Received: by mail-wm0-f48.google.com with SMTP id b205so79140855wmb.1 for ; Mon, 15 Feb 2016 10:42:15 -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=373EVlsWY2nzQc1oejh0pfSIjZycNZ2O/uCWGHAj+q4=; b=fqXXQJAEdgRshOwKZXJIaHAaW4ZccbhUD66RoIH43Ra1yuB9ZNOKEbK1gcrVLtq3Wb wxikPXRmKA73kDvfHJvW3itqS4Fq1jm99RFU5LowRj2cLEnrPI2xv/b6yKL3Q/Z7taqn WGtiAU8yTrLhum0Ojsz7dT9TM6llHE++oFxYQ= 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=373EVlsWY2nzQc1oejh0pfSIjZycNZ2O/uCWGHAj+q4=; b=ARfEDP84QkSIyfFd1wWtwxsXWS8SJrH7LfGPv/+vw+VHpqVfCCbe7MSDsoZXx4eSR1 TjWIandM3s3wuuJo4PcO/wuR5V8vZB0ohRQmrRwKyBNZTZz7gepiU26Fhg9l7WuQnErX lzBDGi1qhpxxOeYYcYcwpT7ZS6beL9UUFMUNEch283bQv5eT489sayRPVRebaAMrcGDV +sVhuF9hIJZ/T+cHNtyuhr0udm6as2K+X0jASdtFpajfXlhDoSwkcD9QW/owzTXEx0bO xDKFTfjOdAqdHvsGoGsOgAqAtJ43wqV0c7QIaf3clKeTOmFVr5y5L5iFVDZeCaCJS3BO GHMw== X-Gm-Message-State: AG10YOTYCs9m022rA7+ZkPog1Sh2wXjnbyn/3XwHMs+tMXHWyQCYFPMQssg5p5WG9gh5Nw== X-Received: by 10.195.13.16 with SMTP id eu16mr19801097wjd.140.1455561734236; Mon, 15 Feb 2016 10:42:14 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Feb 2016 10:42:13 -0800 (PST) From: Rasmus Villemoes To: David Airlie Subject: [PATCH 1/3] drm/amdgpu: use post-decrement in error handling Date: Mon, 15 Feb 2016 19:41:45 +0100 Message-Id: <1455561708-32390-2-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 pci_map_page undone also for i==0, and to avoid some very unpleasant behaviour if pci_map_page failed already at i==0. Signed-off-by: Rasmus Villemoes --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 8a1752ff3d8e..e53558c25b6b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -712,7 +712,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm) 0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); if (pci_dma_mapping_error(adev->pdev, gtt->ttm.dma_address[i])) { - while (--i) { + while (i--) { pci_unmap_page(adev->pdev, gtt->ttm.dma_address[i], PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); gtt->ttm.dma_address[i] = 0;