ttm_range_manager.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. #ifndef _TTM_RANGE_MANAGER_H_
  3. #define _TTM_RANGE_MANAGER_H_
  4. #include <drm/ttm/ttm_resource.h>
  5. #include <drm/ttm/ttm_device.h>
  6. #include <drm/drm_mm.h>
  7. /**
  8. * struct ttm_range_mgr_node
  9. *
  10. * @base: base clase we extend
  11. * @mm_nodes: MM nodes, usually 1
  12. *
  13. * Extending the ttm_resource object to manage an address space allocation with
  14. * one or more drm_mm_nodes.
  15. */
  16. struct ttm_range_mgr_node {
  17. struct ttm_resource base;
  18. struct drm_mm_node mm_nodes[];
  19. };
  20. /**
  21. * to_ttm_range_mgr_node
  22. *
  23. * @res: the resource to upcast
  24. *
  25. * Upcast the ttm_resource object into a ttm_range_mgr_node object.
  26. */
  27. static inline struct ttm_range_mgr_node *
  28. to_ttm_range_mgr_node(struct ttm_resource *res)
  29. {
  30. return container_of(res, struct ttm_range_mgr_node, base);
  31. }
  32. int ttm_range_man_init_nocheck(struct ttm_device *bdev,
  33. unsigned type, bool use_tt,
  34. unsigned long p_size);
  35. int ttm_range_man_fini_nocheck(struct ttm_device *bdev,
  36. unsigned type);
  37. static __always_inline int ttm_range_man_init(struct ttm_device *bdev,
  38. unsigned int type, bool use_tt,
  39. unsigned long p_size)
  40. {
  41. BUILD_BUG_ON(__builtin_constant_p(type) && type >= TTM_NUM_MEM_TYPES);
  42. return ttm_range_man_init_nocheck(bdev, type, use_tt, p_size);
  43. }
  44. static __always_inline int ttm_range_man_fini(struct ttm_device *bdev,
  45. unsigned int type)
  46. {
  47. BUILD_BUG_ON(__builtin_constant_p(type) && type >= TTM_NUM_MEM_TYPES);
  48. return ttm_range_man_fini_nocheck(bdev, type);
  49. }
  50. #endif