|
@@ -32,6 +32,7 @@
|
|
#include <linux/slab.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/log2.h>
|
|
#include <linux/log2.h>
|
|
#include <linux/cma.h>
|
|
#include <linux/cma.h>
|
|
|
|
+#include <linux/highmem.h>
|
|
|
|
|
|
struct cma {
|
|
struct cma {
|
|
unsigned long base_pfn;
|
|
unsigned long base_pfn;
|
|
@@ -163,6 +164,8 @@ int __init cma_declare_contiguous(phys_addr_t base,
|
|
bool fixed, struct cma **res_cma)
|
|
bool fixed, struct cma **res_cma)
|
|
{
|
|
{
|
|
struct cma *cma;
|
|
struct cma *cma;
|
|
|
|
+ phys_addr_t memblock_end = memblock_end_of_DRAM();
|
|
|
|
+ phys_addr_t highmem_start = __pa(high_memory);
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
pr_debug("%s(size %lx, base %08lx, limit %08lx alignment %08lx)\n",
|
|
pr_debug("%s(size %lx, base %08lx, limit %08lx alignment %08lx)\n",
|
|
@@ -196,6 +199,24 @@ int __init cma_declare_contiguous(phys_addr_t base,
|
|
if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
|
|
if (!IS_ALIGNED(size >> PAGE_SHIFT, 1 << order_per_bit))
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * adjust limit to avoid crossing low/high memory boundary for
|
|
|
|
+ * automatically allocated regions
|
|
|
|
+ */
|
|
|
|
+ if (((limit == 0 || limit > memblock_end) &&
|
|
|
|
+ (memblock_end - size < highmem_start &&
|
|
|
|
+ memblock_end > highmem_start)) ||
|
|
|
|
+ (!fixed && limit > highmem_start && limit - size < highmem_start)) {
|
|
|
|
+ limit = highmem_start;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (fixed && base < highmem_start && base+size > highmem_start) {
|
|
|
|
+ ret = -EINVAL;
|
|
|
|
+ pr_err("Region at %08lx defined on low/high memory boundary (%08lx)\n",
|
|
|
|
+ (unsigned long)base, (unsigned long)highmem_start);
|
|
|
|
+ goto err;
|
|
|
|
+ }
|
|
|
|
+
|
|
/* Reserve memory */
|
|
/* Reserve memory */
|
|
if (base && fixed) {
|
|
if (base && fixed) {
|
|
if (memblock_is_region_reserved(base, size) ||
|
|
if (memblock_is_region_reserved(base, size) ||
|