Skip to content

Commit

Permalink
x11/nvidia-driver: kernel module fails on vt() to load: link_elf_obj:…
Browse files Browse the repository at this point in the history
… symbol sc_get_softc undefined

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216050

regression: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214769

kernel: KLD nvidia-modeset.ko: depends on nvidia - not available or version mismatch
kernel: linker_load_file: Unsupported file type
kernel: link_elf_obj: symbol sc_get_softc undefined
kernel: linker_load_file: Unsupported file type

FreeBSD rimwks 11.0-STABLE FreeBSD 11.0-STABLE freebsd#1 r312105M: Sat Jan 14 05:59:46 MSK 2017

I try to rewrite patch to make it respect kernel options, but it is undone:
1. No code for VT
2. Make does not get DEV_SC and DEV_VT from opt_syscons.h - it is empty,
and does not included from ${KERNBUILDDIR}.
  • Loading branch information
rozhuk-im committed Jan 26, 2025
1 parent 8c7d263 commit 9eadafb
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 5 deletions.
3 changes: 2 additions & 1 deletion x11/nvidia-driver/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ SUB_PATCHES += extra-patch-src_nvidia-modeset_nvidia-modeset-freebsd.c
.endif
.if ${NVVERSION} < 460.039
. if ${NVVERSION} >= 358.009
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-src_nvidia-modeset_nvidia-modeset-freebsd.c
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-src_nvidia-modeset_nvidia-modeset-freebsd.c \
${FILESDIR}/extra-patch-src_nvidia_nvidia_os.c
. endif
SUB_PATCHES+= extra-patch-src-nvidia_ctl.c \
extra-patch-src-nvidia_linux.c
Expand Down
19 changes: 15 additions & 4 deletions x11/nvidia-driver/files/extra-patch-src-Makefile.in
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
--- src/%%NVSRC%%/Makefile.orig 2017-09-14 20:46:30 UTC
+++ src/%%NVSRC%%/Makefile
@@ -30,6 +30,15 @@ NOOBJ= true
@@ -26,9 +26,25 @@
stdarg.h:
@ln -s machine/stdarg.h stdarg.h

+SRCS+= opt_global.h
+.if ${MACHINE_ARCH} == "i386" && !defined(KERNBUILDDIR)
+SRCS+= opt_global.h opt_syscons.h
+.if defined(KERNBUILDDIR)
+MKDEP= -include ${KERNBUILDDIR}/opt_global.h -include ${KERNBUILDDIR}/opt_syscons.h
+.else
+CFLAGS+= -include opt_global.h -include opt_syscons.h
+MKDEP= -include opt_global.h -include opt_syscons.h
+
+.if ${MACHINE_ARCH} == "i386"
+PAE!= sed -n '/define NV_SUPPORT_PAE/p' nv-freebsd.h
+.if !empty(PAE)
+opt_global.h:
+ echo "#define PAE 1" > ${.TARGET}
+.endif
+.endif
+.endif
+
*.c: stdarg.h

beforeinstall: ${KMOD}.ko
-beforeinstall: ${KMOD}.ko
+beforeinstall_dontexecute_dontexecute: ${KMOD}.ko

all: ${OSOBJ}

67 changes: 67 additions & 0 deletions x11/nvidia-driver/files/extra-patch-src_nvidia_nvidia_os.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
--- src/nvidia/nvidia_os.c.orig 2017-05-01 21:17:21 UTC
+++ src/nvidia/nvidia_os.c
@@ -8,6 +8,7 @@
* _NVRM_COPYRIGHT_END_
*/

+#include "opt_syscons.h"
#include "nv-misc.h"
#include "os-interface.h"
#include "nv.h"
@@ -17,7 +18,9 @@
#include <sys/fbio.h>
#include <sys/linker.h>
#include <sys/timex.h>
+#ifdef DEV_SC
#include <dev/syscons/syscons.h>
+#endif

// This bootloader metadata interface was added to metadata.h in FreeBSD 10.1
// with commit 3a7cd99956b1 and FreeBSD 11 with commit d2c99117cd3b.
@@ -800,29 +803,32 @@
}
}
#endif
+
+#ifdef DEV_VT
+ /* TODO */
+#endif
+
+#ifdef DEV_SC
{
const sc_softc_t *sc = sc_get_softc(0, SC_KERNEL_CONSOLE);
+ const struct video_info *vi;

- if (sc)
+ if (sc && sc->adp)
{
- const video_adapter_t *adp = sc->adp;
+ vi = &sc->adp->va_info;

- if (adp)
+ if (vi && (vi->vi_flags & V_INFO_LINEAR))
{
- const struct video_info *vi = &adp->va_info;
-
- if (vi && (vi->vi_flags & V_INFO_LINEAR))
- {
- *pPhysicalAddress = vi->vi_buffer;
- *pFbWidth = vi->vi_width;
- *pFbHeight = vi->vi_height;
- *pFbDepth = vi->vi_depth;
- *pFbPitch = adp->va_line_width;
- return;
- }
+ *pPhysicalAddress = vi->vi_buffer;
+ *pFbWidth = vi->vi_width;
+ *pFbHeight = vi->vi_height;
+ *pFbDepth = vi->vi_depth;
+ *pFbPitch = sc->adp->va_line_width;
+ return;
}
}
}
+#endif

*pPhysicalAddress = 0;
*pFbWidth = *pFbHeight = *pFbDepth = *pFbPitch = 0;

0 comments on commit 9eadafb

Please sign in to comment.