From patchwork Fri May 3 23:00:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 2519891 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 558093FCA5 for ; Fri, 3 May 2013 23:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934258Ab3ECXBJ (ORCPT ); Fri, 3 May 2013 19:01:09 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:50166 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763484Ab3ECXBG (ORCPT ); Fri, 3 May 2013 19:01:06 -0400 Received: by mail-pd0-f178.google.com with SMTP id w11so1135758pde.9 for ; Fri, 03 May 2013 16:01:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-gm-message-state; bh=va/DF8AfvFFgzKBEF0TBzFCERTVIQRdZNa9AtrRVUq0=; b=SlkcpEcTniNKQIL+EcYRWaJiuNyyNpYRy4OmqZcgirt9JVW/qNRSmIWNpnkP++KGnx F9yGfU9yF3vlSWYKW5FAL4OPllTGEHTnYt9w1yUTXd8C3pLrMHX+1utbjqOeGn4b2aM1 nuHKFHFaGUEes0G4GICcR25MSJK0RkNhIGWpkWBwEvvYmH/gf3Ev5anox3faWOwFtDmM 8/N10EEnV7+fOcZfSxkzHqkDje9FgUm1i/5hK1hxXiyZMXeWrU5vAz83yMkZy6vMerlQ Afz7T4i61id6gap6rdvzIWafsqneftn97HAHoiqvMgDF1oyzyjmQs5egC125CVKKn/5e gyzg== X-Received: by 10.68.189.67 with SMTP id gg3mr15926235pbc.141.1367622066095; Fri, 03 May 2013 16:01:06 -0700 (PDT) Received: from localhost (50-76-60-73-ip-static.hfc.comcastbusiness.net. [50.76.60.73]) by mx.google.com with ESMTPSA id em2sm13298279pbb.0.2013.05.03.16.01.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 03 May 2013 16:01:04 -0700 (PDT) From: Andy Lutomirski To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org Cc: Andy Lutomirski Subject: [PATCH 5/7] i915: Use drm_mtrr_{add,del}_wc Date: Fri, 3 May 2013 16:00:33 -0700 Message-Id: <55ce0249bc74fc15af617349cfd5e68a159cf75b.1367621039.git.luto@amacapital.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQnoXihYYIEGTmOy4sKqKhbcpq9q2OAS/K/FlhOfPUW6npwnYN553F7RTY+wYIW9nJcvZ4Os Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org i915 open-coded logic that was essentially equivalent to the new drm_mtrr_{add,del}_wc. Signed-off-by: Andy Lutomirski --- drivers/gpu/drm/i915/i915_dma.c | 43 ++++++----------------------------------- 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 4fa6beb..0fc95ba 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1393,29 +1393,6 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master) master->driver_priv = NULL; } -static void -i915_mtrr_setup(struct drm_i915_private *dev_priv, unsigned long base, - unsigned long size) -{ - dev_priv->mm.gtt_mtrr = -1; - -#if defined(CONFIG_X86_PAT) - if (cpu_has_pat) - return; -#endif - - /* Set up a WC MTRR for non-PAT systems. This is more common than - * one would think, because the kernel disables PAT on first - * generation Core chips because WC PAT gets overridden by a UC - * MTRR if present. Even if a UC MTRR isn't present. - */ - dev_priv->mm.gtt_mtrr = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1); - if (dev_priv->mm.gtt_mtrr < 0) { - DRM_INFO("MTRR allocation failed. Graphics " - "performance may suffer.\n"); - } -} - static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv) { struct apertures_struct *ap; @@ -1552,8 +1529,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) goto out_rmmap; } - i915_mtrr_setup(dev_priv, dev_priv->gtt.mappable_base, - aperture_size); + dev_priv->mm.gtt_mtrr = drm_mtrr_add_wc(dev_priv->gtt.mappable_base, + aperture_size); /* The i915 workqueue is primarily used for batched retirement of * requests (and thus managing bo) once the task has been completed @@ -1656,12 +1633,8 @@ out_gem_unload: intel_teardown_mchbar(dev); destroy_workqueue(dev_priv->wq); out_mtrrfree: - if (dev_priv->mm.gtt_mtrr >= 0) { - mtrr_del(dev_priv->mm.gtt_mtrr, - dev_priv->gtt.mappable_base, - aperture_size); - dev_priv->mm.gtt_mtrr = -1; - } + drm_mtrr_del_wc(dev_priv->mm.gtt_mtrr); + dev_priv->mm.gtt_mtrr = -1; io_mapping_free(dev_priv->gtt.mappable); out_rmmap: pci_iounmap(dev->pdev, dev_priv->regs); @@ -1697,12 +1670,8 @@ int i915_driver_unload(struct drm_device *dev) cancel_delayed_work_sync(&dev_priv->mm.retire_work); io_mapping_free(dev_priv->gtt.mappable); - if (dev_priv->mm.gtt_mtrr >= 0) { - mtrr_del(dev_priv->mm.gtt_mtrr, - dev_priv->gtt.mappable_base, - dev_priv->gtt.mappable_end); - dev_priv->mm.gtt_mtrr = -1; - } + drm_mtrr_del_wc(dev_priv->mm.gtt_mtrr); + dev_priv->mm.gtt_mtrr = -1; acpi_video_unregister();