以下の nvidia のドライバが Linux 5.4 でコンパイルできない話.
- nvidia-kernel-dkms 418.74-1
- nvidia-legacy-390xx-kernel-dkms 390.116-1
まず以下のエラー.
The Module.symvers file is missing, or does not contain any
symbols exported from the kernel. This could cause the NVIDIA
kernel modules to be built against a configuration that does
not accurately reflect the actual target kernel.
The Module.symvers file check can be disabled by setting the
environment variable IGNORE_MISSING_MODULE_SYMVERS to 1.
これは modpost: add support for symbol namespaces で Module.symvers
に1つエントリ(namespace)が追加されたことによる.conftest.sh
で Module.symvers
の symbol をチェックするがその箇所はただの grep
なので影響なし.IGNORE_MISSING_MODULE_SYMVERS=1
にしても問題ないが conftest.sh
を修正する.
次,以下のエラー.
In file included from /var/lib/dkms/nvidia-current/418.74/build/nvidia/nv.c:14:
/var/lib/dkms/nvidia-current/418.74/build/common/inc/nv-linux.h:1852:6: error: "NV_BUILD_MODULE_INSTANCES" is not defined, evaluates to 0 [-Werror=undef]
#if (NV_BUILD_MODULE_INSTANCES != 0)
^~~~~~~~~~~~~~~~~~~~~~~~~
これ,なに由来のエラーか不明.NV_BUILD_MODULE_INSTANCES = 0
で問題ないはずなので,Kbuild
ファイルで define してしまう.
次,以下のエラー.
/var/lib/dkms/nvidia-current/418.74/build/nvidia-drm/nvidia-drm-drv.c:657:44: error: ‘DRIVER_PRIME’ undeclared here (not in a function); did you mean ‘DRIVER_PCI_DMA’?
.driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER,
^~~~~~~~~~~~
DRIVER_PCI_DMA
これは drm/prime: Actually remove DRIVER_PRIME everywhereでDRIVER_PRIME
が削除されたことによる.削除する.
次,以下のエラー.
/var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-gem.c: In function ‘nv_drm_gem_prime_export’:
/var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-gem.c:64:33: error: passing argument 1 of ‘drm_gem_prime_export’ from incomp
atible pointer type [-Werror=incompatible-pointer-types]
return drm_gem_prime_export(dev, gem, flags);
^~~
In file included from ./include/drm/drmP.h:75,
from /var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-priv.h:30,
from /var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-gem.c:27:
./include/drm/drm_prime.h:94:17: note: expected ‘struct drm_gem_object *’ but argument is of type ‘struct drm_device *’
struct dma_buf *drm_gem_prime_export(struct drm_gem_object *obj,
^~~~~~~~~~~~~~~~~~~~
/var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-gem.c:64:38: warning: passing argument 2 of ‘drm_gem_prime_export’ makes int
eger from pointer without a cast [-Wint-conversion]
return drm_gem_prime_export(dev, gem, flags);
^~~
In file included from ./include/drm/drmP.h:75,
from /var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-priv.h:30,
from /var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-gem.c:27:
./include/drm/drm_prime.h:94:17: note: expected ‘int’ but argument is of type ‘struct drm_gem_object *’
struct dma_buf *drm_gem_prime_export(struct drm_gem_object *obj,
^~~~~~~~~~~~~~~~~~~~
/var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-gem.c:64:12: error: too many arguments to function ‘drm_gem_prime_export’
return drm_gem_prime_export(dev, gem, flags);
^~~~~~~~~~~~~~~~~~~~
In file included from ./include/drm/drmP.h:75,
from /var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-priv.h:30,
from /var/lib/dkms/nvidia-legacy-390xx/390.116/build/nvidia-drm/nvidia-drm-gem.c:27:
./include/drm/drm_prime.h:94:17: note: declared here
struct dma_buf *drm_gem_prime_export(struct drm_gem_object *obj,
^~~~~~~~~~~~~~~~~~~~
これdrm/prime: Align gem_prime_export with obj_funcs.exportによりdrm_gem_prime_export
の引数が変更になった(3つの引数のうち1つ目が削除された)ことが原因.
以下まとめてパッチ.ただし5.3でコンパイルするためのパッチがあたっていることを想定.
nvidia-kernel-dkms 418.74-1
diff --git a/Kbuild b/Kbuild
index 6a65185..ff3417c 100644
--- a/Kbuild
+++ b/Kbuild
@@ -62,6 +62,7 @@ EXTRA_CFLAGS += -Wall -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-error -Wno-
EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"418.74\" -Wno-unused-function -Wuninitialized -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE
EXTRA_CFLAGS += $(call cc-option,-Werror=undef,)
EXTRA_CFLAGS += -DNV_SPECTRE_V2=$(NV_SPECTRE_V2)
+EXTRA_CFLAGS += -DNV_BUILD_MODULE_INSTANCES=0
#
# Detect SGI UV systems and apply system-specific optimizations.
diff --git a/conftest.sh b/conftest.sh
index d17ba21..087fda5 100644
--- a/conftest.sh
+++ b/conftest.sh
@@ -3708,7 +3708,7 @@ case "$6" in
TAB=' '
if [ -f "$OUTPUT/Module.symvers" ] && \
- grep -e "^[^${TAB}]*${TAB}[^${TAB}]*${TAB}vmlinux" \
+ grep -e "^[^${TAB}]*${TAB}[^${TAB}]*${TAB}[^${TAB}]*${TAB}vmlinux" \
"$OUTPUT/Module.symvers" >/dev/null 2>&1; then
exit 0
fi
diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c
index 6ec01f4..18cf167 100644
--- a/nvidia-drm/nvidia-drm-drv.c
+++ b/nvidia-drm/nvidia-drm-drv.c
@@ -654,7 +654,7 @@ static const struct drm_ioctl_desc nv_drm_ioctls[] = {
static struct drm_driver nv_drm_driver = {
- .driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER,
+ .driver_features = DRIVER_GEM | DRIVER_RENDER,
.gem_free_object = nv_drm_gem_free,
nvidia-legacy-390xx-kernel-dkms 390.116-1
diff --git a/Kbuild b/Kbuild
index 0665f50..992a48c 100644
--- a/Kbuild
+++ b/Kbuild
@@ -61,6 +61,7 @@ EXTRA_CFLAGS += -I$(src)
EXTRA_CFLAGS += -Wall -MD $(DEFINES) $(INCLUDES) -Wsign-compare -Wno-cast-qual -Wno-error
EXTRA_CFLAGS += -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"390.116\" -Wno-unused-function -Wuninitialized -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE -Wno-sign-compare -Wno-format-extra-args
EXTRA_CFLAGS += $(call cc-option,-Werror=undef,)
+EXTRA_CFLAGS += -DNV_BUILD_MODULE_INSTANCES=0
#
# Detect SGI UV systems and apply system-specific optimizations.
diff --git a/nvidia-drm/nvidia-drm-drv.c b/nvidia-drm/nvidia-drm-drv.c
index 90ce30b..d9f3961 100644
--- a/nvidia-drm/nvidia-drm-drv.c
+++ b/nvidia-drm/nvidia-drm-drv.c
@@ -634,7 +634,7 @@ static const struct drm_ioctl_desc nv_drm_ioctls[] = {
static struct drm_driver nv_drm_driver = {
- .driver_features = DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER,
+ .driver_features = DRIVER_GEM | DRIVER_RENDER,
.gem_free_object = nv_drm_gem_free,
diff --git a/nvidia-drm/nvidia-drm-gem.c b/nvidia-drm/nvidia-drm-gem.c
index 3d51196..addff14 100644
--- a/nvidia-drm/nvidia-drm-gem.c
+++ b/nvidia-drm/nvidia-drm-gem.c
@@ -46,10 +46,9 @@ void nv_drm_gem_free(struct drm_gem_object *gem)
nv_gem->ops->free(nv_gem);
}
-
-struct dma_buf *nv_drm_gem_prime_export(struct drm_device *dev,
- struct drm_gem_object *gem, int flags)
+struct dma_buf *nv_drm_gem_prime_export(struct drm_gem_object *gem, int flags)
{
+ struct drm_device *dev = gem->dev;
struct nv_drm_device *nv_dev = to_nv_device(dev);
struct nv_drm_gem_object *nv_gem = to_nv_gem_object(gem);
@@ -61,7 +60,7 @@ struct dma_buf *nv_drm_gem_prime_export(struct drm_device *dev,
return ERR_PTR(-EINVAL);
}
- return drm_gem_prime_export(dev, gem, flags);
+ return drm_gem_prime_export(gem, flags);
}
struct sg_table *nv_drm_gem_prime_get_sg_table(struct drm_gem_object *gem)
diff --git a/nvidia-drm/nvidia-drm-gem.h b/nvidia-drm/nvidia-drm-gem.h
index c3cb875..c4da335 100644
--- a/nvidia-drm/nvidia-drm-gem.h
+++ b/nvidia-drm/nvidia-drm-gem.h
@@ -156,8 +156,7 @@ done:
void nv_drm_gem_free(struct drm_gem_object *gem);
-struct dma_buf *nv_drm_gem_prime_export(struct drm_device *dev,
- struct drm_gem_object *gem, int flags);
+struct dma_buf *nv_drm_gem_prime_export(struct drm_gem_object *gem, int flags);
static inline struct nv_drm_gem_object *nv_drm_gem_object_lookup(
struct drm_device *dev,