From patchwork Sun Jul 1 15:09:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1144351 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 06246DFB7C for ; Sun, 1 Jul 2012 15:10:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 00D7D9EEBC for ; Sun, 1 Jul 2012 08:10:50 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 2039E9E806 for ; Sun, 1 Jul 2012 08:09:51 -0700 (PDT) Received: by eekd17 with SMTP id d17so1862793eek.36 for ; Sun, 01 Jul 2012 08:09:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer; bh=QE3764O6kHZ43AiYjzurIy8/8dKOBr7Judq8BBmNlH4=; b=bI2+kzvHtjWubpKvblqWgLvjPHvAfRSXFyUW6bnusKTwtfFOk54G8Xggez+rqTcK3d 1U+D21+kWSXxyMnB7UOHlt1APsx5ZPFFyjTSLiTwz8zf1XY9eLCIcAVm0qLqepOXKyPf JtpL//lBju9lnRpXRqwmMiIZ99zZH4vzk90u8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=QE3764O6kHZ43AiYjzurIy8/8dKOBr7Judq8BBmNlH4=; b=JdoE3WxAKM0I9EuJsoNUSKUisxmLp0zTz0RbezMOaDxLWDo65VaLKv2YOncuvNJxuJ fs0sEYXZl9IZDl7jVXfGsCiZOCOgzkwyVdtNj3Lamog6J9Ow8TXx3pyZuYS6lYtmoFWo DbhUWocXmT7DfwfVE8t0BxFcmG+PClKIJU5DGVE5+1DNT22EHrCnZcgaMJh0XZ24l9Wi xLo+cWbNE/ssLLTUaud8Gli0ecoXvKyQ2LibwQEcylL5VqdJyyS7PxXy4mDCRRcK+Heh lWRYInwT9PhrmTDAvLJ8ScabY/dGvpAGNObHm9nqAc1RF30hYdywnl6XRrdqVQ9cQEjL khbA== Received: by 10.14.40.84 with SMTP id e60mr2371574eeb.75.1341155390802; Sun, 01 Jul 2012 08:09:50 -0700 (PDT) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id m46sm25952793eeh.9.2012.07.01.08.09.49 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Jul 2012 08:09:49 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Subject: [PATCH] drm/i915: kick any firmware framebuffers before claiming the gtt Date: Sun, 1 Jul 2012 17:09:42 +0200 Message-Id: <1341155382-4710-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10 X-Gm-Message-State: ALoCoQk8YGTX80utpzx1sfLUu6NRzTm1IO/XteHvgYeMNW+tTWWqpsjeGQ/iumcFaXQNdH/M+siJ Cc: Daniel Vetter , stable@vger.kernel.org, DRI Development X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Especially vesafb likes to map everything as uc- (yikes), and if that mapping hangs around still while we try to map the gtt as wc the kernel will downgrade our request to uc-, resulting in abyssal performance. Unfortunately we can't do this as early as readon does (i.e. as the first thing we do when initializing the hw) because our fb/mmio space region moves around on a per-gen basis. So I've had to move it below the gtt initialization, but that seems to work, too. The important thing is that we do this before we set up the gtt wc mapping. Now an altogether different question is why people compile their kernels with vesafb enabled, but I guess making things just work isn't bad per se ... v2: - s/radeondrmfb/inteldrmfb/ - fix up error handling v3: Kill #ifdef X86, this is Intel after all. Noticed by Ben Widawsky. v4: Jani Nikula complained about the pointless bool primary initialization. v5: Don't oops if we can't allocate, noticed by Chris Wilson. v6: Resolve conflicts with agp rework and fixup whitespace. This is commit e188719a2891f01b3100d in drm-next. Backport to 3.5 -fixes queue requested by Dave Airlie - due to grub using vesa on fedora their initrd seems to load vesafb before loading the real kms driver. So tons more people actually experience a dead-slow gpu. Hence also the Cc: stable. Cc: Dave Airlie Cc: stable@vger.kernel.org Reported-and-tested-by: "Kilarski, Bernard R" Reviewed-by: Chris Wilson Signed-Off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_dma.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index f947926..36822b9 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1401,6 +1401,27 @@ i915_mtrr_setup(struct drm_i915_private *dev_priv, unsigned long base, } } +static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv) +{ + struct apertures_struct *ap; + struct pci_dev *pdev = dev_priv->dev->pdev; + bool primary; + + ap = alloc_apertures(1); + if (!ap) + return; + + ap->ranges[0].base = dev_priv->dev->agp->base; + ap->ranges[0].size = + dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; + primary = + pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; + + remove_conflicting_framebuffers(ap, "inteldrmfb", primary); + + kfree(ap); +} + /** * i915_driver_load - setup chip and create an initial config * @dev: DRM device @@ -1446,6 +1467,15 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) goto free_priv; } + dev_priv->mm.gtt = intel_gtt_get(); + if (!dev_priv->mm.gtt) { + DRM_ERROR("Failed to initialize GTT\n"); + ret = -ENODEV; + goto put_bridge; + } + + i915_kick_out_firmware_fb(dev_priv); + pci_set_master(dev->pdev); /* overlay on gen2 is broken and can't address above 1G */ @@ -1471,13 +1501,6 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) goto put_bridge; } - dev_priv->mm.gtt = intel_gtt_get(); - if (!dev_priv->mm.gtt) { - DRM_ERROR("Failed to initialize GTT\n"); - ret = -ENODEV; - goto out_rmmap; - } - aperture_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; dev_priv->mm.gtt_mapping =