Skip to content

Commit 92b519f

Browse files
hcahcaVasily Gorbik
authored andcommitted
s390/cmma: cleanup inline assemblies
Cleanup cmma related inline assemblies: - consolidate inline assemblies - use symbolic names - add same white space where missing - add braces to for-loops which contain a multi-line statement 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 5cf1a56 commit 92b519f

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

arch/s390/mm/page-states.c

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static inline int cmma_test_essa(void)
4040
" .insn rrf,0xb9ab0000,%[tmp],%[tmp],%[cmd],0\n"
4141
"0: la %[rc],0\n"
4242
"1:\n"
43-
EX_TABLE(0b,1b)
43+
EX_TABLE(0b, 1b)
4444
: [rc] "+&d" (rc), [tmp] "+&d" (tmp)
4545
: [cmd] "i" (ESSA_GET_STATE));
4646
return rc;
@@ -58,37 +58,41 @@ void __init cmma_init(void)
5858
cmma_flag = 2;
5959
}
6060

61-
static inline void set_page_unused(struct page *page, int order)
61+
static __always_inline void essa(unsigned long paddr, unsigned char cmd)
6262
{
63-
int i, rc;
63+
unsigned long rc;
6464

65-
for (i = 0; i < (1 << order); i++)
66-
asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
67-
: "=&d" (rc)
68-
: "a" (page_to_phys(page + i)),
69-
"i" (ESSA_SET_UNUSED));
65+
asm volatile(
66+
" .insn rrf,0xb9ab0000,%[rc],%[paddr],%[cmd],0"
67+
: [rc] "=d" (rc)
68+
: [paddr] "d" (paddr),
69+
[cmd] "i" (cmd));
7070
}
7171

72-
static inline void set_page_stable_dat(struct page *page, int order)
72+
static __always_inline void __set_page_state(struct page *page, int order, unsigned char cmd)
7373
{
74-
int i, rc;
74+
unsigned long paddr = page_to_phys(page);
75+
unsigned long num_pages = 1UL << order;
7576

76-
for (i = 0; i < (1 << order); i++)
77-
asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
78-
: "=&d" (rc)
79-
: "a" (page_to_phys(page + i)),
80-
"i" (ESSA_SET_STABLE));
77+
while (num_pages--) {
78+
essa(paddr, cmd);
79+
paddr += PAGE_SIZE;
80+
}
8181
}
8282

83-
static inline void set_page_stable_nodat(struct page *page, int order)
83+
static inline void set_page_unused(struct page *page, int order)
8484
{
85-
int i, rc;
85+
__set_page_state(page, order, ESSA_SET_UNUSED);
86+
}
8687

87-
for (i = 0; i < (1 << order); i++)
88-
asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
89-
: "=&d" (rc)
90-
: "a" (page_to_phys(page + i)),
91-
"i" (ESSA_SET_STABLE_NODAT));
88+
static inline void set_page_stable_dat(struct page *page, int order)
89+
{
90+
__set_page_state(page, order, ESSA_SET_STABLE);
91+
}
92+
93+
static inline void set_page_stable_nodat(struct page *page, int order)
94+
{
95+
__set_page_state(page, order, ESSA_SET_STABLE_NODAT);
9296
}
9397

9498
static void mark_kernel_pmd(pud_t *pud, unsigned long addr, unsigned long end)

0 commit comments

Comments
 (0)