From patchwork Thu Jun 9 14:04:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 9167125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 797476048F for ; Thu, 9 Jun 2016 14:05:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68C3824B44 for ; Thu, 9 Jun 2016 14:05:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CD022834A; Thu, 9 Jun 2016 14:05:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 093FD24B44 for ; Thu, 9 Jun 2016 14:05:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B3BBD6EBD6; Thu, 9 Jun 2016 14:05:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-x243.google.com (mail-qg0-x243.google.com [IPv6:2607:f8b0:400d:c04::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id A66E56EBD4 for ; Thu, 9 Jun 2016 14:05:05 +0000 (UTC) Received: by mail-qg0-x243.google.com with SMTP id t106so2977985qgt.2 for ; Thu, 09 Jun 2016 07:05:05 -0700 (PDT) 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=d8SB7Yo1VqWC3lufY2dz2H9JvSYL5EAIJ9FIB04CXzA=; b=huCBsLYERz67VooMmJj9RdeEOreFoGWA2JiDPQCfoBbA0FrZYbwSyKwDRbm7QTpUWJ WJzup84sbSW3I47FVqTBudvZYKw5fsO3ulv+fuLI2I9NCvF1L+TsgSzQkW7vzqhjj/Vr WxEXCzwZt+gCtvNmsWBcyhfzN1I1lyFfSsZUNechQungD1BXhMPLOkmmQEh3Xrk23m3r xEcxXKiNwK905y82MWXNO1ITwjIA5I00YMpmbEFCn0mh5rti6e7+L1HnrJ1Z/oQftueH XwoHWAlTXmqV0ZMDHfu7gSgQdqi0cm3LLP2XQFuCRjB9WFJ5JSPjCxDeHskbL9m3kmiG Lekg== 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=d8SB7Yo1VqWC3lufY2dz2H9JvSYL5EAIJ9FIB04CXzA=; b=HNQ5PtQ8DhiOSrcJQ81AksRG6aIpFXiCzQcTdAiAbg2O5jFEZC1JlFmkuNXV/43bSK WUh2voOO1Yjm8UxmJiqw3SKuDbytNmE4g77YckjqKqFd553G6TJVw4RNWKjcEerBh8O0 cVnW3ls7X4hgxPb0t8JZQbl7sHEdeB6sHvZDU9sRjLa/XLvnJo8P/xEIIEZhAA8XBsdc QhywjQLd37+C7kA/v5PxkoSUyR+zqdExLRUtPx6ZgYjQzl9DouUim9So9oNxZdkIkgyN 5sZHX6nM3CPwv4waGIo68ftb5zOyxAf4nskN/Vsfs/wzK+IE0F5ST7lqx3VgAUDJptQX 4a1w== X-Gm-Message-State: ALyK8tLWlSHPH7+9MBCBF2bd67i4uIl6JmbfAM1kOhWSbXhbt8oMm2j0I3fufuj1nEzoKQ== X-Received: by 10.140.16.75 with SMTP id 69mr9974963qga.31.1465481104134; Thu, 09 Jun 2016 07:05:04 -0700 (PDT) Received: from cm.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by smtp.gmail.com with ESMTPSA id y55sm1755250qtc.0.2016.06.09.07.05.03 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 09 Jun 2016 07:05:03 -0700 (PDT) From: Alex Deucher X-Google-Original-From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/amdgpu: Initialize the variables in a straight-forward way Date: Thu, 9 Jun 2016 10:04:56 -0400 Message-Id: <1465481096-17395-3-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465481096-17395-1-git-send-email-alexander.deucher@amd.com> References: <1465481096-17395-1-git-send-email-alexander.deucher@amd.com> MIME-Version: 1.0 Cc: Alex Deucher , Alex Xie 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-Virus-Scanned: ClamAV using ClamSMTP From: Alex Xie Initialize the variable in a straight-forward way instead of hiding the initialization inside the loop. This can also reduce one function call. Signed-off-by: Alex Xie Reviewed-by: Christian König Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 0c17348..311a7c3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c @@ -762,15 +762,36 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, { const uint64_t mask = AMDGPU_VM_PTE_COUNT - 1; - uint64_t cur_pe_start = ~0, cur_pe_end = ~0, cur_dst = ~0; + uint64_t cur_pe_start, cur_pe_end, cur_dst; uint64_t addr; /* next GPU address to be updated */ + uint64_t pt_idx; + struct amdgpu_bo *pt; + unsigned nptes; /* next number of ptes to be updated */ + uint64_t next_pe_start; + + /* initialize the variables */ + addr = start; + pt_idx = addr >> amdgpu_vm_block_size; + pt = vm->page_tables[pt_idx].entry.robj; + + if ((addr & ~mask) == (end & ~mask)) + nptes = end - addr; + else + nptes = AMDGPU_VM_PTE_COUNT - (addr & mask); + + cur_pe_start = amdgpu_bo_gpu_offset(pt); + cur_pe_start += (addr & mask) * 8; + cur_pe_end = cur_pe_start + 8 * nptes; + cur_dst = dst; + + /* for next ptb*/ + addr += nptes; + dst += nptes * AMDGPU_GPU_PAGE_SIZE; /* walk over the address space and update the page tables */ - for (addr = start; addr < end; ) { - uint64_t pt_idx = addr >> amdgpu_vm_block_size; - struct amdgpu_bo *pt = vm->page_tables[pt_idx].entry.robj; - unsigned nptes; /* next number of ptes to be updated */ - uint64_t next_pe_start; + while (addr < end) { + pt_idx = addr >> amdgpu_vm_block_size; + pt = vm->page_tables[pt_idx].entry.robj; if ((addr & ~mask) == (end & ~mask)) nptes = end - addr; @@ -796,6 +817,7 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, cur_dst = dst; } + /* for next ptb*/ addr += nptes; dst += nptes * AMDGPU_GPU_PAGE_SIZE; }