Re: [PATCH v2] vga16fb: refuse to load in face of other driver controlling primary card

From: Geert Uytterhoeven
Date: Fri Jul 23 2010 - 11:00:22 EST


On Fri, Jul 23, 2010 at 15:10, Marcin Slusarz <marcin.slusarz@xxxxxxxxx> wrote:
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 731fce6..cb19cae 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1504,6 +1504,7 @@ static bool fb_do_apertures_overlap(struct apertures_struct *gena,
> Â}
>
> Â#define VGA_FB_PHYS 0xA0000
> +#define VGA_FB_PHYS_LEN 65536

Does this really belong here?

> Âvoid remove_conflicting_framebuffers(struct apertures_struct *a,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â const char *name, bool primary)
> Â{
> @@ -1532,6 +1533,17 @@ void remove_conflicting_framebuffers(struct apertures_struct *a,
> Â}
> ÂEXPORT_SYMBOL(remove_conflicting_framebuffers);
>
> +struct resource *request_vga_mem_region(const char *name)
> +{
> + Â Â Â struct resource *res = request_mem_region(VGA_FB_PHYS,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â VGA_FB_PHYS_LEN, name);
> + Â Â Â if (res == NULL)
> + Â Â Â Â Â Â Â printk(KERN_INFO "%s: other driver owns the primary card, refusing to load\n",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â name);
> + Â Â Â return res;
> +}
> +EXPORT_SYMBOL(request_vga_mem_region);
> +
> Â/**
> Â* Â Â register_framebuffer - registers a frame buffer device
> Â* Â Â @fb_info: frame buffer info structure
> @@ -1548,6 +1560,8 @@ register_framebuffer(struct fb_info *fb_info)
> Â Â Â Âint i;
> Â Â Â Âstruct fb_event event;
> Â Â Â Âstruct fb_videomode mode;
> + Â Â Â bool primary;
> + Â Â Â struct resource *res = fb_info->resource;
>
> Â Â Â Âif (num_registered_fb == FB_MAX)
> Â Â Â Â Â Â Â Âreturn -ENXIO;
> @@ -1555,8 +1569,19 @@ register_framebuffer(struct fb_info *fb_info)
> Â Â Â Âif (fb_check_foreignness(fb_info))
> Â Â Â Â Â Â Â Âreturn -ENOSYS;
>
> + Â Â Â primary = fb_is_primary_device(fb_info);
> Â Â Â Âremove_conflicting_framebuffers(fb_info->apertures, fb_info->fix.id,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âfb_is_primary_device(fb_info));
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â primary);
> +
> + Â Â Â /*
> + Â Â Â Â* if the card is primary and the resource was not already allocated
> + Â Â Â Â* by framebuffer driver then lock vga memory region
> + Â Â Â Â*/
> + Â Â Â if (primary && res == NULL) {
> + Â Â Â Â Â Â Â res = request_vga_mem_region(fb_info->fix.id);
> + Â Â Â Â Â Â Â if (res == NULL)
> + Â Â Â Â Â Â Â Â Â Â Â return -EBUSY;
> + Â Â Â }

More VGA-specific stuff in drivers/video/fbmem.c.
Not all platforms have VGA memory.

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/