linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fbdev: Fix crash if fb_set_var() called before register_framebuffer()
@ 2004-11-24 17:15 Antonino A. Daplas
  2004-11-26  0:20 ` Mario Gaucher
  0 siblings, 1 reply; 5+ messages in thread
From: Antonino A. Daplas @ 2004-11-24 17:15 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds; +Cc: Linux Fbdev development list, linux-kernel

The field info->modelist is initialized during register_framebuffer.  This
field is also referred to in fb_set_var().  Thus a call to fb_set_var()
before register_framebuffer() will cause a crash.  A few drivers do this,
notably controlfb.  (This might fix reports of controlfb crashing in
powermacs).

Signed-off-by: Antonino Daplas <adaplas@pol.net>
---

 fbmem.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)

diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
--- a/drivers/video/fbmem.c	2004-11-23 21:20:13 +08:00
+++ b/drivers/video/fbmem.c	2004-11-25 01:09:22 +08:00
@@ -725,7 +725,10 @@
 			fb_set_cmap(&info->cmap, info);
 
 			fb_var_to_videomode(&mode, &info->var);
-			fb_add_videomode(&mode, &info->modelist);
+
+			if (info->modelist.prev && info->modelist.next &&
+			    !list_empty(&info->modelist))
+				fb_add_videomode(&mode, &info->modelist);
 
 			if (info->flags & FBINFO_MISC_MODECHANGEUSER) {
 				struct fb_event event;





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fbdev: Fix crash if fb_set_var() called before register_framebuffer()
  2004-11-24 17:15 [PATCH] fbdev: Fix crash if fb_set_var() called before register_framebuffer() Antonino A. Daplas
@ 2004-11-26  0:20 ` Mario Gaucher
  2004-11-26  0:45   ` Antonino A. Daplas
  0 siblings, 1 reply; 5+ messages in thread
From: Mario Gaucher @ 2004-11-26  0:20 UTC (permalink / raw)
  To: adaplas; +Cc: linux-kernel


> The field info->modelist is initialized during register_framebuffer.  This
> field is also referred to in fb_set_var().  Thus a call to fb_set_var()
> before register_framebuffer() will cause a crash.  A few drivers do this,
> notably controlfb.  (This might fix reports of controlfb crashing in
> powermacs).


this patch works well... I can now boot my PowerMac 7300 using
2.6.10-rc2-bk8 (that I got on kernel.org) with this patch...

but I still has some problem with my Matrox Millenium PCI card using
matroxfb driver... the kernel boot... but I get corrupted characters on
the console... X load ok and display ok...
It works really well with the onboard video (controlfb driver)

matroxfb driver works fine on 2.6.8


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fbdev: Fix crash if fb_set_var() called before register_framebuffer()
  2004-11-26  0:20 ` Mario Gaucher
@ 2004-11-26  0:45   ` Antonino A. Daplas
  2004-11-26 23:17     ` Mario Gaucher
  0 siblings, 1 reply; 5+ messages in thread
From: Antonino A. Daplas @ 2004-11-26  0:45 UTC (permalink / raw)
  To: Mario Gaucher; +Cc: linux-kernel

On Friday 26 November 2004 08:20, Mario Gaucher wrote:
> > The field info->modelist is initialized during register_framebuffer. 
> > This field is also referred to in fb_set_var().  Thus a call to
> > fb_set_var() before register_framebuffer() will cause a crash.  A few
> > drivers do this, notably controlfb.  (This might fix reports of controlfb
> > crashing in powermacs).
>
> this patch works well... I can now boot my PowerMac 7300 using
> 2.6.10-rc2-bk8 (that I got on kernel.org) with this patch...

That's good.

>
> but I still has some problem with my Matrox Millenium PCI card using
> matroxfb driver... the kernel boot... but I get corrupted characters on
> the console... X load ok and display ok...

Try this first.

1. Open drivers/video/matrox/matrofb_accel.c
2. At the end of the file is this function:

static void matroxfb_imageblit(struct fb_info* info, const struct fb_image* image) {
	MINFO_FROM_INFO(info);

	DBG_HEAVY(__FUNCTION__);

	if (image->depth == 1) {
		u_int32_t fgx, bgx;

		fgx = ((u_int32_t*)info->pseudo_palette)[image->fg_color];
		bgx = ((u_int32_t*)info->pseudo_palette)[image->bg_color];
		matroxfb_1bpp_imageblit(PMINFO fgx, bgx, image->data, image->width, image->height, image->dy, image->dx);
	} else {
		/* Danger! image->depth is useless: logo painting code always
		   passes framebuffer color depth here, although logo data are
		   always 8bpp and info->pseudo_palette is changed to contain
		   logo palette to be used (but only for true/direct-color... sic...).
		   So do it completely in software... */
		cfb_imageblit(info, image);
	}
}

3. Replace the above function to use software drawing so it becomes like this:

static void matroxfb_imageblit(struct fb_info* info, const struct fb_image* image) {
	cfb_imageblit(info, image);
}

Tony



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fbdev: Fix crash if fb_set_var() called before register_framebuffer()
  2004-11-26  0:45   ` Antonino A. Daplas
@ 2004-11-26 23:17     ` Mario Gaucher
  2004-11-26 23:35       ` Antonino A. Daplas
  0 siblings, 1 reply; 5+ messages in thread
From: Mario Gaucher @ 2004-11-26 23:17 UTC (permalink / raw)
  To: adaplas; +Cc: Linux-Kernel


From: "Antonino A. Daplas" <adaplas@hotpop.com>
> > but I still has some problem with my Matrox Millenium PCI card using
> > matroxfb driver... the kernel boot... but I get corrupted characters on
> > the console... X load ok and display ok...
> 
> Try this first.
> 
> 1. Open drivers/video/matrox/matrofb_accel.c
> 2. At the end of the file is this function:
> 
> static void matroxfb_imageblit(struct fb_info* info, const struct
fb_image* image) {
> 	MINFO_FROM_INFO(info);
> 
> 	DBG_HEAVY(__FUNCTION__);
> 
> 	if (image->depth == 1) {
> 		u_int32_t fgx, bgx;
> 
> 		fgx = ((u_int32_t*)info->pseudo_palette)[image->fg_color];
> 		bgx = ((u_int32_t*)info->pseudo_palette)[image->bg_color];
> 		matroxfb_1bpp_imageblit(PMINFO fgx, bgx, image->data, image->width,
image->height, image->dy, image->dx);
> 	} else {
> 		/* Danger! image->depth is useless: logo painting code always
> 		   passes framebuffer color depth here, although logo data are
> 		   always 8bpp and info->pseudo_palette is changed to contain
> 		   logo palette to be used (but only for true/direct-color... sic...).
> 		   So do it completely in software... */
> 		cfb_imageblit(info, image);
> 	}
> }
> 
> 3. Replace the above function to use software drawing so it becomes like
this:
> 
> static void matroxfb_imageblit(struct fb_info* info, const struct
fb_image* image) {
> 	cfb_imageblit(info, image);
> }


this patch works fine on my PowerMac 7300 with my Matrox Millenium PCI
card... 

so I think that both patch you sent me should be included in the kernel... 

thank you


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fbdev: Fix crash if fb_set_var() called before register_framebuffer()
  2004-11-26 23:17     ` Mario Gaucher
@ 2004-11-26 23:35       ` Antonino A. Daplas
  0 siblings, 0 replies; 5+ messages in thread
From: Antonino A. Daplas @ 2004-11-26 23:35 UTC (permalink / raw)
  To: Mario Gaucher, adaplas; +Cc: Linux-Kernel, Petr Vandrovec

On Saturday 27 November 2004 07:17, Mario Gaucher wrote:
> From: "Antonino A. Daplas" <adaplas@hotpop.com>
>
> > > but I still has some problem with my Matrox Millenium PCI card using
> > > matroxfb driver... the kernel boot... but I get corrupted characters on
> > > the console... X load ok and display ok...
> >
> > Try this first.
> >
> > 1. Open drivers/video/matrox/matrofb_accel.c
> > 2. At the end of the file is this function:
> >
> > static void matroxfb_imageblit(struct fb_info* info, const struct
>
> fb_image* image) {
>
> > 	MINFO_FROM_INFO(info);
> >
> > 	DBG_HEAVY(__FUNCTION__);
> >
> > 	if (image->depth == 1) {
> > 		u_int32_t fgx, bgx;
> >
> > 		fgx = ((u_int32_t*)info->pseudo_palette)[image->fg_color];
> > 		bgx = ((u_int32_t*)info->pseudo_palette)[image->bg_color];
> > 		matroxfb_1bpp_imageblit(PMINFO fgx, bgx, image->data, image->width,
>
> image->height, image->dy, image->dx);
>
> > 	} else {
> > 		/* Danger! image->depth is useless: logo painting code always
> > 		   passes framebuffer color depth here, although logo data are
> > 		   always 8bpp and info->pseudo_palette is changed to contain
> > 		   logo palette to be used (but only for true/direct-color... sic...).
> > 		   So do it completely in software... */
> > 		cfb_imageblit(info, image);
> > 	}
> > }
> >
> > 3. Replace the above function to use software drawing so it becomes like
>
> this:
> > static void matroxfb_imageblit(struct fb_info* info, const struct
>
> fb_image* image) {
>
> > 	cfb_imageblit(info, image);
> > }
>
> this patch works fine on my PowerMac 7300 with my Matrox Millenium PCI
> card...
>
> so I think that both patch you sent me should be included in the kernel...

No, this modification is for testing purposes only.  It means that hardware
color expansion in matroxfb for powerpc's got broken.  CC'ed Petr.

Tony



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-11-27  2:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-24 17:15 [PATCH] fbdev: Fix crash if fb_set_var() called before register_framebuffer() Antonino A. Daplas
2004-11-26  0:20 ` Mario Gaucher
2004-11-26  0:45   ` Antonino A. Daplas
2004-11-26 23:17     ` Mario Gaucher
2004-11-26 23:35       ` Antonino A. Daplas

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).