mirror of https://github.com/OpenIPC/firmware.git
70 lines
1.8 KiB
Diff
70 lines
1.8 KiB
Diff
diff -drupN a/mm/cma.c b/mm/cma.c
|
|
--- a/mm/cma.c 2018-08-06 17:23:04.000000000 +0300
|
|
+++ b/mm/cma.c 2022-06-12 05:28:14.000000000 +0300
|
|
@@ -36,6 +36,7 @@
|
|
#include <linux/highmem.h>
|
|
#include <linux/io.h>
|
|
#include <trace/events/cma.h>
|
|
+#include <linux/dma-contiguous.h>
|
|
|
|
#include "cma.h"
|
|
|
|
@@ -459,3 +460,57 @@ bool cma_release(struct cma *cma, const
|
|
|
|
return true;
|
|
}
|
|
+
|
|
+#define MAPS_AREA_RANGE ((1U<<20)*20)
|
|
+#define MAPS_UNIT_BLOCK 0X100 /* 1MB /4KB =256 */
|
|
+#define MAPS_AREA_BLOCK (MAPS_AREA_RANGE>>PAGE_SHIFT)
|
|
+
|
|
+int dma_contiguous_area_maps(struct seq_file *s)
|
|
+{
|
|
+ unsigned int i;
|
|
+ unsigned int active_bit = 0;
|
|
+ unsigned int free_bit = 0;
|
|
+ unsigned long base_offset = 0;
|
|
+ unsigned long end_offset = 0;
|
|
+
|
|
+ struct cma *cma = dev_get_cma_area(NULL);
|
|
+
|
|
+ if (!cma || !cma->count)
|
|
+ return (-EINVAL);
|
|
+
|
|
+ base_offset = cma->base_pfn << PAGE_SHIFT;
|
|
+ end_offset = (cma->base_pfn + cma->count) << PAGE_SHIFT;
|
|
+ seq_printf(s, "\n 0x%lx: ", base_offset);
|
|
+ for (i = 0; i < cma->count; i++) {
|
|
+ if (((i + 1) % MAPS_UNIT_BLOCK) == 0) {
|
|
+ if ((i + 1) % MAPS_AREA_BLOCK == 0) {
|
|
+ if (active_bit)
|
|
+ seq_printf(s, " %2x\n", active_bit - 1);
|
|
+ else
|
|
+ seq_printf(s, " %s\n", "00");
|
|
+ seq_printf(s, " 0x%lx: ",
|
|
+ base_offset + (i + 1) /
|
|
+ MAPS_AREA_BLOCK * MAPS_AREA_RANGE);
|
|
+ } else {
|
|
+ if (active_bit)
|
|
+ seq_printf(s, " %2x", active_bit - 1);
|
|
+ else
|
|
+ seq_printf(s, " %s", "00");
|
|
+ }
|
|
+ active_bit = 0;
|
|
+ }
|
|
+ if (test_bit(i, cma->bitmap))
|
|
+ active_bit++;
|
|
+ else
|
|
+ free_bit++;
|
|
+ }
|
|
+ seq_printf(s, "\n Cma area start:0x%lx end:0x%lx\n", base_offset,
|
|
+ end_offset);
|
|
+ seq_printf(s, " Cma area Total:%uMB Free:%uKB ~= %uMB\n",
|
|
+ (unsigned int)(cma->count << PAGE_SHIFT) >> 20,
|
|
+ (free_bit << PAGE_SHIFT) / 1024,
|
|
+ (free_bit << PAGE_SHIFT) >> 20);
|
|
+ return 0;
|
|
+}
|
|
+EXPORT_SYMBOL(dma_contiguous_area_maps);
|
|
+
|