diff options
author | mux <mux@FreeBSD.org> | 2003-03-06 09:12:23 +0800 |
---|---|---|
committer | mux <mux@FreeBSD.org> | 2003-03-06 09:12:23 +0800 |
commit | 96b164f3e4bfd2b938a7e632c8db931a2c7b3883 (patch) | |
tree | d2565065276e99e8806719dda0462ca938599a6a /x11 | |
parent | 0e7ea37a82c887352f1aaec65ec6d90c0acf2472 (diff) | |
download | freebsd-ports-gnome-96b164f3e4bfd2b938a7e632c8db931a2c7b3883.tar.gz freebsd-ports-gnome-96b164f3e4bfd2b938a7e632c8db931a2c7b3883.tar.zst freebsd-ports-gnome-96b164f3e4bfd2b938a7e632c8db931a2c7b3883.zip |
Add patches so that the nVidia driver works with -CURRENT. Be
aware that nVidia doesn't officially supports -CURRENT though.
Older versions of -CURRENT (ie. __FreeBSD_version < 500105) are
not supported. 5.0-RELEASE is thus unsupported as well.
Requested by: many
Diffstat (limited to 'x11')
-rw-r--r-- | x11/nvidia-driver/Makefile | 4 | ||||
-rw-r--r-- | x11/nvidia-driver/files/patch-nv-freebsd.h | 43 | ||||
-rw-r--r-- | x11/nvidia-driver/files/patch-nvidia_ctl.c | 30 | ||||
-rw-r--r-- | x11/nvidia-driver/files/patch-nvidia_dev.c | 66 | ||||
-rw-r--r-- | x11/nvidia-driver/files/patch-nvidia_subr.c | 124 |
5 files changed, 265 insertions, 2 deletions
diff --git a/x11/nvidia-driver/Makefile b/x11/nvidia-driver/Makefile index 1c72acf31679..4723b5e6c3f7 100644 --- a/x11/nvidia-driver/Makefile +++ b/x11/nvidia-driver/Makefile @@ -30,8 +30,8 @@ USE_LINUX= yes .include <bsd.port.pre.mk> -.if ${OSVERSION} > 500000 -IGNORE= "Drivers are not supported on 5.x" +.if ${OSVERSION} > 500000 && ${OSVERSION} < 500105 +IGNORE= "You need a more recent version of -CURRENT for this driver" .endif .if defined(WITH_FREEBSD_AGP) || defined(FORCE_AGP_RATE) diff --git a/x11/nvidia-driver/files/patch-nv-freebsd.h b/x11/nvidia-driver/files/patch-nv-freebsd.h new file mode 100644 index 000000000000..a5690cc5756a --- /dev/null +++ b/x11/nvidia-driver/files/patch-nv-freebsd.h @@ -0,0 +1,43 @@ +--- src/nv-freebsd.h.orig Wed Oct 30 15:30:58 2002 ++++ src/nv-freebsd.h Thu Mar 6 01:27:10 2003 +@@ -27,12 +27,6 @@ + * active development and also unsupported. + */ + +-#if __FreeBSD_version >= 500000 +-#error This driver does not support FreeBSD 5.0/-CURRENT! +-#elif __FreeBSD_version < 470000 +-#error This driver requires FreeBSD 4.7 or later! +-#endif +- + #include <sys/systm.h> + #include <sys/types.h> + #include <sys/queue.h> +@@ -86,6 +80,7 @@ + + #if __FreeBSD_version >= 500000 + #include <sys/mutex.h> ++#include <sys/filedesc.h> + #include <dev/pci/pcireg.h> + #include <dev/pci/pcivar.h> + +@@ -115,6 +110,9 @@ + #define __TD_FDT(td) ((td)->p_fd) + #define __TD_FDT_CNT(td) ((td)->p_fd->fd_refcnt) + ++#define vm_page_lock_queues() ++#define vm_page_unlock_queues() ++ + #endif + + /* +@@ -306,7 +304,8 @@ + int nvidia_open_dev (struct nvidia_softc *); + int nvidia_close_ctl (dev_t, d_thread_t *); + int nvidia_close_dev (struct nvidia_softc *, dev_t, d_thread_t *); +-int nvidia_mmap_dev (struct nvidia_softc *, vm_offset_t); ++int nvidia_mmap_dev (struct nvidia_softc *, vm_offset_t, ++ vm_offset_t *); + + #endif /* __NV_FREEBSD_H__ */ + diff --git a/x11/nvidia-driver/files/patch-nvidia_ctl.c b/x11/nvidia-driver/files/patch-nvidia_ctl.c new file mode 100644 index 000000000000..6514b873d19b --- /dev/null +++ b/x11/nvidia-driver/files/patch-nvidia_ctl.c @@ -0,0 +1,30 @@ +--- src/nvidia_ctl.c.orig Wed Oct 30 15:30:58 2002 ++++ src/nvidia_ctl.c Thu Mar 6 01:07:57 2003 +@@ -19,6 +19,7 @@ + static d_poll_t nvidia_ctl_poll; + + static struct cdevsw nvidia_ctl_cdevsw = { ++#if __FreeBSD_version < 500000 + /* open */ nvidia_ctl_open, + /* close */ nvidia_ctl_close, + /* read */ noread, +@@ -32,10 +33,17 @@ + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ D_TRACKCLOSE, +-#if __FreeBSD_version < 500000 + /* bmaj */ -1, +-#endif + /* kqfilter */ NULL, ++#else ++ .d_open = nvidia_ctl_open, ++ .d_close = nvidia_ctl_close, ++ .d_ioctl = nvidia_ctl_ioctl, ++ .d_poll = nvidia_ctl_poll, ++ .d_name = "nvidiactl", ++ .d_maj = CDEV_MAJOR, ++ .d_flags = D_TRACKCLOSE ++#endif + }; + + static dev_t nvidia_ctl_cdev; diff --git a/x11/nvidia-driver/files/patch-nvidia_dev.c b/x11/nvidia-driver/files/patch-nvidia_dev.c new file mode 100644 index 000000000000..d53e31741c73 --- /dev/null +++ b/x11/nvidia-driver/files/patch-nvidia_dev.c @@ -0,0 +1,66 @@ +--- src/nvidia_dev.c.orig Wed Oct 30 15:30:58 2002 ++++ src/nvidia_dev.c Thu Mar 6 01:09:05 2003 +@@ -20,6 +20,7 @@ + static d_mmap_t nvidia_dev_mmap; + + static struct cdevsw nvidia_dev_cdevsw = { ++#if __FreeBSD_version < 500000 + /* open */ nvidia_dev_open, + /* close */ nvidia_dev_close, + /* read */ noread, +@@ -33,10 +34,18 @@ + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ D_MEM|D_TRACKCLOSE, +-#if __FreeBSD_version < 500000 + /* bmaj */ -1, +-#endif + /* kqfilter */ NULL, ++#else ++ .d_open = nvidia_dev_open, ++ .d_close = nvidia_dev_close, ++ .d_ioctl = nvidia_dev_ioctl, ++ .d_poll = nvidia_dev_poll, ++ .d_mmap = nvidia_dev_mmap, ++ .d_name = "nvidia", ++ .d_maj = CDEV_MAJOR, ++ .d_flags = D_MEM|D_TRACKCLOSE ++#endif + }; + + int nvidia_dev_open( +@@ -135,11 +144,15 @@ + int nvidia_dev_mmap( + dev_t dev, + vm_offset_t offset, ++#if __FreeBSD_version >= 500000 ++ vm_offset_t *paddr, ++#endif + int nprot + ) + { + nv_state_t *nv; + struct nvidia_softc *sc; ++ vm_offset_t phys; + + int status; + int unit = minor(dev); +@@ -148,10 +161,17 @@ + nv = sc->nv_state; + + nv_lock_api(nv); +- status = nvidia_mmap_dev(sc, offset); ++ status = nvidia_mmap_dev(sc, offset, &phys); + nv_unlock_api(nv); + ++#if __FreeBSD_version >= 500000 ++ *paddr = phys; + return status; ++#else ++ if (status == -1) ++ return -1; ++ return atop(phys); ++#endif + } + + int nvidia_dev_attach (struct nvidia_softc *sc) diff --git a/x11/nvidia-driver/files/patch-nvidia_subr.c b/x11/nvidia-driver/files/patch-nvidia_subr.c new file mode 100644 index 000000000000..edd6fa4da0e6 --- /dev/null +++ b/x11/nvidia-driver/files/patch-nvidia_subr.c @@ -0,0 +1,124 @@ +--- src/nvidia_subr.c.orig Wed Oct 30 15:30:58 2002 ++++ src/nvidia_subr.c Thu Mar 6 01:25:20 2003 +@@ -925,7 +925,9 @@ + * prevent random crashes. + */ + pa = vtophys((vm_offset_t) vm + (i * PAGE_SIZE)); ++ vm_page_lock_queues(); + vm_page_wire(PHYS_TO_VM_PAGE(pa)); ++ vm_page_unlock_queues(); + } + + at->object = 0; +@@ -963,6 +965,7 @@ + count = at->size / PAGE_SIZE; + SLIST_REMOVE(&sc->alloc_list, at, nv_alloc, list); + ++ vm_page_lock_queues(); + for (i = 0; i < count; i++) { + /* + * Release "one wiring" of this page; this may reenable paging as +@@ -971,6 +974,7 @@ + pa = vtophys(at->address + (i * PAGE_SIZE)); + vm_page_unwire(PHYS_TO_VM_PAGE(pa), 0); + } ++ vm_page_unlock_queues(); + + free(at, M_NVIDIA); + free(address, M_NVIDIA); +@@ -1007,13 +1011,19 @@ + * will be allocated. + */ + ++#if __FreeBSD_version < 500000 + m = vm_page_grab(object, i, VM_ALLOC_NORMAL); ++#else ++ m = vm_page_grab(object, i, VM_ALLOC_NORMAL | VM_ALLOC_WIRED); ++#endif + if (!m) { ++ vm_page_lock_queues(); + for (i -= 1; i >= 0; i--) { + m = vm_page_lookup(object, i); + vm_page_wakeup(m); + vm_page_unwire(m, 0); + } ++ vm_page_unlock_queues(); + return -ENOMEM; + } + +@@ -1022,7 +1032,9 @@ + * paging it out while we're still using it. This is necessary to + * prevent random crashes. + */ ++#if __FreeBSD_version < 500000 + vm_page_wire(m); ++#endif + vm_page_wakeup(m); + } + +@@ -1061,6 +1073,7 @@ + count = at->size / PAGE_SIZE; + SLIST_REMOVE(&sc->alloc_list, at, nv_alloc, list); + ++ vm_page_lock_queues(); + for (i = 0; i < count; i++) { + /* + * Release "one wiring" of this page; this may reenable paging as +@@ -1069,6 +1082,7 @@ + m = vm_page_lookup(at->object, i); + vm_page_unwire(m, 0); + } ++ vm_page_unlock_queues(); + + free(at, M_NVIDIA); + vm_object_deallocate(at->object); +@@ -1401,7 +1415,8 @@ + + int nvidia_mmap_dev( + struct nvidia_softc *sc, +- vm_offset_t offset ++ vm_offset_t offset, ++ vm_offset_t *paddr + ) + { + nv_alloc_t *at; +@@ -1412,14 +1427,20 @@ + * are physical addresses and mapped into user-space directly. We can + * only do some basic sanity checking here. + */ +- if (IS_FB_OFFSET(nv, offset, PAGE_SIZE)) +- return atop(offset); ++ if (IS_FB_OFFSET(nv, offset, PAGE_SIZE)) { ++ *paddr = offset; ++ return 0; ++ } + +- if (IS_REG_OFFSET(nv, offset, PAGE_SIZE)) +- return atop(offset); ++ if (IS_REG_OFFSET(nv, offset, PAGE_SIZE)) { ++ *paddr = offset; ++ return 0; ++ } + +- if (IS_AGP_OFFSET(nv, offset, PAGE_SIZE)) +- return atop(offset); ++ if (IS_AGP_OFFSET(nv, offset, PAGE_SIZE)) { ++ *paddr = offset; ++ return 0; ++ } + + /* + * If the offset does not fall into any of the relevant apertures, we +@@ -1430,8 +1451,10 @@ + */ + SLIST_FOREACH(at, &sc->alloc_list, list) { + if (offset >= at->address && +- offset < at->address + at->size) +- return atop(vtophys(offset)); ++ offset < at->address + at->size) { ++ *paddr = vtophys(offset); ++ return 0; ++ } + } + + return -1; |