[PATCH] drm/radeon: make all PCI GPUs use 32 bits DMA bit mask

From: Thomas “illwieckz“ Debesse
Date: Thu Nov 05 2020 - 05:32:26 EST


I wish to be personally CC'ed the answers/comments posted to the list in
response to my posting.

This patch prevents to fail r600_ring_test on ATI PCI devices
hosted on K8 or K10 platforms, this error:

> [drm:r600_ring_test [radeon]] *ERROR* radeon:
>   ring 0 test failed (scratch(0x8504)=0xCAFEDEAD)
> radeon 0000:03:00.0: disabling GPU acceleration

and this error:

> trying to bind memory to uninitialized GART !

Such PCI hardware works correctly on Intel 82801
platform, so this change may be non-optimal for them
on non-K8/K10 platforms.

Initial code was testing for GPU chip families to choose
between 40 bits or 32 bits, it looks like a better code
would be to test for platforms (PCI bridge, maybe?).

This is not enough to fix PCI GPUs on K8 (K8T800) and
K10 (nForce3), also, non-ATI Nvidia PCI GPUs are affected
by at least one other unknown bug that may be in common.

This may also prevents the uninitialized GART error to occur
when ATI AGP cards run in PCI mode. This is not a call to
disable AGP, and other bug(s) leaves AGP hardware unusable
once AGP is disabled. Also this patch uncovers some other bugs
happening when AGP cards are driven as PCI ones.

I have probably reached my skill cap with this patch in regards to
the topic. This may help specialists to investigate further by giving
them an entry point.

I have access to some not-so-old still-relevant PCI GPUs by ATI
and Nvidia (TeraScale, Tesla 1.0, both OpenGL 3.3 capable) and
some K8 and K10 computers that can be purposed for testing
patches written by others in hope to get a complete fix one day.

See related bugs for details about GPUs, host platforms, and a
a lot of details and logs about issues faced:

- https://bugs.launchpad.net/bugs/1902795
> PCI graphics broken on AMD K8/K10 platform (while it works on Intel)
> verified from Linux 4.4 to 5.10-rc1

- https://bugs.launchpad.net/bugs/1902981
> AGP GPUs driven as PCI ones (when AGP is disabled at kernel build
> time) are known to fail on K8 and K10 platforms

- https://bugs.launchpad.net/bugs/1899304
> AGP disablement leaves GPUs without working alternative
> (PCI fallback is broken), makes very-capable ATI TeraScale GPUs
> unusable

--
Thomas “illwieckz” Debesse
From 13e3a45c319ab600ee4a2b9a1d892d9b6cd23243 Mon Sep 17 00:00:00 2001
From: Thomas Debesse <dev@xxxxxxxxxxxxx>
Date: Wed, 4 Nov 2020 06:03:27 +0100
Subject: [PATCH] drm/radeon: make all PCI GPUs use 32 bits DMA bit mask

Prevent to fail r600_ring_test on ATI PCI devices
hosted on K8 or K10 platforms, this error:

> [drm:r600_ring_test [radeon]] *ERROR* radeon:
> ring 0 test failed (scratch(0x8504)=0xCAFEDEAD)
> radeon 0000:03:00.0: disabling GPU acceleration

and this error:

> trying to bind memory to uninitialized GART !

Such PCI hardware works correctly on Intel 82801
platform, so this change may be non-optimal for them
on non-K8/K10 platforms.

Signed-off-by: Thomas Debesse <dev@xxxxxxxxxxxxx>
---
drivers/gpu/drm/radeon/radeon_device.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 266e3cbbd09b..b4cf4297d427 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1372,8 +1372,16 @@ int radeon_device_init(struct radeon_device *rdev,
dma_bits = 40;
if (rdev->flags & RADEON_IS_AGP)
dma_bits = 32;
- if ((rdev->flags & RADEON_IS_PCI) &&
- (rdev->family <= CHIP_RS740))
+ /* Some platforms may accept 40 bits for the same PCI hardware
+ * that would requires 32 bits on other ones.
+ * PCI ATI Radeon HD 4350 (RV710) is known to work with 40 bits
+ * on computers running Intel Eaglelake E5200 CPU with 82801 PCI
+ * bridge while 32 bits are required to not fail r600_ring_test
+ * on computers running AMD K8 Athlon 3200+ CPU with K8T800Pro
+ * VT8237/8251 PCI bridge and computers running AMD K10 Phenom II
+ * X4 970 with Nvidia nForce3 250Gb PCI bridge.
+ */
+ if (rdev->flags & RADEON_IS_PCI)
dma_bits = 32;
#ifdef CONFIG_PPC64
if (rdev->family == CHIP_CEDAR)
--
2.25.1

Attachment: OpenPGP_0xE06292933E2CA275.asc
Description: application/pgp-keys

Attachment: OpenPGP_signature
Description: OpenPGP digital signature