dma-mapping.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef _ASM_S390_DMA_MAPPING_H
  2. #define _ASM_S390_DMA_MAPPING_H
  3. #include <linux/kernel.h>
  4. #include <linux/types.h>
  5. #include <linux/mm.h>
  6. #include <linux/scatterlist.h>
  7. #include <linux/dma-attrs.h>
  8. #include <linux/dma-debug.h>
  9. #include <linux/io.h>
  10. #define DMA_ERROR_CODE (~(dma_addr_t) 0x0)
  11. extern struct dma_map_ops s390_dma_ops;
  12. static inline struct dma_map_ops *get_dma_ops(struct device *dev)
  13. {
  14. return &s390_dma_ops;
  15. }
  16. extern int dma_set_mask(struct device *dev, u64 mask);
  17. extern int dma_is_consistent(struct device *dev, dma_addr_t dma_handle);
  18. static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
  19. enum dma_data_direction direction)
  20. {
  21. }
  22. #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
  23. #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
  24. #include <asm-generic/dma-mapping-common.h>
  25. static inline int dma_supported(struct device *dev, u64 mask)
  26. {
  27. struct dma_map_ops *dma_ops = get_dma_ops(dev);
  28. if (dma_ops->dma_supported == NULL)
  29. return 1;
  30. return dma_ops->dma_supported(dev, mask);
  31. }
  32. static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
  33. {
  34. if (!dev->dma_mask)
  35. return 0;
  36. return addr + size - 1 <= *dev->dma_mask;
  37. }
  38. static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
  39. {
  40. struct dma_map_ops *dma_ops = get_dma_ops(dev);
  41. if (dma_ops->mapping_error)
  42. return dma_ops->mapping_error(dev, dma_addr);
  43. return (dma_addr == 0UL);
  44. }
  45. static inline void *dma_alloc_coherent(struct device *dev, size_t size,
  46. dma_addr_t *dma_handle, gfp_t flag)
  47. {
  48. struct dma_map_ops *ops = get_dma_ops(dev);
  49. void *ret;
  50. ret = ops->alloc(dev, size, dma_handle, flag, NULL);
  51. debug_dma_alloc_coherent(dev, size, *dma_handle, ret);
  52. return ret;
  53. }
  54. static inline void dma_free_coherent(struct device *dev, size_t size,
  55. void *cpu_addr, dma_addr_t dma_handle)
  56. {
  57. struct dma_map_ops *dma_ops = get_dma_ops(dev);
  58. dma_ops->free(dev, size, cpu_addr, dma_handle, NULL);
  59. debug_dma_free_coherent(dev, size, cpu_addr, dma_handle);
  60. }
  61. #endif /* _ASM_S390_DMA_MAPPING_H */