BACKPORT: FROMLIST: drm/ttm: save the device's DMA coherency status in ttm_device

Currently TTM utilizes cached memory regardless of whether the device
have full DMA coherency (can snoop CPU cache).

Save the device's DMA coherency status in struct ttm_device, to allow
further support of devices w/o snooping capability (the capability
missing on at least one part of the transmission between the CPU and the
device).

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
Link: https://lore.kernel.org/r/20240629052247.2653363-2-uwu@icenowy.me
[ Han Gao: add conditional compilation for dma_coherent ]
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
This commit is contained in:
2024-06-29 13:22:46 +08:00
committed by Han Gao
parent a687990d16
commit fc5d914ad1
2 changed files with 15 additions and 0 deletions

View File

@@ -246,6 +246,12 @@ int ttm_device_init(struct ttm_device *bdev, const struct ttm_device_funcs *func
list_add_tail(&bdev->device_list, &glob->device_list);
mutex_unlock(&ttm_global_mutex);
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
bdev->dma_coherent = dev->dma_coherent;
#endif
return 0;
}
EXPORT_SYMBOL(ttm_device_init);

View File

@@ -225,6 +225,15 @@ struct ttm_device {
*/
const struct ttm_device_funcs *funcs;
#if defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
/**
* @dma_coherent: if the device backed is dma-coherent.
*/
bool dma_coherent;
#endif
/**
* @sysman: Resource manager for the system domain.
* Access via ttm_manager_type.