Linux 6.13-rc7
[linux.git] / arch / openrisc / mm / ioremap.c
blobf59ea4c10b0f81f2c53015bfe0205e78268ea831
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * OpenRISC ioremap.c
5 * Linux architectural port borrowing liberally from similar works of
6 * others. All original copyrights apply as per the original source
7 * declaration.
9 * Modifications for the OpenRISC architecture:
10 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
11 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
14 #include <linux/vmalloc.h>
15 #include <linux/io.h>
16 #include <linux/pgtable.h>
17 #include <asm/pgalloc.h>
18 #include <asm/fixmap.h>
19 #include <asm/bug.h>
20 #include <linux/sched.h>
21 #include <asm/tlbflush.h>
23 extern int mem_init_done;
26 * OK, this one's a bit tricky... ioremap can get called before memory is
27 * initialized (early serial console does this) and will want to alloc a page
28 * for its mapping. No userspace pages will ever get allocated before memory
29 * is initialized so this applies only to kernel pages. In the event that
30 * this is called before memory is initialized we allocate the page using
31 * the memblock infrastructure.
34 pte_t __ref *pte_alloc_one_kernel(struct mm_struct *mm)
36 pte_t *pte;
38 if (likely(mem_init_done)) {
39 pte = (pte_t *)get_zeroed_page(GFP_KERNEL);
40 } else {
41 pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
42 if (!pte)
43 panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
44 __func__, PAGE_SIZE, PAGE_SIZE);
47 return pte;