From patchwork Fri Feb 28 03:47:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 3738311 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9BD44BF13A for ; Fri, 28 Feb 2014 03:47:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9C672014A for ; Fri, 28 Feb 2014 03:47:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9C0BB20237 for ; Fri, 28 Feb 2014 03:47:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7465AFBA92; Thu, 27 Feb 2014 19:47:44 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 566A9FBA92 for ; Thu, 27 Feb 2014 19:47:42 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by azsmga102.ch.intel.com with ESMTP; 27 Feb 2014 19:47:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,559,1389772800"; d="scan'208";a="483303669" Received: from unknown (HELO ironside.amr.corp.intel.com) ([10.255.14.31]) by fmsmga001.fm.intel.com with ESMTP; 27 Feb 2014 19:47:40 -0800 From: Ben Widawsky To: Intel GFX Date: Thu, 27 Feb 2014 19:47:38 -0800 Message-Id: <1393559258-1405-1-git-send-email-benjamin.widawsky@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1393525802-978-1-git-send-email-benjamin.widawsky@intel.com> References: <1393525802-978-1-git-send-email-benjamin.widawsky@intel.com> Cc: Ben Widawsky , Ben Widawsky Subject: [Intel-gfx] [PATCH] [v2] drm/i915: Paranoia - get zeroed page table pages X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 normally clear the page tables as one of the first things during initialization. They are however wired up (and potentially valid) before we clear them. To prevent the GPU from doing anything we might later regret, simply get zeroed pages, which always mean invalid on all GENs. NOTE: that a similar paranoia could be applied to GGTT via making sure all entries are invalid ASAP. I think the extra work required to fix such a BIOS bug is unwarranted until proven necessary. v2: Remove useless GFP_ZERO in the kcallocs Signed-off-by: Ben Widawsky --- drivers/gpu/drm/i915/i915_gem_gtt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 0c27d8a..5e3957e 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c @@ -359,7 +359,7 @@ static struct page **__gen8_alloc_page_tables(void) return ERR_PTR(-ENOMEM); for (i = 0; i < GEN8_PDES_PER_PAGE; i++) { - pt_pages[i] = alloc_page(GFP_KERNEL); + pt_pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO); if (!pt_pages[i]) goto bail; } @@ -421,7 +421,8 @@ static int gen8_ppgtt_allocate_dma(struct i915_hw_ppgtt *ppgtt) static int gen8_ppgtt_allocate_page_directories(struct i915_hw_ppgtt *ppgtt, const int max_pdp) { - ppgtt->pd_pages = alloc_pages(GFP_KERNEL, get_order(max_pdp << PAGE_SHIFT)); + ppgtt->pd_pages = alloc_pages(GFP_KERNEL | __GFP_ZERO, + get_order(max_pdp << PAGE_SHIFT)); if (!ppgtt->pd_pages) return -ENOMEM; @@ -1021,7 +1022,7 @@ static int gen6_ppgtt_allocate_page_tables(struct i915_hw_ppgtt *ppgtt) return -ENOMEM; for (i = 0; i < ppgtt->num_pd_entries; i++) { - ppgtt->pt_pages[i] = alloc_page(GFP_KERNEL); + ppgtt->pt_pages[i] = alloc_page(GFP_KERNEL | __GFP_ZERO); if (!ppgtt->pt_pages[i]) { gen6_ppgtt_free(ppgtt); return -ENOMEM;