Merge branch 'akpm' (patchbomb from Andrew Morton)
Merge incoming from Andrew Morton: - Various misc things. - arch/sh updates. - Part of ocfs2. Review is slow. - Slab updates. - Most of -mm. - printk updates. - lib/ updates. - checkpatch updates. * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (226 commits) checkpatch: update $declaration_macros, add uninitialized_var checkpatch: warn on missing spaces in broken up quoted checkpatch: fix false positives for --strict "space after cast" test checkpatch: fix false positive MISSING_BREAK warnings with --file checkpatch: add test for native c90 types in unusual order checkpatch: add signed generic types checkpatch: add short int to c variable types checkpatch: add for_each tests to indentation and brace tests checkpatch: fix brace style misuses of else and while checkpatch: add --fix option for a couple OPEN_BRACE misuses checkpatch: use the correct indentation for which() checkpatch: add fix_insert_line and fix_delete_line helpers checkpatch: add ability to insert and delete lines to patch/file checkpatch: add an index variable for fixed lines checkpatch: warn on break after goto or return with same tab indentation checkpatch: emit a warning on file add/move/delete checkpatch: add test for commit id formatting style in commit log checkpatch: emit fewer kmalloc_array/kcalloc conversion warnings checkpatch: improve "no space after cast" test checkpatch: allow multiple const * types ...
This commit is contained in:
@@ -289,16 +289,6 @@ config CMA_ALIGNMENT
|
||||
|
||||
If unsure, leave the default value "8".
|
||||
|
||||
config CMA_AREAS
|
||||
int "Maximum count of the CMA device-private areas"
|
||||
default 7
|
||||
help
|
||||
CMA allows to create CMA areas for particular devices. This parameter
|
||||
sets the maximum number of such device private CMA areas in the
|
||||
system.
|
||||
|
||||
If unsure, leave the default value "7".
|
||||
|
||||
endif
|
||||
|
||||
endmenu
|
||||
|
@@ -24,23 +24,9 @@
|
||||
|
||||
#include <linux/memblock.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/page-isolation.h>
|
||||
#include <linux/sizes.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/mm_types.h>
|
||||
#include <linux/dma-contiguous.h>
|
||||
|
||||
struct cma {
|
||||
unsigned long base_pfn;
|
||||
unsigned long count;
|
||||
unsigned long *bitmap;
|
||||
struct mutex lock;
|
||||
};
|
||||
|
||||
struct cma *dma_contiguous_default_area;
|
||||
#include <linux/cma.h>
|
||||
|
||||
#ifdef CONFIG_CMA_SIZE_MBYTES
|
||||
#define CMA_SIZE_MBYTES CONFIG_CMA_SIZE_MBYTES
|
||||
@@ -48,6 +34,8 @@ struct cma *dma_contiguous_default_area;
|
||||
#define CMA_SIZE_MBYTES 0
|
||||
#endif
|
||||
|
||||
struct cma *dma_contiguous_default_area;
|
||||
|
||||
/*
|
||||
* Default global CMA area size can be defined in kernel's .config.
|
||||
* This is useful mainly for distro maintainers to create a kernel
|
||||
@@ -154,65 +142,6 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
|
||||
}
|
||||
}
|
||||
|
||||
static DEFINE_MUTEX(cma_mutex);
|
||||
|
||||
static int __init cma_activate_area(struct cma *cma)
|
||||
{
|
||||
int bitmap_size = BITS_TO_LONGS(cma->count) * sizeof(long);
|
||||
unsigned long base_pfn = cma->base_pfn, pfn = base_pfn;
|
||||
unsigned i = cma->count >> pageblock_order;
|
||||
struct zone *zone;
|
||||
|
||||
cma->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
|
||||
|
||||
if (!cma->bitmap)
|
||||
return -ENOMEM;
|
||||
|
||||
WARN_ON_ONCE(!pfn_valid(pfn));
|
||||
zone = page_zone(pfn_to_page(pfn));
|
||||
|
||||
do {
|
||||
unsigned j;
|
||||
base_pfn = pfn;
|
||||
for (j = pageblock_nr_pages; j; --j, pfn++) {
|
||||
WARN_ON_ONCE(!pfn_valid(pfn));
|
||||
/*
|
||||
* alloc_contig_range requires the pfn range
|
||||
* specified to be in the same zone. Make this
|
||||
* simple by forcing the entire CMA resv range
|
||||
* to be in the same zone.
|
||||
*/
|
||||
if (page_zone(pfn_to_page(pfn)) != zone)
|
||||
goto err;
|
||||
}
|
||||
init_cma_reserved_pageblock(pfn_to_page(base_pfn));
|
||||
} while (--i);
|
||||
|
||||
mutex_init(&cma->lock);
|
||||
return 0;
|
||||
|
||||
err:
|
||||
kfree(cma->bitmap);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static struct cma cma_areas[MAX_CMA_AREAS];
|
||||
static unsigned cma_area_count;
|
||||
|
||||
static int __init cma_init_reserved_areas(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cma_area_count; i++) {
|
||||
int ret = cma_activate_area(&cma_areas[i]);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
core_initcall(cma_init_reserved_areas);
|
||||
|
||||
/**
|
||||
* dma_contiguous_reserve_area() - reserve custom contiguous area
|
||||
* @size: Size of the reserved area (in bytes),
|
||||
@@ -234,72 +163,17 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
|
||||
phys_addr_t limit, struct cma **res_cma,
|
||||
bool fixed)
|
||||
{
|
||||
struct cma *cma = &cma_areas[cma_area_count];
|
||||
phys_addr_t alignment;
|
||||
int ret = 0;
|
||||
int ret;
|
||||
|
||||
pr_debug("%s(size %lx, base %08lx, limit %08lx)\n", __func__,
|
||||
(unsigned long)size, (unsigned long)base,
|
||||
(unsigned long)limit);
|
||||
|
||||
/* Sanity checks */
|
||||
if (cma_area_count == ARRAY_SIZE(cma_areas)) {
|
||||
pr_err("Not enough slots for CMA reserved regions!\n");
|
||||
return -ENOSPC;
|
||||
}
|
||||
|
||||
if (!size)
|
||||
return -EINVAL;
|
||||
|
||||
/* Sanitise input arguments */
|
||||
alignment = PAGE_SIZE << max(MAX_ORDER - 1, pageblock_order);
|
||||
base = ALIGN(base, alignment);
|
||||
size = ALIGN(size, alignment);
|
||||
limit &= ~(alignment - 1);
|
||||
|
||||
/* Reserve memory */
|
||||
if (base && fixed) {
|
||||
if (memblock_is_region_reserved(base, size) ||
|
||||
memblock_reserve(base, size) < 0) {
|
||||
ret = -EBUSY;
|
||||
goto err;
|
||||
}
|
||||
} else {
|
||||
phys_addr_t addr = memblock_alloc_range(size, alignment, base,
|
||||
limit);
|
||||
if (!addr) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
} else {
|
||||
base = addr;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Each reserved area must be initialised later, when more kernel
|
||||
* subsystems (like slab allocator) are available.
|
||||
*/
|
||||
cma->base_pfn = PFN_DOWN(base);
|
||||
cma->count = size >> PAGE_SHIFT;
|
||||
*res_cma = cma;
|
||||
cma_area_count++;
|
||||
|
||||
pr_info("CMA: reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
|
||||
(unsigned long)base);
|
||||
ret = cma_declare_contiguous(base, size, limit, 0, 0, fixed, res_cma);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Architecture specific contiguous memory fixup. */
|
||||
dma_contiguous_early_fixup(base, size);
|
||||
return 0;
|
||||
err:
|
||||
pr_err("CMA: failed to reserve %ld MiB\n", (unsigned long)size / SZ_1M);
|
||||
return ret;
|
||||
}
|
||||
dma_contiguous_early_fixup(cma_get_base(*res_cma),
|
||||
cma_get_size(*res_cma));
|
||||
|
||||
static void clear_cma_bitmap(struct cma *cma, unsigned long pfn, int count)
|
||||
{
|
||||
mutex_lock(&cma->lock);
|
||||
bitmap_clear(cma->bitmap, pfn - cma->base_pfn, count);
|
||||
mutex_unlock(&cma->lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,62 +190,10 @@ static void clear_cma_bitmap(struct cma *cma, unsigned long pfn, int count)
|
||||
struct page *dma_alloc_from_contiguous(struct device *dev, int count,
|
||||
unsigned int align)
|
||||
{
|
||||
unsigned long mask, pfn, pageno, start = 0;
|
||||
struct cma *cma = dev_get_cma_area(dev);
|
||||
struct page *page = NULL;
|
||||
int ret;
|
||||
|
||||
if (!cma || !cma->count)
|
||||
return NULL;
|
||||
|
||||
if (align > CONFIG_CMA_ALIGNMENT)
|
||||
align = CONFIG_CMA_ALIGNMENT;
|
||||
|
||||
pr_debug("%s(cma %p, count %d, align %d)\n", __func__, (void *)cma,
|
||||
count, align);
|
||||
|
||||
if (!count)
|
||||
return NULL;
|
||||
|
||||
mask = (1 << align) - 1;
|
||||
|
||||
|
||||
for (;;) {
|
||||
mutex_lock(&cma->lock);
|
||||
pageno = bitmap_find_next_zero_area(cma->bitmap, cma->count,
|
||||
start, count, mask);
|
||||
if (pageno >= cma->count) {
|
||||
mutex_unlock(&cma->lock);
|
||||
break;
|
||||
}
|
||||
bitmap_set(cma->bitmap, pageno, count);
|
||||
/*
|
||||
* It's safe to drop the lock here. We've marked this region for
|
||||
* our exclusive use. If the migration fails we will take the
|
||||
* lock again and unmark it.
|
||||
*/
|
||||
mutex_unlock(&cma->lock);
|
||||
|
||||
pfn = cma->base_pfn + pageno;
|
||||
mutex_lock(&cma_mutex);
|
||||
ret = alloc_contig_range(pfn, pfn + count, MIGRATE_CMA);
|
||||
mutex_unlock(&cma_mutex);
|
||||
if (ret == 0) {
|
||||
page = pfn_to_page(pfn);
|
||||
break;
|
||||
} else if (ret != -EBUSY) {
|
||||
clear_cma_bitmap(cma, pfn, count);
|
||||
break;
|
||||
}
|
||||
clear_cma_bitmap(cma, pfn, count);
|
||||
pr_debug("%s(): memory range at %p is busy, retrying\n",
|
||||
__func__, pfn_to_page(pfn));
|
||||
/* try again with a bit different memory target */
|
||||
start = pageno + mask + 1;
|
||||
}
|
||||
|
||||
pr_debug("%s(): returned %p\n", __func__, page);
|
||||
return page;
|
||||
return cma_alloc(dev_get_cma_area(dev), count, align);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,23 +209,5 @@ struct page *dma_alloc_from_contiguous(struct device *dev, int count,
|
||||
bool dma_release_from_contiguous(struct device *dev, struct page *pages,
|
||||
int count)
|
||||
{
|
||||
struct cma *cma = dev_get_cma_area(dev);
|
||||
unsigned long pfn;
|
||||
|
||||
if (!cma || !pages)
|
||||
return false;
|
||||
|
||||
pr_debug("%s(page %p)\n", __func__, (void *)pages);
|
||||
|
||||
pfn = page_to_pfn(pages);
|
||||
|
||||
if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count)
|
||||
return false;
|
||||
|
||||
VM_BUG_ON(pfn + count > cma->base_pfn + cma->count);
|
||||
|
||||
free_contig_range(pfn, count);
|
||||
clear_cma_bitmap(cma, pfn, count);
|
||||
|
||||
return true;
|
||||
return cma_release(dev_get_cma_area(dev), pages, count);
|
||||
}
|
||||
|
@@ -284,7 +284,7 @@ static int memory_subsys_online(struct device *dev)
|
||||
* attribute and need to set the online_type.
|
||||
*/
|
||||
if (mem->online_type < 0)
|
||||
mem->online_type = ONLINE_KEEP;
|
||||
mem->online_type = MMOP_ONLINE_KEEP;
|
||||
|
||||
ret = memory_block_change_state(mem, MEM_ONLINE, MEM_OFFLINE);
|
||||
|
||||
@@ -315,23 +315,23 @@ store_mem_state(struct device *dev,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!strncmp(buf, "online_kernel", min_t(int, count, 13)))
|
||||
online_type = ONLINE_KERNEL;
|
||||
else if (!strncmp(buf, "online_movable", min_t(int, count, 14)))
|
||||
online_type = ONLINE_MOVABLE;
|
||||
else if (!strncmp(buf, "online", min_t(int, count, 6)))
|
||||
online_type = ONLINE_KEEP;
|
||||
else if (!strncmp(buf, "offline", min_t(int, count, 7)))
|
||||
online_type = -1;
|
||||
if (sysfs_streq(buf, "online_kernel"))
|
||||
online_type = MMOP_ONLINE_KERNEL;
|
||||
else if (sysfs_streq(buf, "online_movable"))
|
||||
online_type = MMOP_ONLINE_MOVABLE;
|
||||
else if (sysfs_streq(buf, "online"))
|
||||
online_type = MMOP_ONLINE_KEEP;
|
||||
else if (sysfs_streq(buf, "offline"))
|
||||
online_type = MMOP_OFFLINE;
|
||||
else {
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
switch (online_type) {
|
||||
case ONLINE_KERNEL:
|
||||
case ONLINE_MOVABLE:
|
||||
case ONLINE_KEEP:
|
||||
case MMOP_ONLINE_KERNEL:
|
||||
case MMOP_ONLINE_MOVABLE:
|
||||
case MMOP_ONLINE_KEEP:
|
||||
/*
|
||||
* mem->online_type is not protected so there can be a
|
||||
* race here. However, when racing online, the first
|
||||
@@ -342,7 +342,7 @@ store_mem_state(struct device *dev,
|
||||
mem->online_type = online_type;
|
||||
ret = device_online(&mem->dev);
|
||||
break;
|
||||
case -1:
|
||||
case MMOP_OFFLINE:
|
||||
ret = device_offline(&mem->dev);
|
||||
break;
|
||||
default:
|
||||
@@ -406,7 +406,9 @@ memory_probe_store(struct device *dev, struct device_attribute *attr,
|
||||
int i, ret;
|
||||
unsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block;
|
||||
|
||||
phys_addr = simple_strtoull(buf, NULL, 0);
|
||||
ret = kstrtoull(buf, 0, &phys_addr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))
|
||||
return -EINVAL;
|
||||
|
@@ -126,7 +126,7 @@ static ssize_t node_read_meminfo(struct device *dev,
|
||||
nid, K(node_page_state(nid, NR_FILE_PAGES)),
|
||||
nid, K(node_page_state(nid, NR_FILE_MAPPED)),
|
||||
nid, K(node_page_state(nid, NR_ANON_PAGES)),
|
||||
nid, K(node_page_state(nid, NR_SHMEM)),
|
||||
nid, K(i.sharedram),
|
||||
nid, node_page_state(nid, NR_KERNEL_STACK) *
|
||||
THREAD_SIZE / 1024,
|
||||
nid, K(node_page_state(nid, NR_PAGETABLE)),
|
||||
|
Reference in New Issue
Block a user