Skip to content

Commit e02f5c1

Browse files
Ard BiesheuvelChristianKoenigAMD
authored andcommitted
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>
1 parent 6198f40 commit e02f5c1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

include/drm/drm_cache.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ static inline bool drm_arch_can_wc_memory(void)
4747
return false;
4848
#elif defined(CONFIG_MIPS) && defined(CONFIG_CPU_LOONGSON3)
4949
return false;
50+
#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
51+
/*
52+
* The DRM driver stack is designed to work with cache coherent devices
53+
* only, but permits an optimization to be enabled in some cases, where
54+
* for some buffers, both the CPU and the GPU use uncached mappings,
55+
* removing the need for DMA snooping and allocation in the CPU caches.
56+
*
57+
* The use of uncached GPU mappings relies on the correct implementation
58+
* of the PCIe NoSnoop TLP attribute by the platform, otherwise the GPU
59+
* will use cached mappings nonetheless. On x86 platforms, this does not
60+
* seem to matter, as uncached CPU mappings will snoop the caches in any
61+
* case. However, on ARM and arm64, enabling this optimization on a
62+
* platform where NoSnoop is ignored results in loss of coherency, which
63+
* breaks correct operation of the device. Since we have no way of
64+
* detecting whether NoSnoop works or not, just disable this
65+
* optimization entirely for ARM and arm64.
66+
*/
67+
return false;
5068
#else
5169
return true;
5270
#endif

0 commit comments

Comments
 (0)