Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Feb 2021 15:19:01 +0100
From:      Christoph Moench-Tegeder <cmt@burggraben.net>
To:        Alexey Dokuchaev <danfe@freebsd.org>
Cc:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   Re: svn commit: r564088 - in head/x11: linux-nvidia-libs nvidia-driver nvidia-driver/files nvidia-settings nvidia-xconfig
Message-ID:  <YB1T1SmtIVz6Yx4z@elch.exwg.net>
In-Reply-To: <20210205112841.GA3021@squirrel.exwg.net>
References:  <202102050727.1157RtXv030475@repo.freebsd.org> <20210205112841.GA3021@squirrel.exwg.net>

next in thread | previous in thread | raw e-mail | index | archive | help
There we go: included fixes the problem for me.
This is effectively a forward-port of extra-patch-src-nvidia_ctl.c.in
which did apply to 440 but not to 460 anymore and (therefore?) was
droppen in the update to 460 (if would at least try to understand the
patches they're deleting... but well).

I don't feel that confident with the X driver stuff, so I'd rather
have someone look at it in case I missed something (more patches needed?).


commit 5bb445c9128cbe69435d3cc93794f9c89a35ff58
Author: Christoph Moench-Tegeder <cmt@burggraben.net>
Date:   Fri Feb 5 15:12:49 2021 +0100

    restore linux compat in nvidia_ctl.c
    
    fixes "kernel: link_elf_obj: symbol nvidia_driver_name undefined" error
    when loading kernel module

diff --git a/x11/nvidia-driver/Makefile b/x11/nvidia-driver/Makefile
index 57f9fbc2c1fa..f0c1fd95a226 100644
--- a/x11/nvidia-driver/Makefile
+++ b/x11/nvidia-driver/Makefile
@@ -13,7 +13,7 @@
 PORTNAME=	nvidia-driver
 DISTVERSION?=	460.39
 # Always try to set PORTREVISION as it can be overridden by the slave ports
-PORTREVISION?=	0
+PORTREVISION?=	1
 CATEGORIES=	x11
 MASTER_SITES=	NVIDIA/XFree86/FreeBSD-${ARCH_SUFX}/${DISTVERSION}
 DISTNAME=	NVIDIA-FreeBSD-${ARCH_SUFX}-${DISTVERSION}
@@ -73,7 +73,8 @@ SUB_PATCHES+=	extra-patch-src-nvidia_ctl.c \
 		extra-patch-src-nvidia_linux.c
 .else
 EXTRA_PATCHES+=	${FILESDIR}/460-patch-lib-libGLX_nvidia-Makefile
-SUB_PATCHES+=	460-patch-src-nvidia_linux.c
+SUB_PATCHES+=	460-patch-src-nvidia_linux.c \
+		460-patch-src-nvidia_ctl.c
 .endif
 
 OPTIONS_DEFINE=	ACPI_PM LINUX WBINVD DOCS
diff --git a/x11/nvidia-driver/files/460-patch-src-nvidia_ctl.c.in b/x11/nvidia-driver/files/460-patch-src-nvidia_ctl.c.in
new file mode 100644
index 000000000000..3f49fbc27a63
--- /dev/null
+++ b/x11/nvidia-driver/files/460-patch-src-nvidia_ctl.c.in
@@ -0,0 +1,72 @@
+--- src/%%NVSRC%%/nvidia_ctl.c.orig	2021-01-21 21:50:34 UTC
++++ src/%%NVSRC%%/nvidia_ctl.c
+@@ -13,6 +13,12 @@
+ #include "nv.h"
+ #include "nv-freebsd.h"
+ 
++#ifdef NV_SUPPORT_LINUX_COMPAT /* (COMPAT_LINUX || COMPAT_LINUX32) */
++#include <compat/linux/linux_util.h>
++
++const char nvidia_driver_name[] = "nvidia";
++#endif
++
+ static d_open_t  nvidia_ctl_open;
+ static d_ioctl_t nvidia_ctl_ioctl;
+ static d_poll_t  nvidia_ctl_poll;
+@@ -163,6 +169,18 @@
+ 
+ int nvidia_ctl_attach(void)
+ {
++#ifdef NV_SUPPORT_LINUX_COMPAT
++    struct linux_device_handler nvidia_ctl_linux_handler = {
++        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
++        .linux_driver_name = __DECONST(char *, nvidia_driver_name),
++        .bsd_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
++        .linux_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
++        .linux_major = NV_MAJOR_DEVICE_NUMBER,
++        .linux_minor = 255,
++        .linux_char_device = 1
++    };
++#endif
++
+     if (nvidia_count == 0) {
+         nvidia_ctl_cdev = make_dev(&nvidia_ctl_cdevsw,
+                 CDEV_CTL_MINOR,
+@@ -170,6 +188,10 @@
+                 "%s", nvidia_ctl_cdevsw.d_name);
+         if (nvidia_ctl_cdev == NULL)
+             return ENOMEM;
++
++#ifdef NV_SUPPORT_LINUX_COMPAT
++        (void)linux_device_register_handler(&nvidia_ctl_linux_handler);
++#endif
+     }
+ 
+     nvidia_count++;
+@@ -178,10 +200,25 @@
+ 
+ int nvidia_ctl_detach(void)
+ {
++#ifdef NV_SUPPORT_LINUX_COMPAT
++    struct linux_device_handler nvidia_ctl_linux_handler = {
++        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
++        .linux_driver_name = __DECONST(char *, nvidia_driver_name),
++        .bsd_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
++        .linux_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
++        .linux_major = NV_MAJOR_DEVICE_NUMBER,
++        .linux_minor = 255,
++        .linux_char_device = 1
++    };
++#endif
+     nvidia_count--;
+ 
+-    if (nvidia_count == 0)
++    if (nvidia_count == 0) {
++#ifdef NV_SUPPORT_LINUX_COMPAT
++        (void)linux_device_unregister_handler(&nvidia_ctl_linux_handler);
++#endif
+         destroy_dev(nvidia_ctl_cdev);
++    }
+ 
+     return 0;
+ }



Regards,
Christoph

-- 
Spare Space



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YB1T1SmtIVz6Yx4z>