commit:     619d0545c04fd9b68c4ab27a1baaa63521c32e9d
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  1 16:18:05 2022 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Sun Oct  2 03:58:23 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=619d0545

x11-drivers/nvidia-drivers: warn about simpledrm again + FB/nouveau

Thought SIMPLEDRM issues had improved. Last time I tried, X was still
working just without tty console display so not "that" bad (that was
with kernel 5.14.x or so).

gentoo-kernel-bin uses Fedora's configs which enables SIMPLEDRM since
5.17.x or so. Formerly without FB_EFI then later re-enabled (was under
the impression this improved things, but I only try -bin when
stabilizing drivers, so 5.15.x), however SIMPLEDRM=y takes priority
and X/wayland breaks entirely and then messes up the tty (worse than
before).

Difference between gentoo-kernel-bin and Fedora's is that they now
patch their kernel to let this configuration work:
https://src.fedoraproject.org/rpms/kernel/blob/e762b5dd/f/patch-5.19-redhat.patch#_882
(seems they do not do this for kernel-6.0, unsure for status with it)

Have not found a (working) way to disable SIMPLEDRM from the kernel's
commandline, so merely adding a warning for bug #840439 if it's builtin

For FB_EFI or FB_VESA to work (aka get a console), also need to disable
SYSFB_SIMPLEFB. FB_SIMPLE seems broken since kernel-5.18.13 due to
another issue. Albeit this doesn't stop X from working.

Ideal would be for gentoo-kernel* to do it by default, but non-bin
gentoo-kernel users using the generic config can (tested with 5.19.12):

mkdir -p /etc/kernel/config.d &&
cat <<EOF > /etc/kernel/config.d/50nvidia.config
# CONFIG_DRM_SIMPLEDRM is not set
# CONFIG_SYSFB_SIMPLEFB is not set
EOF

(this is what gentoo-kernel-bin-5.15.x has)

While here also add an overdue warning for builtin nouveau (formerly
skipped given CONFIG_CHECK was unsuitable), and try to inform about
making the tty console work even though nvidia-drivers doesn't drive
it.

Bug: https://bugs.gentoo.org/840439
Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 .../nvidia-drivers/nvidia-drivers-390.154.ebuild   | 63 +++++++++++++++++++++-
 .../nvidia-drivers-470.141.03.ebuild               | 63 +++++++++++++++++++++-
 .../nvidia-drivers/nvidia-drivers-510.85.02.ebuild | 63 +++++++++++++++++++++-
 .../nvidia-drivers/nvidia-drivers-515.49.19.ebuild | 63 +++++++++++++++++++++-
 .../nvidia-drivers/nvidia-drivers-515.65.01.ebuild | 63 +++++++++++++++++++++-
 .../nvidia-drivers/nvidia-drivers-515.76.ebuild    | 63 +++++++++++++++++++++-
 6 files changed, 372 insertions(+), 6 deletions(-)

diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-390.154.ebuild 
b/x11-drivers/nvidia-drivers/nvidia-drivers-390.154.ebuild
index e3155fa43d82..6fefc8a6b044 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-390.154.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-390.154.ebuild
@@ -97,7 +97,7 @@ pkg_setup() {
        Cannot be directly selected in the kernel's menuconfig, and may need
        selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
        DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
-       local ERROR_X86_KERNEL_IBT="X86_KERNEL_IBT: is set, be warned the 
modules may not load with it.
+       local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set, be warned 
the modules may not load.
        If run into problems, either unset or pass ibt=off to the kernel."
 
        kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
@@ -112,6 +112,67 @@ pkg_setup() {
 
        [[ ${MERGE_TYPE} == binary ]] && return
 
+       # do some extra checks manually as it gets messy to handle builtin-only
+       # and some other conditional checks through CONFIG_CHECK
+       # TODO?: maybe move other custom checks here for uniformity
+       local warn=()
+
+       if linux_chkconfig_builtin DRM_NOUVEAU; then
+               # suggest =m given keeps KMS_HELPER enabled and can serve as 
fallback
+               warn+=(
+                       "  CONFIG_DRM_NOUVEAU: is builtin (=y), and will 
prevent loading NVIDIA"
+                       "    modules (can be safely kept as a module (=m) 
instead)."
+               )
+       fi
+
+       if linux_chkconfig_builtin DRM_SIMPLEDRM; then
+               # wrt prebuilts, Fedora is pushing =y and gentoo-kernel-bin 
uses its
+               # configs (bug #840439), but without Fedora's kernel patch to
+               # workaround this issue (which is unlikely to work for us 
anyway)
+               # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/228
+               warn+=(
+                       "  CONFIG_DRM_SIMPLEDRM: is builtin (=y), and may 
conflict with NVIDIA"
+                       "    (i.e. blanks when X/wayland starts, and tty loses 
display)."
+                       "    For prebuilt kernels, unfortunately no known good 
workarounds."
+               )
+       fi
+
+       if ! linux_chkconfig_present FB_EFI &&
+               ! linux_chkconfig_present FB_SIMPLE &&
+               ! linux_chkconfig_present FB_VESA
+       then
+               # nvidia-drivers does not handle the tty (beside mode 
restoration) but,
+               # given few options are viable, try to warn if all missing
+               warn+=(
+                       "  CONFIG_FB_(EFI|SIMPLE|VESA): none set, but note at 
least one is needed"
+                       "    to get a display for the tty console. In most 
cases, it is"
+                       "    recommended to enable FB_EFI=y and disable 
FB_SIMPLE (can be quirky)."
+                       "    Non-EFI systems are likely to want FB_VESA=y."
+               )
+       fi
+
+       if kernel_is -ge 5 18 13; then
+               if linux_chkconfig_present FB_SIMPLE; then
+                       warn+=(
+                               "  CONFIG_FB_SIMPLE: is set, recommended to 
disable and switch to FB_EFI"
+                               "    as it is currently known broken with 
>=kernel-5.18.13 + NVIDIA."
+                               "    
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/341";
+                       )
+               fi
+
+               if linux_chkconfig_present SYSFB_SIMPLEFB &&
+                       { linux_chkconfig_present FB_EFI || 
linux_chkconfig_present FB_VESA; }
+               then
+                       warn+=(
+                               "  CONFIG_SYSFB_SIMPLEFB: is set, this may 
prevent FB_EFI or FB_VESA"
+                               "    from providing a working tty console 
display (ignore if unused)."
+                       )
+               fi
+       fi
+
+       (( ${#warn[@]} )) &&
+               ewarn "Detected potential configuration issues with used 
kernel:${warn[*]/#/$'\n'}"
+
        BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" 
SYSOUT="${KV_OUT_DIR}"'
        use x86 && BUILD_PARAMS+=' ARCH=i386'
        BUILD_TARGETS="modules"

diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-470.141.03.ebuild 
b/x11-drivers/nvidia-drivers/nvidia-drivers-470.141.03.ebuild
index f956843454c4..c4c457890298 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-470.141.03.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-470.141.03.ebuild
@@ -99,7 +99,7 @@ pkg_setup() {
        Cannot be directly selected in the kernel's menuconfig, and may need
        selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
        DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
-       local ERROR_X86_KERNEL_IBT="X86_KERNEL_IBT: is set, be warned the 
modules may not load with it.
+       local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set, be warned 
the modules may not load.
        If run into problems, either unset or pass ibt=off to the kernel."
 
        use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
@@ -115,6 +115,67 @@ pkg_setup() {
 
        [[ ${MERGE_TYPE} == binary ]] && return
 
+       # do some extra checks manually as it gets messy to handle builtin-only
+       # and some other conditional checks through CONFIG_CHECK
+       # TODO?: maybe move other custom checks here for uniformity
+       local warn=()
+
+       if linux_chkconfig_builtin DRM_NOUVEAU; then
+               # suggest =m given keeps KMS_HELPER enabled and can serve as 
fallback
+               warn+=(
+                       "  CONFIG_DRM_NOUVEAU: is builtin (=y), and will 
prevent loading NVIDIA"
+                       "    modules (can be safely kept as a module (=m) 
instead)."
+               )
+       fi
+
+       if linux_chkconfig_builtin DRM_SIMPLEDRM; then
+               # wrt prebuilts, Fedora is pushing =y and gentoo-kernel-bin 
uses its
+               # configs (bug #840439), but without Fedora's kernel patch to
+               # workaround this issue (which is unlikely to work for us 
anyway)
+               # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/228
+               warn+=(
+                       "  CONFIG_DRM_SIMPLEDRM: is builtin (=y), and may 
conflict with NVIDIA"
+                       "    (i.e. blanks when X/wayland starts, and tty loses 
display)."
+                       "    For prebuilt kernels, unfortunately no known good 
workarounds."
+               )
+       fi
+
+       if ! linux_chkconfig_present FB_EFI &&
+               ! linux_chkconfig_present FB_SIMPLE &&
+               ! linux_chkconfig_present FB_VESA
+       then
+               # nvidia-drivers does not handle the tty (beside mode 
restoration) but,
+               # given few options are viable, try to warn if all missing
+               warn+=(
+                       "  CONFIG_FB_(EFI|SIMPLE|VESA): none set, but note at 
least one is needed"
+                       "    to get a display for the tty console. In most 
cases, it is"
+                       "    recommended to enable FB_EFI=y and disable 
FB_SIMPLE (can be quirky)."
+                       "    Non-EFI systems are likely to want FB_VESA=y."
+               )
+       fi
+
+       if kernel_is -ge 5 18 13; then
+               if linux_chkconfig_present FB_SIMPLE; then
+                       warn+=(
+                               "  CONFIG_FB_SIMPLE: is set, recommended to 
disable and switch to FB_EFI"
+                               "    as it is currently known broken with 
>=kernel-5.18.13 + NVIDIA."
+                               "    
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/341";
+                       )
+               fi
+
+               if linux_chkconfig_present SYSFB_SIMPLEFB &&
+                       { linux_chkconfig_present FB_EFI || 
linux_chkconfig_present FB_VESA; }
+               then
+                       warn+=(
+                               "  CONFIG_SYSFB_SIMPLEFB: is set, this may 
prevent FB_EFI or FB_VESA"
+                               "    from providing a working tty console 
display (ignore if unused)."
+                       )
+               fi
+       fi
+
+       (( ${#warn[@]} )) &&
+               ewarn "Detected potential configuration issues with used 
kernel:${warn[*]/#/$'\n'}"
+
        BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" 
SYSOUT="${KV_OUT_DIR}"'
        BUILD_TARGETS="modules"
 

diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-510.85.02.ebuild 
b/x11-drivers/nvidia-drivers/nvidia-drivers-510.85.02.ebuild
index 72881337a6cd..6739680f1336 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-510.85.02.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-510.85.02.ebuild
@@ -102,7 +102,7 @@ pkg_setup() {
        Cannot be directly selected in the kernel's menuconfig, and may need
        selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
        DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
-       local ERROR_X86_KERNEL_IBT="X86_KERNEL_IBT: is set, be warned the 
modules may not load with it.
+       local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set, be warned 
the modules may not load.
        If run into problems, either unset or pass ibt=off to the kernel."
 
        use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
@@ -118,6 +118,67 @@ pkg_setup() {
 
        [[ ${MERGE_TYPE} == binary ]] && return
 
+       # do some extra checks manually as it gets messy to handle builtin-only
+       # and some other conditional checks through CONFIG_CHECK
+       # TODO?: maybe move other custom checks here for uniformity
+       local warn=()
+
+       if linux_chkconfig_builtin DRM_NOUVEAU; then
+               # suggest =m given keeps KMS_HELPER enabled and can serve as 
fallback
+               warn+=(
+                       "  CONFIG_DRM_NOUVEAU: is builtin (=y), and will 
prevent loading NVIDIA"
+                       "    modules (can be safely kept as a module (=m) 
instead)."
+               )
+       fi
+
+       if linux_chkconfig_builtin DRM_SIMPLEDRM; then
+               # wrt prebuilts, Fedora is pushing =y and gentoo-kernel-bin 
uses its
+               # configs (bug #840439), but without Fedora's kernel patch to
+               # workaround this issue (which is unlikely to work for us 
anyway)
+               # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/228
+               warn+=(
+                       "  CONFIG_DRM_SIMPLEDRM: is builtin (=y), and may 
conflict with NVIDIA"
+                       "    (i.e. blanks when X/wayland starts, and tty loses 
display)."
+                       "    For prebuilt kernels, unfortunately no known good 
workarounds."
+               )
+       fi
+
+       if ! linux_chkconfig_present FB_EFI &&
+               ! linux_chkconfig_present FB_SIMPLE &&
+               ! linux_chkconfig_present FB_VESA
+       then
+               # nvidia-drivers does not handle the tty (beside mode 
restoration) but,
+               # given few options are viable, try to warn if all missing
+               warn+=(
+                       "  CONFIG_FB_(EFI|SIMPLE|VESA): none set, but note at 
least one is needed"
+                       "    to get a display for the tty console. In most 
cases, it is"
+                       "    recommended to enable FB_EFI=y and disable 
FB_SIMPLE (can be quirky)."
+                       "    Non-EFI systems are likely to want FB_VESA=y."
+               )
+       fi
+
+       if kernel_is -ge 5 18 13; then
+               if linux_chkconfig_present FB_SIMPLE; then
+                       warn+=(
+                               "  CONFIG_FB_SIMPLE: is set, recommended to 
disable and switch to FB_EFI"
+                               "    as it is currently known broken with 
>=kernel-5.18.13 + NVIDIA."
+                               "    
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/341";
+                       )
+               fi
+
+               if linux_chkconfig_present SYSFB_SIMPLEFB &&
+                       { linux_chkconfig_present FB_EFI || 
linux_chkconfig_present FB_VESA; }
+               then
+                       warn+=(
+                               "  CONFIG_SYSFB_SIMPLEFB: is set, this may 
prevent FB_EFI or FB_VESA"
+                               "    from providing a working tty console 
display (ignore if unused)."
+                       )
+               fi
+       fi
+
+       (( ${#warn[@]} )) &&
+               ewarn "Detected potential configuration issues with used 
kernel:${warn[*]/#/$'\n'}"
+
        BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" 
SYSOUT="${KV_OUT_DIR}"'
        BUILD_TARGETS="modules"
 

diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-515.49.19.ebuild 
b/x11-drivers/nvidia-drivers/nvidia-drivers-515.49.19.ebuild
index 2158dbd987aa..6568dcc23e75 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-515.49.19.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-515.49.19.ebuild
@@ -104,7 +104,7 @@ pkg_setup() {
        Cannot be directly selected in the kernel's menuconfig, and may need
        selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
        DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
-       local ERROR_X86_KERNEL_IBT="X86_KERNEL_IBT: is set, be warned the 
modules may not load with it.
+       local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set, be warned 
the modules may not load.
        If run into problems, either unset or pass ibt=off to the kernel."
 
        use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
@@ -127,6 +127,67 @@ pkg_setup() {
 
        [[ ${MERGE_TYPE} == binary ]] && return
 
+       # do some extra checks manually as it gets messy to handle builtin-only
+       # and some other conditional checks through CONFIG_CHECK
+       # TODO?: maybe move other custom checks here for uniformity
+       local warn=()
+
+       if linux_chkconfig_builtin DRM_NOUVEAU; then
+               # suggest =m given keeps KMS_HELPER enabled and can serve as 
fallback
+               warn+=(
+                       "  CONFIG_DRM_NOUVEAU: is builtin (=y), and will 
prevent loading NVIDIA"
+                       "    modules (can be safely kept as a module (=m) 
instead)."
+               )
+       fi
+
+       if linux_chkconfig_builtin DRM_SIMPLEDRM; then
+               # wrt prebuilts, Fedora is pushing =y and gentoo-kernel-bin 
uses its
+               # configs (bug #840439), but without Fedora's kernel patch to
+               # workaround this issue (which is unlikely to work for us 
anyway)
+               # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/228
+               warn+=(
+                       "  CONFIG_DRM_SIMPLEDRM: is builtin (=y), and may 
conflict with NVIDIA"
+                       "    (i.e. blanks when X/wayland starts, and tty loses 
display)."
+                       "    For prebuilt kernels, unfortunately no known good 
workarounds."
+               )
+       fi
+
+       if ! linux_chkconfig_present FB_EFI &&
+               ! linux_chkconfig_present FB_SIMPLE &&
+               ! linux_chkconfig_present FB_VESA
+       then
+               # nvidia-drivers does not handle the tty (beside mode 
restoration) but,
+               # given few options are viable, try to warn if all missing
+               warn+=(
+                       "  CONFIG_FB_(EFI|SIMPLE|VESA): none set, but note at 
least one is needed"
+                       "    to get a display for the tty console. In most 
cases, it is"
+                       "    recommended to enable FB_EFI=y and disable 
FB_SIMPLE (can be quirky)."
+                       "    Non-EFI systems are likely to want FB_VESA=y."
+               )
+       fi
+
+       if kernel_is -ge 5 18 13; then
+               if linux_chkconfig_present FB_SIMPLE; then
+                       warn+=(
+                               "  CONFIG_FB_SIMPLE: is set, recommended to 
disable and switch to FB_EFI"
+                               "    as it is currently known broken with 
>=kernel-5.18.13 + NVIDIA."
+                               "    
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/341";
+                       )
+               fi
+
+               if linux_chkconfig_present SYSFB_SIMPLEFB &&
+                       { linux_chkconfig_present FB_EFI || 
linux_chkconfig_present FB_VESA; }
+               then
+                       warn+=(
+                               "  CONFIG_SYSFB_SIMPLEFB: is set, this may 
prevent FB_EFI or FB_VESA"
+                               "    from providing a working tty console 
display (ignore if unused)."
+                       )
+               fi
+       fi
+
+       (( ${#warn[@]} )) &&
+               ewarn "Detected potential configuration issues with used 
kernel:${warn[*]/#/$'\n'}"
+
        BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" 
SYSOUT="${KV_OUT_DIR}"'
        BUILD_TARGETS="modules"
 

diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-515.65.01.ebuild 
b/x11-drivers/nvidia-drivers/nvidia-drivers-515.65.01.ebuild
index e1f5cfc6ceff..9edb6fe04224 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-515.65.01.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-515.65.01.ebuild
@@ -104,7 +104,7 @@ pkg_setup() {
        Cannot be directly selected in the kernel's menuconfig, and may need
        selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
        DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
-       local ERROR_X86_KERNEL_IBT="X86_KERNEL_IBT: is set, be warned the 
modules may not load with it.
+       local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set, be warned 
the modules may not load.
        If run into problems, either unset or pass ibt=off to the kernel."
 
        use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
@@ -127,6 +127,67 @@ pkg_setup() {
 
        [[ ${MERGE_TYPE} == binary ]] && return
 
+       # do some extra checks manually as it gets messy to handle builtin-only
+       # and some other conditional checks through CONFIG_CHECK
+       # TODO?: maybe move other custom checks here for uniformity
+       local warn=()
+
+       if linux_chkconfig_builtin DRM_NOUVEAU; then
+               # suggest =m given keeps KMS_HELPER enabled and can serve as 
fallback
+               warn+=(
+                       "  CONFIG_DRM_NOUVEAU: is builtin (=y), and will 
prevent loading NVIDIA"
+                       "    modules (can be safely kept as a module (=m) 
instead)."
+               )
+       fi
+
+       if linux_chkconfig_builtin DRM_SIMPLEDRM; then
+               # wrt prebuilts, Fedora is pushing =y and gentoo-kernel-bin 
uses its
+               # configs (bug #840439), but without Fedora's kernel patch to
+               # workaround this issue (which is unlikely to work for us 
anyway)
+               # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/228
+               warn+=(
+                       "  CONFIG_DRM_SIMPLEDRM: is builtin (=y), and may 
conflict with NVIDIA"
+                       "    (i.e. blanks when X/wayland starts, and tty loses 
display)."
+                       "    For prebuilt kernels, unfortunately no known good 
workarounds."
+               )
+       fi
+
+       if ! linux_chkconfig_present FB_EFI &&
+               ! linux_chkconfig_present FB_SIMPLE &&
+               ! linux_chkconfig_present FB_VESA
+       then
+               # nvidia-drivers does not handle the tty (beside mode 
restoration) but,
+               # given few options are viable, try to warn if all missing
+               warn+=(
+                       "  CONFIG_FB_(EFI|SIMPLE|VESA): none set, but note at 
least one is needed"
+                       "    to get a display for the tty console. In most 
cases, it is"
+                       "    recommended to enable FB_EFI=y and disable 
FB_SIMPLE (can be quirky)."
+                       "    Non-EFI systems are likely to want FB_VESA=y."
+               )
+       fi
+
+       if kernel_is -ge 5 18 13; then
+               if linux_chkconfig_present FB_SIMPLE; then
+                       warn+=(
+                               "  CONFIG_FB_SIMPLE: is set, recommended to 
disable and switch to FB_EFI"
+                               "    as it is currently known broken with 
>=kernel-5.18.13 + NVIDIA."
+                               "    
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/341";
+                       )
+               fi
+
+               if linux_chkconfig_present SYSFB_SIMPLEFB &&
+                       { linux_chkconfig_present FB_EFI || 
linux_chkconfig_present FB_VESA; }
+               then
+                       warn+=(
+                               "  CONFIG_SYSFB_SIMPLEFB: is set, this may 
prevent FB_EFI or FB_VESA"
+                               "    from providing a working tty console 
display (ignore if unused)."
+                       )
+               fi
+       fi
+
+       (( ${#warn[@]} )) &&
+               ewarn "Detected potential configuration issues with used 
kernel:${warn[*]/#/$'\n'}"
+
        BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" 
SYSOUT="${KV_OUT_DIR}"'
        BUILD_TARGETS="modules"
 

diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-515.76.ebuild 
b/x11-drivers/nvidia-drivers/nvidia-drivers-515.76.ebuild
index b7fba7fefd0f..f5d9379122e2 100644
--- a/x11-drivers/nvidia-drivers/nvidia-drivers-515.76.ebuild
+++ b/x11-drivers/nvidia-drivers/nvidia-drivers-515.76.ebuild
@@ -104,7 +104,7 @@ pkg_setup() {
        Cannot be directly selected in the kernel's menuconfig, and may need
        selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
        DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in."
-       local ERROR_X86_KERNEL_IBT="X86_KERNEL_IBT: is set, be warned the 
modules may not load with it.
+       local ERROR_X86_KERNEL_IBT="CONFIG_X86_KERNEL_IBT: is set, be warned 
the modules may not load.
        If run into problems, either unset or pass ibt=off to the kernel."
 
        use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
@@ -127,6 +127,67 @@ pkg_setup() {
 
        [[ ${MERGE_TYPE} == binary ]] && return
 
+       # do some extra checks manually as it gets messy to handle builtin-only
+       # and some other conditional checks through CONFIG_CHECK
+       # TODO?: maybe move other custom checks here for uniformity
+       local warn=()
+
+       if linux_chkconfig_builtin DRM_NOUVEAU; then
+               # suggest =m given keeps KMS_HELPER enabled and can serve as 
fallback
+               warn+=(
+                       "  CONFIG_DRM_NOUVEAU: is builtin (=y), and will 
prevent loading NVIDIA"
+                       "    modules (can be safely kept as a module (=m) 
instead)."
+               )
+       fi
+
+       if linux_chkconfig_builtin DRM_SIMPLEDRM; then
+               # wrt prebuilts, Fedora is pushing =y and gentoo-kernel-bin 
uses its
+               # configs (bug #840439), but without Fedora's kernel patch to
+               # workaround this issue (which is unlikely to work for us 
anyway)
+               # https://github.com/NVIDIA/open-gpu-kernel-modules/issues/228
+               warn+=(
+                       "  CONFIG_DRM_SIMPLEDRM: is builtin (=y), and may 
conflict with NVIDIA"
+                       "    (i.e. blanks when X/wayland starts, and tty loses 
display)."
+                       "    For prebuilt kernels, unfortunately no known good 
workarounds."
+               )
+       fi
+
+       if ! linux_chkconfig_present FB_EFI &&
+               ! linux_chkconfig_present FB_SIMPLE &&
+               ! linux_chkconfig_present FB_VESA
+       then
+               # nvidia-drivers does not handle the tty (beside mode 
restoration) but,
+               # given few options are viable, try to warn if all missing
+               warn+=(
+                       "  CONFIG_FB_(EFI|SIMPLE|VESA): none set, but note at 
least one is needed"
+                       "    to get a display for the tty console. In most 
cases, it is"
+                       "    recommended to enable FB_EFI=y and disable 
FB_SIMPLE (can be quirky)."
+                       "    Non-EFI systems are likely to want FB_VESA=y."
+               )
+       fi
+
+       if kernel_is -ge 5 18 13; then
+               if linux_chkconfig_present FB_SIMPLE; then
+                       warn+=(
+                               "  CONFIG_FB_SIMPLE: is set, recommended to 
disable and switch to FB_EFI"
+                               "    as it is currently known broken with 
>=kernel-5.18.13 + NVIDIA."
+                               "    
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/341";
+                       )
+               fi
+
+               if linux_chkconfig_present SYSFB_SIMPLEFB &&
+                       { linux_chkconfig_present FB_EFI || 
linux_chkconfig_present FB_VESA; }
+               then
+                       warn+=(
+                               "  CONFIG_SYSFB_SIMPLEFB: is set, this may 
prevent FB_EFI or FB_VESA"
+                               "    from providing a working tty console 
display (ignore if unused)."
+                       )
+               fi
+       fi
+
+       (( ${#warn[@]} )) &&
+               ewarn "Detected potential configuration issues with used 
kernel:${warn[*]/#/$'\n'}"
+
        BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" 
SYSOUT="${KV_OUT_DIR}"'
        BUILD_TARGETS="modules"
 

Reply via email to