Skip to content

Build radeon+amdgpu on aarch64 #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 30, 2019

Conversation

valpackett
Copy link
Contributor

first-ever-freebsd-aarch64-amdgpu

It works!!

Requires: D20787 and D20789

Tested on: Marvell MACCHIATObin + AMD Radeon RX 480

@@ -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

@zeising
Copy link
Member

zeising commented Jun 29, 2019

How does this relate to the work manu@ is doing? I know he's also working on DRM for arm64 stuff.

@valpackett
Copy link
Contributor Author

@zeising the recent allwinner work? Yeah, it's quite different — @evadot made a from-scratch BSD-licensed driver for the Allwinner display engine, and it's based on drmlib which is an import of linuxkpi-gplv2 stuff etc. into FreeBSD base, and currently still has some GPL code in base as I understand. The rationale is that the various single board computers should have display support out of the box, without installing a package.

Meanwhile this is a tested small patch that enables AMD Radeon support on desktop-class arm64 systems.

@zeising
Copy link
Member

zeising commented Jun 30, 2019

@zeising the recent allwinner work? Yeah, it's quite different — @evadot made a from-scratch BSD-licensed driver for the Allwinner display engine, and it's based on drmlib which is an import of linuxkpi-gplv2 stuff etc. into FreeBSD base, and currently still has some GPL code in base as I understand. The rationale is that the various single board computers should have display support out of the box, without installing a package.

Meanwhile this is a tested small patch that enables AMD Radeon support on desktop-class arm64 systems.

Thank you for the explanation!

@valpackett
Copy link
Contributor Author

valpackett commented Jul 1, 2019

hi

wayfire says hello! with some buffer corruption on client applications (that goes away and reappears occasionally), but i've heard about that on linux, so that's not freebsd's fault

UPD: it's this: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923723 let's backport this tiny patch

better now

wf-aa64-fs8

:)

@valpackett
Copy link
Contributor Author

Update: we also need to use MSI (old in-tree DRM did, btw!!) instead of legacy interrupts, because legacy is a disaster on aarch64 (I've been getting an interrupt rate of 300000, which was wasting CPU time and reducing responsiveness/performance). (This is not a GPU-exclusive thing, on a KVM VPS I've had MSI blacklisted for some reason and legacy interrupts resulted in horrible virtio disk performance :D)

https://reviews.freebsd.org/D21008 — kernel patch for implementing the enable/disable functions. (updates are required in here too, but I haven't pushed that yet)

@valpackett
Copy link
Contributor Author

and here's a screenshot with something you might recognize :)

G A M I N G

@andreasdr
Copy link

andreasdr commented Jul 20, 2019 via email

@valpackett valpackett force-pushed the drm-v5.0-aarch64 branch 3 times, most recently from 3fca783 to 1539c66 Compare August 7, 2019 01:02
@zeising
Copy link
Member

zeising commented Aug 7, 2019

Is #163 a prerequisite for this?

@valpackett
Copy link
Contributor Author

Not really, #163 improves performance but is not required to build. The prerequisites are the kernel patches linked in the first post.

@zeising
Copy link
Member

zeising commented Aug 7, 2019

Ok, thank you!
Is there an ordering thing here? Will this build without the kernel update? Will drm-kmod build with the kernel update but not this?

I'm just asking because I need to know in which order things need to happen, and preferably, it would be good to keep backwards compat, meaning that with your kernel update, older versions of drm-kmod works (on at least the arches that worked before).

@valpackett
Copy link
Contributor Author

valpackett commented Aug 7, 2019

On aarch64, both the kernel update and this are required obviously. But it's not like aarch64 was enabled already :)

On amd64, i386, powerpc64 everything should build as normal, the kernel update doesn't touch them.

Would be nice if someone retested on power with this though.

@zeising
Copy link
Member

zeising commented Aug 7, 2019

Noted, thanks!

@valpackett
Copy link
Contributor Author

valpackett commented Aug 9, 2019

New test results: with a Cape Verde XT card, which is recognized by the EFI GOP driver (Polaris for some reason is just ignored, I'll contact AMD about that), even switching from efifb to amdgpu fb works :)

Also this card allows me to test radeonkms too. It works.

UPD: lol, my Polaris card was ignored because the VBIOS was modified (for performance)

@@ -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?

@@ -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

Upstream only builds it on amd64 for now, and it was not doing anything
on POWER since CONFIG_DRM_AMD_DC_DCN1_0 is ifdef'd to amd64.
…6/amd64

AGP files were built on POWER (which was successful due to old PowerPC
Mac stuff in tree), but CONFIG_AGP was not enabled so drivers did not
actually use AGP.

On aarch64, agp is completely absent, so depending on the module is not
possible.
valpackett and others added 2 commits August 28, 2019 20:03
Tested on: Marvell MACCHIATObin + AMD Radeon RX 480 (POLARIS10)
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.

Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: David Zhou <David1.Zhou@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Junwei Zhang <Jerry.Zhang@amd.com>
Cc: Michel Daenzer <michel.daenzer@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: amd-gfx list <amd-gfx@lists.freedesktop.org>
Cc: dri-devel <dri-devel@lists.freedesktop.org>
Reported-by: Carsten Haitzler <Carsten.Haitzler@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.kernel.org/patch/10778815/
Signed-off-by: Christian König <christian.koenig@amd.com>
@johalun johalun merged commit 4ec15b7 into FreeBSDDesktop:drm-v5.0 Aug 30, 2019
evadot pushed a commit to evadot/kms-drm that referenced this pull request May 5, 2020
* amdgpu: only build DML (Display Mode Library) on amd64

Upstream only builds it on amd64 for now, and it was not doing anything
on POWER since CONFIG_DRM_AMD_DC_DCN1_0 is ifdef'd to amd64.

* Use CONFIG_AGP for agp module dependency, only build agp files on i386/amd64

AGP files were built on POWER (which was successful due to old PowerPC
Mac stuff in tree), but CONFIG_AGP was not enabled so drivers did not
actually use AGP.

On aarch64, agp is completely absent, so depending on the module is not
possible.

* linux_notifier: use CONFIG_ACPI instead of X86 to check for ACPI

ACPI is available on aarch64.

* drm: disable uncached DMA optimization for ARM and 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.

Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: David Zhou <David1.Zhou@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: Junwei Zhang <Jerry.Zhang@amd.com>
Cc: Michel Daenzer <michel.daenzer@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: amd-gfx list <amd-gfx@lists.freedesktop.org>
Cc: dri-devel <dri-devel@lists.freedesktop.org>
Reported-by: Carsten Haitzler <Carsten.Haitzler@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.kernel.org/patch/10778815/
Signed-off-by: Christian König <christian.koenig@amd.com>

* Enable radeon+amdgpu on aarch64

Tested on: Marvell MACCHIATObin + AMD Radeon RX 480 (POLARIS10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants