From patchwork Sat Nov 27 13:37:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Schlichter X-Patchwork-Id: 361302 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oARDbvVF008430 for ; Sat, 27 Nov 2010 13:37:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752314Ab0K0Nhn (ORCPT ); Sat, 27 Nov 2010 08:37:43 -0500 Received: from fmmailgate03.web.de ([217.72.192.234]:59117 "EHLO fmmailgate03.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752196Ab0K0Nhm (ORCPT ); Sat, 27 Nov 2010 08:37:42 -0500 Received: from smtp05.web.de ( [172.20.4.166]) by fmmailgate03.web.de (Postfix) with ESMTP id 33D64178FCBE6; Sat, 27 Nov 2010 14:37:39 +0100 (CET) Received: from [92.194.206.175] (helo=netbook.localnet) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #24) id 1PMKyA-0005HW-00; Sat, 27 Nov 2010 14:37:39 +0100 To: Michal Januszewski Subject: [PATCH] uvesafb, vesafb: create write-combining or write-back PAT entries From: Thomas Schlichter Cc: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 27 Nov 2010 14:37:37 +0100 MIME-Version: 1.0 Message-Id: <201011271437.38126.thomas.schlichter@web.de> X-Sender: thomas.schlichter@web.de X-Provags-ID: V01U2FsdGVkX18mD65AlhIqJHk91eC5Jr1tWijwWvT+7EKAxIs0 OxO4VLg72KlVBqCg0pGpa5uO0c754+ydP7wnHjCyGnmohW7r5g OKaa0cOhGoT59uS+fsRg== Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sat, 27 Nov 2010 13:37:57 +0000 (UTC) diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c index 52ec095..5a34bc8 100644 --- a/drivers/video/uvesafb.c +++ b/drivers/video/uvesafb.c @@ -1552,8 +1552,7 @@ static void __devinit uvesafb_init_mtrr(struct fb_info *info) int rc; /* Find the largest power-of-two */ - while (temp_size & (temp_size - 1)) - temp_size &= (temp_size - 1); + temp_size = roundup_pow_of_two(temp_size); /* Try and find a power of two to add */ do { @@ -1736,15 +1735,37 @@ static int __devinit uvesafb_probe(struct platform_device *dev) uvesafb_init_info(info, mode); + if (!request_region(0x3c0, 32, "uvesafb")) { + printk(KERN_ERR "uvesafb: request region 0x3c0-0x3e0 failed\n"); + err = -EIO; + goto out_mode; + } + if (!request_mem_region(info->fix.smem_start, info->fix.smem_len, "uvesafb")) { printk(KERN_ERR "uvesafb: cannot reserve video memory at " "0x%lx\n", info->fix.smem_start); err = -EIO; - goto out_mode; + goto out_reg; } - info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); + uvesafb_init_mtrr(info); + + switch (mtrr) { + case 1: /* uncachable */ + info->screen_base = ioremap_nocache(info->fix.smem_start, info->fix.smem_len); + break; + case 2: /* write-back */ + info->screen_base = ioremap_cache(info->fix.smem_start, info->fix.smem_len); + break; + case 3: /* write-combining */ + info->screen_base = ioremap_wc(info->fix.smem_start, info->fix.smem_len); + break; + case 4: /* write-through */ + default: + info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); + break; + } if (!info->screen_base) { printk(KERN_ERR @@ -1755,20 +1776,13 @@ static int __devinit uvesafb_probe(struct platform_device *dev) goto out_mem; } - if (!request_region(0x3c0, 32, "uvesafb")) { - printk(KERN_ERR "uvesafb: request region 0x3c0-0x3e0 failed\n"); - err = -EIO; - goto out_unmap; - } - - uvesafb_init_mtrr(info); platform_set_drvdata(dev, info); if (register_framebuffer(info) < 0) { printk(KERN_ERR "uvesafb: failed to register framebuffer device\n"); err = -EINVAL; - goto out_reg; + goto out_unmap; } printk(KERN_INFO "uvesafb: framebuffer at 0x%lx, mapped to 0x%p, " @@ -1785,12 +1799,12 @@ static int __devinit uvesafb_probe(struct platform_device *dev) return 0; -out_reg: - release_region(0x3c0, 32); out_unmap: iounmap(info->screen_base); out_mem: release_mem_region(info->fix.smem_start, info->fix.smem_len); +out_reg: + release_region(0x3c0, 32); out_mode: if (!list_empty(&info->modelist)) fb_destroy_modelist(&info->modelist);