0002-skip-simpledrm-if-nvidia-drm.modeset=1-is.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. From 768a5cf69b200e3990fbe0bb7e9017a50036844f Mon Sep 17 00:00:00 2001
  2. From: Javier Martinez Canillas <javierm@redhat.com>
  3. Date: Thu, 19 May 2022 14:40:07 +0200
  4. Subject: [PATCH] drivers/firmware: skip simpledrm if nvidia-drm.modeset=1 is
  5. set
  6. The Nvidia proprietary driver has some bugs that leads to issues if used
  7. with the simpledrm driver. The most noticeable is that does not register
  8. an emulated fbdev device.
  9. It just relies on a fbdev to be registered by another driver, that could
  10. be that could be attached to the framebuffer console. On UEFI machines,
  11. this is the efifb driver.
  12. This means that disabling the efifb driver will cause virtual consoles to
  13. not be present in the system when using the Nvidia driver. Legacy BIOS is
  14. not affected just because fbcon is not used there, but instead vgacon.
  15. Unless a VGA mode is specified using the vga= kernel command line option,
  16. in that case the vesafb driver is used instead and its fbdev attached to
  17. the fbcon.
  18. This is a problem because with CONFIG_SYSFB_SIMPLEFB=y, the sysfb platform
  19. code attempts to register a "simple-framebuffer" platform device (that is
  20. matched against simpledrm) and only registers either an "efi-framebuffer"
  21. or "vesa-framebuffer" if this fails to be registered due the video modes
  22. not being compatible.
  23. The Nvidia driver relying on another driver to register the fbdev is quite
  24. fragile, since it can't really assume those will stick around. For example
  25. there are patches posted to remove the EFI and VESA platform devices once
  26. a real DRM or fbdev driver probes.
  27. But in any case, moving to a simpledrm + emulated fbdev only breaks this
  28. assumption and causes users to not have VT if the Nvidia driver is used.
  29. So to prevent this, let's add a workaround and make the sysfb to skip the
  30. "simple-framebuffer" registration when nvidia-drm.modeset=1 option is set.
  31. This is quite horrible, but honestly I can't think of any other approach.
  32. For this to work, the CONFIG_FB_EFI and CONFIG_FB_VESA config options must
  33. be enabled besides CONFIG_DRM_SIMPLEDRM.
  34. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
  35. Cherry-picked-for: https://bugs.archlinux.org/task/73720
  36. ---
  37. drivers/firmware/sysfb.c | 18 +++++++++++++++++-
  38. 1 file changed, 17 insertions(+), 1 deletion(-)
  39. diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c
  40. index 82fcfd29bc4d29..17b7e096b6828b 100644
  41. --- a/drivers/firmware/sysfb.c
  42. +++ b/drivers/firmware/sysfb.c
  43. @@ -34,6 +34,22 @@
  44. #include <linux/screen_info.h>
  45. #include <linux/sysfb.h>
  46. +static int skip_simpledrm;
  47. +
  48. +static int __init simpledrm_disable(char *opt)
  49. +{
  50. + if (!opt)
  51. + return -EINVAL;
  52. +
  53. + get_option(&opt, &skip_simpledrm);
  54. +
  55. + if (skip_simpledrm)
  56. + pr_info("The simpledrm driver will not be probed\n");
  57. +
  58. + return 0;
  59. +}
  60. +early_param("nvidia-drm.modeset", simpledrm_disable);
  61. +
  62. static struct platform_device *pd;
  63. static DEFINE_MUTEX(disable_lock);
  64. static bool disabled;
  65. @@ -85,7 +101,7 @@ static __init int sysfb_init(void)
  66. /* try to create a simple-framebuffer device */
  67. compatible = sysfb_parse_mode(si, &mode);
  68. - if (compatible) {
  69. + if (compatible && !skip_simpledrm) {
  70. pd = sysfb_create_simplefb(si, &mode);
  71. if (!IS_ERR(pd))
  72. goto unlock_mutex;