SimpleDRM Driver (was: dvbe driver)
Subsystems (6)
cover SimpleDRM Driver (was: dvbe driver)
Hi
This is my second revision of the dvbe driver. I renamed it to SimpleDRM to show the resemblence with the recently introduced simplefb.c fbdev driver. The driver is supposed to be the most basic DRM driver similar to efifb.c, vesafb.c, offb.c, simplefb.c, ...
It provides a single virtual CRTC+encoder+connector and allows user-space to create one dumb-buffer at a time and attach it.
The setup changed slightly. It no longer uses shadow buffers but instead maps the framebuffer directly into userspace. Furthermore, a new infrastructure is used to unload firmware drivers during real hardware drivers probe cycles. Only nouveau was changed to use it, yet.
I still have an odd problem when unloading DRM drivers (not just SimpleDRM) with an fbdev fallback. If I call printk() directly after unregister_framebufer(), I get a NULL-deref somewhere in the VT layer (most times hide_cursor()). I haven't figured out exactly where that happens, but I am also very reluctant to spend more time debugging the VT layer.
Anyhow, comments welcome. If someone wants to test it, you probably need to add a line to ./include/linux/platform_data/simplefb.h and add the modeline of your VESA/EFI framebuffer.
Cheers
David
David Herrmann (6):
fbdev: simplefb: add init through platform_data
x86: provide platform-devices for boot-framebuffers
drm: add SimpleDRM driver
drm: simpledrm: add fbdev fallback support
drm: add helpers to kick out firmware drivers
drm: nouveau: kick out firmware drivers during probe
MAINTAINERS | 8 + arch/x86/Kconfig | 18 ++ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/sysfb.c | 157 ++++++++++++ drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_pci.c | 1 + drivers/gpu/drm/drm_platform.c | 1 + drivers/gpu/drm/drm_stub.c | 107 ++++++++ drivers/gpu/drm/drm_usb.c | 1 + drivers/gpu/drm/nouveau/nouveau_drm.c | 29 ++- drivers/gpu/drm/simpledrm/Kconfig | 29 +++ drivers/gpu/drm/simpledrm/Makefile | 9 + drivers/gpu/drm/simpledrm/simpledrm.h | 114 +++++++++ drivers/gpu/drm/simpledrm/simpledrm_drv.c | 231 ++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 180 ++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_main.c | 366 ++++++++++++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_mem.c | 254 +++++++++++++++++++ drivers/video/Kconfig | 5 +- drivers/video/simplefb.c | 45 +++- include/drm/drmP.h | 26 ++ include/linux/platform_data/simplefb.h | 40 +++ 22 files changed, 1604 insertions(+), 21 deletions(-) create mode 100644 arch/x86/kernel/sysfb.c create mode 100644 drivers/gpu/drm/simpledrm/Kconfig create mode 100644 drivers/gpu/drm/simpledrm/Makefile create mode 100644 drivers/gpu/drm/simpledrm/simpledrm.h create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_drv.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_main.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_mem.c create mode 100644 include/linux/platform_data/simplefb.h
Signature · 1 line
1.8.3.1
RFC 1/6 fbdev: simplefb: add init through platform_data
If we create proper platform-devices in x86 boot-code, we can use simplefb for VBE or EFI framebuffers, too. However, there is normally no OF support so we introduce a platform_data object so x86 boot-code can pass the paramaters via plain old platform-data.
This also removes the OF dependency as it is not needed. The headers provide proper dummies for the case OF is disabled.
Furthermore, we move the FORMAT-definitions to the common platform header so initialization code can use it to transform "struct screen_info" to the right format-name.
--- drivers/video/Kconfig | 5 ++-- drivers/video/simplefb.c | 45 +++++++++++++++++++++++++--------- include/linux/platform_data/simplefb.h | 40 ++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 include/linux/platform_data/simplefb.h
drivers/video/Kconfig +2 -3
@@ -2455,7 +2455,7 @@ config FB_HYPERV config FB_SIMPLE bool "Simple framebuffer support" - depends on (FB = y) && OF + depends on (FB = y) select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT
@@ -2467,8 +2467,7 @@ config FB_SIMPLE pre-allocated frame buffer surface. Configuration re: surface address, size, and format must be provided - through device tree, or potentially plain old platform data in the - future. + through device tree, or plain old platform data. source "drivers/video/omap/Kconfig" source "drivers/video/omap2/Kconfig"
drivers/video/simplefb.c +34 -11
70 lines not on this page · raw message
include/linux/platform_data/simplefb.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* simplefb.h - Simple Framebuffer Device +* +* Copyright (C) 2013 David Herrmann <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +*/ + +#ifndef __PLATFORM_DATA_SIMPLEFB_H__ +#define __PLATFORM_DATA_SIMPLEFB_H__ + +#include <drm/drm_fourcc.h> +#include <linux/fb.h> +#include <linux/kernel.h> + +#define SIMPLEFB_FORMATS \ + { "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0}, DRM_FORMAT_RGB565 } + +struct simplefb_format { +const char *name; +u32 bits_per_pixel; +struct fb_bitfield red; +struct fb_bitfield green; +struct fb_bitfield blue; +struct fb_bitfield transp; +u32 fourcc; +}; + +/* the framebuffer size and location is available as IORESOURCE_MEM */ +struct simplefb_platform_data { +u32 width; +u32 height; +u32 stride; +char format[64 ]; +}; + +#endif /* __PLATFORM_DATA_SIMPLEFB_H__ */
Signature · 1 line
1.8.3.1
Re: [RFC 1/6] fbdev: simplefb: add init through platform_data
Quoted 13 lines · David Herrmann
If we create proper platform-devices in x86 boot-code, we can use simplefb for VBE or EFI framebuffers, too. However, there is normally no OF support so we introduce a
platform_dataobject so x86 boot-code can pass the paramaters via plain old platform-data.This also removes the OF dependency as it is not needed. The headers provide proper dummies for the case OF is disabled.
Furthermore, we move the FORMAT-definitions to the common platform header so initialization code can use it to transform "struct
screen_info" to the right format-name.
include/linux/platform_data/simplefb.h line 38
Quoted 8 lines
include/linux/platform_data/simplefb.h +7
-0+/* the framebuffer size and location is available as IORESOURCE_MEM */ +struct simplefb_platform_data { +u32 width; +u32 height; +u32 stride; +char format[64 ]; +};
Any reason not to make format:
const char *format;
You should be able to initialize that just as easily in platform code, either as static data or at runtime, I think.
Re: [RFC 1/6] fbdev: simplefb: add init through platform_data
Hi
Quoted 25 lines · Stephen Warren
Quoted 13 lines · David Herrmann
If we create proper platform-devices in x86 boot-code, we can use simplefb for VBE or EFI framebuffers, too. However, there is normally no OF support so we introduce a
platform_dataobject so x86 boot-code can pass the paramaters via plain old platform-data.This also removes the OF dependency as it is not needed. The headers provide proper dummies for the case OF is disabled.
Furthermore, we move the FORMAT-definitions to the common platform header so initialization code can use it to transform "struct
screen_info" to the right format-name.include/linux/platform_data/simplefb.h line 38
Quoted 8 lines
include/linux/platform_data/simplefb.h +7
-0+/* the framebuffer size and location is available as IORESOURCE_MEM */ +struct simplefb_platform_data { +u32 width; +u32 height; +u32 stride; +char format[64 ]; +};Any reason not to make format:
Quoted 4 lines
const char *format;
You should be able to initialize that just as easily in platform code, either as static data or at runtime, I think.
That makes sense. I fixed it up.
Thanks
David
RFC 2/6 x86: provide platform-devices for boot-framebuffers
In reply to David HerrmannThe current situation regarding boot-framebuffers (VGA, VESA/VBE, EFI) on x86 causes troubles when loading multiple fbdev drivers. The global "struct screen_info" does not provide any state-tracking about which drivers use the FBs. request_mem_region() theoretically works, but unfortunately vesafb/efifb ignore it due to quirks for broken boards.
Avoid this by creating a "platform-framebuffer" device with a pointer to the "struct screen_info" as platform-data. Drivers can now create platform-drivers and the driver-core will refuse multiple drivers being active simultaneously.
We keep the screen_info available for backwards-compatibility. Drivers can be converted in follow-up patches.
Apart from "platform-framebuffer" devices, this also introduces a compatibility option for "simple-framebuffer" drivers which recently got introduced for OF based systems. If CONFIG_X86_SYSFB is selected, we try to match the screen_info against a simple-framebuffer supported format. If we succeed, we create a "simple-framebuffer" device instead of a platform-framebuffer.
This allows to reuse the simplefb.c driver across architectures and also to introduce a SimpleDRM driver. There is no need to have vesafb.c, efifb.c, simplefb.c and more just to have architecture specific quirks in their setup-routines.
Instead, we now move the architecture specific quirks into x86-setup and provide a generic simple-framebuffer. For backwards-compatibility (if strange formats are used), we still allow vesafb/efifb to be loaded simultaneously and pick up all remaining devices.
--- arch/x86/Kconfig | 18 ++++++ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/sysfb.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 176 insertions(+) create mode 100644 arch/x86/kernel/sysfb.c
arch/x86/Kconfig +18 -0
@@ -2255,6 +2255,24 @@ config RAPIDIO source "drivers/rapidio/Kconfig" +config X86_SYSFB + bool "Mark VGA/VBE/EFI FB as generic system framebuffer" + help + Firmwares often provide initial graphics framebuffers so the BIOS, + bootloader or kernel can show basic video-output during boot for + user-guidance and debugging. Historically, x86 used the VESA BIOS + Extensions and EFI-framebuffers for this, which are mostly limited + to x86. However, a generic system-framebuffer initialization emerged + recently on some non-x86 architectures. + This option, if enabled, marks VGA/VBE/EFI framebuffers as generic + framebuffers so the new generic system-framebuffer drivers can be + used on x86. + + This breaks any x86-only driver like efifb, vesafb, uvesafb, which + will not work if this is selected. + + If unsure, say N. + endmenu
arch/x86/kernel/Makefile +1 -0
@@ -100,6 +100,7 @@ obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o obj-$(CONFIG_OF) += devicetree.o obj-$(CONFIG_UPROBES) += uprobes.o +obj-y += sysfb.o obj-$(CONFIG_PERF_EVENTS) += perf_regs.o
arch/x86/kernel/sysfb.c new file +157 -0
157 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [RFC 2/6] x86: provide platform-devices for boot-framebuffers
Quoted 31 lines · David Herrmann
The current situation regarding boot-framebuffers (VGA, VESA/VBE, EFI) on x86 causes troubles when loading multiple fbdev drivers. The global "struct
screen_info" does not provide any state-tracking about which drivers use the FBs.request_mem_region()theoretically works, but unfortunately vesafb/efifb ignore it due to quirks for broken boards.Avoid this by creating a "platform-framebuffer" device with a pointer to the "struct
screen_info" as platform-data. Drivers can now create platform-drivers and the driver-core will refuse multiple drivers being active simultaneously.We keep the
screen_infoavailable for backwards-compatibility. Drivers can be converted in follow-up patches.Apart from "platform-framebuffer" devices, this also introduces a compatibility option for "simple-framebuffer" drivers which recently got introduced for OF based systems. If
CONFIG_X86_SYSFBis selected, we try to match thescreen_infoagainst a simple-framebuffer supported format. If we succeed, we create a "simple-framebuffer" device instead of a platform-framebuffer.
This allows to reuse thesimplefb.cdriver across architectures and also to introduce a SimpleDRM driver. There is no need to havevesafb.c,efifb.c,simplefb.cand more just to have architecture specific quirks in their setup-routines.Instead, we now move the architecture specific quirks into x86-setup and provide a generic simple-framebuffer. For backwards-compatibility (if strange formats are used), we still allow vesafb/efifb to be loaded simultaneously and pick up all remaining devices.
arch/x86/Kconfig config RAPIDIO · line 2266
Quoted 10 lines
arch/x86/Kconfig +9
-0+config X86_SYSFB + bool "Mark VGA/VBE/EFI FB as generic system framebuffer" + help + Firmwares often provide initial graphics framebuffers so the BIOS, + bootloader or kernel can show basic video-output during boot for + user-guidance and debugging. Historically, x86 used the VESA BIOS + Extensions and EFI-framebuffers for this, which are mostly limited + to x86. However, a generic system-framebuffer initialization emerged + recently on some non-x86 architectures.
After this patch has been in the kernel a while, that very last won't really be true; simplefb won't have been introduced recently. Perhaps just delete that one sentence?
arch/x86/Kconfig config RAPIDIO · line 2272
Quoted 6 lines
arch/x86/Kconfig +6
-0+ This option, if enabled, marks VGA/VBE/EFI framebuffers as generic + framebuffers so the new generic system-framebuffer drivers can be + used on x86. + + This breaks any x86-only driver like efifb, vesafb, uvesafb, which + will not work if this is selected.
Doesn't that imply that some form of conflicts or depends ! statement should be added here?
arch/x86/kernel/Makefile
Quoted 3 lines
arch/x86/kernel/Makefile +1
-0+obj-y += sysfb.o
I suspect that should be obj-$(CONFIG_X86_SYSFB) += sysfb.o.
arch/x86/kernel/sysfb.c
Quoted 3 lines
arch/x86/kernel/sysfb.c +1
-0+#ifdef CONFIG_X86_SYSFB
Rather than ifdef'ing the body of this file, why not create a dummy static inline version of add_sysfb() and put that into a header file that users include. There should be a header file to prototype the function anyway. That way, you avoid all of the ifdefs and static inline functions in this file.
arch/x86/kernel/sysfb.c line 72
Quoted 4 lines
arch/x86/kernel/sysfb.c +3
-0+static bool parse_mode(const struct screen_info *si, + struct simplefb_platform_data *mode) + strlcpy(mode->format, f->name, sizeof(mode->format));
Per my comments about the type of mode->format, I think that could just be:
mode->format = f->name;
... since formats[] (i.e. f) isn't initdata.
Quoted 5 lines
arch/x86/kernel/sysfb.c +5
-0+#else /* CONFIG_X86_SYSFB */ + +static bool parse_mode (const struct screen_info *si, +struct simplefb_platform_data *mode) +{
arch/x86/kernel/sysfb.c line 132
Quoted 10 lines
arch/x86/kernel/sysfb.c +10
-0+ return false; +} + +static int create_simplefb (const struct screen_info *si, +const struct simplefb_platform_data *mode) +{ +return -EINVAL ; +} + +#endif /* CONFIG_X86_SYSFB */
Following on from my ifdef comment above, I believe those versions of those functions will always cause add_sysfb() to return -ENODEV, so you may as well provide a static inline for add_sysfb() instead.
Re: [RFC 2/6] x86: provide platform-devices for boot-framebuffers
Hi
Quoted 43 lines · Stephen Warren
Quoted 31 lines · David Herrmann
The current situation regarding boot-framebuffers (VGA, VESA/VBE, EFI) on x86 causes troubles when loading multiple fbdev drivers. The global "struct
screen_info" does not provide any state-tracking about which drivers use the FBs.request_mem_region()theoretically works, but unfortunately vesafb/efifb ignore it due to quirks for broken boards.Avoid this by creating a "platform-framebuffer" device with a pointer to the "struct
screen_info" as platform-data. Drivers can now create platform-drivers and the driver-core will refuse multiple drivers being active simultaneously.We keep the
screen_infoavailable for backwards-compatibility. Drivers can be converted in follow-up patches.Apart from "platform-framebuffer" devices, this also introduces a compatibility option for "simple-framebuffer" drivers which recently got introduced for OF based systems. If
CONFIG_X86_SYSFBis selected, we try to match thescreen_infoagainst a simple-framebuffer supported format. If we succeed, we create a "simple-framebuffer" device instead of a platform-framebuffer.
This allows to reuse thesimplefb.cdriver across architectures and also to introduce a SimpleDRM driver. There is no need to havevesafb.c,efifb.c,simplefb.cand more just to have architecture specific quirks in their setup-routines.Instead, we now move the architecture specific quirks into x86-setup and provide a generic simple-framebuffer. For backwards-compatibility (if strange formats are used), we still allow vesafb/efifb to be loaded simultaneously and pick up all remaining devices.
arch/x86/Kconfig config RAPIDIO · line 2266
Quoted 10 lines
arch/x86/Kconfig +9
-0+config X86_SYSFB + bool "Mark VGA/VBE/EFI FB as generic system framebuffer" + help + Firmwares often provide initial graphics framebuffers so the BIOS, + bootloader or kernel can show basic video-output during boot for + user-guidance and debugging. Historically, x86 used the VESA BIOS + Extensions and EFI-framebuffers for this, which are mostly limited + to x86. However, a generic system-framebuffer initialization emerged + recently on some non-x86 architectures.
Quoted 3 lines
After this patch has been in the kernel a while, that very last won't really be true; simplefb won't have been introduced recently. Perhaps just delete that one sentence?
It rather belongs in the commit message, right. I will rephrase that.
Quoted 9 lines
arch/x86/Kconfig config RAPIDIO · line 2272
Quoted 6 lines
arch/x86/Kconfig +6
-0+ This option, if enabled, marks VGA/VBE/EFI framebuffers as generic + framebuffers so the new generic system-framebuffer drivers can be + used on x86. + + This breaks any x86-only driver like efifb, vesafb, uvesafb, which + will not work if this is selected.Doesn't that imply that some form of conflicts or depends ! statement should be added here?
There is no real conflict here. You still can use vesafb/... with this option, but they will not pick up the device. I intend to fix these up to use "platform-framebuffer" devices instead of globally binding to "struct screen_info". This way, framebuffers either end up as simple-framebuffers or platform-framebuffers. This option selects which device they end up as.
As all non-compatible framebuffers (with incompatible pixel-formats) always end up as "platform-framebuffer", it still makes sense to use vesafb as fallback. Hence, I'd not introduce any "conflicts" dependency here.
Maybe I should rephrase the warning to something that makes clear that if this option is selected, you need simplefb.c or simpledrm to make use of these devices.
Quoted 5 lines
arch/x86/kernel/Makefile
Quoted 3 lines
arch/x86/kernel/Makefile +1
-0+obj-y += sysfb.oI suspect that should be obj-$(CONFIG_X86_SYSFB) += sysfb.o.
No. This patch tries to solve two things: First of all, every system-framebuffer now gets a "platform-framebuffer" platform-device. Iff X86_SYSFB is selected, it additionally tries to parse the framebuffer information as "simple-framebuffer". If it succeeds, it created a "simple-framebuffer" object, if it doesn't, a fallback "platform-framebuffer" is provided.
This series is missing vesafb/efifb/.. patches, which should now bind to "platform-framebuffer" devices instead of using "struct screen_info" directly. I intend to add these in the next round.
Quoted 32 lines
arch/x86/kernel/sysfb.c
Quoted 3 lines
arch/x86/kernel/sysfb.c +1
-0+#ifdef CONFIG_X86_SYSFB Rather than ifdef'ing the body of this file, why not create a dummy static inline version of
add_sysfb()and put that into a header file that users include. There should be a header file to prototype the function anyway. That way, you avoid all of the ifdefs and static inline functions in this file.arch/x86/kernel/sysfb.c line 72
Quoted 4 lines
arch/x86/kernel/sysfb.c +3
-0+static bool parse_mode(const struct screen_info *si, + struct simplefb_platform_data *mode) + strlcpy(mode->format, f->name, sizeof(mode->format));Per my comments about the type of
mode->format, I think that could just be:
mode->format=f->name;... since formats[] (i.e. f) isn't initdata.
Quoted 11 lines
arch/x86/kernel/sysfb.c +11
-0+#else /* CONFIG_X86_SYSFB */ + +static bool parse_mode (const struct screen_info *si, +struct simplefb_platform_data *mode) +{ +return false; +} + +static int create_simplefb (const struct screen_info *si, +const struct simplefb_platform_data *mode) +{
Quoted 8 lines
arch/x86/kernel/sysfb.c line 132
Quoted 4 lines
arch/x86/kernel/sysfb.c +4
-0+ return -EINVAL; +} + +#endif /* CONFIG_X86_SYSFB */ Following on from my ifdef comment above, I believe those versions of those functions will always cause
add_sysfb()to return-ENODEV, so you may as well provide a static inline foradd_sysfb()instead.
No. add_sysfb() is supposed to always succeed. However, if parse_mode/create_simplefb fail, it creates a "platform-framebuffer" as fallback. I don't see any way to avoid these ifdefs. Considering the explanation above, could you elaborate how you think this should work?
Thanks
David
Re: [RFC 2/6] x86: provide platform-devices for boot-framebuffers
Quoted 24 lines · David Herrmann
Hi
Quoted 21 lines · Stephen Warren
Quoted 20 lines · David Herrmann
The current situation regarding boot-framebuffers (VGA, VESA/VBE, EFI) on x86 causes troubles when loading multiple fbdev drivers. The global "struct
screen_info" does not provide any state-tracking about which drivers use the FBs.request_mem_region()theoretically works, but unfortunately vesafb/efifb ignore it due to quirks for broken boards.Avoid this by creating a "platform-framebuffer" device with a pointer to the "struct
screen_info" as platform-data. Drivers can now create platform-drivers and the driver-core will refuse multiple drivers being active simultaneously.We keep the
screen_infoavailable for backwards-compatibility. Drivers can be converted in follow-up patches.Apart from "platform-framebuffer" devices, this also introduces a compatibility option for "simple-framebuffer" drivers which recently got introduced for OF based systems. If
CONFIG_X86_SYSFBis selected, we try to match thescreen_infoagainst a simple-framebuffer supported format. If we succeed, we create a "simple-framebuffer" device instead of a platform-framebuffer.
...
Quoted 1 line
Quoted 1 line
Quoted 1 line
arch/x86/kernel/sysfb.c +0
-0
...
Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
arch/x86/kernel/sysfb.c +11
-0+#else /* CONFIG_X86_SYSFB */ + +static bool parse_mode (const struct screen_info *si, +struct simplefb_platform_data *mode) +{ +return false; +} + +static int create_simplefb (const struct screen_info *si, +const struct simplefb_platform_data *mode) +{Quoted 8 lines
arch/x86/kernel/sysfb.c line 132
Quoted 4 lines
arch/x86/kernel/sysfb.c +4
-0+ return -EINVAL; +} + +#endif /* CONFIG_X86_SYSFB */ Following on from my ifdef comment above, I believe those versions of those functions will always cause
add_sysfb()to return-ENODEV, so you may as well provide a static inline foradd_sysfb()instead.
Quoted 5 lines
No.
add_sysfb()is supposed to always succeed. However, if parse_mode/create_simplefb fail, it creates a "platform-framebuffer" as fallback. I don't see any way to avoid these ifdefs. Considering the explanation above, could you elaborate how you think this should work?
Ah, I wasn't getting the fallback mechanism; that if creating a simplefb wasn't possible or didn't succeed, a platformfb device would be created instead.
Perhaps the following might be slightly clearer; there are certainly fewer nesting levels:
static __init int add_sysfb(void)
{
const struct screen_info *si = &screen_info;
struct simplefb_platform_data mode;
struct platform_device *pd;
bool compatible = false;
int ret;
compatible = parse_mode(si, &mode);
if (compatible) {
ret = create_simplefb(si, &mode);
if (!ret)
return 0;
}
pd = platform_device_register_resndata(NULL,
"platform-framebuffer", 0,
NULL, 0, si, sizeof(*si));
ret = IS_ERR(pd) ? PTR_ERR(pd) : 0;
return ret;
}RFC 3/6 drm: add SimpleDRM driver
In reply to David HerrmannThe SimpleDRM driver binds to simple-framebuffer devices and provides a DRM/KMS API. It provides only a single CRTC+encoder+connector combination plus one initial mode.
Userspace can create one dumb-buffer and attach it to the CRTC. Only if the buffer is destroyed, a new buffer can be created. The buffer is directly mapped into user-space, so we have only resources for a single buffer. Otherwise, shadow buffers plus damage-request would be needed.
--- MAINTAINERS | 8 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/simpledrm/Kconfig | 18 ++ drivers/gpu/drm/simpledrm/Makefile | 5 + drivers/gpu/drm/simpledrm/simpledrm.h | 91 ++++++++ drivers/gpu/drm/simpledrm/simpledrm_drv.c | 230 ++++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_main.c | 330 +++++++++++++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_mem.c | 254 ++++++++++++++++++++++ 9 files changed, 939 insertions(+) create mode 100644 drivers/gpu/drm/simpledrm/Kconfig create mode 100644 drivers/gpu/drm/simpledrm/Makefile create mode 100644 drivers/gpu/drm/simpledrm/simpledrm.h create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_drv.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_main.c create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_mem.c
MAINTAINERS +8 -0
@@ -7305,6 +7305,14 @@ S: Odd Fixes F: drivers/media/platform/sh_vou.c F: include/media/sh_vou.h +SIMPLE DRM DRIVER +M: David Herrmann <[email protected]> +L: [email protected] +T: git git://people.freedesktop.org/~dvdhrm/linux +S: Maintained +F: drivers/gpu/drm/simpledrm +F: include/linux/platform_data/simpledrm.h + SIMPLE FIRMWARE INTERFACE (SFI) M: Len Brown <[email protected]> L: [email protected]
drivers/gpu/drm/Kconfig +2 -0
@@ -220,3 +220,5 @@ source "drivers/gpu/drm/omapdrm/Kconfig" source "drivers/gpu/drm/tilcdc/Kconfig" source "drivers/gpu/drm/qxl/Kconfig" + +source "drivers/gpu/drm/simpledrm/Kconfig"
drivers/gpu/drm/Makefile +1 -0
@@ -52,4 +52,5 @@ obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/ obj-$(CONFIG_DRM_OMAP) += omapdrm/ obj-$(CONFIG_DRM_TILCDC) += tilcdc/ obj-$(CONFIG_DRM_QXL) += qxl/ +obj-$(CONFIG_DRM_SIMPLEDRM) += simpledrm/ obj-y += i2c/
drivers/gpu/drm/simpledrm/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +config DRM_SIMPLEDRM + tristate "Simple firmware framebuffer DRM driver" + depends on DRM && !FB_SIMPLE + help + SimpleDRM can run on all systems with pre-initialized graphics + hardware. It uses a framebuffer that was initialized during + firmware boot. No page-flipping, modesetting or other advanced + features are available. However, other DRM drivers can be loaded + later and take over from SimpleDRM if they provide real hardware + support. + + SimpleDRM supports: "simple-framebuffer" DeviceTree objects, x86 VESA + BIOS Extensions (VBE), EFI framebuffers + + If unsure, say Y. + + To compile this driver as a module, choose M here: the + module will be called simpledrm.
drivers/gpu/drm/simpledrm/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +ccflags-y := -Iinclude/drm + +simpledrm-y := simpledrm_drv.o simpledrm_main.o simpledrm_mem.o + +obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o
drivers/gpu/drm/simpledrm/simpledrm.h new file +91 -0
91 lines not on this page · raw message
drivers/gpu/drm/simpledrm/simpledrm_drv.c new file +230 -0
230 lines not on this page · raw message
drivers/gpu/drm/simpledrm/simpledrm_main.c new file +330 -0
330 lines not on this page · raw message
drivers/gpu/drm/simpledrm/simpledrm_mem.c new file +254 -0
254 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [RFC 3/6] drm: add SimpleDRM driver
drivers/gpu/drm/simpledrm/simpledrm_drv.c line 164
Quoted 1 line · David Herrmann
drivers/gpu/drm/simpledrm/simpledrm_drv.c new file +1
-0+ sdrm->fb_map =ioremap (sdrm->fb_base, sdrm->fb_size);
This should probably be ioremap_wc. Otherwise it will be *really* slow if used in legacy mode and it may cause conflicts with the pgprot_writecombine mode for mmap.
(Watching boot messages go by on fbcon on efifb was like using an old 2400 baud modem before I made the corresponding change to efifb.)
--Andy
Re: [RFC 3/6] drm: add SimpleDRM driver
Hi
Quoted 6 lines · Andy Lutomirski
Quoted 1 line · David Herrmann
+
sdrm->fb_map=ioremap(sdrm->fb_base, sdrm->fb_size);This should probably be
ioremap_wc. Otherwise it will be *really* slow if used in legacy mode and it may cause conflicts with thepgprot_writecombinemode for mmap.
Whoops, yepp, I fixed that.
Thanks
David
Re: [RFC 3/6] drm: add SimpleDRM driver
In reply to David HerrmannQuoted 14 lines · David Herrmann
The SimpleDRM driver binds to simple-framebuffer devices and provides a DRM/KMS API. It provides only a single CRTC+encoder+connector combination plus one initial mode.
Userspace can create one dumb-buffer and attach it to the CRTC. Only if the buffer is destroyed, a new buffer can be created. The buffer is directly mapped into user-space, so we have only resources for a single buffer. Otherwise, shadow buffers plus damage-request would be needed.
drivers/gpu/drm/simpledrm/Kconfig +3
-0+config DRM_SIMPLEDRM + tristate "Simple firmware framebuffer DRM driver" + depends on DRM && !FB_SIMPLE
drivers/gpu/drm/simpledrm/Kconfig line 13
Quoted 10 lines
drivers/gpu/drm/simpledrm/Kconfig +10
-0+ help + SimpleDRM can run on all systems with pre-initialized graphics + hardware. It uses a framebuffer that was initialized during + firmware boot. No page-flipping, modesetting or other advanced + features are available. However, other DRM drivers can be loaded + later and take over from SimpleDRM if they provide real hardware + support. + + SimpleDRM supports: "simple-framebuffer" DeviceTree objects, x86 VESA + BIOS Extensions (VBE), EFI framebuffers
DT objects, yes. I'm not sure it's quite true to say it actually directly supports VBE or EFI FBs; it's more the code in patch 2/6 that supports those. I guess this is a bit nit-picky of a distinction though.
drivers/gpu/drm/simpledrm/simpledrm_drv.c line 92
Quoted 6 lines
drivers/gpu/drm/simpledrm/simpledrm_drv.c +3
-0+static int parse_dt(struct platform_device *pdev, + struct simplefb_platform_data *mode) + strlcpy(mode->format, format, sizeof(mode->format));
Even here, I believe the DT data sticks around so just copying the pointer should be safe. It'd be worth validating that for sure though.
I didn't review the DRM stuff here since I'm not at all familiar with DRM.
Re: [RFC 3/6] drm: add SimpleDRM driver
Hi
Quoted 21 lines · Stephen Warren
Quoted 20 lines · David Herrmann
The SimpleDRM driver binds to simple-framebuffer devices and provides a DRM/KMS API. It provides only a single CRTC+encoder+connector combination plus one initial mode.
Userspace can create one dumb-buffer and attach it to the CRTC. Only if the buffer is destroyed, a new buffer can be created. The buffer is directly mapped into user-space, so we have only resources for a single buffer. Otherwise, shadow buffers plus damage-request would be needed.
drivers/gpu/drm/simpledrm/Kconfig +9
-0+config DRM_SIMPLEDRM + tristate "Simple firmware framebuffer DRM driver" + depends on DRM && !FB_SIMPLE + help + SimpleDRM can run on all systems with pre-initialized graphics + hardware. It uses a framebuffer that was initialized during + firmware boot. No page-flipping, modesetting or other advanced + features are available. However, other DRM drivers can be loaded + later and take over from SimpleDRM if they provide real hardware
Quoted 8 lines
drivers/gpu/drm/simpledrm/Kconfig line 13
Quoted 4 lines
drivers/gpu/drm/simpledrm/Kconfig +4
-0+ support. + + SimpleDRM supports: "simple-framebuffer" DeviceTree objects, x86 VESA + BIOS Extensions (VBE), EFI framebuffersDT objects, yes. I'm not sure it's quite true to say it actually directly supports VBE or EFI FBs; it's more the code in patch 2/6 that supports those. I guess this is a bit nit-picky of a distinction though.
I initially intended to add support for "platform-framebuffer" objects, too. This would make vesafb/... obsolete but I dropped that idea for now. I will fix the Kconfig description.
Quoted 9 lines
drivers/gpu/drm/simpledrm/simpledrm_drv.c line 92
Quoted 6 lines
drivers/gpu/drm/simpledrm/simpledrm_drv.c +3
-0+static int parse_dt(struct platform_device *pdev, + struct simplefb_platform_data *mode) + strlcpy(mode->format, format, sizeof(mode->format));Even here, I believe the DT data sticks around so just copying the pointer should be safe. It'd be worth validating that for sure though.
Yep, indeed, I fixed that.
Thanks!
David
Quoted 1 line
I didn't review the DRM stuff here since I'm not at all familiar with DRM.
RFC 4/6 drm: simpledrm: add fbdev fallback support
In reply to David HerrmannCreate a simple fbdev device during SimpleDRM setup so legacy user-space and fbcon can use it.
fbdev deletion is quite buggy. A unregister_framebuffer() call followed by a printk() causes NULL-derefs in hide_cursor() and other places in the VT layer. Hence, we leak the fbdev device currently to make the VT layer happy. This needs to be fixed soon! Otherwise, we need a "depends !VT" line for SimpleDRM.
--- drivers/gpu/drm/simpledrm/Kconfig | 11 ++ drivers/gpu/drm/simpledrm/Makefile | 4 + drivers/gpu/drm/simpledrm/simpledrm.h | 22 ++++ drivers/gpu/drm/simpledrm/simpledrm_fbdev.c | 180 ++++++++++++++++++++++++++++ drivers/gpu/drm/simpledrm/simpledrm_main.c | 2 + 5 files changed, 219 insertions(+) create mode 100644 drivers/gpu/drm/simpledrm/simpledrm_fbdev.c
drivers/gpu/drm/simpledrm/Kconfig +11 -0
@@ -12,7 +12,18 @@ config DRM_SIMPLEDRM SimpleDRM supports: "simple-framebuffer" DeviceTree objects, x86 VESA BIOS Extensions (VBE), EFI framebuffers + If fbdev support is enabled, this driver will also provide an fbdev + compatibility layer. + If unsure, say Y. To compile this driver as a module, choose M here: the module will be called simpledrm. + +config DRM_SIMPLEDRM_FBDEV + bool + depends on DRM_SIMPLEDRM && FB + default y + select FB_CFB_FILLRECT + select FB_CFB_COPYAREA + select FB_CFB_IMAGEBLIT
drivers/gpu/drm/simpledrm/Makefile +4 -0
@@ -2,4 +2,8 @@ ccflags-y := -Iinclude/drm simpledrm-y := simpledrm_drv.o simpledrm_main.o simpledrm_mem.o +ifdef CONFIG_DRM_SIMPLEDRM_FBDEV + simpledrm-y += simpledrm_fbdev.o +endif + obj-$(CONFIG_DRM_SIMPLEDRM) := simpledrm.o
drivers/gpu/drm/simpledrm/simpledrm.h +22 -0
@@ -48,6 +48,9 @@ struct sdrm_device {struct drm_encoder enc;struct drm_connector conn;struct drm_display_mode *mode; + +/* fbdev */ +struct fb_info *fbdev; };int sdrm_drm_load (struct drm_device *ddev,unsigned long flags);
@@ -88,4 +91,23 @@ struct sdrm_framebuffer {#define to_sdrm_fb (x) container_of(x, struct sdrm_framebuffer, base) +/* simpledrm fbdev helpers */ + +#ifdef CONFIG_DRM_SIMPLEDRM_FBDEV + +void sdrm_fbdev_init (struct sdrm_device *sdrm); +void sdrm_fbdev_cleanup (struct sdrm_device *sdrm); + +#else /* CONFIG_DRM_SIMPLEDRM_FBDEV */ + +static inline void sdrm_fbdev_init (struct sdrm_device *sdrm) +{ +} + +static inline void sdrm_fbdev_cleanup (struct sdrm_device *sdrm) +{ +} + +#endif /* CONFIG_DRM_SIMPLEDRM_FBDEV */ +#endif /* SDRM_DRV_H */
drivers/gpu/drm/simpledrm/simpledrm_fbdev.c new file +180 -0
180 lines not on this page · raw message
drivers/gpu/drm/simpledrm/simpledrm_main.c +2 -0
@@ -305,6 +305,7 @@ int sdrm_drm_load(struct drm_device *ddev, unsigned long flags)if (ret) goto err_cleanup; +sdrm_fbdev_init (sdrm);return 0 ; err_cleanup:
@@ -322,6 +323,7 @@ int sdrm_drm_unload(struct drm_device *ddev) {struct sdrm_device *sdrm = ddev->dev_private; +sdrm_fbdev_cleanup (sdrm);drm_mode_config_cleanup (ddev);sdrm_pdev_destroy (sdrm);kfree (sdrm);
Signature · 1 line
1.8.3.1
Re: [RFC 4/6] drm: simpledrm: add fbdev fallback support
Quoted 10 lines · David Herrmann
Create a simple fbdev device during SimpleDRM setup so legacy user-space and fbcon can use it.
fbdev deletion is quite buggy. A
unregister_framebuffer()call followed by aprintk()causes NULL-derefs inhide_cursor()and other places in the VT layer. Hence, we leak the fbdev device currently to make the VT layer happy. This needs to be fixed soon! Otherwise, we need a "depends !VT" line for SimpleDRM.
drivers/gpu/drm/simpledrm/Makefile ccflags-y := -Iinclude/drm · line 7
Quoted 6 lines
drivers/gpu/drm/simpledrm/Makefile +3
-0simpledrm-y := simpledrm_drv.o simpledrm_main.o simpledrm_mem.o +ifdef CONFIG_DRM_SIMPLEDRM_FBDEV + simpledrm-y += simpledrm_fbdev.o +endif
I think that's:
+ simpledrm-$(CONFIG_DRM_SIMPLEDRM_FBDEV) += simpledrm_fbdev.o
Re: [RFC 4/6] drm: simpledrm: add fbdev fallback support
Hi
Quoted 14 lines · Stephen Warren
Quoted 13 lines · David Herrmann
Create a simple fbdev device during SimpleDRM setup so legacy user-space and fbcon can use it.
fbdev deletion is quite buggy. A
unregister_framebuffer()call followed by aprintk()causes NULL-derefs inhide_cursor()and other places in the VT layer. Hence, we leak the fbdev device currently to make the VT layer happy. This needs to be fixed soon! Otherwise, we need a "depends !VT" line for SimpleDRM.drivers/gpu/drm/simpledrm/Makefile +0
-0simpledrm-y := simpledrm_drv.o simpledrm_main.o simpledrm_mem.o
Quoted 7 lines
drivers/gpu/drm/simpledrm/Makefile ccflags-y := -Iinclude/drm · line 7
Quoted 3 lines
drivers/gpu/drm/simpledrm/Makefile +3
-0+ifdef CONFIG_DRM_SIMPLEDRM_FBDEV + simpledrm-y += simpledrm_fbdev.o +endifI think that's:
+ simpledrm-$(CONFIG_DRM_SIMPLEDRM_FBDEV) += simpledrm_fbdev.o
Ugh, I got errors trying that because SIMPLEDRM_FBDEV is a boolean but SIMPLEDRM is a tristate. But I guess I tried:
obj-$(CONFIG_DRM_SIMPLEDRM_FBDEV) += simpledrm_fbdev.o which obviously fails if SIMPLEDRM=m and SIMPLEDRM_FBDEV=y. I will try to fix that.
Thanks
David
RFC 5/6 drm: add helpers to kick out firmware drivers
In reply to David HerrmannIf we load a real hardware DRM driver, we want all firmware drivers to be unloaded. Historically, this was done via remove_conflicting_framebuffers(), but for DRM drivers (like SimpleDRM) we need a new way.
This patch introduces DRIVER_FIRMWARE and DRM apertures to provide a quite similar way to kick out firmware DRM drivers. Additionally, unlike the fbdev equivalent, DRM firmware drivers can now query the system whether a real hardware driver is already loaded and prevent loading themselves.
--- drivers/gpu/drm/drm_pci.c | 1 + drivers/gpu/drm/drm_platform.c | 1 + drivers/gpu/drm/drm_stub.c | 107 +++++++++++++++++++++++++++++ drivers/gpu/drm/drm_usb.c | 1 + drivers/gpu/drm/simpledrm/simpledrm.h | 1 + drivers/gpu/drm/simpledrm/simpledrm_drv.c | 3 +- drivers/gpu/drm/simpledrm/simpledrm_main.c | 34 +++++++++ include/drm/drmP.h | 26 +++++++ 8 files changed, 173 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_pci.c +1 -0
@@ -366,6 +366,7 @@ int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent, }list_add_tail (&dev->driver_item, &driver->device_list); +list_add_tail (&dev->global_item, &drm_devlist); DRM_INFO("Initialized %s %d.%d.%d %s for %s on minor %d\n", driver->name, driver->major, driver->minor, driver->patchlevel,
drivers/gpu/drm/drm_platform.c +1 -0
@@ -88,6 +88,7 @@ int drm_get_platform_dev(struct platform_device *platdev, }list_add_tail (&dev->driver_item, &driver->device_list); +list_add_tail (&dev->global_item, &drm_devlist);mutex_unlock (&drm_global_mutex);
drivers/gpu/drm/drm_stub.c +107 -0
123 lines not on this page · raw message
drivers/gpu/drm/drm_usb.c +1 -0
@@ -50,6 +50,7 @@ int drm_get_usb_dev(struct usb_interface *interface, goto err_g3;list_add_tail (&dev->driver_item, &driver->device_list); +list_add_tail (&dev->global_item, &drm_devlist);mutex_unlock (&drm_global_mutex);
drivers/gpu/drm/simpledrm/simpledrm.h +1 -0
@@ -55,6 +55,7 @@ struct sdrm_device {int sdrm_drm_load (struct drm_device *ddev,unsigned long flags);int sdrm_drm_unload (struct drm_device *ddev); +void sdrm_drm_kick_out_firmware (struct drm_device *ddev);int sdrm_drm_mmap (struct file *filp,struct vm_area_struct *vma);int sdrm_pdev_init (struct sdrm_device *sdrm);void sdrm_pdev_destroy (struct sdrm_device *sdrm);
drivers/gpu/drm/simpledrm/simpledrm_drv.c +2 -1
@@ -36,9 +36,10 @@ static const struct file_operations sdrm_drm_fops = { };static struct drm_driver sdrm_drm_driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_FIRMWARE , .load = sdrm_drm_load, .unload = sdrm_drm_unload, + .kick_out_firmware = sdrm_drm_kick_out_firmware, .fops = &sdrm_drm_fops, .gem_init_object = sdrm_gem_init_object,
drivers/gpu/drm/simpledrm/simpledrm_main.c +34 -0
@@ -269,6 +269,21 @@ int sdrm_drm_load(struct drm_device *ddev, unsigned long flags)if (ret) goto err_name; + ddev->apertures =alloc_apertures (1 ); +if (!ddev->apertures) { + ret = -ENOMEM ; + goto err_pdev; + } + + ddev->apertures->ranges[0 ].base = sdrm->fb_base; + ddev->apertures->ranges[0 ].size = sdrm->fb_size; + +if (drm_is_firmware_used (ddev->apertures)) { +dev_info (ddev->dev,"firmware framebuffer is already in use\n" ); + ret = -EBUSY ; + goto err_apert; + } +drm_mode_config_init (ddev); ddev->mode_config.min_width =0 ; ddev->mode_config.min_height =0 ;
@@ -310,6 +325,9 @@ int sdrm_drm_load(struct drm_device *ddev, unsigned long flags) err_cleanup:drm_mode_config_cleanup (ddev); +err_apert: +kfree (ddev->apertures); +err_pdev:sdrm_pdev_destroy (sdrm); err_name:kfree (ddev->devname);
@@ -326,7 +344,23 @@ int sdrm_drm_unload(struct drm_device *ddev)sdrm_fbdev_cleanup (sdrm);drm_mode_config_cleanup (ddev);sdrm_pdev_destroy (sdrm); +kfree (ddev->apertures);kfree (sdrm);return 0 ; } + +void sdrm_drm_kick_out_firmware (struct drm_device *ddev) +{ +struct sdrm_device *sdrm = ddev->dev_private; + +mutex_lock (&ddev->struct_mutex); + +sdrm_fbdev_cleanup (sdrm); +drm_unplug_dev_locked (ddev); +if (sdrm->fb_obj) +sdrm_gem_unmap_object (sdrm->fb_obj); +sdrm_pdev_destroy (sdrm); + +mutex_unlock (&ddev->struct_mutex); +}
include/drm/drmP.h +26 -0
@@ -47,6 +47,7 @@#include <linux/fs.h> #include <linux/proc_fs.h> #include <linux/init.h> +#include <linux/fb.h> #include <linux/file.h> #include <linux/platform_device.h> #include <linux/pci.h>
@@ -156,6 +157,7 @@ int drm_err(const char *func, const char *format, ...);#define DRIVER_GEM 0x1000#define DRIVER_MODESET 0x2000#define DRIVER_PRIME 0x4000 +#define DRIVER_FIRMWARE 0x8000#define DRIVER_BUS_PCI 0x1#define DRIVER_BUS_PLATFORM 0x2
@@ -954,6 +956,23 @@ struct drm_driver {struct drm_device *dev, uint32_t handle); +/** +* kick_out_firmware - kick out firmware driver +* @dev: DRM device +* +* Iff this driver has DRIVER_FIRMWARE set, this function is called +* when a real hw-driver is loaded and claims the framebuffer memory +* that is mapped by the firmware driver. This is called with the +* global drm mutex held. +* Drivers should unmap any memory-mappings, disable the device and +* schedule a driver removal. +* +* Note that a driver setting DRIVER_FIRMWARE is supposed to also set +* the "apertures" information on @dev. It is used to match the memory +* regions that are used by firmware drivers. +*/ +void (*kick_out_firmware) (struct drm_device *dev); +/* Driver private ops for this object */ const struct vm_operations_struct *gem_vm_ops;
@@ -1077,6 +1096,7 @@ struct drm_pending_vblank_event {*/ struct drm_device {struct list_head driver_item;/**< list of devices per driver */ +struct list_head global_item;/**< global list of devices */ char *devname;/**< For /proc/interrupts */ int if_version;/**< Highest interface version set */
@@ -1218,6 +1238,8 @@ struct drm_device {int switch_power_state;atomic_t unplugged;/* device has been unplugged or gone away */ +struct apertures_struct *apertures;/**< fbmem apertures */ +bool apert_boot;/**< true if mapped as boot fb */ };#define DRM_SWITCH_POWER_ON 0
@@ -1532,6 +1554,10 @@ extern void drm_master_put(struct drm_master **master);extern void drm_put_dev (struct drm_device *dev);extern int drm_put_minor (struct drm_minor **minor);extern void drm_unplug_dev (struct drm_device *dev); +extern void drm_unplug_dev_locked (struct drm_device *dev); +extern void drm_kick_out_firmware (struct apertures_struct *ap,bool boot); +extern bool drm_is_firmware_used (struct apertures_struct *ap); +extern struct list_head drm_devlist;extern unsigned int drm_debug;extern unsigned int drm_vblank_offdelay;
Signature · 1 line
1.8.3.1
RFC 6/6 drm: nouveau: kick out firmware drivers during probe
In reply to David HerrmannUse the new DRM infrastructure to kick out firmware drivers before probing the real driver.
--- drivers/gpu/drm/nouveau/nouveau_drm.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +22 -7
@@ -233,13 +233,11 @@ nouveau_accel_init(struct nouveau_drm *drm)nouveau_bo_move_init (drm); } -static int nouveau_drm_probe (struct pci_dev *pdev, -const struct pci_device_id *pent) +static int nouveau_kick_out_firmware (struct drm_device *dev) { -struct nouveau_device *device;struct apertures_struct *aper;bool boot = false; -int ret; +struct pci_dev *pdev = dev->pdev;/* remove conflicting drivers (vesafb, efifb etc) */ aper =alloc_apertures (3 );
@@ -265,8 +263,18 @@ static int nouveau_drm_probe(struct pci_dev *pdev,#ifdef CONFIG_X86 boot = pdev->resource[PCI_ROM_RESOURCE ].flags &IORESOURCE_ROM_SHADOW ;#endif -remove_conflicting_framebuffers (aper,"nouveaufb" , boot); -kfree (aper); + +drm_kick_out_firmware (aper, boot); + dev->apertures = aper; + dev->apert_boot = boot; +return 0 ; +} + +static int nouveau_drm_probe (struct pci_dev *pdev, +const struct pci_device_id *pent) +{ +struct nouveau_device *device; +int ret; ret =nouveau_device_create (pdev,nouveau_name (pdev),pci_name (pdev), nouveau_config, nouveau_debug, &device);
@@ -294,9 +302,13 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)struct nouveau_drm *drm;int ret; - ret =nouveau_cli_create (pdev,"DRM" ,sizeof (*drm), (void **)&drm); + ret =nouveau_kick_out_firmware (dev);if (ret)return ret; + + ret =nouveau_cli_create (pdev,"DRM" ,sizeof (*drm), (void **)&drm); +if (ret) + goto fail_apert;lockdep_set_class (&drm->client.mutex, &drm_client_lock_class_key); dev->dev_private = drm;
@@ -392,6 +404,9 @@ fail_ttm:nouveau_vga_fini (drm); fail_device:nouveau_cli_destroy (&drm->client); +fail_apert: +kfree (dev->apertures); + dev->apertures =NULL ;return ret; }
Signature · 1 line
1.8.3.1
Quoted 14 lines · David Herrmann
Hi
This is my second revision of the dvbe driver. I renamed it to SimpleDRM to show the resemblence with the recently introduced
simplefb.cfbdev driver. The driver is supposed to be the most basic DRM driver similar toefifb.c,vesafb.c,offb.c,simplefb.c, ...
It provides a single virtual CRTC+encoder+connector and allows user-space to create one dumb-buffer at a time and attach it.The setup changed slightly. It no longer uses shadow buffers but instead maps the framebuffer directly into userspace. Furthermore, a new infrastructure is used to unload firmware drivers during real hardware drivers probe cycles. Only nouveau was changed to use it, yet.
Quoted 5 lines
I still have an odd problem when unloading DRM drivers (not just SimpleDRM) with an fbdev fallback. If I call
printk()directly afterunregister_framebufer(), I get a NULL-deref somewhere in the VT layer (most timeshide_cursor()). I haven't figured out exactly where that happens, but I am also very reluctant to spend more time debugging the VT layer.
I tested this on a Tegra ARM system, and it basically worked.
I have one question: With the simplefb driver, and console=tty1 on the kernel command-line, I see both the penguins logo and Linux's boot messages on the LCD panel that's hooked up through simplefb. However, with simpledrm, I only see the penguins logo, but no boot messages. Is that expected? How would I solve that if so?
Note: I needed to apply the following patch to get it to compile:
(quoted diff) +0 -0
b/drivers/gpu/drm/simpledrm/simpledrm_fbdev.c
index 40a2696..39885c8 100644
drivers/gpu/drm/simpledrm/simpledrm_fbdev.c +1 -1
@@ -159,7 +159,7 @@ void sdrm_fbdev_cleanup(struct sdrm_device *sdrm) {struct fb_info *info; -if (!sdrm->info) +if (!sdrm->fbdev)return ;dev_info (sdrm->ddev->dev,"fbdev cleanup\n" );
Hi
Quoted 15 lines · Stephen Warren
Quoted 14 lines · David Herrmann
Hi
This is my second revision of the dvbe driver. I renamed it to SimpleDRM to show the resemblence with the recently introduced
simplefb.cfbdev driver. The driver is supposed to be the most basic DRM driver similar toefifb.c,vesafb.c,offb.c,simplefb.c, ...
It provides a single virtual CRTC+encoder+connector and allows user-space to create one dumb-buffer at a time and attach it.The setup changed slightly. It no longer uses shadow buffers but instead maps the framebuffer directly into userspace. Furthermore, a new infrastructure is used to unload firmware drivers during real hardware drivers probe cycles. Only nouveau was changed to use it, yet.
Quoted 7 lines
Quoted 5 lines
I still have an odd problem when unloading DRM drivers (not just SimpleDRM) with an fbdev fallback. If I call
printk()directly afterunregister_framebufer(), I get a NULL-deref somewhere in the VT layer (most timeshide_cursor()). I haven't figured out exactly where that happens, but I am also very reluctant to spend more time debugging the VT layer.I tested this on a Tegra ARM system, and it basically worked.
Thanks a lot for the feedback!
Quoted 5 lines
I have one question: With the simplefb driver, and console=tty1 on the kernel command-line, I see both the penguins logo and Linux's boot messages on the LCD panel that's hooked up through simplefb. However, with simpledrm, I only see the penguins logo, but no boot messages. Is that expected? How would I solve that if so?
No idea what is going wrong there. Somehow the simpledrm-fbdev device is not picked up as primary device. I only got a black-cursor on black-background (visible if painting something else on the fb0 device). And I get NULL-derefs in cursor_hide() during unregistration. I digged through fbcon.c to find out what's going wrong but without any success. I will see what I can do.
However, X-server or other apps work perfectly fine with it.
Quoted 8 lines
Note: I needed to apply the following patch to get it to compile:
drivers/gpu/drm/simpledrm/simpledrm_fbdev.c +0
-0
drivers/gpu/drm/simpledrm/simpledrm_fbdev.c void sdrm_fbdev_cleanup(struct sdrm_device *sdrm) · line 163
Quoted 6 lines
drivers/gpu/drm/simpledrm/simpledrm_fbdev.c +1
-1@@ -159,7 +159,7 @@ void sdrm_fbdev_cleanup(struct sdrm_device *sdrm) {struct fb_info *info; -if (!sdrm->info) +if (!sdrm->fbdev)return ;
Ugh, embarrassing, sorry. I fixed it up. It was a late fix to a avoid fbcon from panicking.
Thanks!
David
Quoted 5 lines
drivers/gpu/drm/simpledrm/simpledrm_fbdev.c +0
-0dev_info (sdrm->ddev->dev,"fbdev cleanup\n" );