Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: buffer-dma: support getting the DMA channel

Implement the .get_dma_dev() callback for DMA buffers by returning the
device that owns the DMA channel. This allows the core DMABUF
infrastructure to properly map DMA buffers using the correct device,
avoiding the need for bounce buffers on systems where memory is mapped
above the 32-bit range.

The function returns the DMA queue's device, which is the actual device
responsible for DMA operations in buffer-dma implementations.

Cc: stable@vger.kernel.org
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Nuno Sá and committed by
Jonathan Cameron
f9c198c3 a514bb10

+7
+6
drivers/iio/buffer/industrialio-buffer-dma.c
··· 786 786 } 787 787 EXPORT_SYMBOL_NS_GPL(iio_dma_buffer_enqueue_dmabuf, "IIO_DMA_BUFFER"); 788 788 789 + struct device *iio_dma_buffer_get_dma_dev(struct iio_buffer *buffer) 790 + { 791 + return iio_buffer_to_queue(buffer)->dev; 792 + } 793 + EXPORT_SYMBOL_NS_GPL(iio_dma_buffer_get_dma_dev, "IIO_DMA_BUFFER"); 794 + 789 795 void iio_dma_buffer_lock_queue(struct iio_buffer *buffer) 790 796 { 791 797 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer);
+1
include/linux/iio/buffer-dma.h
··· 174 174 size_t size, bool cyclic); 175 175 void iio_dma_buffer_lock_queue(struct iio_buffer *buffer); 176 176 void iio_dma_buffer_unlock_queue(struct iio_buffer *buffer); 177 + struct device *iio_dma_buffer_get_dma_dev(struct iio_buffer *buffer); 177 178 178 179 #endif