VRAM detection in controlfb
PATCH 1/1 VRAM detection in controlfb
Hi list,
I've finally gotten bored by control's VRAM detection code that is only semi-functional (either 7x00 or 8x00 VRAM is incorrectly detected). Until somebody comes up with a failsafe method to detect VRAM, I've added a command line option to control the amount of VRAM used:
- either kernel command line (compiled-in):
video=controlfb:vram:3
- or insmod option (no idea whether controlfb works as module):
insmod controlfb vram=3
Possible values are:
0 = autodetect (default) 1 = 2MB bank1 2 = 2MB bank2 3 = 4MB (most useful; 4MB doesn't always get detected right)
Larger values get cropped to bits 0 & 1.
If I hear no opposition, I'll send this off to Alan; it might make it into 2.4.0-final.
Cheers
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
drivers/video/controlfb.c +37 -7
@@ -109,6 +109,11 @@ } fbcon_cmap; }; +static int vram =0 ;/* VRAM config: 1 = 2MB bank1; 2 = 2MB bank2; +3 = 4MB */ +MODULE_PARM (vram,"i" ); +MODULE_PARM_DESC (vram,"Override VRAM detection: 1 = 2MB bank1; 2 = 2MB bank2; 3 = 4MB" ); +/******************** Prototypes for exported functions ********************/ static int control_open (struct fb_info *info,int user);static int control_release (struct fb_info *info,int user);
@@ -628,8 +633,8 @@out_le32 (&p->control_regs->flags.r, flags);out_le32 (&p->control_regs->start_addr.r, par->yoffset * (par->vxres << cmode)); -out_le32 (&p->control_regs->reg18.r,0x1e5 ); -out_le32 (&p->control_regs->reg19.r,0 ); +out_le32 (&p->control_regs->refr_cnt.r,0x1e5 ); +out_le32 (&p->control_regs->int_en.r,0 );for (i =0 ; i <16 ; ++i) { controlfb_setcolreg(color_table[i], default_red[i]<<8,
@@ -715,6 +720,29 @@* - with 4M vram, it appears only as a 4M block at offset 0. */ +/* Unfortunately, above is only true on 8x00 machines. 7x00 machines +* behave differently. Until somebody comes up with a way to +* differentiate between the two, you can use the vram= insmod or +* video=controlfb:vram: command-line option to force a specific +* VRAM config. +* Michel Lanners <[email protected]> +*/ + +if (vram !=0 ) { + bank1 = vram &1 ; + bank2 = (vram &2 ) /2 ; +printk (KERN_INFO "controlfb: Overriding VRAM detection, set to" +" %s%s%s.\n" , (bank1 && bank2) ?"4MB" :"2MB " , + (bank1 && !bank2) ?"(bank1)" :"" , + (!bank1 && bank2) ?"(bank2)" :"" ); +if (!bank1) { + p->control_use_bank2 =1 ; + p->frame_buffer +=0x600000 ; + p->frame_buffer_phys +=0x600000 ; + } + goto detect_done; + } +/* We know there is something at 2M if there is something at 0M. */ out_8 (&p->frame_buffer[0x200000 ],0xa5 );out_8 (&p->frame_buffer[0x200001 ],0x38 );
@@ -743,7 +771,8 @@ p->frame_buffer +=0x600000 ; p->frame_buffer_phys +=0x600000 ; } - + +detect_done: p->total_vram = (bank1 + bank2) *0x200000 ; printk(KERN_INFO "controlfb: Memory bank 1 %s, bank 2 %s, total VRAM %dMB\n",
@@ -1194,11 +1223,10 @@break ;memcpy (fontname, this_opt +5 , i); fontname[i] =0 ; - } -if (!strncmp (this_opt,"vmode:" ,6 )) { + }else if (!strncmp (this_opt,"vmode:" ,6 )) {int vmode =simple_strtoul (this_opt+6 ,NULL ,0 ); -if (vmode >0 && vmode <=VMODE_MAX ) - default_vmode = vmode; +if (vmode >0 && vmode <=VMODE_MAX ) + default_vmode = vmode; }else if (!strncmp (this_opt,"cmode:" ,6 )) {int depth =simple_strtoul (this_opt+6 ,NULL ,0 );switch (depth) {
@@ -1219,6 +1247,8 @@ default_cmode =CMODE_32 ;break ; } + }else if (!strncmp (this_opt,"vram:" ,5 )) { + vram =3 &simple_strtoul (this_opt+5 ,NULL ,0 ); } } }
drivers/video/controlfb.h +13 -12
@@ -21,13 +21,13 @@* Structure of the registers for the RADACAL colormap device. */ struct cmap_regs { -unsigned char addr; +unsigned char addr;/* REG-ADDR */ char pad1[15 ]; -unsigned char d1; +unsigned char d1;/* CRSR-PALETTE */ char pad2[15 ]; -unsigned char d2; +unsigned char d2;/* REG-DATA */ char pad3[15 ]; -unsigned char lut; +unsigned char lut;/* COLOR-PALETTE */ char pad4[15 ]; };
@@ -51,26 +51,27 @@struct preg vesync;/* vert end sync */ struct preg vssync;/* vert start sync */ struct preg vperiod;/* vert period */ -struct preg reg8; +struct preg reg8;/* PipeDelayHWCursor */ /* Horizontal params are in units of 2 pixels */ struct preg hperiod;/* horiz period - 2 */ struct preg hsblank;/* horiz start blank */ struct preg heblank;/* horiz end blank */ struct preg hesync;/* horiz end sync */ struct preg hssync;/* horiz start sync */ -struct preg rege; -struct preg regf; -struct preg reg10; -struct preg reg11; +struct preg rege;/* HEQ */ +struct preg regf;/* HLFLN */ +struct preg reg10;/* HSERR */ +struct preg reg11;/* CNTTST */ struct preg ctrl;/* display control */ struct preg start_addr;/* start address: 5 lsbs zero */ struct preg pitch;/* addrs diff between scan lines */ struct preg mon_sense;/* monitor sense bits */ struct preg flags;struct preg mode; -struct preg reg18; -struct preg reg19; -struct preg res[6 ]; +struct preg refr_cnt;/* REFRESH-COUNT */ +struct preg int_en;/* interrupt enable */ +struct preg int_st;/* interrupt status */ +struct preg res[5 ]; };struct control_regints {
Hi Michel,
On Thu, 1 Jun 2000, Michel Lanners wrote:
[...]
Quoted 2 lines
If I hear no opposition, I'll send this off to Alan; it might make it into 2.4.0-final.
Actually, I have sent a similar patch to DanJ a few weeks ago. The patch attached includes a few bug fixes as well as a feature enhancement in that it is now possible to program all aspects of control frame buffer geometry/timings to your liking; that is, you can use xvidtune to ruin your monitor if you are not careful. Also, mode-switching-on-the-fly is possible if X server supports it.
Takashi Oe
Hi Takashi,
On 31 May, this message from Takashi Oe echoed through cyberspace:
Quoted 5 lines
[...]
Quoted 2 lines
If I hear no opposition, I'll send this off to Alan; it might make it into 2.4.0-final.
Actually, I have sent a similar patch to DanJ a few weeks ago.
Do you mind if I merge yours and my patch to keep your bugfixes and enhancements, and my command line code? I think mine is easier in the sense that you can _exactly_ specify what is in the box, including indicating the bank for 2MB configs.
For those with multiple display adapters, do you think an option controlfb:off might make sense? As there is no way to control which card gets assigned which framebuffer device, that might help in certain situations...
Quoted 5 lines
The patch
attached includes a few bug fixes as well as a feature enhancement in that it is now possible to program all aspects of control frame buffer geometry/timings to your liking; that is, you can use xvidtune to ruin your monitor if you are not careful.
I've had a quick try in XFree 4, but that didn't work. How did you do that?
Also, when running Xfree 4, I get a wrapped-around screen in the sense that the leftmost ~200 pixels appear on the _right_ side of the monitor. Might that be the offset of pixel #1 in the framebuffer? Although, that's around 100 bytes IIRC, so wouldn't explain the 200 pixels at 32 bit/pixel.... FWIW, I'm running Jack Howarth's XF4-12a RPMs.
Thanks
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 7 lines · Michel Lanners
Hi Takashi,
On 31 May, this message from Takashi Oe echoed through cyberspace:
Quoted 4 lines
[...]
Quoted 2 lines
If I hear no opposition, I'll send this off to Alan; it might make it into 2.4.0-final.
Quoted 6 lines
Quoted 1 line
Actually, I have sent a similar patch to DanJ a few weeks ago.
Do you mind if I merge yours and my patch to keep your bugfixes and enhancements, and my command line code? I think mine is easier in the sense that you can _exactly_ specify what is in the box, including indicating the bank for 2MB configs.
I don't mind, but can you improve the way to specify the vram config? Your method is precise but not very intuitive. Besides, is there anyone with 2MB vram have the vram detection problem with either 2.2 or 2.{3,4} controlfb codes? I have only seen the problem with 4 MB, so being able to specifiy which bank is in use may be overkill.
Quoted 6 lines
For those with multiple display adapters, do you think an option controlfb:off might make sense? As there is no way to control which card gets assigned which framebuffer device, that might help in certain situations...
Quoted 8 lines
Quoted 5 lines
The patch
attached includes a few bug fixes as well as a feature enhancement in that it is now possible to program all aspects of control frame buffer geometry/timings to your liking; that is, you can use xvidtune to ruin your monitor if you are not careful.I've had a quick try in XFree 4, but that didn't work. How did you do that?
I'm using XF4 server with XFree86-3.3.x xvidtune, and it does what I think it should do.
Quoted 5 lines
Also, when running Xfree 4, I get a wrapped-around screen in the sense that the leftmost ~200 pixels appear on the _right_ side of the monitor. Might that be the offset of pixel #1 in the framebuffer? Although, that's around 100 bytes IIRC, so wouldn't explain the 200 pixels at 32 bit/pixel.... FWIW, I'm running Jack Howarth's XF4-12a RPMs.
XF4's fbdev is not working right for me either. The weird displacement occurs on both of display cards (control, matrox) I have. I think the current XF4 is of no use for fbdev only people.
Try fbset for finding resolution/timings you like for now and use XF68_FBDev.
By the way, I've heard there is a work-in-progress Xpmac with software accelerated code by Ryuichi. I'd think this one would be the best X server for control or any other Apple un-accelerated display adapters. If you ask him now, he might consider adding XF86VidMode extension support.
Takashi Oe
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 10 lines · Takashi Oe
Quoted 5 lines · Michel Lanners
Also, when running Xfree 4, I get a wrapped-around screen in the sense that the leftmost ~200 pixels appear on the _right_ side of the monitor. Might that be the offset of pixel #1 in the framebuffer? Although, that's around 100 bytes IIRC, so wouldn't explain the 200 pixels at 32 bit/pixel.... FWIW, I'm running Jack Howarth's XF4-12a RPMs.
XF4's fbdev is not working right for me either. The weird displacement occurs on both of display cards (control, matrox) I have. I think the current XF4 is of no use for fbdev only people.
Probably XF4 handles fix.smem_start being not on a page boundary incorrectly.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines · Michel Lanners
For those with multiple display adapters, do you think an option controlfb:off might make sense? As there is no way to control which card gets assigned which framebuffer device, that might help in certain situations...
Immediately after I read this, I thought: isn't that already implemented through fbmem.c? Then I remembered that controlfb is initialized from offb, and not directly from fbmem_init().
I looked at the source, and surprise, controlfb can also be initialised on its own:
int __init control_init(void)
{
#ifndef CONFIG_FB_OF
struct device_node *dp;
dp = find_devices("control");
if (dp != 0)
control_of_init(dp);
#endif /* CONFIG_FB_OF */
return 0;
}
void __init control_of_init(struct device_node *dp)
{
...
}Thus if you compile a kernel with CONFIG_FB_OF=n, controlfb will still work! In addition you can disable it with video=controlfb:off!
If controlfb would (1) use request_mem_region() to mark the I/O regions it uses busy and (2) be initialized before offb, it would also work when offb is present and we can remove the test for a control display from offb.
Below you can find an (untested) patch that illustrates this idea. Can someone please take a look at this?
A similar thing can be done for at least platinumfb, valkyriefb, chipsfb and imsttfb. Five more steps closer to the removal of offb_init_driver()!
drivers/video/Config.in renamed from drivers/video/Config.in.orig +1 -1
@@ -64,8 +64,8 @@ fi if [ "$CONFIG_PPC" = "y" ]; then bool ' Open Firmware frame buffer device support' CONFIG_FB_OF + bool ' Apple "control" display support' CONFIG_FB_CONTROL if [ "$CONFIG_FB_OF" = "y" ]; then - bool ' Apple "control" display support' CONFIG_FB_CONTROL bool ' Apple "platinum" display support' CONFIG_FB_PLATINUM bool ' Apple "valkyrie" display support' CONFIG_FB_VALKYRIE bool ' IMS Twin Turbo display support' CONFIG_FB_IMSTT
drivers/video/offb.c renamed from drivers/video/offb.c.orig +0 -9
@@ -296,9 +296,6 @@#ifdef CONFIG_FB_MATROX extern int matrox_of_init (struct device_node *dp);#endif /* CONFIG_FB_MATROX */ -#ifdef CONFIG_FB_CONTROL -extern void control_of_init (struct device_node *dp); -#endif /* CONFIG_FB_CONTROL */ #ifdef CONFIG_FB_VALKYRIE extern void valkyrie_of_init (struct device_node *dp);#endif /* CONFIG_FB_VALKYRIE */
@@ -435,12 +432,6 @@return 1 ; }#endif /* CONFIG_FB_MATROX */ -#ifdef CONFIG_FB_CONTROL -if (!strcmp (dp->name,"control" )) { -control_of_init (dp); -return 1 ; - } -#endif /* CONFIG_FB_CONTROL */ #ifdef CONFIG_FB_VALKYRIE if (!strcmp (dp->name,"valkyrie" )) {valkyrie_of_init (dp);
drivers/video/fbmem.c renamed from drivers/video/fbmem.c.orig +4 -4
@@ -165,10 +165,13 @@ #ifdef CONFIG_FB_ATY128 { "aty128fb", aty128fb_init, aty128fb_setup }, #endif +#ifdef CONFIG_FB_CONTROL + { "controlfb", control_init, control_setup }, +#endif #ifdef CONFIG_FB_OF /* * Offb must be initialized _after_ all other frame buffer devices - * that use PCI probing and PCI resources! [ Geert ] + * that use I/O memory resources! [ Geert ] */ { "offb", offb_init, offb_setup }, #endif
@@ -211,9 +214,6 @@ #ifdef CONFIG_FB_HP300 { "hpfb", hpfb_init, hpfb_setup }, #endif -#ifdef CONFIG_FB_CONTROL - { "controlfb", control_init, control_setup }, -#endif #ifdef CONFIG_FB_VALKYRIE { "valkyriefb", valkyriefb_init, valkyriefb_setup }, #endif
drivers/video/controlfb.c renamed from drivers/video/controlfb.c.orig +16 -26
85 lines not on this page · raw message
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 6 lines · Geert Uytterhoeven
Quoted 3 lines
XF4's fbdev is not working right for me either. The weird displacement occurs on both of display cards (control, matrox) I have. I think the current XF4 is of no use for fbdev only people.
Probably XF4 handles fix.smem_start being not on a page boundary incorrectly.
What would it have to do to handle it?
Michel
--
Man invented language to satisfy his deep need to complain.
______________________________________________________________________________
Earthling Michel Dänzer (MrCooper) \ CS student and free software enthusiast
Debian GNU/Linux (powerpc,i386) user \ member of XFree86, Team *AMIGA*, AUGS
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Am Thu, 01 Jun 2000 schrieb Michel Lanners:
Quoted 22 lines
Quoted 1 line
Hi list,
I've finally gotten bored by control's VRAM detection code that is only semi-functional (either 7x00 or 8x00 VRAM is incorrectly detected). Until somebody comes up with a failsafe method to detect VRAM, I've added a command line option to control the amount of VRAM used:
- either kernel command line (compiled-in):
video=controlfb:vram:3
- or insmod option (no idea whether controlfb works as module):
insmod controlfb vram=3
Possible values are:
0 = autodetect (default) 1 = 2MB bank1 2 = 2MB bank2 3 = 4MB (most useful; 4MB doesn't always get detected right)
Quoted 4 lines
Larger values get cropped to bits 0 & 1.
If I hear no opposition, I'll send this off to Alan; it might make it into 2.4.0-final.
Hi,
if you don't mind, would you try to replace the "dcbi" assembler instructions in the detection code with "dcbf" instructions? It seems Dan inherited my bug I had in the platinumfb driver...
Franz.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 9 lines · Michel Dänzer
Quoted 6 lines · Geert Uytterhoeven
Quoted 3 lines
XF4's fbdev is not working right for me either. The weird displacement occurs on both of display cards (control, matrox) I have. I think the current XF4 is of no use for fbdev only people.
Probably XF4 handles fix.smem_start being not on a page boundary incorrectly.
What would it have to do to handle it?
Round down smem_start and mmap() it, and readd the offset. Cfr.
ati_smem_start = (unsigned long)fb_fix.smem_start & PAGE_MASK;
ati_smem_offset = (unsigned long)fb_fix.smem_start & ~PAGE_MASK;
ati_smem_len = (ati_smem_offset+fb_fix.smem_len+~PAGE_MASK) & PAGE_MASK;
addr = (unsigned long)mmap(NULL, ati_smem_len, PROT_READ | PROT_WRITE,
MAP_SHARED, fb_fd, 0);
ati_smem = addr+ati_smem_offset;
...
munmap((caddr_t)(ati_smem & PAGE_MASK), ati_smem_len);Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines · Michel Lanners
For those with multiple display adapters, do you think an option controlfb:off might make sense? As there is no way to control which card gets assigned which framebuffer device, that might help in certain situations...
Yes, sounds like a great idea.
Dan
/--------------------------------\ /--------------------------------\
| Daniel Jacobowitz |__| SCS Class of 2002 | | Debian GNU/Linux Developer __ Carnegie Mellon University | | [email protected] | | [email protected] | \--------------------------------/ \--------------------------------/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines · Michel Lanners
For those with multiple display adapters, do you think an option controlfb:off might make sense? As there is no way to control which card gets assigned which framebuffer device, that might help in certain situations...
I believe you can set which driver gets init'ed first by using the args:
video=foo:blah video=bar:blah
foo's _init will be called first, and bar's next, (therefore being fb0 and fb1 respectively).
ani
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi Franz,
On 3 Jun, this message from Franz Sirl echoed through cyberspace:
[hacking controlfb]
Quoted 3 lines
if you don't mind, would you try to replace the "dcbi" assembler instructions in the detection code with "dcbf" instructions? It seems Dan inherited my bug I had in the platinumfb driver...
Sure, no problem.
In what sense is that a bug, and what would be the symptom? I know close to nothing about PPC assembler, and fully understanding the detection code might help fix the detection problems we still have in some situations...
Thanks
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi all,
On 3 Jun, this message from Ani Joshi echoed through cyberspace:
Quoted 2 lines
Quoted 2 lines
For those with multiple display adapters, do you think an option controlfb:off might make sense?
Silly me; that's already taken care of in fbmem.c.
Quoted 7 lines
Quoted 3 lines
As there is no way to control which card
gets assigned which framebuffer device, that might help in certain situations...I believe you can set which driver gets init'ed first by using the args:
video=foo:blah video=bar:blah
Right, that's handles in fbmem.c. Unfortunately, I've never seen it documented anywhere... So, I've started to write up a doc about framebuffer kernel command line options. I've come across a few oddities; among others the format of options:
1. What do the vc: and map: options do?
2. Why can you specify more options after 'scrollback:', separated with a ',', but not after the 'map:' option (no other options possible), whereas you can have more options following 'vc:', but without a separator?
Thanks
Michel
BTW, anybody have the fbutils compiled for 2k and recent kernels? I can't seem to get it to compile....
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 10 lines · Michel Lanners
Hi Franz,
On 3 Jun, this message from Franz Sirl echoed through cyberspace:
[hacking controlfb]Quoted 5 lines
if you don't mind, would you try to replace the "dcbi" assembler instructions
in the detection code with "dcbf" instructions? It seems Dan inherited my bug
I had in the platinumfb driver...
Quoted 6 lines
Sure, no problem.
In what sense is that a bug, and what would be the symptom? I know close to nothing about PPC assembler, and fully understanding the detection code might help fix the detection problems we still have in some situations...
dcbi = data cache block invalidate. If you do this on a dirty cache block, data will be lost.
dcbf = data cache block flush. If you do this on a block that isn't in a coherent state, data will be lost.
If you have a block that's both dirty and incoherent... well, don't do that. :)
btw, my mail server messed up and I got bounced off the list a few weeks back, have I missed anything interesting?
Cheers - Tony :)
--
Tony Mantler Renaissance Nerd Extraordinaire [email protected]
Winnipeg, Manitoba, Canada http://nicoya.feline.pp.se/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 7 lines · Tony Mantler
dcbi = data cache block invalidate. If you do this on a dirty cache block, data will be lost.
dcbf = data cache block flush. If you do this on a block that isn't in a coherent state, data will be lost.
If you have a block that's both dirty and incoherent... well, don't do that. :)
Ew. I wonder if that's our problem...
Dan
/--------------------------------\ /--------------------------------\
| Daniel Jacobowitz |__| SCS Class of 2002 | | Debian GNU/Linux Developer __ Carnegie Mellon University | | [email protected] | | [email protected] | \--------------------------------/ \--------------------------------/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
On 4 Jun, this message from Daniel Jacobowitz echoed through cyberspace:
Quoted 11 lines · Tony Mantler
Quoted 7 lines
dcbi = data cache block invalidate. If you do this on a dirty cache block, data will be lost.
dcbf = data cache block flush. If you do this on a block that isn't in a coherent state, data will be lost.
If you have a block that's both dirty and incoherent... well, don't do that. :)
Ew. I wonder if that's our problem...
Would make sense, and I thought so too.... dcbi is wrong in any case for us, since we did modify that block. However, I wonder whether caching is on at all for the framebuffer adresses? (And if so, is that a good idea? Do we want to trash the cache with a xsetroot?)
Anyway, a quick test showed no changes in the detection with dcbf instead of dcbi. I'll have to test more thoroughly, but only after I get Xpmac to run again...
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi there,
On 3 Jun, this message from Geert Uytterhoeven echoed through cyberspace:
Quoted 6 lines
Immediately after I read this, I thought: isn't that already implemented through
fbmem.c? Then I remembered that controlfb is initialized from offb, and not directly fromfbmem_init().I looked at the source, and surprise, controlfb can also be initialised on its own:
(patch deleted)
I applied the patch; XF4 works (just as badly) as before, but Xpmac crashes big-time (panic on access of bad area (9C9C9D9D, iirc). makes syslogd panic as well ??). But it started misbehaving already before your patch, so there is probably something else as well...
I'll keep on looking.
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 3 lines · Michel Lanners
On 4 Jun, this message from Daniel Jacobowitz echoed through cyberspace:
Quoted 2 lines · Tony Mantler
[...]
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
If you have a block that's both dirty and incoherent... well, don't do that. :)
Ew. I wonder if that's our problem...
Would make sense, and I thought so too.... dcbi is wrong in any case for us, since we did modify that block. However, I wonder whether caching is on at all for the framebuffer adresses? (And if so, is that a good idea? Do we want to trash the cache with a xsetroot?)
I'm not sure of the design specifics of the Control video, but most of the Apple video designs I've seen put the high-bandwidth low-latency video ram right on the main bus, so it's already half way to being a cache in and of itself (I seem to recall apple's sound manager using vram for buffer space), and would benefit very little from the CPU cache, except perhaps in a multi-cpu machine to keep bus chatter down to a minimum, but the exact tradeoffs of that would take a bit of consideration to quantify.
Besides that, unlike main ram, what has and hasn't been written back to the framebuffer makes a big difference in what you see on screen. Caching would probably make for some mighty weird flicker, jumpy or inconsistent video playback, and all sorts of evil visual gremlins. You could always cache the framebuffer as write-through, but then any value you might have got from the caching goes right out the window, as framebuffer writes should outnumber framebuffer reads by an order of magnitude.
Anyways, that's the long answer. The short answer is: no, you probably don't want to cache the framebuffer.
Cheers - Tony :)
--
Tony Mantler Renaissance Nerd Extraordinaire [email protected]
Winnipeg, Manitoba, Canada http://nicoya.feline.pp.se/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 1 line · Michel Lanners
1. What do the vc: and map: options do?
map: maps framebuffer devices to VCs. E.g. I use
video=pm2fb:... video=amifb:... video=map:000011
So pm2fb is fb0 and amifb fb1, and VCs 1-4 are handled by pm2fb while 5 and six are handled by amifb. Hope you get the idea.
Quoted 2 lines
2. Why can you specify more options after 'scrollback:', separated with a ',', but not after the 'map:' option (no other options possible),
I guess it doesn't make sense to mix map: with device specific options because it affects all devices.
Quoted 2 lines
whereas you can have more options following 'vc:', but without a separator?
If only I knew what vc: is for :)
Michel
--
...and that is how we know the Earth to be banana-shaped.
______________________________________________________________________________
Earthling Michel Dänzer (MrCooper) \ CS student and free software enthusiast
Debian GNU/Linux (powerpc,i386) user \ member of XFree86, Team *AMIGA*, AUGS
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi all,
[about caching and framebuffers]
Quoted 7 lines
I'm not sure of the design specifics of the Control video, but most of the Apple video designs I've seen put the high-bandwidth low-latency video ram right on the main bus, so it's already half way to being a cache in and of itself (I seem to recall apple's sound manager using vram for buffer space), and would benefit very little from the CPU cache, except perhaps in a multi-cpu machine to keep bus chatter down to a minimum, but the exact tradeoffs of that would take a bit of consideration to quantify.
In the case of control, the VRAM seems to be the same basic type as main RAM (i.e. 60/70ns DRAM), and it is conceptually behind a PCI bridge. So by itself it is not faster than main RAM....
Quoted 7 lines
Besides that, unlike main ram, what has and hasn't been written back to the framebuffer makes a big difference in what you see on screen. Caching would probably make for some mighty weird flicker, jumpy or inconsistent video playback, and all sorts of evil visual gremlins. You could always cache the framebuffer as write-through, but then any value you might have got from the caching goes right out the window, as framebuffer writes should outnumber framebuffer reads by an order of magnitude.
The main reason for marking the VRAM cacheable (_how_ is a different story) would be so that the CPU can burst to it; the net result being (as I have understood it, but I may be wrong) that the CPU can fill the PCI bridge's buffer with fast burst writes, and let the bridge take care of getting the data to VRAM. According to Apple's doc on their PCI implementation, all address space excpet main RAM is marked uncacheable by default, but only cacheable space gets bursted to by the CPU.
So I guess the optimum would be to mark the VRAM cacheable, but in a way that writes don't go into the cache. Would that be write-through?
Quoted 2 lines
Anyways, that's the long answer. The short answer is: no, you probably don't want to cache the framebuffer.
Except for the above reasons ;-)
Cheers
Michel
-------------------------------------------------------
.sig enjoying a day off
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 2 lines · Michel Lanners
So I guess the optimum would be to mark the VRAM cacheable, but in a way that writes don't go into the cache. Would that be write-through?
That's indeed write-through. Note that writes will still be cached in such a way that a consecutive read from the same location will return the cached value. But writes will immediately be sent to the host bridge.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 8 lines · Geert Uytterhoeven
Quoted 3 lines · Michel Lanners
So I guess the optimum would be to mark the VRAM cacheable, but in a way that
writes don't go into the cache. Would that be write-through?That's indeed write-through. Note that writes will still be cached in such a way that a consecutive read from the same location will return the cached value. But writes will immediately be sent to the host bridge.
True enough. Is the vram genuinley behind the PCI bridge, or is it just magically managed as a PCI resource from the main bus? If the reads and writes don't really go through the bridge then, again, I don't see that there would be much benefit in using a write-through cache, with perhaps the exception of SMP.
It would atleast be worthwhile mapping it non-cached until the driver can be proven 100% stable (well, 95% atleast) :), then turn caching back on (write-through, of course) and see what breaks again, knowing this time that it's definatley cache-related.
And I mean, if all else fails, stability should always prevail over speed, right?... right?... *tumbleweed rolls by*
;)
Cheers - Tony :)
--
Tony Mantler Renaissance Nerd Extraordinaire [email protected]
Winnipeg, Manitoba, Canada http://nicoya.feline.pp.se/
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 8 lines · Geert Uytterhoeven
Quoted 3 lines · Michel Lanners
So I guess the optimum would be to mark the VRAM cacheable, but in
a way that
writes don't go into the cache. Would that be write-through?That's indeed write-through. Note that writes will still be cached in such a way that a consecutive read from the same location will return the cached value. But writes will immediately be sent to the host bridge.
Unfortunately a side effect of write-through mode is that it prevents burst writes. Memory must be cacheable in copy-back mode for existing PowerPC CPUs to perform burst writes.
Many Intel CPUs implement write combining for precisely this region. In a memory region marked as OK for write combining, the CPU is free to wait and collect data from several writes to perform a burst write rather than performing a write immediately.
Tim Seufert
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Probably XF4 handles fix.smem_start being not on a page boundary incorrectly.
Quoted 9 lines
Quoted 1 line
What would it have to do to handle it?
Round down
smem_startandmmap()it, and readd the offset. Cfr.addr = (unsigned long)mmap(NULL, ati_smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0); ati_smem = addr+ati_smem_offset;
Basically what we do in fbdev.c since two years or so (first happened on Mac68k). But I don't think that's it: mmap would have barfed if you feed it a start address that isn't page aligned.
Maybe a timing problem with the monitor?
Michael
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 4 lines
Anyways, that's the long answer. The short answer is: no, you probably don't want to cache the framebuffer.
Thanks for the long answer, and all those nasty gremlins have actually been observed long time ago when people started to play with the framebuffer drivers. At least on m68k, the framebuffer address space was set non-cacheable right from the start (in head.S). I would hope that somehow translated to PPC as well :-)
Michael
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi there,
On 6 Jun, this message from Michael Schmitz echoed through cyberspace:
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Probably XF4 handles fix.smem_start being not on a page boundary incorrectly.
What would it have to do to handle it?
Round down
smem_startandmmap()it, and readd the offset. Cfr.
Quoted 8 lines
Quoted 4 lines
addr = (unsigned long)mmap(NULL, ati_smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb_fd, 0); ati_smem = addr+ati_smem_offset;Basically what we do in
fbdev.csince two years or so (first happened on Mac68k). But I don't think that's it: mmap would have barfed if you feed it a start address that isn't page aligned.
How about incorrect rounding? Here is what I see (in ASCII art ;-):
Pixel (168,-1) (0,-1)(0,0) Pixel (167,0) *----------------------------------------**-----------------* | || |
I _think_ it starts with line -1, and not line 0. I could be wrong... There could be an aliased region of VRAM just below framebuffer start...
Entire diplay width is 1152 pixels à 32 bit. So there are 1152-168=984 pixels on screen that are below pixel (0,0) in memory. The offset between fb address 0 and pixel (0,0) is 80 bytes in this mode. 984 pixels are 964*4=3936 bytes. If you look closely, offset plus displacement is just 80 bytes (offset again...) below the next page boundary:
80 + 3936 = 4016 = 4096 - 80
Bug in my calculation or XF4's?
Quoted 1 line
Maybe a timing problem with the monitor?
No, because both halves of the display fit together without sync artefacts.
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Hi all,
On 6 Jun, this message from Michael Schmitz echoed through cyberspace:
Quoted 8 lines
Quoted 2 lines
Anyways, that's the long answer. The short answer is: no, you probably don't want to cache the framebuffer.
Thanks for the long answer, and all those nasty gremlins have actually been observed long time ago when people started to play with the framebuffer drivers. At least on m68k, the framebuffer address space was set non-cacheable right from the start (in
head.S). I would hope that somehow translated to PPC as well :-)
That's what fbmem.c does in its default mmap(). However, at least for control (and maybe other comparable video implementations as well), you get much better performance on scroll and other fb-to-fb copy operations, without visible inconvenients, when the framebuffer is set to write-through caching.
For fun, I tried write-back caching as well. Makes for some really nice visual effects when your killed netscape starts to fade away as the cache gets slowly flushed ;-))) And it doesn't even get you any speed improvement...
Michel
-------------------------------------------------------------------------
Michel Lanners | " Read Philosophy. Study Art. 23, Rue Paul Henkes | Ask Questions. Make Mistakes. L-1710 Luxembourg | email [email protected] | http://www.cpu.lu/~mlan | Learn Always. "
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 10 lines · Michel Lanners
On 6 Jun, this message from Michael Schmitz echoed through cyberspace:
Quoted 8 lines
Quoted 2 lines
Anyways, that's the long answer. The short answer is: no, you probably don't want to cache the framebuffer.
Thanks for the long answer, and all those nasty gremlins have actually been observed long time ago when people started to play with the framebuffer drivers. At least on m68k, the framebuffer address space was set non-cacheable right from the start (in
head.S). I would hope that somehow translated to PPC as well :-)
Quoted 5 lines
That's what
fbmem.cdoes in its defaultmmap(). However, at least for control (and maybe other comparable video implementations as well), you get much better performance on scroll and other fb-to-fb copy operations, without visible inconvenients, when the framebuffer is set to write-through caching.
| $ grep ioremap drivers/video/amifb.c
| videomemory = (u_long)ioremap_writethrough(videomemory_phys, videomemorysize);
It does mean that if the accel engine draws something, and the CPU wants to chnge that, that there may be a cache incoherency. For amifb that doesn't matter since it's unaccelerated.
Summarized: use write-through cachine for unaccelerated hardware, no caching for accelerated hardware.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/