View | Details | Raw Unified | Return to bug 249505 | Differences between
and this patch

Collapse All | Expand All

(-)x11/nvidia-driver/Makefile (-2 / +14 lines)
Lines 11-17 Link Here
11
# or `x11/nvidia-driver-304').
11
# or `x11/nvidia-driver-304').
12
12
13
PORTNAME=	nvidia-driver
13
PORTNAME=	nvidia-driver
14
DISTVERSION?=	440.100
14
DISTVERSION?=	450.66
15
# Always try to set PORTREVISION as it can be overridden by the slave ports
15
# Always try to set PORTREVISION as it can be overridden by the slave ports
16
PORTREVISION?=	0
16
PORTREVISION?=	0
17
CATEGORIES=	x11
17
CATEGORIES=	x11
Lines 44-56 SUB_FILES= pkg-message nvidia.conf Link Here
44
.if ${NVVERSION} < 410.057
44
.if ${NVVERSION} < 410.057
45
SUB_FILES+=	pkg-deinstall pkg-install
45
SUB_FILES+=	pkg-deinstall pkg-install
46
.endif
46
.endif
47
.if ${NVVERSION} >= 450.057
47
SUB_PATCHES=	extra-patch-src-Makefile \
48
SUB_PATCHES=	extra-patch-src-Makefile \
48
		extra-patch-src-nv-freebsd.h \
49
		extra-patch-src-nv-freebsd.h \
49
		extra-patch-src-nv-misc.h \
50
		extra-patch-src-nv-misc.h \
51
		extra-patch-450-src-nvidia_ctl.c \
52
		extra-patch-src-nvidia_dev.c \
53
		extra-patch-src-nvidia_linux.c \
54
		extra-patch-src-nvidia_pci.c
55
.else
56
SUB_PATCHES=	extra-patch-src-Makefile \
57
		extra-patch-src-nv-freebsd.h \
58
		extra-patch-src-nv-misc.h \
50
		extra-patch-src-nvidia_ctl.c \
59
		extra-patch-src-nvidia_ctl.c \
51
		extra-patch-src-nvidia_dev.c \
60
		extra-patch-src-nvidia_dev.c \
52
		extra-patch-src-nvidia_linux.c \
61
		extra-patch-src-nvidia_linux.c \
53
		extra-patch-src-nvidia_pci.c
62
		extra-patch-src-nvidia_pci.c
63
.endif
54
DOCSDIR=	${PREFIX}/share/doc/NVIDIA_GLX-1.0
64
DOCSDIR=	${PREFIX}/share/doc/NVIDIA_GLX-1.0
55
MODULESDIR=	lib/xorg/modules
65
MODULESDIR=	lib/xorg/modules
56
PORTDOCS=	*
66
PORTDOCS=	*
Lines 67-73 NVSRC= . Link Here
67
NVSRC=		nvidia
77
NVSRC=		nvidia
68
.endif
78
.endif
69
79
70
.if ${NVVERSION} >= 358.009
80
.if ${NVVERSION} >= 450.057
81
EXTRA_PATCHES+= ${FILESDIR}/extra-patch-450-src_nvidia-modeset_nvidia-modeset-freebsd.c
82
.else if ${NVVERSION} >= 358.009
71
# Initialize memory allocations to avoid spurious "lock re-initialization"
83
# Initialize memory allocations to avoid spurious "lock re-initialization"
72
# errors.  A little more detail can be found in bug 201340 starting around
84
# errors.  A little more detail can be found in bug 201340 starting around
73
# comment #50.
85
# comment #50.
(-)x11/nvidia-driver/distinfo (-2 / +2 lines)
Lines 1-6 Link Here
1
TIMESTAMP = 1482026038
1
TIMESTAMP = 1482026038
2
SHA256 (NVIDIA-FreeBSD-x86_64-440.100.tar.gz) = da5abe605560890405976785eb28e6d9fa79181ac7d158e52e5327d4d0faef5f
2
SHA256 (NVIDIA-FreeBSD-x86_64-450.66.tar.gz) = 8c8ccfc2c9e2e888f3342a9b520ef95b483a1d2f01587d02c2014ffab01d3abb
3
SIZE (NVIDIA-FreeBSD-x86_64-440.100.tar.gz) = 82523267
3
SIZE (NVIDIA-FreeBSD-x86_64-450.66.tar.gz) = 82963662
4
SHA256 (NVIDIA-FreeBSD-x86_64-390.138.tar.gz) = 51cb38cd826ba34c1cc71db5bd3ef645b4cfb5647311e255b4631e5c41d0ba07
4
SHA256 (NVIDIA-FreeBSD-x86_64-390.138.tar.gz) = 51cb38cd826ba34c1cc71db5bd3ef645b4cfb5647311e255b4631e5c41d0ba07
5
SIZE (NVIDIA-FreeBSD-x86_64-390.138.tar.gz) = 65280213
5
SIZE (NVIDIA-FreeBSD-x86_64-390.138.tar.gz) = 65280213
6
SHA256 (NVIDIA-FreeBSD-x86-390.138.tar.gz) = ca06e877af81e2e895a92fc9ec6f5bc106a48a0223912992d5cb0f482c9dac9a
6
SHA256 (NVIDIA-FreeBSD-x86-390.138.tar.gz) = ca06e877af81e2e895a92fc9ec6f5bc106a48a0223912992d5cb0f482c9dac9a
(-)x11/nvidia-driver/files/extra-patch-450-src_nvidia-modeset_nvidia-modeset-freebsd.c (+104 lines)
Added Link Here
1
--- src/nvidia-modeset/nvidia-modeset-freebsd.c.orig	2018-08-21 23:09:28 UTC
2
+++ src/nvidia-modeset/nvidia-modeset-freebsd.c
3
@@ -26,6 +26,7 @@
4
 #include <sys/file.h>
5
 #include <sys/proc.h>
6
 #include <sys/stack.h>
7
+#include <sys/sysproto.h>
8
 
9
 #include "nvkms-ioctl.h"
10
 #include "nvidia-modeset-os-interface.h"
11
@@ -48,6 +49,7 @@
12
     #include "machine/../linux32/linux32_proto.h"
13
   #endif
14
   #include <compat/linux/linux_ioctl.h>
15
+  #include <compat/linux/linux_util.h>
16
 #endif
17
 
18
 
19
@@ -250,7 +252,7 @@ struct nvkms_ref_ptr {
20
 
21
 struct nvkms_ref_ptr* NVKMS_API_CALL nvkms_alloc_ref_ptr(void *ptr)
22
 {
23
-    struct nvkms_ref_ptr *ref_ptr = nvkms_alloc(sizeof(*ref_ptr), NV_FALSE);
24
+    struct nvkms_ref_ptr *ref_ptr = nvkms_alloc(sizeof(*ref_ptr), NV_TRUE);
25
     if (ref_ptr) {
26
         mtx_init(&ref_ptr->lock, "nvkms-ref-ptr-lock", NULL, MTX_SPIN);
27
         // The ref_ptr owner counts as a reference on the ref_ptr itself.
28
@@ -867,33 +869,31 @@ static int nvkms_poll(
29
  *************************************************************************/
30
 
31
 #if defined(NVKMS_SUPPORT_LINUX_COMPAT)
32
+static struct linux_device_handler nvkms_linux_device_handler = {
33
+    .bsd_driver_name = "nvidia-modeset",
34
+    .linux_driver_name = "nvidia-modeset",
35
+    .bsd_device_name = "nvidia-modeset",
36
+    .linux_device_name = "nvidia-modeset",
37
+    .linux_major = 195,
38
+    .linux_minor = 254,
39
+    .linux_char_device = 1
40
+};
41
 
42
 static int nvkms_linux_ioctl_function(
43
     struct thread *td,
44
     struct linux_ioctl_args *args
45
 )
46
 {
47
-    struct file *fp;
48
-    int status;
49
-    u_long cmd;
50
+    static const uint32_t dir[4] = { IOC_VOID, IOC_IN, IOC_OUT, IOC_INOUT };
51
 
52
-#if NV_FGET_HAS_CAP_RIGHTS_T_ARG
53
-    cap_rights_t rights;
54
-    status = fget(td, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp);
55
-#else
56
-    status = fget(td, args->fd, &fp);
57
-#endif
58
-
59
-    if (status != 0) {
60
-        return status;
61
+    if ((args->cmd & (1<<29)) != 0) {
62
+        /* FreeBSD has only 13 bits to encode the size. */
63
+        printf("nvidia: pid %d (%s): ioctl cmd=0x%x size too large\n",
64
+            (int)td->td_proc->p_pid, td->td_proc->p_comm, args->cmd);
65
+        return (EINVAL);
66
     }
67
-
68
-    cmd = args->cmd;
69
-
70
-    status = fo_ioctl(fp, cmd, (caddr_t)args->arg, td->td_ucred, td);
71
-    fdrop(fp, td);
72
-
73
-    return status;
74
+    args->cmd = (args->cmd & ~IOC_DIRMASK) | dir[args->cmd >> 30];
75
+    return (sys_ioctl(td, (struct ioctl_args *)args));
76
 }
77
 
78
 #define NVKMS_LINUX_IOCTL_MIN _IOC(0, NVKMS_IOCTL_MAGIC, NVKMS_IOCTL_CMD, 0)
79
@@ -909,6 +909,7 @@ static struct linux_ioctl_handler nvkms_linux_ioctl_ha
80
 static void nvkms_linux_compat_load(void)
81
 {
82
 #if defined(NVKMS_SUPPORT_LINUX_COMPAT)
83
+    linux_device_register_handler(&nvkms_linux_device_handler);
84
     linux_ioctl_register_handler(&nvkms_linux_ioctl_handler);
85
 #endif
86
 }
87
@@ -917,6 +918,7 @@ static void nvkms_linux_compat_unload(void)
88
 {
89
 #if defined(NVKMS_SUPPORT_LINUX_COMPAT)
90
     linux_ioctl_unregister_handler(&nvkms_linux_ioctl_handler);
91
+    linux_device_unregister_handler(&nvkms_linux_device_handler);
92
 #endif
93
 }
94
 
95
@@ -1100,4 +1102,9 @@ MODULE_DEPEND(nvidia_modeset,               /* module 
96
 MODULE_DEPEND(nvidia_modeset,               /* module name */
97
               linux,                        /* prerequisite module */
98
               1, 1, 1);                     /* vmin, vpref, vmax */
99
+#if defined(NVCPU_X86_64)
100
+MODULE_DEPEND(nvidia_modeset,               /* module name */
101
+              linux_common,                 /* prerequisite module */
102
+              1, 1, 1);                     /* vmin, vpref, vmax */
103
+#endif
104
 #endif
(-)x11/nvidia-driver/files/extra-patch-450-src-nvidia_ctl.c.in (+72 lines)
Added Link Here
1
--- src/%%NVSRC%%/nvidia_ctl.c.orig	2017-09-14 20:46:30 UTC
2
+++ src/%%NVSRC%%/nvidia_ctl.c
3
@@ -13,6 +13,12 @@
4
 #include "nv.h"
5
 #include "nv-freebsd.h"
6
 
7
+#ifdef NV_SUPPORT_LINUX_COMPAT /* (COMPAT_LINUX || COMPAT_LINUX32) */
8
+#include <compat/linux/linux_util.h>
9
+
10
+const char nvidia_driver_name[] = "nvidia";
11
+#endif
12
+
13
 static d_open_t  nvidia_ctl_open;
14
 static void nvidia_ctl_dtor(void *arg);
15
 static d_ioctl_t nvidia_ctl_ioctl;
16
@@ -138,6 +144,18 @@ static int nvidia_ctl_poll(
17
 
18
 int nvidia_ctl_attach(void)
19
 {
20
+#ifdef NV_SUPPORT_LINUX_COMPAT
21
+    struct linux_device_handler nvidia_ctl_linux_handler = {
22
+        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
23
+        .linux_driver_name = __DECONST(char *, nvidia_driver_name),
24
+        .bsd_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
25
+        .linux_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
26
+        .linux_major = NV_MAJOR_DEVICE_NUMBER,
27
+        .linux_minor = 255,
28
+        .linux_char_device = 1
29
+    };
30
+#endif
31
+
32
     if (nvidia_count == 0) {
33
         nvidia_ctl_cdev = make_dev(&nvidia_ctl_cdevsw,
34
                 CDEV_CTL_MINOR,
35
@@ -145,6 +163,10 @@ int nvidia_ctl_attach(void)
36
                 "%s", nvidia_ctl_cdevsw.d_name);
37
         if (nvidia_ctl_cdev == NULL)
38
             return ENOMEM;
39
+
40
+#ifdef NV_SUPPORT_LINUX_COMPAT
41
+        (void)linux_device_register_handler(&nvidia_ctl_linux_handler);
42
+#endif
43
     }
44
 
45
     nvidia_count++;
46
@@ -153,10 +175,25 @@ int nvidia_ctl_attach(void)
47
 
48
 int nvidia_ctl_detach(void)
49
 {
50
+#ifdef NV_SUPPORT_LINUX_COMPAT
51
+    struct linux_device_handler nvidia_ctl_linux_handler = {
52
+        .bsd_driver_name = __DECONST(char *, nvidia_driver_name),
53
+        .linux_driver_name = __DECONST(char *, nvidia_driver_name),
54
+        .bsd_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
55
+        .linux_device_name = __DECONST(char *, nvidia_ctl_cdevsw.d_name),
56
+        .linux_major = NV_MAJOR_DEVICE_NUMBER,
57
+        .linux_minor = 255,
58
+        .linux_char_device = 1
59
+    };
60
+#endif
61
     nvidia_count--;
62
 
63
-    if (nvidia_count == 0)
64
+    if (nvidia_count == 0) {
65
+#ifdef NV_SUPPORT_LINUX_COMPAT
66
+        (void)linux_device_unregister_handler(&nvidia_ctl_linux_handler);
67
+#endif
68
         destroy_dev(nvidia_ctl_cdev);
69
+    }
70
 
71
     return 0;
72
 }

Return to bug 249505