From patchwork Fri Mar 30 12:27:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10317651 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 C99E760383 for ; Fri, 30 Mar 2018 12:27:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A79B12A3BD for ; Fri, 30 Mar 2018 12:27:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B4362A3CB; Fri, 30 Mar 2018 12:27:27 +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]) (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 362E12A3BD for ; Fri, 30 Mar 2018 12:27:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7E3B6E40A; Fri, 30 Mar 2018 12:27:24 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 471A76E40A; Fri, 30 Mar 2018 12:27:23 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id o23so2051507wmf.0; Fri, 30 Mar 2018 05:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VqUJdZvuV2FCAghMo2Zzqe/cA7+1kZFNT6N9uWw5qG0=; b=AuhCXaBKGqSWGrAAk+SYM+BLiSuUlwRW4pYNWWC2ds+UETSboRMlo5Camqt+l/Ka/e n9JzM5VD4GYhqp2e18P+OzLRBEyqHPsUrwa60ZomKEaitYeu9UpJ1mfG/aILJ+LwEyRR cvy4/WVi5aYC3BAaKS2hcjb3/6iwi/n4eJS3OP5KYUMsNEDcDJLzfHLPgWK9Z5Wtu/sx cvIdZ9vLOSBW/4tSr8wJa4XdRT+5NmKjXqUEr/siM/PfZqKuOilXoyyldMkZjYrIp7v/ DrthYp86BWcRWSvP9U6IXM4E9bsgKn3NCGsZv7k6R9s7pj3fmeG04E6I/LvGVFJqqs60 y2Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VqUJdZvuV2FCAghMo2Zzqe/cA7+1kZFNT6N9uWw5qG0=; b=Tfepis0SlxyVvdA1I0kxK8zY8pQnqr6z1lykWZIYEdB+3EVtSobJ0NW6tZX5y7cEcg yfMQIWHA+JejID+WWRGAtHKm+urixOG/+y/WVSuBqjjGnKzxSFvuynzB+awsGJeER1Wz 0I3Dys0X8HZFX0e/tZ51+CL2mtMRNkXNk8qwn/UEuN9fFMtBrrgA/XLxYNCuivwLJgPH 8MKJi++Q8RfoPBucwrDnGMxXVF5TW5d3UryhnL+S58toX+alBvnLGGJlllbDqDC+33ew GbZtxlgJONKF1v59It8mSQSc0BIYfI655Vjo6gURMmodSjHHXcWq7mtg46D8r7R3fx9A sIgQ== X-Gm-Message-State: AElRT7EEawfxYdQ6qT92cAwx6+Y58rbF64oe7nhtbytMjf74UtUObLcJ wVQpy/iqe5EJOmrfGEOwRu0= X-Google-Smtp-Source: AIpwx496HMpVFBU1zYZ1nnbMKLPir4hqtGwa+oG4wRRNTF2m3Ez/FjQJUOD0OqX8PEekzgHR7ZbA7Q== X-Received: by 10.80.166.99 with SMTP id d90mr2734304edc.53.1522412841869; Fri, 30 Mar 2018 05:27:21 -0700 (PDT) Received: from shalem.localdomain (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id g55sm5539329eda.15.2018.03.30.05.27.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Mar 2018 05:27:21 -0700 (PDT) From: Hans de Goede X-Google-Original-From: Hans de Goede To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Date: Fri, 30 Mar 2018 14:27:15 +0200 Message-Id: <20180330122715.18209-1-hdegoede@redhat.com> X-Mailer: git-send-email 2.17.0.rc2 Subject: [Intel-gfx] [PATCH] drm/i915: Do NOT skip the first 4k of stolen memory for pre-allocated buffers 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: , Cc: Hans de Goede , intel-gfx , dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Before this commit the WaSkipStolenMemoryFirstPage workaround code was skipping the first 4k by passing 4096 as start of the address range passed to drm_mm_init(). This means that calling drm_mm_reserve_node() to try and reserve the firmware framebuffer so that we can inherit it would always fail, as the firmware framebuffer starts at address 0. Commit d43537610470 ("drm/i915: skip the first 4k of stolen memory on everything >= gen8") says in its commit message: "This is confirmed to fix Skylake screen flickering issues (probably caused by the fact that we initialized a ring in the first page of stolen, but I didn't 100% confirm this theory)." Which suggests that it is safe to use the first page for a linear framebuffer as the firmware is doing. This commit always passes 0 as start to drm_mm_init() and works around WaSkipStolenMemoryFirstPage in i915_gem_stolen_insert_node_in_range() by insuring the start address passed by to drm_mm_insert_node_in_range() is always 4k or more. All entry points to i915_gem_stolen.c go through i915_gem_stolen_insert_node_in_range(), so that any newly allocated objects such as ring-buffers will not be allocated in the first 4k. The one exception is i915_gem_object_create_stolen_for_preallocated() which directly calls drm_mm_reserve_node() which now will be able to use the first 4k. This fixes the i915 driver no longer being able to inherit the firmware framebuffer on gen8+, which fixes the video output changing from the vendor logo to a black screen as soon as the i915 driver is loaded (on systems without fbcon). Signed-off-by: Hans de Goede --- drivers/gpu/drm/i915/i915_gem_stolen.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index af915d041281..ad949cc30928 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -51,6 +51,10 @@ int i915_gem_stolen_insert_node_in_range(struct drm_i915_private *dev_priv, if (!drm_mm_initialized(&dev_priv->mm.stolen)) return -ENODEV; + /* WaSkipStolenMemoryFirstPage:bdw+ */ + if (INTEL_GEN(dev_priv) >= 8 && start < 4096) + start = 4096; + mutex_lock(&dev_priv->mm.stolen_lock); ret = drm_mm_insert_node_in_range(&dev_priv->mm.stolen, node, size, alignment, 0, @@ -343,7 +347,6 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv) { resource_size_t reserved_base, stolen_top; resource_size_t reserved_total, reserved_size; - resource_size_t stolen_usable_start; mutex_init(&dev_priv->mm.stolen_lock); @@ -435,17 +438,11 @@ int i915_gem_init_stolen(struct drm_i915_private *dev_priv) (u64)resource_size(&dev_priv->dsm) >> 10, ((u64)resource_size(&dev_priv->dsm) - reserved_total) >> 10); - stolen_usable_start = 0; - /* WaSkipStolenMemoryFirstPage:bdw+ */ - if (INTEL_GEN(dev_priv) >= 8) - stolen_usable_start = 4096; - dev_priv->stolen_usable_size = - resource_size(&dev_priv->dsm) - reserved_total - stolen_usable_start; + resource_size(&dev_priv->dsm) - reserved_total; /* Basic memrange allocator for stolen space. */ - drm_mm_init(&dev_priv->mm.stolen, stolen_usable_start, - dev_priv->stolen_usable_size); + drm_mm_init(&dev_priv->mm.stolen, 0, dev_priv->stolen_usable_size); return 0; }