dma-mapping-fast.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2019, 2021, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __LINUX_DMA_MAPPING_FAST_H
  6. #define __LINUX_DMA_MAPPING_FAST_H
  7. #include <linux/iommu.h>
  8. #include <linux/io-pgtable-fast.h>
  9. #include <linux/rbtree.h>
  10. #include <linux/mutex.h>
  11. struct dma_iommu_mapping;
  12. struct io_pgtable_ops;
  13. struct iova_domain;
  14. struct dma_fast_smmu_mapping {
  15. struct device *dev;
  16. struct iommu_domain *domain;
  17. struct iova_domain *iovad;
  18. dma_addr_t base;
  19. size_t size;
  20. size_t num_4k_pages;
  21. unsigned int bitmap_size;
  22. /* bitmap has 1s marked only valid mappings */
  23. unsigned long *bitmap;
  24. /* clean_bitmap has 1s marked for both valid and stale tlb mappings */
  25. unsigned long *clean_bitmap;
  26. unsigned long next_start;
  27. bool have_stale_tlbs;
  28. dma_addr_t pgtbl_dma_handle;
  29. struct io_pgtable_ops *pgtbl_ops;
  30. spinlock_t lock;
  31. struct notifier_block notifier;
  32. struct rb_node node;
  33. struct mutex msi_cookie_init_lock;
  34. };
  35. #ifdef CONFIG_IOMMU_IO_PGTABLE_FAST
  36. int fast_smmu_init_mapping(struct device *dev, struct iommu_domain *domain,
  37. struct io_pgtable_ops *pgtable_ops);
  38. void fast_smmu_put_dma_cookie(struct iommu_domain *domain);
  39. void fast_smmu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size);
  40. int __init dma_mapping_fast_init(void);
  41. #else
  42. static inline int fast_smmu_init_mapping(struct device *dev,
  43. struct iommu_domain *domain,
  44. struct io_pgtable_ops *pgtable_ops)
  45. {
  46. return -ENODEV;
  47. }
  48. static inline void fast_smmu_put_dma_cookie(struct iommu_domain *domain) {}
  49. static inline void fast_smmu_setup_dma_ops(struct device *dev, u64 dma_base, u64 size) {}
  50. static inline int __init dma_mapping_fast_init(void)
  51. {
  52. return 0;
  53. }
  54. #endif
  55. #endif /* __LINUX_DMA_MAPPING_FAST_H */