Skip to content

Commit

Permalink
[PPC] 8xx: swap bug-fix
Browse files Browse the repository at this point in the history
This makes swap routines operate correctly on the ppc_8xx based machines.

Recent kernel's size makes swap feature very important on low-memory platfor
those are actually non-operable without it.

Signed-off-by: Yuri Tikhonov <yur@emcraft.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
  • Loading branch information
Yuri Tikhonov authored and Kumar Gala committed Mar 7, 2008
1 parent 3e0d65b commit 1757f2d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
30 changes: 29 additions & 1 deletion arch/ppc/kernel/head_8xx.S
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,18 @@ InstructionTLBMiss:
mfspr r11, SPRN_MD_TWC /* ....and get the pte address */
lwz r10, 0(r11) /* Get the pte */

#ifdef CONFIG_SWAP
/* do not set the _PAGE_ACCESSED bit of a non-present page */
andi. r11, r10, _PAGE_PRESENT
beq 4f
ori r10, r10, _PAGE_ACCESSED
mfspr r11, SPRN_MD_TWC /* get the pte address again */
stw r10, 0(r11)
4:
#else
ori r10, r10, _PAGE_ACCESSED
stw r10, 0(r11)
#endif

/* The Linux PTE won't go exactly into the MMU TLB.
* Software indicator bits 21, 22 and 28 must be clear.
Expand Down Expand Up @@ -395,8 +405,17 @@ DataStoreTLBMiss:
DO_8xx_CPU6(0x3b80, r3)
mtspr SPRN_MD_TWC, r11

mfspr r11, SPRN_MD_TWC /* get the pte address again */
#ifdef CONFIG_SWAP
/* do not set the _PAGE_ACCESSED bit of a non-present page */
andi. r11, r10, _PAGE_PRESENT
beq 4f
ori r10, r10, _PAGE_ACCESSED
4:
/* and update pte in table */
#else
ori r10, r10, _PAGE_ACCESSED
#endif
mfspr r11, SPRN_MD_TWC /* get the pte address again */
stw r10, 0(r11)

/* The Linux PTE won't go exactly into the MMU TLB.
Expand Down Expand Up @@ -575,7 +594,16 @@ DataTLBError:

/* Update 'changed', among others.
*/
#ifdef CONFIG_SWAP
ori r10, r10, _PAGE_DIRTY|_PAGE_HWWRITE
/* do not set the _PAGE_ACCESSED bit of a non-present page */
andi. r11, r10, _PAGE_PRESENT
beq 4f
ori r10, r10, _PAGE_ACCESSED
4:
#else
ori r10, r10, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
#endif
mfspr r11, SPRN_MD_TWC /* Get pte address again */
stw r10, 0(r11) /* and update pte in table */

Expand Down
8 changes: 0 additions & 8 deletions include/asm-ppc/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,6 @@ extern unsigned long ioremap_bot, ioremap_base;
#define _PMD_PAGE_MASK 0x000c
#define _PMD_PAGE_8M 0x000c

/*
* The 8xx TLB miss handler allegedly sets _PAGE_ACCESSED in the PTE
* for an address even if _PAGE_PRESENT is not set, as a performance
* optimization. This is a bug if you ever want to use swap unless
* _PAGE_ACCESSED is 2, which it isn't, or unless you have 8xx-specific
* definitions for __swp_entry etc. below, which would be gross.
* -- paulus
*/
#define _PTE_NONE_MASK _PAGE_ACCESSED

#else /* CONFIG_6xx */
Expand Down

0 comments on commit 1757f2d

Please sign in to comment.