FROMGIT: dma-mapping: add a dma_need_unmap helper
Add helper that allows a driver to skip calling dma_unmap_* if the DMA layer can guarantee that they are no-nops. Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Jens Axboe <axboe@kernel.dk> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> (cherry picked from commit 5f3b133a23c545272b6bc1e818a5a35e1ca84b1e https://git.kernel.org/pub/scm/linux/kernel/git/mszyprowski/linux.git) Bug: 416098329 Change-Id: I21b5eda3fda17ff4223a5f9a8826cbd26ac3b001
This commit is contained in:
committed by
Carlos Llamas
parent
66bc206d64
commit
26405baef4
@@ -410,6 +410,7 @@ static inline bool dma_need_sync(struct device *dev, dma_addr_t dma_addr)
|
|||||||
{
|
{
|
||||||
return dma_dev_need_sync(dev) ? __dma_need_sync(dev, dma_addr) : false;
|
return dma_dev_need_sync(dev) ? __dma_need_sync(dev, dma_addr) : false;
|
||||||
}
|
}
|
||||||
|
bool dma_need_unmap(struct device *dev);
|
||||||
#else /* !CONFIG_HAS_DMA || !CONFIG_DMA_NEED_SYNC */
|
#else /* !CONFIG_HAS_DMA || !CONFIG_DMA_NEED_SYNC */
|
||||||
static inline bool dma_dev_need_sync(const struct device *dev)
|
static inline bool dma_dev_need_sync(const struct device *dev)
|
||||||
{
|
{
|
||||||
@@ -435,6 +436,10 @@ static inline bool dma_need_sync(struct device *dev, dma_addr_t dma_addr)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
static inline bool dma_need_unmap(struct device *dev)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endif /* !CONFIG_HAS_DMA || !CONFIG_DMA_NEED_SYNC */
|
#endif /* !CONFIG_HAS_DMA || !CONFIG_DMA_NEED_SYNC */
|
||||||
|
|
||||||
struct page *dma_alloc_pages(struct device *dev, size_t size,
|
struct page *dma_alloc_pages(struct device *dev, size_t size,
|
||||||
|
|||||||
@@ -442,6 +442,24 @@ bool __dma_need_sync(struct device *dev, dma_addr_t dma_addr)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__dma_need_sync);
|
EXPORT_SYMBOL_GPL(__dma_need_sync);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dma_need_unmap - does this device need dma_unmap_* operations
|
||||||
|
* @dev: device to check
|
||||||
|
*
|
||||||
|
* If this function returns %false, drivers can skip calling dma_unmap_* after
|
||||||
|
* finishing an I/O. This function must be called after all mappings that might
|
||||||
|
* need to be unmapped have been performed.
|
||||||
|
*/
|
||||||
|
bool dma_need_unmap(struct device *dev)
|
||||||
|
{
|
||||||
|
if (!dma_map_direct(dev, get_dma_ops(dev)))
|
||||||
|
return true;
|
||||||
|
if (!dev->dma_skip_sync)
|
||||||
|
return true;
|
||||||
|
return IS_ENABLED(CONFIG_DMA_API_DEBUG);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dma_need_unmap);
|
||||||
|
|
||||||
static void dma_setup_need_sync(struct device *dev)
|
static void dma_setup_need_sync(struct device *dev)
|
||||||
{
|
{
|
||||||
const struct dma_map_ops *ops = get_dma_ops(dev);
|
const struct dma_map_ops *ops = get_dma_ops(dev);
|
||||||
|
|||||||
Reference in New Issue
Block a user