ttm_kmap_iter.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright © 2021 Intel Corporation
  4. */
  5. #ifndef __TTM_KMAP_ITER_H__
  6. #define __TTM_KMAP_ITER_H__
  7. #include <linux/types.h>
  8. struct ttm_kmap_iter;
  9. struct iosys_map;
  10. /**
  11. * struct ttm_kmap_iter_ops - Ops structure for a struct
  12. * ttm_kmap_iter.
  13. * @maps_tt: Whether the iterator maps TT memory directly, as opposed
  14. * mapping a TT through an aperture. Both these modes have
  15. * struct ttm_resource_manager::use_tt set, but the latter typically
  16. * returns is_iomem == true from ttm_mem_io_reserve.
  17. */
  18. struct ttm_kmap_iter_ops {
  19. /**
  20. * kmap_local() - Map a PAGE_SIZE part of the resource using
  21. * kmap_local semantics.
  22. * @res_iter: Pointer to the struct ttm_kmap_iter representing
  23. * the resource.
  24. * @dmap: The struct iosys_map holding the virtual address after
  25. * the operation.
  26. * @i: The location within the resource to map. PAGE_SIZE granularity.
  27. */
  28. void (*map_local)(struct ttm_kmap_iter *res_iter,
  29. struct iosys_map *dmap, pgoff_t i);
  30. /**
  31. * unmap_local() - Unmap a PAGE_SIZE part of the resource previously
  32. * mapped using kmap_local.
  33. * @res_iter: Pointer to the struct ttm_kmap_iter representing
  34. * the resource.
  35. * @dmap: The struct iosys_map holding the virtual address after
  36. * the operation.
  37. */
  38. void (*unmap_local)(struct ttm_kmap_iter *res_iter,
  39. struct iosys_map *dmap);
  40. bool maps_tt;
  41. };
  42. /**
  43. * struct ttm_kmap_iter - Iterator for kmap_local type operations on a
  44. * resource.
  45. * @ops: Pointer to the operations struct.
  46. *
  47. * This struct is intended to be embedded in a resource-specific specialization
  48. * implementing operations for the resource.
  49. *
  50. * Nothing stops us from extending the operations to vmap, vmap_pfn etc,
  51. * replacing some or parts of the ttm_bo_util. cpu-map functionality.
  52. */
  53. struct ttm_kmap_iter {
  54. const struct ttm_kmap_iter_ops *ops;
  55. };
  56. #endif /* __TTM_KMAP_ITER_H__ */