amshafer / nvidia-driver

Fork of the Nvidia FreeBSD driver to port the nvidia-drm.ko module from Linux
44 stars 5 forks source link

dma-mapping.h:20:1: error: redefinition of 'dma_map_sgtable' #5

Closed iron-udjin closed 1 year ago

iron-udjin commented 1 year ago

13.1-STABLE n253290-47f21d91808c

Steps to reproduce:

$ cd ~apps
$ git clone https://github.com/freebsd/drm-kmod
$ git clone https://github.com/amshafer/nvidia-driver
$ cd nvidia-driver/nvidia
$ env DRMKMODDIR=/home/iron/apps/drm-kmod make

Result:

Warning: Object directory not changed from original /usr/home/iron/apps/nvidia-driver/nvidia/src/nvidia-drm
cc  -O2 -pipe -O2 -pipe -march=native -g -O0 -Wno-visibility -Wno-error=unused-but-set-variable -DNV_VERSION_STRING=\"525.53\" -Werror=undef -D_KERNEL -DKLD_MODULE -nostdinc -Wno-cast-qual -Wno-incompatible-pointer-types-discards-qualifiers  -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc  -Imachine -I/usr/src/sys/sys -I/usr/include -I../common/inc -I/home/iron/apps/drm-kmod/linuxkpi/bsd/include -I/home/iron/apps/drm-kmod/linuxkpi/gplv2/include/ -I/usr/src/sys/compat/linuxkpi/common/include/ -I/home/iron/apps/drm-kmod/linuxkpi/dummy/include/ -I/home/iron/apps/drm-kmod/include/ -I/home/iron/apps/drm-kmod/include/uapi/ -I/home/iron/apps/drm-kmod/drivers/gpu/ -I/usr/src/sys/contrib/ck/include -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -I../nvidia/ -include /usr/home/iron/apps/nvidia-driver/nvidia/src/nvidia-drm/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include     -MD  -MF.depend.nvidia-drm-connector.o -MTnvidia-drm-connector.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-address-of-packed-member -Wno-error=unused-but-set-variable -Wno-format-zero-length   -mno-aes -mno-avx  -std=iso9899:1999 -c nvidia-drm-connector.c -o nvidia-drm-connector.o
In file included from nvidia-drm-connector.c:23:
In file included from ./nvidia-drm-conftest.h:84:
In file included from /home/iron/apps/drm-kmod/include/drm/drm_gem.h:44:
In file included from /home/iron/apps/drm-kmod/include/drm/drm_vma_manager.h:26:
In file included from /home/iron/apps/drm-kmod/include/drm/drm_mm.h:49:
In file included from /home/iron/apps/drm-kmod/include/drm/drm_print.h:35:
In file included from /home/iron/apps/drm-kmod/include/uapi/drm/drm.h:69:
In file included from /home/iron/apps/drm-kmod/drivers/gpu/drm/drm_os_freebsd.h:17:
In file included from /home/iron/apps/drm-kmod/linuxkpi/gplv2/include/linux/fb.h:10:
In file included from /home/iron/apps/drm-kmod/linuxkpi/gplv2/include/linux/pci.h:10:
In file included from /usr/src/sys/compat/linuxkpi/common/include/linux/pci.h:56:
/home/iron/apps/drm-kmod/linuxkpi/bsd/include/linux/dma-mapping.h:20:1: error: redefinition of 'dma_map_sgtable'
dma_map_sgtable(struct device *dev, struct sg_table *sgt,
^
/usr/src/sys/compat/linuxkpi/common/include/linux/dma-mapping.h:356:1: note: previous definition is here
dma_map_sgtable(struct device *dev, struct sg_table *sgt,
^
In file included from nvidia-drm-connector.c:23:
In file included from ./nvidia-drm-conftest.h:84:
In file included from /home/iron/apps/drm-kmod/include/drm/drm_gem.h:44:
In file included from /home/iron/apps/drm-kmod/include/drm/drm_vma_manager.h:26:
In file included from /home/iron/apps/drm-kmod/include/drm/drm_mm.h:49:
In file included from /home/iron/apps/drm-kmod/include/drm/drm_print.h:35:
In file included from /home/iron/apps/drm-kmod/include/uapi/drm/drm.h:69:
In file included from /home/iron/apps/drm-kmod/drivers/gpu/drm/drm_os_freebsd.h:17:
In file included from /home/iron/apps/drm-kmod/linuxkpi/gplv2/include/linux/fb.h:10:
In file included from /home/iron/apps/drm-kmod/linuxkpi/gplv2/include/linux/pci.h:10:
In file included from /usr/src/sys/compat/linuxkpi/common/include/linux/pci.h:56:
/home/iron/apps/drm-kmod/linuxkpi/bsd/include/linux/dma-mapping.h:36:1: error: redefinition of 'dma_unmap_sgtable'
dma_unmap_sgtable(struct device *dev, struct sg_table *sgt,
^
/usr/src/sys/compat/linuxkpi/common/include/linux/dma-mapping.h:365:1: note: previous definition is here
dma_unmap_sgtable(struct device *dev, struct sg_table *sgt,
^
2 errors generated.
*** Error code 1
amshafer commented 1 year ago

Thanks for the report, I think what's happened here is some kind of conflict with __FreeBSD_version. uname -a should be able to tell what that number is for the installation iirc, or you can go track it down (it's in sys/param.h ). These dma functions are defined in both the FreeBSD src tree and drm-kmod, which one gets used depends on if the source tree has a high enough __FreeBSD_version to signify that it has the definitions.

Basically I think what's happened is your src tree doesn't match your installation. According to the version string you linked your __FreeBSD_version is 1301510. I think your source tree has a newer version that contains these definitions (i.e. you checked out CURRENT in /usr/src) while the base system has the version I just mentioned. This leads to both being present and the error you see. Could you please check that your /usr/src/sys/sys/param.h matches /usr/include/sys/param.h by grepping for __FreeBSD_version?

iron-udjin commented 1 year ago
# uname -a
FreeBSD IRON 13.1-STABLE FreeBSD 13.1-STABLE #5 stable/13-n253339-39db0c62b210: Wed Dec 28 20:26:46 EET 2022     root@IRON:/usr/obj/usr/src/amd64.amd64/sys/IRON amd64
# cd /usr/src && git branch
* stable/13
# git log | head -1
commit 39db0c62b2104753c196fd1cb7257f33a95ce10f
# diff -Naur /usr/src/sys/sys/param.h /usr/include/sys/param.h
# (no output)

So... nothing wrong with the OS version and source tree.

amshafer commented 1 year ago

What branch are you using on drm-kmod? It sounds like you are using master, which is only supported on CURRENT, you should use 5.10-lts instead.

iron-udjin commented 1 year ago

Yes, I use master branch. As described in README I just did: git clone https://github.com/freebsd/drm-kmod There were no mention about other branches to use.

iron-udjin commented 1 year ago

With 5.10-lts branch it has been compiled fine. Please update documentation to reflect proper branches to use in the build process. Thank you!

amshafer commented 1 year ago

Right, sorry so far I've only been running current. Updated