Files
twx-linux/include/linux
Simon Xue ed2c9c09f4 dma-buf: dma-buf-cache: fix concurrency issue
The same dma-buf may attach/map on different cpu at the same time,
this lead to concurrency issue. Add mutex lock to make dma-buf-cache
thread-safe

		cpu1					cpu2
		|					|
	dma_buf_cache_map_attachment		dma_buf_cache_map_attachment
		|					|
	dma_buf_map_attachment			dma_buf_map_attachment
		|					|
	system_heap_map_dma_buf			system_heap_map_dma_buf
		|					|
	iommu_dma_map_sg			iommu_dma_map_sg
		|					|
	__finalise_sg				__finalise_sg
		|					|
	sg_dma_address(sg) = iova1			|
		|					|
	cache->sg_table = sg_table		sg_dma_address(sg) = iova2 + iova1

after add mutex lock

		cpu1					cpu2
		|					|
	dma_buf_cache_map_attachment		dma_buf_cache_map_attachment
		|					|
	mutex_lock				mutex_lock
		|					|
	dma_buf_map_attachment			return cache->sg_table
		|					|
	system_heap_map_dma_buf			mutex_unlock
		|
	iommu_dma_map_sg
		|
	__finalise_sg
		|
	sg_dma_address(sg) = iova1
		|
	cache->sg_table = sg_table
		|
	mutex_unlock

Change-Id: I2e08dafe61668ce35467b2c3b074f132f08ed6ba
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2023-02-23 10:22:23 +08:00
..
2023-01-03 18:07:33 +08:00
2022-07-22 16:14:12 +08:00