Skip to content

Commit fe6c98a

Browse files
Youling Tangtsbogend
authored andcommitted
MIPS: crash_dump.c: Simplify copy_oldmem_page()
Replace kmap_atomic_pfn() with kmap_local_pfn() which is preemptible and can take page faults. Remove the indirection of the dump page and the related cruft which is not longer required. Remove unused or redundant header files. Signed-off-by: Youling Tang <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent 4088024 commit fe6c98a

File tree

1 file changed

+6
-35
lines changed

1 file changed

+6
-35
lines changed

arch/mips/kernel/crash_dump.c

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <linux/highmem.h>
3-
#include <linux/memblock.h>
43
#include <linux/crash_dump.h>
5-
#include <linux/uaccess.h>
6-
#include <linux/slab.h>
7-
8-
static void *kdump_buf_page;
94

105
/**
116
* copy_oldmem_page - copy one page from "oldmem"
@@ -19,10 +14,6 @@ static void *kdump_buf_page;
1914
*
2015
* Copy a page from "oldmem". For this page, there is no pte mapped
2116
* in the current kernel.
22-
*
23-
* Calling copy_to_user() in atomic context is not desirable. Hence first
24-
* copying the data to a pre-allocated kernel page and then copying to user
25-
* space in non-atomic context.
2617
*/
2718
ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
2819
size_t csize, unsigned long offset, int userbuf)
@@ -32,36 +23,16 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
3223
if (!csize)
3324
return 0;
3425

35-
vaddr = kmap_atomic_pfn(pfn);
26+
vaddr = kmap_local_pfn(pfn);
3627

3728
if (!userbuf) {
38-
memcpy(buf, (vaddr + offset), csize);
39-
kunmap_atomic(vaddr);
29+
memcpy(buf, vaddr + offset, csize);
4030
} else {
41-
if (!kdump_buf_page) {
42-
pr_warn("Kdump: Kdump buffer page not allocated\n");
43-
44-
return -EFAULT;
45-
}
46-
copy_page(kdump_buf_page, vaddr);
47-
kunmap_atomic(vaddr);
48-
if (copy_to_user(buf, (kdump_buf_page + offset), csize))
49-
return -EFAULT;
31+
if (copy_to_user(buf, vaddr + offset, csize))
32+
csize = -EFAULT;
5033
}
5134

52-
return csize;
53-
}
54-
55-
static int __init kdump_buf_page_init(void)
56-
{
57-
int ret = 0;
35+
kunmap_local(vaddr);
5836

59-
kdump_buf_page = kmalloc(PAGE_SIZE, GFP_KERNEL);
60-
if (!kdump_buf_page) {
61-
pr_warn("Kdump: Failed to allocate kdump buffer page\n");
62-
ret = -ENOMEM;
63-
}
64-
65-
return ret;
37+
return csize;
6638
}
67-
arch_initcall(kdump_buf_page_init);

0 commit comments

Comments
 (0)