From patchwork Tue Dec 13 19:57:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zanoni, Paulo R" X-Patchwork-Id: 9473103 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 C806660476 for ; Tue, 13 Dec 2016 19:57:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B91EA28687 for ; Tue, 13 Dec 2016 19:57:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADFF42868B; Tue, 13 Dec 2016 19:57:53 +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.2 required=2.0 tests=BAYES_00, 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 6287528687 for ; Tue, 13 Dec 2016 19:57:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 803236E65C; Tue, 13 Dec 2016 19:57:52 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id F193C6E65C for ; Tue, 13 Dec 2016 19:57:50 +0000 (UTC) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 13 Dec 2016 11:57:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,342,1477983600"; d="scan'208";a="41983067" Received: from przanoni-mobl.amr.corp.intel.com ([10.254.189.84]) by orsmga005.jf.intel.com with ESMTP; 13 Dec 2016 11:57:48 -0800 From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Tue, 13 Dec 2016 17:57:26 -0200 Message-Id: <1481659046-30739-2-git-send-email-paulo.r.zanoni@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481659046-30739-1-git-send-email-paulo.r.zanoni@intel.com> References: <1481659046-30739-1-git-send-email-paulo.r.zanoni@intel.com> Cc: dhinakaran.pandiyan@intel.com, stable@vger.kernel.org, Paulo Zanoni Subject: [Intel-gfx] [RFC 2/2] drm/i915: fully apply WaSkipStolenMemoryFirstPage X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Reserve the first page of stolen memory right after initializing the mm allocator. This means that we won't inherit the FB in case the BIOS decides to put it at the start of stolen. IMHO, avoiding constant screen flickering is more important than BIOS framebuffer inheritance. TODO: the goal is to ask everybody with screen flickering problems to test this patch. Hopefully we'll be able to add a bunch of Bugzilla tags here before merging it. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94605 Cc: stable@vger.kernel.org Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/i915_gem_stolen.c | 30 +++++++++++++----------------- 2 files changed, 16 insertions(+), 17 deletions(-) Time to spam bugzilla again with links to patchwork. The tester on fd.o bug 94605 suggests this may be the fix we've been looking for. diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 0e11ed7..0868a88 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1531,6 +1531,9 @@ struct i915_gem_mm { /** LRU list of objects with fence regs on them. */ struct list_head fence_list; + /** First page of stolen, for platforms where it's reserved. */ + struct drm_mm_node first_page; + /** * Are we in a non-interruptible section of code like * modesetting? diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index b1c8897..9b3ae58 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -54,12 +54,6 @@ int i915_gem_stolen_insert_node_in_range(struct drm_i915_private *dev_priv, if (!drm_mm_initialized(&dev_priv->mm.stolen)) return -ENODEV; - /* See the comment at the drm_mm_init() call for more about this check. - * WaSkipStolenMemoryFirstPage:bdw+ (incomplete) - */ - if (start < 4096 && INTEL_GEN(dev_priv) >= 8) - start = 4096; - mutex_lock(&dev_priv->mm.stolen_lock); ret = drm_mm_insert_node_in_range(&dev_priv->mm.stolen, node, size, alignment, start, end, @@ -286,6 +280,9 @@ void i915_gem_cleanup_stolen(struct drm_device *dev) if (!drm_mm_initialized(&dev_priv->mm.stolen)) return; + if (drm_mm_node_allocated(&dev_priv->mm.first_page)) + drm_mm_remove_node(&dev_priv->mm.first_page); + drm_mm_takedown(&dev_priv->mm.stolen); } @@ -491,19 +488,18 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv) ggtt->stolen_usable_size = ggtt->stolen_size - reserved_total; - /* - * Basic memrange allocator for stolen space. - * - * TODO: Notice that some platforms require us to not use the first page - * of the stolen memory but their BIOSes may still put the framebuffer - * on the first page. So we don't reserve this page for now because of - * that. Our current solution is to just prevent new nodes from being - * inserted on the first page - see the check we have at - * i915_gem_stolen_insert_node_in_range(). We may want to fix the fbcon - * problem later. - */ + /* Basic memrange allocator for stolen space. */ drm_mm_init(&dev_priv->mm.stolen, 0, ggtt->stolen_usable_size); + /* WaSkipStolenMemoryFirstPage:bdw+ */ + if (INTEL_GEN(dev_priv) >= 8) { + dev_priv->mm.first_page.start = 0; + dev_priv->mm.first_page.size = 4096; + if (drm_mm_reserve_node(&dev_priv->mm.stolen, + &dev_priv->mm.first_page)) + DRM_DEBUG_KMS("Failed to reserve the first page of stolen memory.\n"); + } + return 0; }