Commit a3e89e20 authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik

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: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 468a3bc2
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#define PAGE_STATES_H #define PAGE_STATES_H
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/page.h>
#define ESSA_GET_STATE 0 #define ESSA_GET_STATE 0
#define ESSA_SET_STABLE 1 #define ESSA_SET_STABLE 1
...@@ -22,4 +23,41 @@ ...@@ -22,4 +23,41 @@
extern int __bootdata_preserved(cmma_flag); extern int __bootdata_preserved(cmma_flag);
static __always_inline unsigned long essa(unsigned long paddr, unsigned char cmd)
{
unsigned long rc;
asm volatile(
" .insn rrf,0xb9ab0000,%[rc],%[paddr],%[cmd],0"
: [rc] "=d" (rc)
: [paddr] "d" (paddr),
[cmd] "i" (cmd));
return rc;
}
static __always_inline void __set_page_state(void *addr, unsigned long num_pages, unsigned char cmd)
{
unsigned long paddr = __pa(addr) & PAGE_MASK;
while (num_pages--) {
essa(paddr, cmd);
paddr += PAGE_SIZE;
}
}
static inline void __set_page_unused(void *addr, unsigned long num_pages)
{
__set_page_state(addr, num_pages, ESSA_SET_UNUSED);
}
static inline void __set_page_stable_dat(void *addr, unsigned long num_pages)
{
__set_page_state(addr, num_pages, ESSA_SET_STABLE);
}
static inline void __set_page_stable_nodat(void *addr, unsigned long num_pages)
{
__set_page_state(addr, num_pages, ESSA_SET_STABLE_NODAT);
}
#endif #endif
...@@ -20,43 +20,6 @@ ...@@ -20,43 +20,6 @@
int __bootdata_preserved(cmma_flag); int __bootdata_preserved(cmma_flag);
static __always_inline void essa(unsigned long paddr, unsigned char cmd)
{
unsigned long rc;
asm volatile(
" .insn rrf,0xb9ab0000,%[rc],%[paddr],%[cmd],0"
: [rc] "=d" (rc)
: [paddr] "d" (paddr),
[cmd] "i" (cmd));
}
static __always_inline void __set_page_state(struct page *page, int order, unsigned char cmd)
{
unsigned long paddr = page_to_phys(page);
unsigned long num_pages = 1UL << order;
while (num_pages--) {
essa(paddr, cmd);
paddr += PAGE_SIZE;
}
}
static inline void set_page_unused(struct page *page, int order)
{
__set_page_state(page, order, ESSA_SET_UNUSED);
}
static inline void set_page_stable_dat(struct page *page, int order)
{
__set_page_state(page, order, ESSA_SET_STABLE);
}
static inline void set_page_stable_nodat(struct page *page, int order)
{
__set_page_state(page, order, ESSA_SET_STABLE_NODAT);
}
static void mark_kernel_pmd(pud_t *pud, unsigned long addr, unsigned long end) static void mark_kernel_pmd(pud_t *pud, unsigned long addr, unsigned long end)
{ {
unsigned long next; unsigned long next;
...@@ -169,7 +132,7 @@ void __init cmma_init_nodat(void) ...@@ -169,7 +132,7 @@ void __init cmma_init_nodat(void)
continue; /* skip page table pages */ continue; /* skip page table pages */
if (!list_empty(&page->lru)) if (!list_empty(&page->lru))
continue; /* skip free pages */ continue; /* skip free pages */
set_page_stable_nodat(page, 0); __set_page_stable_nodat(page_to_virt(page), 1);
} }
} }
} }
...@@ -178,7 +141,7 @@ void arch_free_page(struct page *page, int order) ...@@ -178,7 +141,7 @@ void arch_free_page(struct page *page, int order)
{ {
if (!cmma_flag) if (!cmma_flag)
return; return;
set_page_unused(page, order); __set_page_unused(page_to_virt(page), 1UL << order);
} }
void arch_alloc_page(struct page *page, int order) void arch_alloc_page(struct page *page, int order)
...@@ -186,14 +149,14 @@ void arch_alloc_page(struct page *page, int order) ...@@ -186,14 +149,14 @@ void arch_alloc_page(struct page *page, int order)
if (!cmma_flag) if (!cmma_flag)
return; return;
if (cmma_flag < 2) if (cmma_flag < 2)
set_page_stable_dat(page, order); __set_page_stable_dat(page_to_virt(page), 1UL << order);
else else
set_page_stable_nodat(page, order); __set_page_stable_nodat(page_to_virt(page), 1UL << order);
} }
void arch_set_page_dat(struct page *page, int order) void arch_set_page_dat(struct page *page, int order)
{ {
if (!cmma_flag) if (!cmma_flag)
return; return;
set_page_stable_dat(page, order); __set_page_stable_dat(page_to_virt(page), 1UL << order);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment