mirror of
https://github.com/archlinux-jerry/nvidia-340xx
synced 2024-11-23 16:20:39 +08:00
fix for 5.14, without DRM_LEGACY kernel option
This commit is contained in:
parent
e191027b2c
commit
0b4d1ceb26
3 changed files with 205 additions and 95 deletions
4
.SRCINFO
4
.SRCINFO
|
@ -1,7 +1,7 @@
|
|||
pkgbase = nvidia-340xx
|
||||
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch
|
||||
pkgver = 340.108
|
||||
pkgrel = 23
|
||||
pkgrel = 24
|
||||
url = https://www.nvidia.com/
|
||||
arch = x86_64
|
||||
license = custom
|
||||
|
@ -25,7 +25,7 @@ pkgbase = nvidia-340xx
|
|||
b2sums = 947cb1f149b2db9c3c4f973f285d389790f73fc8c8a6865fc5b78d6a782f49513aa565de5c82a81c07515f1164e0e222d26c8212a14cf016e387bcc523e3fcb1
|
||||
b2sums = 665bf0e1fa22119592e7c75ff40f265e919955f228a3e3e3ebd76e9dffa5226bece5eb032922eb2c009572b31b28e80cd89656f5d0a4ad592277edd98967e68f
|
||||
b2sums = 344cd3a9888a9a61941906c198d3a480ce230119c96c72c72a74b711d23face2a7b1e53b9b4639465809b84762cdc53f38210e740318866705241bc4216e4f35
|
||||
b2sums = c722d07c29bc976c3bdf0c45bf4ad0196e3e3a8d1d39b33b66e26510374968f04a338156870f6f87ea6dda82b8ef2bb8630533ba2732e02cc482f6b9b02856a2
|
||||
b2sums = 31a4047ab84d13e32fd7fdbf9f69c696d3fab6666c541d2acf0a189c1d17c876970985167fd389a4adc0f786021172bdec1aa6d690736e3cf9fcd8ceabe5fd32
|
||||
|
||||
pkgname = nvidia-340xx
|
||||
pkgdesc = NVIDIA drivers for linux, 340xx legacy branch
|
||||
|
|
|
@ -1,5 +1,204 @@
|
|||
--- a/kernel/os-interface.c
|
||||
+++ b/kernel/os-interface.c
|
||||
diff -Naur NVIDIA-Linux-x86_64-340.108-no-compat32.5.13/kernel/nv-drm.c NVIDIA-Linux-x86_64-340.108-no-compat32.5.14/kernel/nv-drm.c
|
||||
--- NVIDIA-Linux-x86_64-340.108-no-compat32.5.13/kernel/nv-drm.c 2021-07-25 10:29:29.336505688 +0200
|
||||
+++ NVIDIA-Linux-x86_64-340.108-no-compat32.5.14/kernel/nv-drm.c 2021-09-16 16:49:10.929858547 +0200
|
||||
@@ -57,8 +57,11 @@
|
||||
#if defined(NV_DRM_GET_PCI_DEV_PRESENT)
|
||||
#define nv_drm_get_pci_dev drm_get_pci_dev
|
||||
#else
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
#include <drm/drm_agpsupport.h>
|
||||
-
|
||||
+#else
|
||||
+#include <drm/drm_legacy.h>
|
||||
+#endif
|
||||
#include "linux/dma-buf.h"
|
||||
|
||||
struct nv_drm_agp_head {
|
||||
@@ -82,6 +85,11 @@
|
||||
struct list_head head;
|
||||
};
|
||||
|
||||
+struct nv_drm_extra_priv_data {
|
||||
+ struct pci_dev *pdev;
|
||||
+ struct drm_agp_head *agp;
|
||||
+};
|
||||
+
|
||||
/*
|
||||
* Code from drm_agp_init/nv_drm_{free,unbind}_agp
|
||||
* Extracted from commit: 5b8b9d0c6d0e0f1993c6c56deaf9646942c49d94, file: drivers/gpu/drm/drm_agpsupport.c
|
||||
@@ -89,13 +97,14 @@
|
||||
struct drm_agp_head *nv_drm_agp_init(struct drm_device *dev)
|
||||
{
|
||||
struct nv_drm_agp_head *head = NULL;
|
||||
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
|
||||
|
||||
head = kzalloc(sizeof(*head), GFP_KERNEL);
|
||||
if (!head)
|
||||
return NULL;
|
||||
- head->bridge = agp_find_bridge(dev->pdev);
|
||||
+ head->bridge = agp_find_bridge(extra->pdev);
|
||||
if (!head->bridge) {
|
||||
- head->bridge = agp_backend_acquire(dev->pdev);
|
||||
+ head->bridge = agp_backend_acquire(extra->pdev);
|
||||
if (!head->bridge) {
|
||||
kfree(head);
|
||||
return NULL;
|
||||
@@ -133,48 +142,71 @@
|
||||
static void nv_drm_pci_agp_init(struct drm_device *dev)
|
||||
{
|
||||
if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
|
||||
- if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
|
||||
- dev->agp = nv_drm_agp_init(dev);
|
||||
- if (dev->agp) {
|
||||
- dev->agp->agp_mtrr = arch_phys_wc_add(
|
||||
- dev->agp->agp_info.aper_base,
|
||||
- dev->agp->agp_info.aper_size *
|
||||
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
|
||||
+
|
||||
+ if (pci_find_capability(extra->pdev, PCI_CAP_ID_AGP))
|
||||
+ extra->agp = nv_drm_agp_init(dev);
|
||||
+ if (extra->agp) {
|
||||
+ extra->agp->agp_mtrr = arch_phys_wc_add(
|
||||
+ extra->agp->agp_info.aper_base,
|
||||
+ extra->agp->agp_info.aper_size *
|
||||
1024 * 1024);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
+
|
||||
+#else
|
||||
+/* copied from v5.14.5 */
|
||||
+int nv_drm_legacy_agp_release(struct drm_device *dev)
|
||||
+{
|
||||
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
|
||||
+
|
||||
+ if (!extra->agp || !extra->agp->acquired)
|
||||
+ return -EINVAL;
|
||||
+ agp_backend_release(extra->agp->bridge);
|
||||
+ extra->agp->acquired = 0;
|
||||
+ return 0;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
void nv_drm_legacy_agp_clear(struct drm_device *dev)
|
||||
{
|
||||
struct nv_drm_agp_mem *entry, *tempe;
|
||||
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
|
||||
|
||||
- if (!dev->agp)
|
||||
+ if (!extra->agp)
|
||||
return;
|
||||
if (!drm_core_check_feature(dev, DRIVER_LEGACY))
|
||||
return;
|
||||
|
||||
- list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
|
||||
+ list_for_each_entry_safe(entry, tempe, &extra->agp->memory, head) {
|
||||
if (entry->bound)
|
||||
nv_drm_unbind_agp(entry->memory);
|
||||
nv_drm_free_agp(entry->memory, entry->pages);
|
||||
kfree(entry);
|
||||
}
|
||||
- INIT_LIST_HEAD(&dev->agp->memory);
|
||||
+ INIT_LIST_HEAD(&extra->agp->memory);
|
||||
|
||||
- if (dev->agp->acquired)
|
||||
+ if (extra->agp->acquired)
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
drm_agp_release(dev);
|
||||
-
|
||||
- dev->agp->acquired = 0;
|
||||
- dev->agp->enabled = 0;
|
||||
+#else
|
||||
+ nv_drm_legacy_agp_release(dev);
|
||||
+#endif
|
||||
+ extra->agp->acquired = 0;
|
||||
+ extra->agp->enabled = 0;
|
||||
}
|
||||
|
||||
void nv_drm_pci_agp_destroy(struct drm_device *dev)
|
||||
{
|
||||
- if (dev->agp) {
|
||||
- arch_phys_wc_del(dev->agp->agp_mtrr);
|
||||
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
|
||||
+ if (extra->agp) {
|
||||
+ arch_phys_wc_del(extra->agp->agp_mtrr);
|
||||
nv_drm_legacy_agp_clear(dev);
|
||||
- kfree(dev->agp);
|
||||
- dev->agp = NULL;
|
||||
+ kfree(extra->agp);
|
||||
+ extra->agp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,6 +215,7 @@
|
||||
struct drm_driver *driver)
|
||||
{
|
||||
struct drm_device *dev;
|
||||
+ struct nv_drm_extra_priv_data *extra;
|
||||
int ret;
|
||||
|
||||
DRM_DEBUG("\n");
|
||||
@@ -191,11 +224,18 @@
|
||||
if (IS_ERR(dev))
|
||||
return PTR_ERR(dev);
|
||||
|
||||
+ extra = kzalloc(sizeof(*extra), GFP_KERNEL);
|
||||
+ if (IS_ERR(extra))
|
||||
+ goto err_free;
|
||||
+
|
||||
+ extra->pdev = pdev;
|
||||
+
|
||||
ret = pci_enable_device(pdev);
|
||||
if (ret)
|
||||
- goto err_free;
|
||||
+ goto err_free2;
|
||||
|
||||
- dev->pdev = pdev;
|
||||
+ /* use the not used (i hope) dev_private to store deprecated/legacy pointers */
|
||||
+ dev->dev_private = extra;
|
||||
#ifdef __alpha__
|
||||
dev->hose = pdev->sysdata;
|
||||
#endif
|
||||
@@ -221,6 +261,8 @@
|
||||
err_agp:
|
||||
nv_drm_pci_agp_destroy(dev);
|
||||
pci_disable_device(pdev);
|
||||
+err_free2:
|
||||
+ kfree(extra);
|
||||
err_free:
|
||||
drm_dev_put(dev);
|
||||
return ret;
|
||||
@@ -303,10 +345,11 @@
|
||||
)
|
||||
{
|
||||
nv_linux_state_t *nvl;
|
||||
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
|
||||
|
||||
for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
|
||||
{
|
||||
- if (nvl->dev == dev->pdev)
|
||||
+ if (nvl->dev == extra->pdev)
|
||||
{
|
||||
nvl->drm = dev;
|
||||
return 0;
|
||||
@@ -327,10 +370,11 @@
|
||||
)
|
||||
{
|
||||
nv_linux_state_t *nvl;
|
||||
+ struct nv_drm_extra_priv_data *extra = dev->dev_private;
|
||||
|
||||
for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
|
||||
{
|
||||
- if (nvl->dev == dev->pdev)
|
||||
+ if (nvl->dev == extra->pdev)
|
||||
{
|
||||
BUG_ON(nvl->drm != dev);
|
||||
nvl->drm = NULL;
|
||||
diff -Naur NVIDIA-Linux-x86_64-340.108-no-compat32.5.13/kernel/os-interface.c NVIDIA-Linux-x86_64-340.108-no-compat32.5.14/kernel/os-interface.c
|
||||
--- NVIDIA-Linux-x86_64-340.108-no-compat32.5.13/kernel/os-interface.c 2021-07-25 10:29:29.083168593 +0200
|
||||
+++ NVIDIA-Linux-x86_64-340.108-no-compat32.5.14/kernel/os-interface.c 2021-09-16 13:17:43.345906445 +0200
|
||||
@@ -549,7 +549,11 @@
|
||||
// the requested timeout has expired, loop until less
|
||||
// than a jiffie of the desired delay remains.
|
||||
|
@ -12,92 +211,3 @@
|
|||
do
|
||||
{
|
||||
schedule_timeout(jiffies);
|
||||
--- a/kernel/nv-drm.c
|
||||
+++ b/kernel/nv-drm.c
|
||||
@@ -57,10 +57,13 @@
|
||||
#if defined(NV_DRM_GET_PCI_DEV_PRESENT)
|
||||
#define nv_drm_get_pci_dev drm_get_pci_dev
|
||||
#else
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
#include <drm/drm_agpsupport.h>
|
||||
+#endif
|
||||
|
||||
#include "linux/dma-buf.h"
|
||||
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
struct nv_drm_agp_head {
|
||||
struct agp_kern_info agp_info;
|
||||
struct list_head memory;
|
||||
@@ -177,6 +180,7 @@
|
||||
dev->agp = NULL;
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
static int nv_drm_get_pci_dev(struct pci_dev *pdev,
|
||||
const struct pci_device_id *ent,
|
||||
@@ -195,7 +199,9 @@
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
dev->pdev = pdev;
|
||||
+#endif
|
||||
#ifdef __alpha__
|
||||
dev->hose = pdev->sysdata;
|
||||
#endif
|
||||
@@ -203,11 +209,13 @@
|
||||
if (drm_core_check_feature(dev, DRIVER_MODESET))
|
||||
pci_set_drvdata(pdev, dev);
|
||||
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
nv_drm_pci_agp_init(dev);
|
||||
|
||||
ret = drm_dev_register(dev, ent->driver_data);
|
||||
if (ret)
|
||||
goto err_agp;
|
||||
+#endif
|
||||
|
||||
/* No locking needed since shadow-attach is single-threaded since it may
|
||||
* only be called from the per-driver module init hook. */
|
||||
@@ -218,9 +226,11 @@
|
||||
|
||||
return 0;
|
||||
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
err_agp:
|
||||
nv_drm_pci_agp_destroy(dev);
|
||||
pci_disable_device(pdev);
|
||||
+#endif
|
||||
err_free:
|
||||
drm_dev_put(dev);
|
||||
return ret;
|
||||
@@ -306,11 +316,13 @@
|
||||
|
||||
for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
|
||||
{
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
if (nvl->dev == dev->pdev)
|
||||
{
|
||||
nvl->drm = dev;
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
@@ -330,12 +342,14 @@
|
||||
|
||||
for (nvl = nv_linux_devices; nvl != NULL; nvl = nvl->next)
|
||||
{
|
||||
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 14, 0)
|
||||
if (nvl->dev == dev->pdev)
|
||||
{
|
||||
BUG_ON(nvl->drm != dev);
|
||||
nvl->drm = NULL;
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
return -ENODEV;
|
||||
|
|
4
PKGBUILD
4
PKGBUILD
|
@ -6,7 +6,7 @@
|
|||
pkgbase=nvidia-340xx
|
||||
pkgname=(nvidia-340xx nvidia-340xx-dkms); [ -n "$NVIDIA_340XX_DKMS_ONLY" ] && pkgname=(nvidia-340xx-dkms)
|
||||
pkgver=340.108
|
||||
pkgrel=23
|
||||
pkgrel=24
|
||||
pkgdesc="NVIDIA drivers for linux, 340xx legacy branch"
|
||||
arch=('x86_64')
|
||||
url="https://www.nvidia.com/"
|
||||
|
@ -31,7 +31,7 @@ b2sums=('6538bbec53b10f8d20977f9b462052625742e9709ef06e24cf2e55de5d0c55f1620a4bb
|
|||
'947cb1f149b2db9c3c4f973f285d389790f73fc8c8a6865fc5b78d6a782f49513aa565de5c82a81c07515f1164e0e222d26c8212a14cf016e387bcc523e3fcb1'
|
||||
'665bf0e1fa22119592e7c75ff40f265e919955f228a3e3e3ebd76e9dffa5226bece5eb032922eb2c009572b31b28e80cd89656f5d0a4ad592277edd98967e68f'
|
||||
'344cd3a9888a9a61941906c198d3a480ce230119c96c72c72a74b711d23face2a7b1e53b9b4639465809b84762cdc53f38210e740318866705241bc4216e4f35'
|
||||
'c722d07c29bc976c3bdf0c45bf4ad0196e3e3a8d1d39b33b66e26510374968f04a338156870f6f87ea6dda82b8ef2bb8630533ba2732e02cc482f6b9b02856a2')
|
||||
'31a4047ab84d13e32fd7fdbf9f69c696d3fab6666c541d2acf0a189c1d17c876970985167fd389a4adc0f786021172bdec1aa6d690736e3cf9fcd8ceabe5fd32')
|
||||
_pkg="NVIDIA-Linux-x86_64-${pkgver}-no-compat32"
|
||||
|
||||
# default is 'linux' substitute custom name here
|
||||
|
|
Loading…
Reference in a new issue