iommu-helper.h 911 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef _LINUX_IOMMU_HELPER_H
  2. #define _LINUX_IOMMU_HELPER_H
  3. #include <linux/kernel.h>
  4. static inline unsigned long iommu_device_max_index(unsigned long size,
  5. unsigned long offset,
  6. u64 dma_mask)
  7. {
  8. if (size + offset > dma_mask)
  9. return dma_mask - offset + 1;
  10. else
  11. return size;
  12. }
  13. extern int iommu_is_span_boundary(unsigned int index, unsigned int nr,
  14. unsigned long shift,
  15. unsigned long boundary_size);
  16. extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
  17. unsigned long start, unsigned int nr,
  18. unsigned long shift,
  19. unsigned long boundary_size,
  20. unsigned long align_mask);
  21. static inline unsigned long iommu_num_pages(unsigned long addr,
  22. unsigned long len,
  23. unsigned long io_page_size)
  24. {
  25. unsigned long size = (addr & (io_page_size - 1)) + len;
  26. return DIV_ROUND_UP(size, io_page_size);
  27. }
  28. #endif