cma.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __MM_CMA_H__
  3. #define __MM_CMA_H__
  4. #include <linux/debugfs.h>
  5. #include <linux/kobject.h>
  6. #include <linux/android_vendor.h>
  7. struct cma_kobject {
  8. struct kobject kobj;
  9. struct cma *cma;
  10. };
  11. struct cma {
  12. unsigned long base_pfn;
  13. unsigned long count;
  14. unsigned long *bitmap;
  15. unsigned int order_per_bit; /* Order of pages represented by one bit */
  16. struct mutex lock;
  17. #ifdef CONFIG_CMA_DEBUGFS
  18. struct hlist_head mem_head;
  19. spinlock_t mem_head_lock;
  20. struct debugfs_u32_array dfs_bitmap;
  21. #endif
  22. char name[CMA_MAX_NAME];
  23. #ifdef CONFIG_CMA_SYSFS
  24. /* the number of CMA page successful allocations */
  25. atomic64_t nr_pages_succeeded;
  26. /* the number of CMA page allocation failures */
  27. atomic64_t nr_pages_failed;
  28. /* kobject requires dynamic object */
  29. struct cma_kobject *cma_kobj;
  30. #endif
  31. ANDROID_OEM_DATA_ARRAY(1, 4);
  32. };
  33. extern struct cma cma_areas[MAX_CMA_AREAS];
  34. extern unsigned cma_area_count;
  35. static inline unsigned long cma_bitmap_maxno(struct cma *cma)
  36. {
  37. return cma->count >> cma->order_per_bit;
  38. }
  39. #ifdef CONFIG_CMA_SYSFS
  40. void cma_sysfs_account_success_pages(struct cma *cma, unsigned long nr_pages);
  41. void cma_sysfs_account_fail_pages(struct cma *cma, unsigned long nr_pages);
  42. #else
  43. static inline void cma_sysfs_account_success_pages(struct cma *cma,
  44. unsigned long nr_pages) {};
  45. static inline void cma_sysfs_account_fail_pages(struct cma *cma,
  46. unsigned long nr_pages) {};
  47. #endif
  48. #endif