cma.c (4b2f8838479eb2abe042e094f7d2cced6d5ea772) cma.c (28b24c1fc8c22cabe5b8a16ffe6a61dfce51a1f2)
1/*
2 * Contiguous Memory Allocator
3 *
4 * Copyright (c) 2010-2011 by Samsung Electronics.
5 * Copyright IBM Corporation, 2013
6 * Copyright LG Electronics Inc., 2014
7 * Written by:
8 * Marek Szyprowski <m.szyprowski@samsung.com>

--- 21 unchanged lines hidden (view full) ---

30#include <linux/mutex.h>
31#include <linux/sizes.h>
32#include <linux/slab.h>
33#include <linux/log2.h>
34#include <linux/cma.h>
35#include <linux/highmem.h>
36#include <linux/io.h>
37
1/*
2 * Contiguous Memory Allocator
3 *
4 * Copyright (c) 2010-2011 by Samsung Electronics.
5 * Copyright IBM Corporation, 2013
6 * Copyright LG Electronics Inc., 2014
7 * Written by:
8 * Marek Szyprowski <m.szyprowski@samsung.com>

--- 21 unchanged lines hidden (view full) ---

30#include <linux/mutex.h>
31#include <linux/sizes.h>
32#include <linux/slab.h>
33#include <linux/log2.h>
34#include <linux/cma.h>
35#include <linux/highmem.h>
36#include <linux/io.h>
37
38struct cma {
39 unsigned long base_pfn;
40 unsigned long count;
41 unsigned long *bitmap;
42 unsigned int order_per_bit; /* Order of pages represented by one bit */
43 struct mutex lock;
44};
38#include "cma.h"
45
39
46static struct cma cma_areas[MAX_CMA_AREAS];
47static unsigned cma_area_count;
40struct cma cma_areas[MAX_CMA_AREAS];
41unsigned cma_area_count;
48static DEFINE_MUTEX(cma_mutex);
49
50phys_addr_t cma_get_base(struct cma *cma)
51{
52 return PFN_PHYS(cma->base_pfn);
53}
54
55unsigned long cma_get_size(struct cma *cma)

--- 16 unchanged lines hidden (view full) ---

72{
73 if (align_order <= cma->order_per_bit)
74 return 0;
75
76 return (ALIGN(cma->base_pfn, (1UL << align_order))
77 - cma->base_pfn) >> cma->order_per_bit;
78}
79
42static DEFINE_MUTEX(cma_mutex);
43
44phys_addr_t cma_get_base(struct cma *cma)
45{
46 return PFN_PHYS(cma->base_pfn);
47}
48
49unsigned long cma_get_size(struct cma *cma)

--- 16 unchanged lines hidden (view full) ---

66{
67 if (align_order <= cma->order_per_bit)
68 return 0;
69
70 return (ALIGN(cma->base_pfn, (1UL << align_order))
71 - cma->base_pfn) >> cma->order_per_bit;
72}
73
80static unsigned long cma_bitmap_maxno(struct cma *cma)
81{
82 return cma->count >> cma->order_per_bit;
83}
84
85static unsigned long cma_bitmap_pages_to_bits(struct cma *cma,
86 unsigned long pages)
87{
88 return ALIGN(pages, 1UL << cma->order_per_bit) >> cma->order_per_bit;
89}
90
91static void cma_clear_bitmap(struct cma *cma, unsigned long pfn, int count)
92{

--- 360 unchanged lines hidden ---
74static unsigned long cma_bitmap_pages_to_bits(struct cma *cma,
75 unsigned long pages)
76{
77 return ALIGN(pages, 1UL << cma->order_per_bit) >> cma->order_per_bit;
78}
79
80static void cma_clear_bitmap(struct cma *cma, unsigned long pfn, int count)
81{

--- 360 unchanged lines hidden ---