From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: earny@net4u.de
Cc: Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: Linux 2.6.3-rc3
Date: Mon, 16 Feb 2004 10:54:04 +1100 [thread overview]
Message-ID: <1076889243.11392.130.camel@gaston> (raw)
In-Reply-To: <200402160033.43438.earny@net4u.de>
On Mon, 2004-02-16 at 10:33, Ernst Herzberg wrote:
> On Montag, 16. Februar 2004 00:08, you wrote:
>
> > It couldn't mmap the framebuffer, the problem is that you have run out
> > of kernel virtual space. I'll try to find a workaround, but in the
> > meantime, you need to change the lowmem/highmem ratio.
Can you try this patch ?
===== drivers/video/aty/radeon_base.c 1.3 vs edited =====
--- 1.3/drivers/video/aty/radeon_base.c Sat Feb 14 23:00:22 2004
+++ edited/drivers/video/aty/radeon_base.c Mon Feb 16 10:53:27 2004
@@ -99,6 +99,8 @@
#include "ati_ids.h"
#include "radeonfb.h"
+#define MAX_MAPPED_VRAM (2048*2048*4)
+#define MIN_MAPPED_VRAM (1024*768*1)
#define CHIP_DEF(id, family, flags) \
{ PCI_VENDOR_ID_ATI, id, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (flags) | (CHIP_FAMILY_##family) }
@@ -566,8 +568,9 @@
break;
}
- do_div(vclk, 1000);
- xtal = (xtal * denom) / num;
+ vclk *= denom;
+ do_div(vclk, 1000 * num);
+ xtal = vclk;
if ((xtal > 26900) && (xtal < 27100))
xtal = 2700;
@@ -825,6 +828,9 @@
v.xres_virtual = (pitch << 6) / ((v.bits_per_pixel + 1) / 8);
}
+ if (((v.xres_virtual * v.yres_virtual * nom) / den) > rinfo->mapped_vram)
+ return -EINVAL;
+
if (v.xres_virtual < v.xres)
v.xres = v.xres_virtual;
@@ -1685,6 +1691,67 @@
+static ssize_t radeonfb_read(struct file *file, char *buf, size_t count, loff_t *ppos)
+{
+ unsigned long p = *ppos;
+ struct inode *inode = file->f_dentry->d_inode;
+ int fbidx = iminor(inode);
+ struct fb_info *info = registered_fb[fbidx];
+ struct radeonfb_info *rinfo = info->par;
+
+ if (p >= rinfo->mapped_vram)
+ return 0;
+ if (count >= rinfo->mapped_vram)
+ count = rinfo->mapped_vram;
+ if (count + p > rinfo->mapped_vram)
+ count = rinfo->mapped_vram - p;
+ radeonfb_sync(info);
+ if (count) {
+ char *base_addr;
+
+ base_addr = info->screen_base;
+ count -= copy_to_user(buf, base_addr+p, count);
+ if (!count)
+ return -EFAULT;
+ *ppos += count;
+ }
+ return count;
+}
+
+static ssize_t radeonfb_write(struct file *file, const char *buf, size_t count,
+ loff_t *ppos)
+{
+ unsigned long p = *ppos;
+ struct inode *inode = file->f_dentry->d_inode;
+ int fbidx = iminor(inode);
+ struct fb_info *info = registered_fb[fbidx];
+ struct radeonfb_info *rinfo = info->par;
+ int err;
+
+ if (p > rinfo->mapped_vram)
+ return -ENOSPC;
+ if (count >= rinfo->mapped_vram)
+ count = rinfo->mapped_vram;
+ err = 0;
+ if (count + p > rinfo->mapped_vram) {
+ count = rinfo->mapped_vram - p;
+ err = -ENOSPC;
+ }
+ radeonfb_sync(info);
+ if (count) {
+ char *base_addr;
+
+ base_addr = info->screen_base;
+ count -= copy_from_user(base_addr+p, buf, count);
+ *ppos += count;
+ err = -EFAULT;
+ }
+ if (count)
+ return count;
+ return err;
+}
+
+
static struct fb_ops radeonfb_ops = {
.owner = THIS_MODULE,
.fb_check_var = radeonfb_check_var,
@@ -1697,6 +1764,8 @@
.fb_fillrect = radeonfb_fillrect,
.fb_copyarea = radeonfb_copyarea,
.fb_imageblit = radeonfb_imageblit,
+ .fb_read = radeonfb_read,
+ .fb_write = radeonfb_write,
.fb_cursor = soft_cursor,
};
@@ -2121,11 +2190,27 @@
RTRACE("radeonfb: probed %s %ldk videoram\n", (rinfo->ram_type), (rinfo->video_ram/1024));
- rinfo->fb_base = (unsigned long) ioremap (rinfo->fb_base_phys, rinfo->video_ram);
+ rinfo->mapped_vram = MAX_MAPPED_VRAM;
+ if (rinfo->video_ram < rinfo->mapped_vram)
+ rinfo->mapped_vram = rinfo->video_ram;
+ for (;;) {
+ rinfo->fb_base = (unsigned long) ioremap (rinfo->fb_base_phys,
+ rinfo->mapped_vram);
+ if (rinfo->fb_base == 0 && rinfo->mapped_vram > MIN_MAPPED_VRAM) {
+ rinfo->mapped_vram /= 2;
+ continue;
+ }
+ break;
+ }
+
if (!rinfo->fb_base) {
printk (KERN_ERR "radeonfb: cannot map FB\n");
goto unmap_rom;
}
+
+ RTRACE("radeonfb: mapped %ldk videoram\n", rinfo->mapped_vram/1024);
+
+
/* Argh. Scary arch !!! */
#ifdef CONFIG_PPC64
rinfo->fb_base = IO_TOKEN_TO_ADDR(rinfo->fb_base);
===== drivers/video/aty/radeonfb.h 1.2 vs edited =====
--- 1.2/drivers/video/aty/radeonfb.h Fri Feb 13 03:10:47 2004
+++ edited/drivers/video/aty/radeonfb.h Mon Feb 16 10:50:42 2004
@@ -282,6 +282,7 @@
u8 family;
u8 rev;
unsigned long video_ram;
+ unsigned long mapped_vram;
int pitch, bpp, depth;
next prev parent reply other threads:[~2004-02-15 23:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-15 3:33 Linux 2.6.3-rc3 Linus Torvalds
2004-02-15 7:41 ` 2.6.3-rc3: twice defined symbols with new radeonfb Adrian Bunk
2004-02-15 7:47 ` Benjamin Herrenschmidt
2004-02-15 13:22 ` Adrian Bunk
2004-02-15 19:19 ` Roman Zippel
2004-02-15 9:17 ` Linux 2.6.3-rc3 Peter Osterlund
2004-02-15 9:54 ` Benjamin Herrenschmidt
2004-02-15 10:25 ` Benjamin Herrenschmidt
2004-02-15 10:51 ` Peter Osterlund
2004-02-15 11:11 ` Benjamin Herrenschmidt
2004-02-15 11:21 ` Geert Uytterhoeven
2004-02-15 10:33 ` Peter Osterlund
2004-02-15 15:03 ` Jonathan Brown
2004-02-15 16:05 ` Tomas Szepe
2004-02-15 16:44 ` Onur Kucuk
2004-02-16 15:58 ` Moritz Muehlenhoff
2004-02-17 16:29 ` Moritz Muehlenhoff
2004-02-15 19:52 ` Ernst Herzberg
2004-02-15 20:11 ` Peter Osterlund
2004-02-15 21:52 ` Ernst Herzberg
2004-02-15 22:29 ` Benjamin Herrenschmidt
[not found] ` <200402152357.25751.earny@net4u.de>
2004-02-15 23:08 ` Benjamin Herrenschmidt
[not found] ` <200402160033.43438.earny@net4u.de>
2004-02-15 23:54 ` Benjamin Herrenschmidt [this message]
2004-02-16 0:29 ` Ernst Herzberg
2004-02-16 0:38 ` Ernst Herzberg
2004-02-16 0:43 ` Benjamin Herrenschmidt
2004-02-16 1:18 ` Ernst Herzberg
2004-02-16 1:47 ` Benjamin Herrenschmidt
2004-02-16 0:41 ` Benjamin Herrenschmidt
[not found] ` <124101c3f435$9a66d3a0$1225a8c0@kittycat>
2004-02-16 2:37 ` Benjamin Herrenschmidt
2004-02-15 22:27 ` Benjamin Herrenschmidt
[not found] ` <200402160005.47892.anib@uni-paderborn.de>
2004-02-15 23:11 ` Benjamin Herrenschmidt
2004-02-16 19:18 ` Linux 2.6.3-rc3 (compile stats) John Cherry
-- strict thread matches above, loose matches on Subject: below --
2004-02-16 6:15 Linux 2.6.3-rc3 Jonathan Brown
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=1076889243.11392.130.camel@gaston \
--to=benh@kernel.crashing.org \
--cc=earny@net4u.de \
--cc=linux-kernel@vger.kernel.org \
/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