From nobody Mon Mar 18 15:26:23 2024 X-Original-To: dev-commits-ports-all@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 4TyzGR4rpbz5DwnG; Mon, 18 Mar 2024 15:26:23 +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 4TyzGR3TxLz4YPn; Mon, 18 Mar 2024 15:26:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710775583; 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=Y8owxrz3j2hMGWhnlZR2mCS3/uzoyiGfEA/2JaWSbsM=; b=kIA25UCnGPhm4Xk+NAyrnFZTNACNyr6YZLEi9e/J7BHTgz12gHbBZacfIhjLXYKXsk0Sgg Upye49eP50gSokrkkiG6i5AJJimNYoOfklXWgQqx7kuXxFQXNXvY+jro6PZnZUJBP2fA2w 9mkf9EaVzpylD2155o1KROz7jOn4UmVYeQzRkJ9Odd+NpkDsnk1HVFa5hr+PBH9KtOdV2V 64WXijwgFs3KVvgaWXXfNP1WBXbO+cMRJ5SeYtx9Agq7Hvdhu1jbRacMbucARm2idBsR2g UNFQxe2SzM2eBIQulpT3Vl6wke1HiZoUhe/RcUny2txyIPxOD2ZVXWfh+BZX7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710775583; a=rsa-sha256; cv=none; b=QESh5r25pjltD1L+LBQsXMBgur+KEm2OBR+yhnkOL+AMpoVBwK8Ervx5KVXjow69naPbSn jxtw00mifJbr0j0fMbqB8cElsQmMlIKOk+2+xK/odn1rro0d5UiMuVrqmtddEdeqH2WMAn ak/cYpXo3ICGI4+1jO6gIK597KrF79shJdELA5rg2ij55TVy7J9c2SKqWvo03LcjfGU38z HX9eRmz4KaYMkujusm3PXGZR0gVjdhuI3ztDdACtQBCa6oEeLufM01oX4Hr/j+HFIEExEw vT6IHqKbkUWAj/M3FJOCNN49FhzJM3pOjBM6cgQdP6aO5IbGT88BWkimRYX89w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710775583; 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=Y8owxrz3j2hMGWhnlZR2mCS3/uzoyiGfEA/2JaWSbsM=; b=om74fCJ2Rx/8YDpCNWbsbySY3/d732sUapVm/9dICNrnt5jMr9w0nwStiAP6BsjJcL8XWI ktkUkvJncBhUqZ2lGzED2f8v0kwAy0fnTipOBv6z2rCPrXE5Yxp5vshrYWyyFZhkxpbLfB yM+I1srVFV9mnHWDAczHaxQlS1CklYyUoCL53dIiP53SDRPTR5w9XJMPuIoNdjbHIQwqwF QybMhT8lVBW2BYzieFEW1fLpnFNz1zSttyyzZTrzqULvyQl1dsFKSL66Kj0nBryMwyoQy6 hzyDNyufDzeCHZPTf1zJ4wIFnFwNcZ/IZ0ryx9xhFEdQdZ+In2g3kRp/4cM6IQ== 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 4TyzGR355ZzRjN; Mon, 18 Mar 2024 15:26:23 +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 42IFQNHM051294; Mon, 18 Mar 2024 15:26:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42IFQNjx051291; Mon, 18 Mar 2024 15:26:23 GMT (envelope-from git) Date: Mon, 18 Mar 2024 15:26:23 GMT Message-Id: <202403181526.42IFQNjx051291@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Gleb Popov Subject: git: 0d98f3a7607f - main - graphics/nvidia-drm-kmod: fix build depends and linuxkpi registration List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arrowd X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0d98f3a7607fc1fb304cecffbebf94ad889af940 Auto-Submitted: auto-generated The branch main has been updated by arrowd: URL: https://cgit.FreeBSD.org/ports/commit/?id=0d98f3a7607fc1fb304cecffbebf94ad889af940 commit 0d98f3a7607fc1fb304cecffbebf94ad889af940 Author: Austin Shafer AuthorDate: 2024-03-18 15:14:23 +0000 Commit: Gleb Popov CommitDate: 2024-03-18 15:24:47 +0000 graphics/nvidia-drm-kmod: fix build depends and linuxkpi registration This fixes an issue where linuxkpi/DRM compatibility was not being correctly detected, causing sway to not work. The conftest.sh script checks the installed kernel modules for symbol presence, but on package builders drm.ko was not being installed due to being in RUN_DEPENDS instead of BUILD_DEPENDS. This also fixes a panic in sway when an external monitor is plugged into a prime laptop. This uses linux_pci_attach_device when possible to actually register everything needed for the pci dev, instead of just filling in the bare miniumum. Differential Revision: https://reviews.freebsd.org/D44308 --- graphics/nvidia-drm-510-kmod/Makefile | 2 + .../files/patch-nvidia-drm-freebsd-lkpi.c | 46 +++++++++++++++++++++ graphics/nvidia-drm-515-kmod/Makefile | 2 + .../files/patch-nvidia-drm-freebsd-lkpi.c | 48 +++++++++++++++++++++- graphics/nvidia-drm-61-kmod/Makefile | 2 + .../files/patch-nvidia-drm-freebsd-lkpi.c | 46 ++++++++++++++++++++- 6 files changed, 143 insertions(+), 3 deletions(-) diff --git a/graphics/nvidia-drm-510-kmod/Makefile b/graphics/nvidia-drm-510-kmod/Makefile index ae46d3bf2289..f63043644036 100644 --- a/graphics/nvidia-drm-510-kmod/Makefile +++ b/graphics/nvidia-drm-510-kmod/Makefile @@ -1,6 +1,8 @@ PORTNAME= nvidia-drm-510-kmod +PORTREVISION= 1 CATEGORIES= graphics +BUILD_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-510-kmod RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-510-kmod CONFLICTS_INSTALL= nvidia-drm-515-kmod nvidia-drm-61-kmod diff --git a/graphics/nvidia-drm-510-kmod/files/patch-nvidia-drm-freebsd-lkpi.c b/graphics/nvidia-drm-510-kmod/files/patch-nvidia-drm-freebsd-lkpi.c new file mode 100644 index 000000000000..76a655dae93c --- /dev/null +++ b/graphics/nvidia-drm-510-kmod/files/patch-nvidia-drm-freebsd-lkpi.c @@ -0,0 +1,46 @@ +--- nvidia-drm-freebsd-lkpi.c.orig 2024-02-22 01:03:15 UTC ++++ nvidia-drm-freebsd-lkpi.c +@@ -115,6 +115,7 @@ int nv_drm_probe_devices(void) + * by the native nvidia.ko by using our devclass. + */ + for (int i = 0; i < NV_MAX_DEVICES; i++) { ++ struct pci_dev *pdev; + nv_gpu_info_t gpu_info; + struct nvidia_softc *sc = devclass_get_softc(nvidia_devclass, i); + if (!sc) { +@@ -124,11 +125,33 @@ int nv_drm_probe_devices(void) + nv_state_t *nv = sc->nv_state; + + /* ++ * Set the ivars for this device if they are not already populated. This ++ * is the bus specific data, and linuxkpi will try to use it. ++ */ ++ if (!device_get_ivars(sc->dev)) { ++ device_t parent = device_get_parent(sc->dev); ++ struct pci_devinfo *dinfo = device_get_ivars(parent); ++ device_set_ivars(sc->dev, dinfo); ++ } ++ ++ /* + * Now we have the state (which gives us the device_t), but what nvidia-drm + * wants is a pci_dev suitable for use with linuxkpi code. We can use +- * lkpinew_pci_dev to fill in a pci_dev struct, ++ * lkpinew_pci_dev to fill in a pci_dev struct, or linux_pci_attach on more ++ * recent kernels (introduced by 253dbe7487705). + */ +- struct pci_dev *pdev = lkpinew_pci_dev(sc->dev); ++#if __FreeBSD_version < 1300093 ++ pdev = lkpinew_pci_dev(sc->dev); ++#else ++ pdev = malloc(sizeof(*pdev), M_DEVBUF, M_WAITOK|M_ZERO); ++ if (!pdev) { ++ return -ENOMEM; ++ } ++ ++ if (linux_pci_attach_device(sc->dev, NULL, NULL, pdev)) { ++ return -ENOMEM; ++ } ++#endif + nv_lkpi_pci_devs[i] = pdev; + + gpu_info.gpu_id = nv->gpu_id; diff --git a/graphics/nvidia-drm-515-kmod/Makefile b/graphics/nvidia-drm-515-kmod/Makefile index fee33ee96bc4..c4a67b394972 100644 --- a/graphics/nvidia-drm-515-kmod/Makefile +++ b/graphics/nvidia-drm-515-kmod/Makefile @@ -1,6 +1,8 @@ PORTNAME= nvidia-drm-515-kmod +PORTREVISION= 1 CATEGORIES= graphics +BUILD_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-515-kmod RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-515-kmod CONFLICTS_INSTALL= nvidia-drm-510-kmod nvidia-drm-61-kmod diff --git a/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-freebsd-lkpi.c b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-freebsd-lkpi.c index 5f707bd2f03d..807e95effe74 100644 --- a/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-freebsd-lkpi.c +++ b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-freebsd-lkpi.c @@ -1,8 +1,52 @@ ---- nvidia-drm-freebsd-lkpi.c.orig 2023-11-06 18:11:13 UTC +--- nvidia-drm-freebsd-lkpi.c.orig 2024-02-22 01:03:15 UTC +++ nvidia-drm-freebsd-lkpi.c -@@ -228,7 +228,6 @@ MODULE_DEPEND(nvidia_drm, linuxkpi, 1, 1, 1); +@@ -115,6 +115,7 @@ int nv_drm_probe_devices(void) + * by the native nvidia.ko by using our devclass. + */ + for (int i = 0; i < NV_MAX_DEVICES; i++) { ++ struct pci_dev *pdev; + nv_gpu_info_t gpu_info; + struct nvidia_softc *sc = devclass_get_softc(nvidia_devclass, i); + if (!sc) { +@@ -124,11 +125,33 @@ int nv_drm_probe_devices(void) + nv_state_t *nv = sc->nv_state; + /* ++ * Set the ivars for this device if they are not already populated. This ++ * is the bus specific data, and linuxkpi will try to use it. ++ */ ++ if (!device_get_ivars(sc->dev)) { ++ device_t parent = device_get_parent(sc->dev); ++ struct pci_devinfo *dinfo = device_get_ivars(parent); ++ device_set_ivars(sc->dev, dinfo); ++ } ++ ++ /* + * Now we have the state (which gives us the device_t), but what nvidia-drm + * wants is a pci_dev suitable for use with linuxkpi code. We can use +- * lkpinew_pci_dev to fill in a pci_dev struct, ++ * lkpinew_pci_dev to fill in a pci_dev struct, or linux_pci_attach on more ++ * recent kernels (introduced by 253dbe7487705). + */ +- struct pci_dev *pdev = lkpinew_pci_dev(sc->dev); ++#if __FreeBSD_version < 1300093 ++ pdev = lkpinew_pci_dev(sc->dev); ++#else ++ pdev = malloc(sizeof(*pdev), M_DEVBUF, M_WAITOK|M_ZERO); ++ if (!pdev) { ++ return -ENOMEM; ++ } ++ ++ if (linux_pci_attach_device(sc->dev, NULL, NULL, pdev)) { ++ return -ENOMEM; ++ } ++#endif + nv_lkpi_pci_devs[i] = pdev; + + gpu_info.gpu_id = nv->gpu_id; +@@ -148,7 +171,6 @@ MODULE_DEPEND(nvidia_drm, linuxkpi, 1, 1, 1); LKPI_DRIVER_MODULE(nvidia_drm, nv_drm_init, nv_drm_exit); + LKPI_PNP_INFO(pci, nvidia_drm, nv_module_device_table); MODULE_DEPEND(nvidia_drm, linuxkpi, 1, 1, 1); -MODULE_DEPEND(nvidia_drm, linuxkpi_gplv2, 1, 1, 1); MODULE_DEPEND(nvidia_drm, drmn, 2, 2, 2); diff --git a/graphics/nvidia-drm-61-kmod/Makefile b/graphics/nvidia-drm-61-kmod/Makefile index 1a4fa5236a4d..0dd1d477b474 100644 --- a/graphics/nvidia-drm-61-kmod/Makefile +++ b/graphics/nvidia-drm-61-kmod/Makefile @@ -1,6 +1,8 @@ PORTNAME= nvidia-drm-61-kmod +PORTREVISION= 1 CATEGORIES= graphics +BUILD_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-61-kmod RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-61-kmod CONFLICTS_INSTALL= nvidia-drm-510-kmod nvidia-drm-515-kmod diff --git a/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-freebsd-lkpi.c b/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-freebsd-lkpi.c index 6fc6285876f2..807e95effe74 100644 --- a/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-freebsd-lkpi.c +++ b/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-freebsd-lkpi.c @@ -1,6 +1,50 @@ --- nvidia-drm-freebsd-lkpi.c.orig 2024-02-22 01:03:15 UTC +++ nvidia-drm-freebsd-lkpi.c -@@ -148,7 +148,6 @@ MODULE_DEPEND(nvidia_drm, linuxkpi, 1, 1, 1); +@@ -115,6 +115,7 @@ int nv_drm_probe_devices(void) + * by the native nvidia.ko by using our devclass. + */ + for (int i = 0; i < NV_MAX_DEVICES; i++) { ++ struct pci_dev *pdev; + nv_gpu_info_t gpu_info; + struct nvidia_softc *sc = devclass_get_softc(nvidia_devclass, i); + if (!sc) { +@@ -124,11 +125,33 @@ int nv_drm_probe_devices(void) + nv_state_t *nv = sc->nv_state; + + /* ++ * Set the ivars for this device if they are not already populated. This ++ * is the bus specific data, and linuxkpi will try to use it. ++ */ ++ if (!device_get_ivars(sc->dev)) { ++ device_t parent = device_get_parent(sc->dev); ++ struct pci_devinfo *dinfo = device_get_ivars(parent); ++ device_set_ivars(sc->dev, dinfo); ++ } ++ ++ /* + * Now we have the state (which gives us the device_t), but what nvidia-drm + * wants is a pci_dev suitable for use with linuxkpi code. We can use +- * lkpinew_pci_dev to fill in a pci_dev struct, ++ * lkpinew_pci_dev to fill in a pci_dev struct, or linux_pci_attach on more ++ * recent kernels (introduced by 253dbe7487705). + */ +- struct pci_dev *pdev = lkpinew_pci_dev(sc->dev); ++#if __FreeBSD_version < 1300093 ++ pdev = lkpinew_pci_dev(sc->dev); ++#else ++ pdev = malloc(sizeof(*pdev), M_DEVBUF, M_WAITOK|M_ZERO); ++ if (!pdev) { ++ return -ENOMEM; ++ } ++ ++ if (linux_pci_attach_device(sc->dev, NULL, NULL, pdev)) { ++ return -ENOMEM; ++ } ++#endif + nv_lkpi_pci_devs[i] = pdev; + + gpu_info.gpu_id = nv->gpu_id; +@@ -148,7 +171,6 @@ MODULE_DEPEND(nvidia_drm, linuxkpi, 1, 1, 1); LKPI_DRIVER_MODULE(nvidia_drm, nv_drm_init, nv_drm_exit); LKPI_PNP_INFO(pci, nvidia_drm, nv_module_device_table); MODULE_DEPEND(nvidia_drm, linuxkpi, 1, 1, 1);