qcom_system_heap.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _QCOM_SYSTEM_HEAP_H
  7. #define _QCOM_SYSTEM_HEAP_H
  8. #include <linux/dma-heap.h>
  9. #include <linux/err.h>
  10. #include "qcom_sg_ops.h"
  11. #include "qcom_dynamic_page_pool.h"
  12. #include "qcom_sg_ops.h"
  13. struct qcom_system_heap {
  14. int uncached;
  15. struct dynamic_page_pool **pool_list;
  16. atomic_long_t total_bytes;
  17. };
  18. #ifdef CONFIG_QCOM_DMABUF_HEAPS_SYSTEM
  19. void qcom_system_heap_create(const char *name, const char *system_alias, bool uncached);
  20. void qcom_system_heap_free(struct qcom_sg_buffer *buffer);
  21. struct page *qcom_sys_heap_alloc_largest_available(struct dynamic_page_pool **pools,
  22. unsigned long size,
  23. unsigned int max_order,
  24. bool movable);
  25. int system_qcom_sg_buffer_alloc(struct dma_heap *heap,
  26. struct qcom_sg_buffer *buffer,
  27. unsigned long len,
  28. bool movable);
  29. enum zone_type dynamic_pool_gfp_zone(gfp_t flags);
  30. bool dynamic_pool_zone_watermark_ok_safe(struct zone *z, unsigned int order,
  31. unsigned long mark, int highest_zoneidx);
  32. #else
  33. static inline void qcom_system_heap_create(const char *name, const char *system_alias,
  34. bool uncached)
  35. {
  36. }
  37. static inline void qcom_system_heap_free(struct qcom_sg_buffer *buffer)
  38. {
  39. }
  40. static inline struct page *qcom_sys_heap_alloc_largest_available(struct dynamic_page_pool **pools,
  41. unsigned long size,
  42. unsigned int max_order,
  43. bool movable)
  44. {
  45. return ERR_PTR(-EOPNOTSUPP);
  46. }
  47. static inline int system_qcom_sg_buffer_alloc(struct dma_heap *heap,
  48. struct qcom_sg_buffer *buffer,
  49. unsigned long len,
  50. bool movable)
  51. {
  52. return -EOPNOTSUPP;
  53. }
  54. enum zone_type dynamic_pool_gfp_zone(gfp_t flags)
  55. {
  56. return -EOPNOTSUPP;
  57. }
  58. bool dynamic_pool_zone_watermark_ok_safe(struct zone *z, unsigned int order,
  59. unsigned long mark, int highest_zoneidx)
  60. {
  61. return -EOPNOTSUPP;
  62. }
  63. #endif
  64. #endif /* _QCOM_SYSTEM_HEAP_H */