linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <syrjala@sci.fi>
To: linux-fbdev-devel@lists.sourceforge.net
Subject: [PATCH] atyfb: MTRR support
Date: Wed, 25 Aug 2004 02:46:30 +0300	[thread overview]
Message-ID: <20040824234630.GA20966@sci.fi> (raw)

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

The attached patch adds MTRR support to atyfb.

Write-combining is enabled for the whole PCI resource and an uncachable 
hole is made for MMIO registers if necessary.

I also changed aty_init() to return 0 on success like the other functions.

-- 
Ville Syrjälä
syrjala@sci.fi
http://www.sci.fi/~syrjala/

[-- Attachment #2: atyfb-2.6-mtrr.patch --]
[-- Type: text/plain, Size: 3473 bytes --]

diff -NaurbB linux-irq2/drivers/video/aty/atyfb.h linux-mtrr/drivers/video/aty/atyfb.h
--- linux-irq2/drivers/video/aty/atyfb.h	2004-07-22 21:08:19.000000000 +0300
+++ linux-mtrr/drivers/video/aty/atyfb.h	2004-08-16 10:13:14.000000000 +0300
@@ -178,6 +178,10 @@
 	unsigned long irq_flags;
 	unsigned int irq;
 	spinlock_t int_lock;
+#ifdef CONFIG_MTRR
+	int mtrr_aper;
+	int mtrr_reg;
+#endif
 };
 
     /*
diff -NaurbB linux-irq2/drivers/video/aty/atyfb_base.c linux-mtrr/drivers/video/aty/atyfb_base.c
--- linux-irq2/drivers/video/aty/atyfb_base.c	2004-08-25 01:52:01.631006776 +0300
+++ linux-mtrr/drivers/video/aty/atyfb_base.c	2004-08-25 01:51:41.023139648 +0300
@@ -92,6 +92,9 @@
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include <asm/backlight.h>
 #endif
+#ifdef CONFIG_MTRR
+#include <asm/mtrr.h>
+#endif
 
 
 /*
@@ -286,6 +289,7 @@
 };
 
 static char noaccel __initdata = 0;
+static char nomtrr __initdata = 0;
 static u32 default_vram __initdata = 0;
 static int default_pll __initdata = 0;
 static int default_mclk __initdata = 0;
@@ -2388,6 +2392,26 @@
 	if (par->aux_start)
 		aty_st_le32(BUS_CNTL, aty_ld_le32(BUS_CNTL, par) | BUS_APER_REG_DIS, par);
 
+#ifdef CONFIG_MTRR
+	par->mtrr_aper = -1;
+	par->mtrr_reg = -1;
+	if (!nomtrr) {
+		/* Cover the whole resource. */
+		par->mtrr_aper = mtrr_add(par->res_start,
+					  par->res_size, MTRR_TYPE_WRCOMB, 1);
+		if (par->mtrr_aper >= 0 && !par->aux_start) {
+			/* Make a hole for mmio. */
+			par->mtrr_reg = mtrr_add(par->res_start + 0x800000 -
+						 GUI_RESERVE, GUI_RESERVE,
+						 MTRR_TYPE_UNCACHABLE, 1);
+			if (par->mtrr_reg < 0) {
+				mtrr_del(par->mtrr_aper, 0, 0);
+				par->mtrr_aper = -1;
+			}
+		}
+	}
+#endif
+
 	/* Clear the video memory */
 	fb_memset((void *) info->screen_base, 0, info->fix.smem_len);
 
@@ -2457,7 +2481,7 @@
 
 	if (atyfb_check_var(&var, info)) {
 		printk(KERN_CRIT "atyfb: can't set default video mode\n");
-		return 0;
+		goto err_del_mtrr;
 	}
 
 #ifdef __sparc__
@@ -2473,13 +2497,22 @@
 	fb_alloc_cmap(&info->cmap, 256, 0);
 
 	if (register_framebuffer(info) < 0)
-		return 0;
+		goto err_del_mtrr;
 
 	fb_list = info;
 
 	printk("fb%d: %s frame buffer device on %s\n",
 	       info->node, info->fix.id, name);
-	return 1;
+	return 0;
+
+ err_del_mtrr:
+#ifdef CONFIG_MTRR
+	if (par->mtrr_reg >= 0)
+		mtrr_del(par->mtrr_reg, 0, 0);
+	if (par->mtrr_aper >= 0)
+		mtrr_del(par->mtrr_aper, 0, 0);
+#endif
+	return -1;
 }
 
 #ifndef MODULE
@@ -2493,6 +2526,8 @@
 	while ((this_opt = strsep(&options, ",")) != NULL) {
 		if (!strncmp(this_opt, "noaccel", 7))
 			noaccel = 1;
+		else if (!strncmp(this_opt, "nomtrr", 6))
+			nomtrr = 1;
 		else if (!strncmp(this_opt, "vram:", 5))
 			default_vram =
 			    simple_strtoul(this_opt + 5, NULL, 0);
@@ -3364,7 +3399,7 @@
 	pci_set_drvdata(pdev, info);
 
 	/* Init chip & register framebuffer */
-	if (!aty_init(info, "PCI"))
+	if (aty_init(info, "PCI"))
 		goto err_release_io;
 
 #ifdef __sparc__
@@ -3466,7 +3501,7 @@
 			break;
 		}
 
-		if (!aty_init(info, "ISA bus")) {
+		if (aty_init(info, "ISA bus")) {
 			framebuffer_release(info);
 			/* This is insufficient! kernel_map has added two large chunks!! */
 			return -ENXIO;
@@ -3482,6 +3517,12 @@
 
 	unregister_framebuffer(info);
 
+#ifdef CONFIG_MTRR
+	if (par->mtrr_reg >= 0)
+		mtrr_del(par->mtrr_reg, 0, 0);
+	if (par->mtrr_aper >= 0)
+		mtrr_del(par->mtrr_aper, 0, 0);
+#endif
 #ifndef __sparc__
 	if (par->ati_regbase)
 		iounmap((void *) par->ati_regbase);

                 reply	other threads:[~2004-08-24 23:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040824234630.GA20966@sci.fi \
    --to=syrjala@sci.fi \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).