Skip to content

Commit 5d8be3b

Browse files
committed
dma-buf: Make it a separate module
This will make it easier to test a BSD implementation. Sponsored by: Beckhoff Automation GmbH & Co. KG
1 parent ba1825b commit 5d8be3b

File tree

10 files changed

+73
-9
lines changed

10 files changed

+73
-9
lines changed

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
SYSDIR?=/usr/src/sys
44
.include "${SYSDIR}/conf/kern.opts.mk"
55

6-
_VALID_KMODS= linuxkpi ttm drm dummygfx i915 amd radeon
6+
_VALID_KMODS= dmabuf linuxkpi ttm drm dummygfx i915 amd radeon
77

88
SUPPORTED_ARCH= amd64 \
99
i386 \
@@ -17,7 +17,8 @@ SUPPORTED_ARCH= amd64 \
1717
.error "Unsupported architetures ${MACHINE_ARCH}"
1818
.endif
1919

20-
DEFAULT_KMODS= linuxkpi \
20+
DEFAULT_KMODS= dmabuf \
21+
linuxkpi \
2122
ttm \
2223
drm \
2324
amd \

dmabuf/Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
SRCDIR= ${.CURDIR:H}/drivers/dma-buf
2+
3+
.PATH: ${SRCDIR}
4+
5+
.include "../kconfig.mk"
6+
7+
KMOD= dmabuf
8+
SRCS= dma-buf-kmod.c \
9+
dma-buf.c \
10+
dma-fence-array.c \
11+
dma-fence-chain.c \
12+
dma-fence.c \
13+
dma-resv.c \
14+
sync_file.c
15+
16+
SRCS+= device_if.h \
17+
bus_if.h \
18+
vnode_if.h
19+
20+
CLEANFILES+= ${KMOD}.ko.full ${KMOD}.ko.debug
21+
22+
CFLAGS+= -I${.CURDIR:H}/linuxkpi/gplv2/include
23+
CFLAGS+= -I${.CURDIR:H}/linuxkpi/bsd/include
24+
CFLAGS+= -I${SYSDIR}/compat/linuxkpi/common/include
25+
CFLAGS+= -I${.CURDIR:H}/linuxkpi/dummy/include # fallback to dummy
26+
27+
CFLAGS+= '-DKBUILD_MODNAME="${KMOD}"'
28+
CFLAGS+= -DLINUXKPI_VERSION=50000
29+
CFLAGS+= ${KCONFIG:C/(.*)/-DCONFIG_\1/}
30+
31+
.include <bsd.kmod.mk>

drivers/dma-buf/dma-buf-kmod.c

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*-
2+
* Copyright (c) 2022 Beckhoff Automation GmbH & Co. KG
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23+
* SUCH DAMAGE.
24+
*
25+
*/
26+
27+
#include <sys/cdefs.h>
28+
__FBSDID("$FreeBSD$");
29+
30+
#include <sys/param.h>
31+
#include <sys/module.h>
32+
33+
MODULE_VERSION(dmabuf, 1);

drivers/gpu/drm/amd/amdgpu/amdgpu_freebsd.c

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ MODULE_DEPEND(amdgpu, drmn, 2, 2, 2);
88
MODULE_DEPEND(amdgpu, ttm, 1, 1, 1);
99
MODULE_DEPEND(amdgpu, linuxkpi, 1, 1, 1);
1010
MODULE_DEPEND(amdgpu, linuxkpi_gplv2, 1, 1, 1);
11+
MODULE_DEPEND(amdgpu, dmabuf, 1, 1, 1);
1112
MODULE_DEPEND(amdgpu, firmware, 1, 1, 1);
1213
#ifdef CONFIG_DEBUG_FS
1314
MODULE_DEPEND(amdgpu, debugfs, 1, 1, 1);

drivers/gpu/drm/drm_os_freebsd.c

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ MODULE_DEPEND(drmn, pci, 1, 1, 1);
253253
MODULE_DEPEND(drmn, mem, 1, 1, 1);
254254
MODULE_DEPEND(drmn, linuxkpi, 1, 1, 1);
255255
MODULE_DEPEND(drmn, linuxkpi_gplv2, 1, 1, 1);
256+
MODULE_DEPEND(drmn, dmabuf, 1, 1, 1);
256257
#ifdef CONFIG_DEBUG_FS
257258
MODULE_DEPEND(drmn, debugfs, 1, 1, 1);
258259
#endif

drivers/gpu/drm/i915/i915_pci.c

+1
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@ MODULE_DEPEND(i915kms, drmn, 2, 2, 2);
11331133
MODULE_DEPEND(i915kms, agp, 1, 1, 1);
11341134
MODULE_DEPEND(i915kms, linuxkpi, 1, 1, 1);
11351135
MODULE_DEPEND(i915kms, linuxkpi_gplv2, 1, 1, 1);
1136+
MODULE_DEPEND(i915kms, dmabuf, 1, 1, 1);
11361137
MODULE_DEPEND(i915kms, firmware, 1, 1, 1);
11371138
#ifdef CONFIG_DEBUG_FS
11381139
MODULE_DEPEND(i915kms, debugfs, 1, 1, 1);

drivers/gpu/drm/radeon/radeon_freebsd.c

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ MODULE_DEPEND(radeonkms, drmn, 2, 2, 2);
88
MODULE_DEPEND(radeonkms, ttm, 1, 1, 1);
99
MODULE_DEPEND(radeonkms, linuxkpi, 1, 1, 1);
1010
MODULE_DEPEND(radeonkms, linuxkpi_gplv2, 1, 1, 1);
11+
MODULE_DEPEND(radeonkms, dmabuf, 1, 1, 1);
1112
MODULE_DEPEND(radeonkms, firmware, 1, 1, 1);
1213
#ifdef CONFIG_DEBUG_FS
1314
MODULE_DEPEND(radeonkms, debugfs, 1, 1, 1);

drivers/gpu/drm/ttm/ttm_module.c

+1
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,5 @@ MODULE_VERSION(ttm, 1);
108108
MODULE_DEPEND(ttm, drmn, 2, 2, 2);
109109
MODULE_DEPEND(ttm, linuxkpi, 1, 1, 1);
110110
MODULE_DEPEND(ttm, linuxkpi_gplv2, 1, 1, 1);
111+
MODULE_DEPEND(ttm, dmabuf, 1, 1, 1);
111112
#endif

linuxkpi/Makefile

-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ SRCS= linux_kmod_gplv2.c \
99
linux_hdmi.c \
1010
linux_i2c.c
1111

12-
SRCS+= dma-buf.c \
13-
dma-fence-array.c \
14-
dma-fence-chain.c \
15-
dma-fence.c \
16-
dma-resv.c \
17-
sync_file.c
18-
1912
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "aarch64"
2013
SRCS+= opt_acpi.h
2114
.endif

linuxkpi/gplv2/src/linux_kmod_gplv2.c

+1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ __FBSDID("$FreeBSD$");
3232

3333
MODULE_VERSION(linuxkpi_gplv2, 1);
3434
MODULE_DEPEND(linuxkpi_gplv2, backlight, 1, 1, 1);
35+
MODULE_DEPEND(linuxkpi_gplv2, dmabuf, 1, 1, 1);
3536
MODULE_DEPEND(linuxkpi_gplv2, firmware, 1, 1, 1);
3637
MODULE_DEPEND(linuxkpi_gplv2, linuxkpi, 1, 1, 1);

0 commit comments

Comments
 (0)