fbdev: Prevent probing generic drivers if a FB is already registered
Subsystems (2)
PATCH v3 1/1 fbdev: Prevent probing generic drivers if a FB is already registered
The efifb and simplefb drivers just render to a pre-allocated frame buffer and rely on the display hardware being initialized before the kernel boots.
But if another driver already probed correctly and registered a fbdev, the generic drivers shouldn't be probed since an actual driver for the display hardware is already present.
This is more likely to occur after commit d391c5827107 ("drivers/firmware:
move x86 Generic System Framebuffers support") since the "efi-framebuffer" and "simple-framebuffer" platform devices are registered at a later time.
---
Changes in v3:
- Cc <[email protected]> since a Fixes: tag is not enough (gregkh).
Changes in v2:
- Add a Link: tag with a reference to the bug report (Thorsten Leemhuis).
- Add a comment explaining why the probe fails earlier (Daniel Vetter).
- Add a Fixes: tag for stable to pick the fix (Daniel Vetter).
- Add Daniel Vetter's Reviewed-by: tag.
- Improve the commit message and mention the culprit commit
drivers/video/fbdev/efifb.c | 11 +++++++++++ drivers/video/fbdev/simplefb.c | 11 +++++++++++ 2 files changed, 22 insertions(+)
video/fbdev/efifb.c +11 -0
@@ -351,6 +351,17 @@ static int efifb_probe(struct platform_device *dev)char *option =NULL ;efi_memory_desc_t md; +/* +* Generic drivers must not be registered if a framebuffer exists. +* If a native driver was probed, the display hardware was already +* taken and attempting to use the system framebuffer is dangerous. +*/ +if (num_registered_fb >0 ) { +dev_err (&dev->dev, +"efifb: a framebuffer is already registered\n" ); +return -EINVAL ; + } +if (screen_info.orig_video_isVGA !=VIDEO_TYPE_EFI || pci_dev_disabled)return -ENODEV ;
video/fbdev/simplefb.c +11 -0
@@ -407,6 +407,17 @@ static int simplefb_probe(struct platform_device *pdev)struct simplefb_par *par;struct resource *mem; +/* +* Generic drivers must not be registered if a framebuffer exists. +* If a native driver was probed, the display hardware was already +* taken and attempting to use the system framebuffer is dangerous. +*/ +if (num_registered_fb >0 ) { +dev_err (&pdev->dev, +"simplefb: a framebuffer is already registered\n" ); +return -EINVAL ; + } +if (fb_get_options ("simplefb" ,NULL ))return -ENODEV ;
Signature · 1 line
2.33.1
Quoted 80 lines · Javier Martinez Canillas
The efifb and simplefb drivers just render to a pre-allocated frame buffer and rely on the display hardware being initialized before the kernel boots.
But if another driver already probed correctly and registered a fbdev, the generic drivers shouldn't be probed since an actual driver for the display hardware is already present.
This is more likely to occur after commit
d391c5827107("drivers/firmware:
move x86 Generic System Framebuffers support") since the "efi-framebuffer" and "simple-framebuffer" platform devices are registered at a later time.Fixes d391c5827107 ("drivers/firmware: move x86 Generic System Framebuffers support")Reported-by Ilya Trukhanov <[email protected]>Cc <[email protected]> # 5.15.xSigned-off-by Javier Martinez Canillas <[email protected]>Reviewed-by Daniel Vetter <[email protected]>---
Changes in v3:
- Cc <[email protected]> since a Fixes: tag is not enough (gregkh).Changes in v2:
- Add a Link: tag with a reference to the bug report (Thorsten Leemhuis).
- Add a comment explaining why the probe fails earlier (Daniel Vetter).
- Add a Fixes: tag for stable to pick the fix (Daniel Vetter).
- Add Daniel Vetter's Reviewed-by: tag.
- Improve the commit message and mention the culprit commitdrivers/video/fbdev/efifb.c | 11 +++++++++++ drivers/video/fbdev/simplefb.c | 11 +++++++++++ 2 files changed, 22 insertions(+)video/fbdev/efifb.c +11
-0@@ -351,6 +351,17 @@ static int efifb_probe(struct platform_device *dev)char *option =NULL ;efi_memory_desc_t md; +/* +* Generic drivers must not be registered if a framebuffer exists. +* If a native driver was probed, the display hardware was already +* taken and attempting to use the system framebuffer is dangerous. +*/ +if (num_registered_fb >0 ) { +dev_err (&dev->dev, +"efifb: a framebuffer is already registered\n" ); +return -EINVAL ; + } +if (screen_info.orig_video_isVGA !=VIDEO_TYPE_EFI || pci_dev_disabled)return -ENODEV ;video/fbdev/simplefb.c +11
-0@@ -407,6 +407,17 @@ static int simplefb_probe(struct platform_device *pdev)struct simplefb_par *par;struct resource *mem; +/* +* Generic drivers must not be registered if a framebuffer exists. +* If a native driver was probed, the display hardware was already +* taken and attempting to use the system framebuffer is dangerous. +*/ +if (num_registered_fb >0 ) { +dev_err (&pdev->dev, +"simplefb: a framebuffer is already registered\n" ); +return -EINVAL ; + } +if (fb_get_options ("simplefb" ,NULL ))return -ENODEV ;Signature · 1 line
2.33.1
This patch fixes the suspend issue I was experiencing. Thank you.