Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions amd/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# $FreeBSD$

.if ${MACHINE_CPUARCH} == "amd64"
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_ARCH} == "powerpc64"
_amdgpu= amdgpu
# _amdkfd= amdkfd
.endif

.if ${MACHINE_ARCH} == "powerpc64"
_amdgpu= amdgpu
.if ${MACHINE_CPUARCH} == "amd64"
# _amdkfd= amdkfd
.endif

SUBDIR= ${_amdgpu} \
Expand Down
46 changes: 21 additions & 25 deletions amd/amdgpu/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ DRM= ${.CURDIR:H:H}/drivers/gpu/drm

KMOD= amdgpu

.if ${MACHINE_CPUARCH} == "amd64"
_dml= ${SRCDIR}/display/dc/dml
.endif

.PATH: ${SRCDIR}/acp \
${SRCDIR}/amdgpu \
${SRCDIR}/amdkfd \
Expand All @@ -25,7 +29,7 @@ KMOD= amdgpu
${SRCDIR}/display/dc/dce120 \
${SRCDIR}/display/dc/dce80 \
${SRCDIR}/display/dc/dcn10 \
${SRCDIR}/display/dc/dml \
${_dml} \
${SRCDIR}/display/dc/gpio \
${SRCDIR}/display/dc/gpio/dce110 \
${SRCDIR}/display/dc/gpio/dce120 \
Expand Down Expand Up @@ -196,10 +200,14 @@ SRCS+= amdgpu_afmt.c \
vcn_v1_0.c \
vega10_ih.c \
vi.c

.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "aarch64"
SRCS+= amdgpu_acpi.c \
amdgpu_atpx_handler.c
.endif

.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= amdgpu_acpi.c \
amdgpu_atpx_handler.c \
dcn10_clk_mgr.c \
SRCS+= dcn10_clk_mgr.c \
dcn10_cm_common.c \
dcn10_dpp.c \
dcn10_dpp_cm.c \
Expand Down Expand Up @@ -297,11 +305,6 @@ SRCS+= amdgpu_dm.c \
dce_scl_filters.c \
dce_stream_encoder.c \
dce_transform.c \
dcn_calc_math.c \
display_mode_lib.c \
display_rq_dlg_helpers.c \
dml1_display_rq_dlg_calc.c \
dml_common_defs.c \
engine_base.c \
fixpt31_32.c \
freesync.c \
Expand Down Expand Up @@ -349,6 +352,14 @@ SRCS+= amdgpu_dm.c \
virtual_link_encoder.c \
virtual_stream_encoder.c

.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= display_mode_lib.c \
dcn_calc_math.c \
display_rq_dlg_helpers.c \
dml_common_defs.c \
dml1_display_rq_dlg_calc.c
.endif

# lib
SRCS+= chash.c

Expand Down Expand Up @@ -435,21 +446,8 @@ SRCS+= device_if.h vnode_if.h bus_if.h pci_if.h device_if.h iicbus_if.h opt_drm.

.include <bsd.kmod.mk>

CFLAGS.gcc+= -Wno-redundant-decls -Wno-cast-qual -Wno-unused-but-set-variable
.if ${MACHINE_CPUARCH} == "powerpc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you remove all the powerpc stuff?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've explained this in the commit message. This part of the code (DML) is not used on powerpc because

#ifdef __amd64__
#define CONFIG_DRM_AMD_DC_DCN1_0 1
#endif

Upstream only builds it on amd64 torvalds/linux@bf2e2e2

IIUC, this code is only for Raven Ridge laptops

CFLAGS.dcn_calcs.c= -maltivec -mhard-float -mfull-toc
CFLAGS.dcn_calc_auto.c= -maltivec -mhard-float -mfull-toc
CFLAGS.dcn_calc_math.c= -maltivec -mhard-float -mfull-toc
CFLAGS.gcc+= -Wno-redundant-decls -Wno-unused-but-set-variable

CFLAGS.display_mode_vba.c= -maltivec -mhard-float -mfull-toc
CFLAGS.display_mode_lib.c= -maltivec -mhard-float -mfull-toc
CFLAGS.display_pipe_clocks.c= -maltivec -mhard-float -mfull-toc
CFLAGS.display_rq_dlg_calc.c= -maltivec -mhard-float -mfull-toc
CFLAGS.dml1_display_rq_dlg_calc.c= -maltivec -mhard-float -mfull-toc
CFLAGS.display_rq_dlg_helpers.c= -maltivec -mhard-float -mfull-toc
CFLAGS.soc_bounding_box.c= -maltivec -mhard-float -mfull-toc
CFLAGS.dml_common_defs.c= -maltivec -mhard-float -mfull-toc
.else
CFLAGS.dcn_calcs.c= -msse -mstack-alignment=4
CFLAGS.dcn_calc_auto.c= -msse -mstack-alignment=4
CFLAGS.dcn_calc_math.c= -msse -mstack-alignment=4 -Wno-tautological-compare
Expand All @@ -462,8 +460,6 @@ CFLAGS.soc_bounding_box.c= -msse -mstack-alignment=4
CFLAGS.dml_common_defs.c= -msse -mstack-alignment=4

CWARNFLAGS+= -Wno-pointer-arith -Wno-format -Wno-cast-qual
.endif
CWARNFLAGS+= -Wno-pointer-arith -Wno-format
CWARNFLAGS+= -Wno-pointer-sign ${CWARNFLAGS.${.IMPSRC:T}}
CWARNFLAGS+= -Wno-expansion-to-defined

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ __FBSDID("$FreeBSD$");

MODULE_DEPEND(amdgpu, drmn, 2, 2, 2);
MODULE_DEPEND(amdgpu, ttm, 1, 1, 1);
#ifdef CONFIG_AGP
MODULE_DEPEND(amdgpu, agp, 1, 1, 1);
#endif
MODULE_DEPEND(amdgpu, linuxkpi, 1, 1, 1);
MODULE_DEPEND(amdgpu, linuxkpi_gplv2, 1, 1, 1);
MODULE_DEPEND(amdgpu, firmware, 1, 1, 1);
Expand Down
12 changes: 10 additions & 2 deletions drivers/gpu/drm/drm_os_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,21 @@
#undef CONFIG_AS_MOVNTDQA
#endif


#ifdef __aarch64__
#define CONFIG_ARM64 1
#define CONFIG_PCI 1
#define CONFIG_ACPI 1
#undef CONFIG_ACPI_SLEEP
#undef CONFIG_DRM_I915_KMS
#undef CONFIG_INTEL_IOMMU
#undef CONFIG_AS_MOVNTDQA
#endif

#ifdef _KERNEL
#define __KERNEL__
#endif

#if !defined(__powerpc__)
#if !defined(__powerpc__) && !defined(__aarch64__)
#define CONFIG_AGP 1
#endif

Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/drm_os_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ static moduledata_t drm_mod = {

DECLARE_MODULE(drmn, drm_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
MODULE_VERSION(drmn, 2);
#ifdef CONFIG_AGP
MODULE_DEPEND(drmn, agp, 1, 1, 1);
#endif
MODULE_DEPEND(drmn, pci, 1, 1, 1);
MODULE_DEPEND(drmn, mem, 1, 1, 1);
MODULE_DEPEND(drmn, linuxkpi, 1, 1, 1);
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/radeon/radeon_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ __FBSDID("$FreeBSD$");

MODULE_DEPEND(radeonkms, drmn, 2, 2, 2);
MODULE_DEPEND(radeonkms, ttm, 1, 1, 1);
#ifdef CONFIG_AGP
MODULE_DEPEND(radeonkms, agp, 1, 1, 1);
#endif
MODULE_DEPEND(radeonkms, linuxkpi, 1, 1, 1);
MODULE_DEPEND(radeonkms, linuxkpi_gplv2, 1, 1, 1);
MODULE_DEPEND(radeonkms, firmware, 1, 1, 1);
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/ttm/ttm_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ MODULE_LICENSE("GPL and additional rights");
#else
LKPI_DRIVER_MODULE(ttm, ttm_init, ttm_exit);
MODULE_VERSION(ttm, 1);
#ifdef CONFIG_AGP
MODULE_DEPEND(ttm, agp, 1, 1, 1);
#endif
MODULE_DEPEND(ttm, drmn, 2, 2, 2);
MODULE_DEPEND(ttm, linuxkpi, 1, 1, 1);
MODULE_DEPEND(ttm, linuxkpi_gplv2, 1, 1, 1);
Expand Down
5 changes: 4 additions & 1 deletion drm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ SRCDIR= ${.CURDIR:H}/drivers/gpu/drm

KMOD= drm
SRCS= ati_pcigart.c \
drm_agpsupport.c \
drm_atomic.c \
drm_atomic_helper.c \
drm_atomic_state_helper.c \
Expand Down Expand Up @@ -86,6 +85,10 @@ SRCS= ati_pcigart.c \
tainted_linux_fb.c \
linux_hdmi.c

.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing powerpc

SRCS+= drm_agpsupport.c
.endif

# Skip for now...
# drm_dp_cec.c

Expand Down
18 changes: 18 additions & 0 deletions include/drm/drm_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ static inline bool drm_arch_can_wc_memory(void)
return false;
#elif defined(CONFIG_MIPS) && defined(CONFIG_CPU_LOONGSON3)
return false;
#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
/*
* The DRM driver stack is designed to work with cache coherent devices
* only, but permits an optimization to be enabled in some cases, where
* for some buffers, both the CPU and the GPU use uncached mappings,
* removing the need for DMA snooping and allocation in the CPU caches.
*
* The use of uncached GPU mappings relies on the correct implementation
* of the PCIe NoSnoop TLP attribute by the platform, otherwise the GPU
* will use cached mappings nonetheless. On x86 platforms, this does not
* seem to matter, as uncached CPU mappings will snoop the caches in any
* case. However, on ARM and arm64, enabling this optimization on a
* platform where NoSnoop is ignored results in loss of coherency, which
* breaks correct operation of the device. Since we have no way of
* detecting whether NoSnoop works or not, just disable this
* optimization entirely for ARM and arm64.
*/
return false;
#else
return true;
#endif
Expand Down
2 changes: 1 addition & 1 deletion linuxkpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SRCS= linux_kmod_gplv2.c \
SRCS+= linux_genalloc.c
.endif

.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "aarch64"
SRCS+= linux_acpi.c \
linux_video.c \
opt_acpi.h
Expand Down
2 changes: 1 addition & 1 deletion linuxkpi/gplv2/include/linux/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#if defined(__i386__) || defined(__amd64__)
#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__)
#ifndef _LINUX_GPLV2_ACPI_H_
#define _LINUX_GPLV2_ACPI_H_

Expand Down
2 changes: 1 addition & 1 deletion linuxkpi/gplv2/include/linux/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include_next <linux/io.h>

#if defined(__amd64__) || defined(__i386__) || defined(__powerpc__)
#if defined(__amd64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__)
extern int arch_io_reserve_memtype_wc(resource_size_t start, resource_size_t size);
extern void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size);
#endif
Expand Down
2 changes: 1 addition & 1 deletion linuxkpi/gplv2/include/linux/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <asm/processor.h>

#if defined(__i386__) || defined(__amd64__) || defined(__powerpc__)
#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__) || defined(__powerpc__)
#define NR_IRQS 512 /* XXX need correct value */
#else
#error "NR_IRQS not defined"
Expand Down
4 changes: 2 additions & 2 deletions linuxkpi/gplv2/src/linux_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$");

#include <linux/idr.h>

#if defined(__i386__) || defined(__amd64__)
#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__)
#include <linux/acpi.h>
#endif
#include <linux/device.h>
Expand Down Expand Up @@ -627,7 +627,7 @@ i2c_check_addr_busy(struct i2c_adapter *adapter, int addr)
static void i2c_dev_set_name(struct i2c_adapter *adap,
struct i2c_client *client)
{
#if defined(__i386__) || defined(__amd64__)
#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__)
struct acpi_device *adev = ACPI_COMPANION(&client->dev);

if (adev) {
Expand Down
8 changes: 2 additions & 6 deletions linuxkpi/gplv2/src/linux_notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
#include <linux/math64.h>
#include <linux/kernel.h>

#if defined(__amd64__) || defined(__i386__)
#define X86
#endif

#ifdef X86
#ifdef CONFIG_ACPI
#include <linux/acpi.h>
#include <acpi/button.h>
#endif
Expand Down Expand Up @@ -167,7 +163,7 @@ unregister_reboot_notifier(struct notifier_block *nb)
return (0);
}

#ifdef X86
#ifdef CONFIG_ACPI
int
acpi_lid_notifier_register(struct notifier_block *nb)
{
Expand Down
2 changes: 1 addition & 1 deletion radeon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ SRCS= atom.c \
vce_v1_0.c \
vce_v2_0.c

.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "aarch64"
SRCS+= opt_acpi.h \
radeon_acpi.c \
radeon_atpx_handler.c
Expand Down
7 changes: 5 additions & 2 deletions ttm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ SRCDIR= ${.CURDIR:H}/drivers/gpu/drm/ttm
.PATH: ${SRCDIR}

KMOD= ttm
SRCS= ttm_agp_backend.c \
ttm_bo.c \
SRCS= ttm_bo.c \
ttm_bo_manager.c \
ttm_bo_util.c \
ttm_bo_vm.c \
Expand All @@ -17,6 +16,10 @@ SRCS= ttm_agp_backend.c \
ttm_page_alloc_dma.c \
ttm_tt.c

.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think powerpc also needs this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think AGP was ever a thing on powerpc64? (and we don't yet run on 32-bit powerpc, right?)

https://github.com/myfreeweb/kms-drm/blob/drm-v5.0-aarch64/drivers/gpu/drm/drm_os_config.h#L62-L64 — it is disabled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be so.. Just don't want to break build on powerpc64. Did you try a powerpc64 cross build?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, is it possible to cross-build this? what are the args? TARGET/TARGET_ARCH seem to be ignored, MACHINE/MACHINE_ARCH just makes it think I'm on powerpc64

// maybe someone with POWER can test? (just that this patch doesn't break powerpc64) /cc @chmeeedalf @mattmacy @bdragon28 @kev009

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the last entry here: https://forums.freebsd.org/threads/cross-compiling-a-kernel-module.45662/
I think I did this before when compiling for i386. I'll give it try myself later today.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that didn't work at all for powerpc :(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early PowerMac G5s did have AGP. Only the last one or two generations had PCIe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, right. But AGP+powerpc is currently disabled here:

#if !defined(__powerpc__)
#define CONFIG_AGP 1
#endif

I think the AGP files should be in sync with the CONFIG_AGP variable. Does the module build on powerpc64 without these files?

SRCS+= ttm_agp_backend.c
.endif

CLEANFILES+= ${KMOD}.ko.full ${KMOD}.ko.debug

CFLAGS+= -I${.CURDIR:H}/linuxkpi/gplv2/include
Expand Down