From nobody Wed Aug 16 20:55:36 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RR0lX6dq0z4TrlS; Wed, 16 Aug 2023 20:55:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RR0lX67Fyz4Bj3; Wed, 16 Aug 2023 20:55:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692219336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kwmchfZOWjsoL0QSN9lNX/nUO/4dYNOvYxopTDBOHww=; b=msoEidH6LYC0SCq30ipFxebyPRj4RdzJ22LF1QvzSFx3n7JmEpeqT5jlH2d99VBvH1Zjhi oJiech9QXLzEP3RJVqr4ng5wxrkhvulkYGAw1IGnAO27egxZVHUQeHUY5tnYSxQ+iYABWT VIe6wzaEz+quJL9yVr5dVjm869y4nIXxnVSxkbVd+oZfEgqJGHXgYC93WWZduz0IwqKjGq ZiYkblhTQHcE7hd8t+xX+Qnuzrf5gcW9Ko0KzCaFvRjOCGdP5aQKJ8NurMGss9sxnCHs2v /rOqva+QF+Pe8jFkPcJuxtoq0bCNllYWKWygfBg2K0ws2TXSaRl1CQf0fMsmdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1692219336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kwmchfZOWjsoL0QSN9lNX/nUO/4dYNOvYxopTDBOHww=; b=mZue3g+vWOPxMsSAf2znzfM/M25yVdwfYV6+jbwJhc+bfmUtc2Wphi/cXY77033Uwr658D 1/fTPSwWn2QDItbPAD8swFiO5BOex/LZGfL83+Npb6jxDpq8F78pZnNFbXb7P7En0gzBQk C7z/Zw5HlW5q1WbSmj8T4HNHyI12SW++9pjG/UJqedI2ep+t0mYOGz0t8xNhTMhGJXObsm ll2BwFm9qY3oNPaiFgc7CiWFjcrfXhcNpvWRRVo7bz+Llt3n8MKyzyBnysLK2UtLWkU4vF 0mrV8S4sxZZX3a6FIH0E0rxNyFelfiFPs1BknR8cKiAs5ZvYnbMpMLw/DwojEg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1692219336; a=rsa-sha256; cv=none; b=yh9/BlZLzOzfMlFy7WKIVoeje+aYDgfXC0DiiiEd6a/IMTUrUBFXT+3FA3rwtjAXD/ATCT PbybPW28hIrD6KWDFo3ZAH1vjwlqwSiZPNQveWV6XgdtfDe7RTIiLlsAjQ39qjL5GtSozo jWcsR9wZenMzCF0h3CBxQak4zEcOIc7dU0peNo7PYBSFgllqv/dYMTl4BD9NaPlpyDZHVe VHZLrbHDtd69UXfCrnxObbR2o03JNKEIW6sNi41GS70PTL6D9M/YJd9+s1kKq1FwGkzGi+ pMIGLPW7TW+lpRHed4jeGuFA1HwT7oDIPmxIrAR4poTYiSiuOc5P/8VQQGnALg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RR0lX5BC0z16DC; Wed, 16 Aug 2023 20:55:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 37GKtao8079085; Wed, 16 Aug 2023 20:55:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37GKta8Q079082; Wed, 16 Aug 2023 20:55:36 GMT (envelope-from git) Date: Wed, 16 Aug 2023 20:55:36 GMT Message-Id: <202308162055.37GKta8Q079082@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Kevin Bowling Subject: git: 49b9705d8fd8 - main - x11/nvidia-driver: Add Makefile.version and patch for nvidia-drm List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 49b9705d8fd8bfea7d87a95658302f8899fb1e32 Auto-Submitted: auto-generated The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/ports/commit/?id=49b9705d8fd8bfea7d87a95658302f8899fb1e32 commit 49b9705d8fd8bfea7d87a95658302f8899fb1e32 Author: Austin Shafer AuthorDate: 2023-08-16 19:21:01 +0000 Commit: Kevin Bowling CommitDate: 2023-08-16 20:55:10 +0000 x11/nvidia-driver: Add Makefile.version and patch for nvidia-drm This moves the version string into a makefile that can be included from child ports. This also adds a patch to nvidia-modeset that handles a deadlock with queueing events observed with nvidia-drm. This fix is only needed in 535, future versions will have a proper implementation included with them. Approved by: maintainer timeout Differential Revision: https://reviews.freebsd.org/D40168 --- x11/linux-nvidia-libs/Makefile | 3 +- x11/nvidia-driver/Makefile | 8 +- x11/nvidia-driver/Makefile.version | 4 + ...-src_nvidia-modeset_nvidia-modeset-freebsd.c.in | 131 +++++++++++++++++++++ 4 files changed, 143 insertions(+), 3 deletions(-) diff --git a/x11/linux-nvidia-libs/Makefile b/x11/linux-nvidia-libs/Makefile index 84a31944ade1..811be656adf5 100644 --- a/x11/linux-nvidia-libs/Makefile +++ b/x11/linux-nvidia-libs/Makefile @@ -1,5 +1,5 @@ PORTNAME= nvidia-libs -DISTVERSION?= 535.98 +DISTVERSION?= ${NVIDIA_DISTVERSION} # Always try to set PORTREVISION as it can be overridden by the slave ports PORTREVISION?= 0 CATEGORIES= x11 linux @@ -13,6 +13,7 @@ COMMENT= NVidia graphics libraries and programs (Linux version) WWW= https://www.nvidia.com/object/unix.html LICENSE_FILE= ${WRKSRC}/LICENSE +.include "${.CURDIR}/../nvidia-driver/Makefile.version" .include "${.CURDIR}/../nvidia-driver/Makefile.common" .if ${DISTVERSION:R} > 390 diff --git a/x11/nvidia-driver/Makefile b/x11/nvidia-driver/Makefile index 24f855878f47..a722675748f7 100644 --- a/x11/nvidia-driver/Makefile +++ b/x11/nvidia-driver/Makefile @@ -12,9 +12,9 @@ # ``make DISTVERSION=xxx.yy.zz -DNO_CHECKSUM'' should typically work. PORTNAME?= nvidia-driver -DISTVERSION?= 535.98 +DISTVERSION?= ${NVIDIA_DISTVERSION} # 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} @@ -25,6 +25,7 @@ COMMENT?= NVidia graphics card binary drivers for hardware OpenGL rendering WWW= https://www.nvidia.com/object/unix.html LICENSE_FILE= ${WRKSRC}/doc/license.txt +.include "${.CURDIR}/../nvidia-driver/Makefile.version" .include "${.CURDIR}/../nvidia-driver/Makefile.common" # Pull GNU sed(1) for "binary" patching of obj/libglvnd/libEGL.so.1 and @@ -97,6 +98,9 @@ SUB_LIST+= KLDNAME=nvidia SUB_LIST+= KLDNAME=nvidia-modeset .endif +.if ${NVVERSION} >= 530.03002 && ${NVVERSION} < 545.00 +SUB_PATCHES += surplus-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 diff --git a/x11/nvidia-driver/Makefile.version b/x11/nvidia-driver/Makefile.version new file mode 100644 index 000000000000..751e2bcb6e9c --- /dev/null +++ b/x11/nvidia-driver/Makefile.version @@ -0,0 +1,4 @@ +# NVIDIA Distversion +# +# This will be included from x11/nvidia-driver and the nvidia-drm port +NVIDIA_DISTVERSION = 535.98 diff --git a/x11/nvidia-driver/files/surplus-patch-src_nvidia-modeset_nvidia-modeset-freebsd.c.in b/x11/nvidia-driver/files/surplus-patch-src_nvidia-modeset_nvidia-modeset-freebsd.c.in new file mode 100644 index 000000000000..0df09d8811c6 --- /dev/null +++ b/x11/nvidia-driver/files/surplus-patch-src_nvidia-modeset_nvidia-modeset-freebsd.c.in @@ -0,0 +1,131 @@ +--- src/nvidia-modeset/nvidia-modeset-freebsd.c.orig 2023-03-28 22:14:28 UTC ++++ src/nvidia-modeset/nvidia-modeset-freebsd.c +@@ -368,6 +368,7 @@ struct nvkms_timer_t { + NvBool cancel; + NvBool complete; + NvBool isRefPtr; ++ NvBool needsNvkmsLock; + NvBool callout_created; + nvkms_timer_proc_t *proc; + void *dataPtr; +@@ -406,7 +407,14 @@ static void nvkms_taskqueue_callback(void *arg, int pe + callout_drain(&timer->callout); + } + +- sx_xlock(&nvkms_lock); ++ /* ++ * Only lock if this timer requests it. DRM's callback nv_drm_event_callback ++ * will not need this, since it may reenter nvkms through the kapi and lock ++ * nvkms_lock then. ++ */ ++ if (timer->needsNvkmsLock) { ++ sx_xlock(&nvkms_lock); ++ } + + if (timer->isRefPtr) { + // If the object this timer refers to was destroyed, treat the timer as +@@ -424,11 +432,13 @@ static void nvkms_taskqueue_callback(void *arg, int pe + timer->complete = NV_TRUE; + } + ++ if (timer->needsNvkmsLock) { ++ sx_xunlock(&nvkms_lock); ++ } ++ + if (timer->cancel || timer->isRefPtr) { + nvkms_free(timer, sizeof(*timer)); + } +- +- sx_xunlock(&nvkms_lock); + } + + static void nvkms_callout_callback(void *arg) +@@ -441,11 +451,13 @@ nvkms_init_timer(struct nvkms_timer_t *timer, nvkms_ti + + static void + nvkms_init_timer(struct nvkms_timer_t *timer, nvkms_timer_proc_t *proc, +- void *dataPtr, NvU32 dataU32, NvBool isRefPtr, NvU64 usec) ++ void *dataPtr, NvU32 dataU32, NvBool isRefPtr, NvU64 usec, ++ NvBool needsNvkmsLock) + { + timer->cancel = NV_FALSE; + timer->complete = NV_FALSE; + timer->isRefPtr = isRefPtr; ++ timer->needsNvkmsLock = needsNvkmsLock; + + timer->proc = proc; + timer->dataPtr = dataPtr; +@@ -479,19 +491,27 @@ nvkms_init_timer(struct nvkms_timer_t *timer, nvkms_ti + mtx_unlock_spin(&nvkms_timers.lock); + } + +-nvkms_timer_handle_t* +-nvkms_alloc_timer(nvkms_timer_proc_t *proc, +- void *dataPtr, NvU32 dataU32, +- NvU64 usec) ++static nvkms_timer_handle_t* ++nvkms_alloc_timer_locked(nvkms_timer_proc_t *proc, ++ void *dataPtr, NvU32 dataU32, ++ NvU64 usec, NvBool needsNvkmsLock) + { + // nvkms_alloc_timer cannot be called from an interrupt context. + struct nvkms_timer_t *timer = nvkms_alloc(sizeof(*timer), NV_TRUE); + if (timer) { +- nvkms_init_timer(timer, proc, dataPtr, dataU32, NV_FALSE, usec); ++ nvkms_init_timer(timer, proc, dataPtr, dataU32, NV_FALSE, usec, needsNvkmsLock); + } + return timer; + } + ++nvkms_timer_handle_t* ++nvkms_alloc_timer(nvkms_timer_proc_t *proc, ++ void *dataPtr, NvU32 dataU32, ++ NvU64 usec) ++{ ++ return nvkms_alloc_timer_locked(proc, dataPtr, dataU32, usec, NV_TRUE); ++} ++ + NvBool + nvkms_alloc_timer_with_ref_ptr(nvkms_timer_proc_t *proc, + struct nvkms_ref_ptr *ref_ptr, +@@ -506,7 +526,7 @@ nvkms_alloc_timer_with_ref_ptr(nvkms_timer_proc_t *pro + // Reference the ref_ptr to make sure that it doesn't get freed before + // the timer fires. + nvkms_inc_ref(ref_ptr); +- nvkms_init_timer(timer, proc, ref_ptr, dataU32, NV_TRUE, usec); ++ nvkms_init_timer(timer, proc, ref_ptr, dataU32, NV_TRUE, usec, NV_TRUE); + } + + return timer != NULL; +@@ -570,10 +590,11 @@ nvkms_event_queue_changed(nvkms_per_open_handle_t *pOp + break; + case NVKMS_CLIENT_KERNEL_SPACE: + if (!popen->kernel.task) { +- popen->kernel.task = nvkms_alloc_timer(nvkms_kapi_task_callback, +- popen, +- 0, /* dataU32 */ +- 0 /* callout delay */); ++ popen->kernel.task = nvkms_alloc_timer_locked(nvkms_kapi_task_callback, ++ popen, ++ 0, /* dataU32 */ ++ 0, /* callout delay */ ++ NV_FALSE); + } + break; + } +@@ -828,10 +849,11 @@ static struct nvkms_per_open *nvkms_open_common(enum N + case NVKMS_CLIENT_KERNEL_SPACE: + /* enqueue our new task */ + popen->kernel.device = device; +- popen->kernel.task = nvkms_alloc_timer(nvkms_kapi_task_callback, +- popen, +- 0, /* dataU32 */ +- 0 /* callout delay */); ++ popen->kernel.task = nvkms_alloc_timer_locked(nvkms_kapi_task_callback, ++ popen, ++ 0, /* dataU32 */ ++ 0, /* callout delay */ ++ NV_FALSE); + break; + } +