From patchwork Fri May 3 23:00:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 2519871 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 223DB40207 for ; Fri, 3 May 2013 23:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934311Ab3ECXBD (ORCPT ); Fri, 3 May 2013 19:01:03 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:39187 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934241Ab3ECXBA (ORCPT ); Fri, 3 May 2013 19:01:00 -0400 Received: by mail-pd0-f178.google.com with SMTP id w11so1121994pde.23 for ; Fri, 03 May 2013 16:00:59 -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=hW3IOf7oCWolel5nS0G7Z2PdP1rdjyuicTZRJnP4dz4=; b=aA/VlLkZ5jmH5FdTxkDai8WiPGG1D2nKgpj99D/hthQl2fubejjiaNY0edff9H5OJV XkdbQL4LxLMdsOx9v2N7327nnXFsvU20jOzE74R4O/28FhpspvSI2Ly/E1s5cpTekzzi GuzdELQDg4rZ8sYJaJJdBcBPGfkhoMbyR4/MQY5SlP1b0uD7bBYtCBJQgXktblrZhwgU QObPm039gKcn5R/DDwVw1BEJB8TpBpn3zH0iAqsVCXAsC9vpvYdw8BlNTs++NpX7+FWW mBO2wlocjt8284a/NjPuM1LxlNEERScHYyAtY+OcFB4xiNV9WC51rHBasP2U9PPb3hYT a7Ow== X-Received: by 10.66.154.72 with SMTP id vm8mr16629299pab.2.1367622059895; Fri, 03 May 2013 16:00:59 -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 pa2sm14531247pac.9.2013.05.03.16.00.58 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 03 May 2013 16:00:59 -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 3/7] drm: Update drm_addmap and drm_mmap to use PAT WC instead of MTRRs Date: Fri, 3 May 2013 16:00:31 -0700 Message-Id: X-Mailer: git-send-email 1.8.1.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQmgtzRPS6sX9DHfx9vb7FUzI7ErFCXUhHPNbBvFyQMr5AmAezfpGKPRuAoScTficoAoRzyZ Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Signed-off-by: Andy Lutomirski --- This needs careful review. I don't really know what this code does, nor do I have the hardware. (I don't understand AGP and the associated caching implications.) drivers/gpu/drm/drm_bufs.c | 11 ++++------- drivers/gpu/drm/drm_vm.c | 13 +++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index 0128147..0ae9cbb 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -210,8 +210,8 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset, if (drm_core_has_MTRR(dev)) { if (map->type == _DRM_FRAME_BUFFER || (map->flags & _DRM_WRITE_COMBINING)) { - map->mtrr = mtrr_add(map->offset, map->size, - MTRR_TYPE_WRCOMB, 1); + map->mtrr = + drm_mtrr_add_wc(map->offset, map->size); } } if (map->type == _DRM_REGISTERS) { @@ -451,11 +451,8 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map) iounmap(map->handle); /* FALLTHROUGH */ case _DRM_FRAME_BUFFER: - if (drm_core_has_MTRR(dev) && map->mtrr >= 0) { - int retcode; - retcode = mtrr_del(map->mtrr, map->offset, map->size); - DRM_DEBUG("mtrr_del=%d\n", retcode); - } + if (drm_core_has_MTRR(dev)) + drm_mtrr_del_wc(map->mtrr); break; case _DRM_SHM: vfree(map->handle); diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index db7bd29..b255fd7 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -43,15 +43,16 @@ static void drm_vm_open(struct vm_area_struct *vma); static void drm_vm_close(struct vm_area_struct *vma); -static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) +static pgprot_t drm_io_prot(struct drm_local_map *map, + struct vm_area_struct *vma) { pgprot_t tmp = vm_get_page_prot(vma->vm_flags); #if defined(__i386__) || defined(__x86_64__) - if (boot_cpu_data.x86 > 3 && map_type != _DRM_AGP) { - pgprot_val(tmp) |= _PAGE_PCD; - pgprot_val(tmp) &= ~_PAGE_PWT; - } + if (map->flags & _DRM_WRITE_COMBINING) + tmp = pgprot_writecombine(tmp); + else if (map->type != _DRM_AGP) + tmp = pgprot_noncached(tmp); #elif defined(__powerpc__) pgprot_val(tmp) |= _PAGE_NO_CACHE; if (map_type == _DRM_REGISTERS) @@ -617,7 +618,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma) case _DRM_REGISTERS: offset = drm_core_get_reg_ofs(dev); vma->vm_flags |= VM_IO; /* not in core dump */ - vma->vm_page_prot = drm_io_prot(map->type, vma); + vma->vm_page_prot = drm_io_prot(map, vma); if (io_remap_pfn_range(vma, vma->vm_start, (map->offset + offset) >> PAGE_SHIFT, vma->vm_end - vma->vm_start,