Skip to content

Commit a3e89e2

Browse files
hcahcaVasily Gorbik
authored andcommitted
s390/cmma: move set_page_stable() and friends to header file
In order to be usable for early boot code move the simple set_page_xxx() function to header file. Also change the parameters, and the function names slightly. This is required since there aren't any struct pages available in early boot code, and renaming of functions is done to make sure that all users are converted to the new API. Instead of a pointer to a struct page a virtual address is passed, and instead of an order the number of pages for which the page state needs be set. Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 468a3bc commit a3e89e2

File tree

2 files changed

+43
-42
lines changed

2 files changed

+43
-42
lines changed

arch/s390/include/asm/page-states.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define PAGE_STATES_H
99

1010
#include <asm/sections.h>
11+
#include <asm/page.h>
1112

1213
#define ESSA_GET_STATE 0
1314
#define ESSA_SET_STABLE 1
@@ -22,4 +23,41 @@
2223

2324
extern int __bootdata_preserved(cmma_flag);
2425

26+
static __always_inline unsigned long essa(unsigned long paddr, unsigned char cmd)
27+
{
28+
unsigned long rc;
29+
30+
asm volatile(
31+
" .insn rrf,0xb9ab0000,%[rc],%[paddr],%[cmd],0"
32+
: [rc] "=d" (rc)
33+
: [paddr] "d" (paddr),
34+
[cmd] "i" (cmd));
35+
return rc;
36+
}
37+
38+
static __always_inline void __set_page_state(void *addr, unsigned long num_pages, unsigned char cmd)
39+
{
40+
unsigned long paddr = __pa(addr) & PAGE_MASK;
41+
42+
while (num_pages--) {
43+
essa(paddr, cmd);
44+
paddr += PAGE_SIZE;
45+
}
46+
}
47+
48+
static inline void __set_page_unused(void *addr, unsigned long num_pages)
49+
{
50+
__set_page_state(addr, num_pages, ESSA_SET_UNUSED);
51+
}
52+
53+
static inline void __set_page_stable_dat(void *addr, unsigned long num_pages)
54+
{
55+
__set_page_state(addr, num_pages, ESSA_SET_STABLE);
56+
}
57+
58+
static inline void __set_page_stable_nodat(void *addr, unsigned long num_pages)
59+
{
60+
__set_page_state(addr, num_pages, ESSA_SET_STABLE_NODAT);
61+
}
62+
2563
#endif

arch/s390/mm/page-states.c

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,6 @@
2020

2121
int __bootdata_preserved(cmma_flag);
2222

23-
static __always_inline void essa(unsigned long paddr, unsigned char cmd)
24-
{
25-
unsigned long rc;
26-
27-
asm volatile(
28-
" .insn rrf,0xb9ab0000,%[rc],%[paddr],%[cmd],0"
29-
: [rc] "=d" (rc)
30-
: [paddr] "d" (paddr),
31-
[cmd] "i" (cmd));
32-
}
33-
34-
static __always_inline void __set_page_state(struct page *page, int order, unsigned char cmd)
35-
{
36-
unsigned long paddr = page_to_phys(page);
37-
unsigned long num_pages = 1UL << order;
38-
39-
while (num_pages--) {
40-
essa(paddr, cmd);
41-
paddr += PAGE_SIZE;
42-
}
43-
}
44-
45-
static inline void set_page_unused(struct page *page, int order)
46-
{
47-
__set_page_state(page, order, ESSA_SET_UNUSED);
48-
}
49-
50-
static inline void set_page_stable_dat(struct page *page, int order)
51-
{
52-
__set_page_state(page, order, ESSA_SET_STABLE);
53-
}
54-
55-
static inline void set_page_stable_nodat(struct page *page, int order)
56-
{
57-
__set_page_state(page, order, ESSA_SET_STABLE_NODAT);
58-
}
59-
6023
static void mark_kernel_pmd(pud_t *pud, unsigned long addr, unsigned long end)
6124
{
6225
unsigned long next;
@@ -169,7 +132,7 @@ void __init cmma_init_nodat(void)
169132
continue; /* skip page table pages */
170133
if (!list_empty(&page->lru))
171134
continue; /* skip free pages */
172-
set_page_stable_nodat(page, 0);
135+
__set_page_stable_nodat(page_to_virt(page), 1);
173136
}
174137
}
175138
}
@@ -178,22 +141,22 @@ void arch_free_page(struct page *page, int order)
178141
{
179142
if (!cmma_flag)
180143
return;
181-
set_page_unused(page, order);
144+
__set_page_unused(page_to_virt(page), 1UL << order);
182145
}
183146

184147
void arch_alloc_page(struct page *page, int order)
185148
{
186149
if (!cmma_flag)
187150
return;
188151
if (cmma_flag < 2)
189-
set_page_stable_dat(page, order);
152+
__set_page_stable_dat(page_to_virt(page), 1UL << order);
190153
else
191-
set_page_stable_nodat(page, order);
154+
__set_page_stable_nodat(page_to_virt(page), 1UL << order);
192155
}
193156

194157
void arch_set_page_dat(struct page *page, int order)
195158
{
196159
if (!cmma_flag)
197160
return;
198-
set_page_stable_dat(page, order);
161+
__set_page_stable_dat(page_to_virt(page), 1UL << order);
199162
}

0 commit comments

Comments
 (0)