Skip to content

Commit b866455

Browse files
author
Christoph Hellwig
committed
dma-mapping: add a dma_addressing_limited helper
This helper returns if the device has issues addressing all present memory in the system. Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 9087c37 commit b866455

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/linux/dma-mapping.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,20 @@ static inline int dma_coerce_mask_and_coherent(struct device *dev, u64 mask)
679679
return dma_set_mask_and_coherent(dev, mask);
680680
}
681681

682+
/**
683+
* dma_addressing_limited - return if the device is addressing limited
684+
* @dev: device to check
685+
*
686+
* Return %true if the devices DMA mask is too small to address all memory in
687+
* the system, else %false. Lack of addressing bits is the prime reason for
688+
* bounce buffering, but might not be the only one.
689+
*/
690+
static inline bool dma_addressing_limited(struct device *dev)
691+
{
692+
return min_not_zero(*dev->dma_mask, dev->bus_dma_mask) <
693+
dma_get_required_mask(dev);
694+
}
695+
682696
#ifdef CONFIG_ARCH_HAS_SETUP_DMA_OPS
683697
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
684698
const struct iommu_ops *iommu, bool coherent);

0 commit comments

Comments
 (0)