From patchwork Fri Jul 19 13:07:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 11050059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28548746 for ; Fri, 19 Jul 2019 13:07:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18D6F2883A for ; Fri, 19 Jul 2019 13:07:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CAAF28900; Fri, 19 Jul 2019 13:07:56 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 995272884A for ; Fri, 19 Jul 2019 13:07:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D3036E827; Fri, 19 Jul 2019 13:07:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F3346E827 for ; Fri, 19 Jul 2019 13:07:51 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 17429448-1500050 for multiple; Fri, 19 Jul 2019 14:07:38 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 19 Jul 2019 14:07:37 +0100 Message-Id: <20190719130737.5835-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915/gtt: Fix rounding for 36b X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP The top-level page directory for 36b is a single entry, not multiple like 32b. Fix up the rounding on the calculation of the size of the top level so that we populate the 4th level correctly for 36b. Reported-by: Jose Souza Signed-off-by: Chris Wilson Fixes: 1eda701eace2 ("drm/i915/gtt: Recursive cleanup for gen8") Cc: Abdiel Janulgue Cc: Jose Souza Tested-by: José Roberto de Souza Reviewed-by: Abdiel Janulgue --- drivers/gpu/drm/i915/i915_gem_gtt.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 220aba5a94d2..7dd08ff6c0eb 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -905,6 +905,12 @@ static inline unsigned int gen8_pt_count(u64 start, u64 end) return end - start; } +static inline unsigned int gen8_pd_top_count(const struct i915_address_space *vm) +{ + unsigned int shift = __gen8_pte_shift(vm->top); + return (vm->total + (1ull << shift) - 1) >> shift; +} + static void __gen8_ppgtt_cleanup(struct i915_address_space *vm, struct i915_page_directory *pd, int count, int lvl) @@ -930,9 +936,7 @@ static void gen8_ppgtt_cleanup(struct i915_address_space *vm) if (intel_vgpu_active(vm->i915)) gen8_ppgtt_notify_vgt(ppgtt, false); - __gen8_ppgtt_cleanup(vm, ppgtt->pd, - vm->total >> __gen8_pte_shift(vm->top), - vm->top); + __gen8_ppgtt_cleanup(vm, ppgtt->pd, gen8_pd_top_count(vm), vm->top); free_scratch(vm); } @@ -1391,7 +1395,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_ppgtt *ppgtt) unsigned int idx; GEM_BUG_ON(vm->top != 2); - GEM_BUG_ON((vm->total >> __gen8_pte_shift(2)) != GEN8_3LVL_PDPES); + GEM_BUG_ON(gen8_pd_top_count(vm) != GEN8_3LVL_PDPES); for (idx = 0; idx < GEN8_3LVL_PDPES; idx++) { struct i915_page_directory *pde; @@ -1428,7 +1432,7 @@ static void ppgtt_init(struct i915_ppgtt *ppgtt, struct intel_gt *gt) static struct i915_page_directory * gen8_alloc_top_pd(struct i915_address_space *vm) { - const unsigned int count = vm->total >> __gen8_pte_shift(vm->top); + const unsigned int count = gen8_pd_top_count(vm); struct i915_page_directory *pd; GEM_BUG_ON(count > ARRAY_SIZE(pd->entry)); @@ -1514,8 +1518,7 @@ static struct i915_ppgtt *gen8_ppgtt_create(struct drm_i915_private *i915) err_free_pd: __gen8_ppgtt_cleanup(&ppgtt->vm, ppgtt->pd, - ppgtt->vm.total >> __gen8_pte_shift(ppgtt->vm.top), - ppgtt->vm.top); + gen8_pd_top_count(&ppgtt->vm), ppgtt->vm.top); err_free_scratch: free_scratch(&ppgtt->vm); err_free: