From: Hugang <hugang@soulinfo.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Nigel Cunningham <ncunningham@users.sourceforge.net>,
ncunningham@clear.net.nz,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
debian-powerpc@lists.debian.org
Subject: Re: Help port swsusp to ppc.
Date: Fri, 23 Jan 2004 18:30:30 +0800 [thread overview]
Message-ID: <20040123183030.02fd16d6@localhost> (raw)
In-Reply-To: <1074841973.974.217.camel@gaston>
[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]
On Fri, 23 Jan 2004 18:12:53 +1100
Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> There is at least one reason I think your code cannot work: When
> resuming, you are basically blowing up the MMU hash table and kernel
> page tables when copying the pages. I'm hacking on an implementation
> of pmdisk at the moment that switches the MMU off during the page
> copy to avoid that problem. This isn't the best way though.
I has hacking on swsusp2 to ppc for whole day. Here is the update
swsusp2-asm.S.
First I can true suspend is ok, the data and CPU context are full write
to disk. Then in resume, the copyback function works.
How I know it?
I'm adding printk before do_swsusp2_lowleve finished, I has printf
the r1, That is the pointer to cpu context, it must right on resume,
when resume it'll triger xmon, I d pm_sleep_storage, and check the
pointer, I see that same things, So I true the copyback is ok, at least
the cpu context memory has backed.
very tire day.
The current problem that is, In resume, It stop with all register
(r0-r32) is zero. I don't known where I am. :)
> I'll keep you informed of my progress
I'm too. :)
--
Hu Gang / Steve
Linux Registered User 204016
GPG Public Key: http://soulinfo.com/~hugang/HuGang.asc
[-- Attachment #2: swsusp2-asm.S --]
[-- Type: application/octet-stream, Size: 10178 bytes --]
#include <linux/config.h>
#include <asm/processor.h>
#include <asm/page.h>
#include <asm/ppc_asm.h>
#include <asm/cputable.h>
#include <asm/cache.h>
#include <asm/thread_info.h>
#include <asm/offsets.h>
/*
* Structure for storing CPU registers on the stack.
*/
#define SL_SP 0
#define SL_PC (SL_SP + 0x4)
#define SL_MSR (SL_SP + 0x8)
#define SL_SDR1 (SL_SP + 0xc)
#define SL_SPRG0 (SL_SP + 0x10) /* 4 sprg's */
#define SL_DBAT0 (SL_SP + 0x20)
#define SL_IBAT0 (SL_SP + 0x28)
#define SL_DBAT1 (SL_SP + 0x30)
#define SL_IBAT1 (SL_SP + 0x38)
#define SL_DBAT2 (SL_SP + 0x40)
#define SL_IBAT2 (SL_SP + 0x48)
#define SL_DBAT3 (SL_SP + 0x50)
#define SL_IBAT3 (SL_SP + 0x58)
#define SL_TB (SL_SP + 0x60)
#define SL_R2 (SL_SP + 0x68)
#define SL_CR (SL_SP + 0x6c)
#define SL_R12 (SL_SP + 0x70) /* r12 to r31 */
#define SL_SIZE (SL_R12 + 80)
#if 0
.section .rodata
ptr_debug:
.string "ptr %x\n"
#endif
.section .text
.align 5
_GLOBAL(do_swsusp_lowlevel)
mflr r0 /* save return address into r0 */
cmpwi 0,r3,0
bc 4,2,.L3627
bl do_swsusp2_suspend_1
stw r0,SL_PC(r1) /* save return address into r1 + 4 */
stwu r1,-SL_SIZE(r1) /* save r1 into r1 - SL_SIZE */
mfcr r0 /* condition register save */
stw r0,SL_CR(r1)
stw r2,SL_R2(r1) /* r2 */
stmw r12,SL_R12(r1) /* r12 */
/* Save MSR & SDR1 */
mfmsr r4
stw r4,SL_MSR(r1)
mfsdr1 r4
stw r4,SL_SDR1(r1)
/* Get a stable timebase and save it */
1: mftbu r4
stw r4,SL_TB(r1)
mftb r5
stw r5,SL_TB+4(r1)
mftbu r3
cmpw r3,r4
bne 1b
/* Save SPRGs */
mfsprg r4,0
stw r4,SL_SPRG0(r1)
mfsprg r4,1
stw r4,SL_SPRG0+4(r1)
mfsprg r4,2
stw r4,SL_SPRG0+8(r1)
mfsprg r4,3
stw r4,SL_SPRG0+12(r1)
/* Save BATs */
mfdbatu r4,0
stw r4,SL_DBAT0(r1)
mfdbatl r4,0
stw r4,SL_DBAT0+4(r1)
mfdbatu r4,1
stw r4,SL_DBAT1(r1)
mfdbatl r4,1
stw r4,SL_DBAT1+4(r1)
mfdbatu r4,2
stw r4,SL_DBAT2(r1)
mfdbatl r4,2
stw r4,SL_DBAT2+4(r1)
mfdbatu r4,3
stw r4,SL_DBAT3(r1)
mfdbatl r4,3
stw r4,SL_DBAT3+4(r1)
mfibatu r4,0
stw r4,SL_IBAT0(r1)
mfibatl r4,0
stw r4,SL_IBAT0+4(r1)
mfibatu r4,1
stw r4,SL_IBAT1(r1)
mfibatl r4,1
stw r4,SL_IBAT1+4(r1)
mfibatu r4,2
stw r4,SL_IBAT2(r1)
mfibatl r4,2
stw r4,SL_IBAT2+4(r1)
mfibatu r4,3
stw r4,SL_IBAT3(r1)
mfibatl r4,3
stw r4,SL_IBAT3+4(r1)
#if 0 /* TEST_CODE */
lis r4,0x1234
ori r4,r4,0x56
stw r4,-(SL_SIZE + 4)(r1)
#endif
/* get r1 physical ptr */
tophys(r5,r1)
addi r5,r5,SL_PC
/* save storage ptr */
lis r3,pm_sleep_storage@ha
addi r3,r3,pm_sleep_storage@l
stw r5,0(r3)
#if 0
/* printf ptr */
lis r3,ptr_debug@ha
la r3,ptr_debug@l(r3)
bl printk
#endif
/* Backup various CPU configs stuffs */
bl __save_cpu_setup
bl do_swsusp2_suspend_2
b restore_stack
.L3627:
bl do_swsusp2_resume_1
lis r9,swsusp_action@ha
lwz r0,swsusp_action@l(r9)
lis r11,swsusp_debug_state@ha
lis r9,state1@ha
stw r0,state1@l(r9)
lwz r8,swsusp_debug_state@l(r11)
lis r10,console_printk@ha
lis r9,state2@ha
lis r11,pagedir_resume@ha
stw r8,state2@l(r9)
la r11,pagedir_resume@l(r11)
lwz r0,console_printk@l(r10)
lwz r5,12(r11)
lis r9,state3@ha
stw r0,state3@l(r9)
lwz r10,0(r5)
lwz r4,56(r11)
lis r9,origoffset@ha
stw r10,origoffset@l(r9)
lwz r0,0(r4)
lis r11,copyoffset@ha
stw r0,copyoffset@l(r11)
lwz r10,origoffset@l(r9)
lwz r8,copyoffset@l(r11)
slwi r9,r10,r2
slwi r11,r8,r2
add r9,r9,r10
add r11,r11,8
lis r0,0xcccc
ori r0,r0,52429
slwi r9,r9,r3
slwi r11,r11,r3
mullw r11,r11,r0
mullw r9,r9,r0
slwi r11,r11,r9
slwi r9,r9,r9
cmpwi r0,r5,r0
addis r9,r9,0xc000
addis r11,r11,0xc000
lis r7,origrange@ha
lis r6,copyrange@ha
lis r10,origpage@ha
lis r8,copypage@ha
lis r24,origrange@ha
lis r25,copyrange@ha
lis r12,origoffset@ha
lis r3,copyoffset@ha
stw r9,origpage@l(r10)
stw r11,copypage@l(r8)
stw r5,origrange@l(r7)
stw r4,copyrange@l(r6)
bc r12,r2,.L3646
lis r4,0xcccc
lis r28,loop@ha
lis r26,origoffset@ha
lis r29,origrange@ha
lis r30,origpage@ha
ori r4,r4,52429
lis r27,copyoffset@ha
lis r31,copypage@ha
.L3632:
li r0,r0
stw r0,loop@l(r28)
lwz r9,loop@l(r28)
cmplwi r0,r9,1023
bc r12,r1,.L3637
lis r7,loop@ha
lis r5,origpage@ha
lis r6,copypage@ha
.L3635:
lwz r8,loop@l(r7)
lwz r9,loop@l(r7)
lwz r11,copypage@l(r6)
slwi r9,r9,r2
lwzx r0,r9,r11
lwz r10,origpage@l(r5)
slwi r8,r8,r2
stwx r0,r8,r10
lwz r9,loop@l(r7)
addi r9,r9,r1
stw r9,loop@l(r7)
lwz r0,loop@l(r7)
cmplwi r0,r0,1023
bc r4,r1,.L3635
.L3637:
lwz r11,origrange@l(r29)
lwz r9,origoffset@l(r26)
lwz r0,4(r11)
cmplw r0,r9,r0
bc r4,r0,.L3638
lwz r9,origoffset@l(r12)
lwz r11,origpage@l(r30)
addi r9,r9,r1
addi r11,r11,4096
stw r9,origoffset@l(r12)
stw r11,origpage@l(r30)
b .L3639
.L3638:
lwz r9,8(r11)
cmpwi r0,r9,r0
stw r9,origrange@l(r24)
bc r12,r2,.L3639
lwz r9,0(r9)
stw r9,origoffset@l(r12)
lwz r0,origoffset@l(r12)
slwi r9,r0,r2
add r9,r9,r0
slwi r9,r9,r3
mullw r9,r9,r4
slwi r9,r9,r9
addis r9,r9,0xc000
stw r9,origpage@l(r30)
.L3639:
lis r9,copyrange@ha
lwz r9,copyrange@l(r9)
lwz r11,copyoffset@l(r27)
lwz r0,4(r9)
cmplw r0,r11,r0
bc r4,r0,.L3642
lwz r9,copyoffset@l(r3)
lwz r11,copypage@l(r31)
addi r9,r9,r1
addi r11,r11,4096
stw r9,copyoffset@l(r3)
stw r11,copypage@l(r31)
b .L3630
.L3642:
lwz r9,r8(r9)
cmpwi r0,r9,r0
stw r9,copyrange@l(r25)
bc r12,r2,.L3630
lwz r9,0(r9)
stw r9,copyoffset@l(r3)
lwz r0,copyoffset@l(r3)
slwi r9,r0,r2
add r9,r9,r0
slwi r9,r9,r3
mullw r9,r9,r4
slwi r9,r9,r9
addis r9,r9,0xc000
stw 9,copypage@l(r31)
.L3630:
lwz r0,origrange@l(r29)
cmpwi r0,r0,r0
bc r4,r2,.L3632
.L3646:
lis r9,state1@ha
lwz r7,state1@l(r9)
lis r11,state2@ha
lwz r8,state2@l(r11)
lis r9,state3@ha
lwz r0,state3@l(r9)
lis r11,swsusp_action@ha
lis r9,swsusp_debug_state@ha
lis r10,console_printk@ha
stw r7,swsusp_action@l(r11)
stw r8,swsusp_debug_state@l(r9)
stw r0,console_printk@l(r10)
#if 0
// bl pm_turn_off_mmu
//#else
// mfmsr r3
// andi. r0,r3,MSR_DR|MSR_IR /* MMU enabled? */
beqlr
andc r3,r3,r0
mtspr SRR0,r4
mtspr SRR1,r3
sync
#endif
#if 0
/* Turn off data relocation. */
mfmsr r3 /* Save MSR in r3 */
rlwinm r3,r3,0,28,26 /* Turn off DR bit */
sync
mtmsr r3
isync
#endif
#if 0 /* force supervisor */
mfmsr r4
li r3,MSR_PR /* ensure supervisor! */
ori r3,r3,MSR_IR|MSR_DR
andc r4,r4,r3
mtmsr r4
isync
#endif
#if 0 /* MMU off */
li r3,0
mtspr IBAT0U,r3
mtspr IBAT0L,r3
mtspr IBAT1U,r3
mtspr IBAT1L,r3
mtspr IBAT2U,r3
mtspr IBAT2L,r3
mtspr IBAT3U,r3
mtspr IBAT3L,r3
mtspr DBAT0U,r3
mtspr DBAT0L,r3
mtspr DBAT1U,r3
mtspr DBAT1L,r3
mtspr DBAT2U,r3
mtspr DBAT2L,r3
mtspr DBAT3U,r3
mtspr DBAT3L,r3
#endif
#if 0
/* Make sure HID0 no longer contains any sleep bit */
mfspr r3,HID0
rlwinm r3,r3,0,11,7 /* clear SLEEP, NAP, DOZE bits */
mtspr HID0,r3
sync
isync
#endif
#if 0
/* Won't that cause problems on CPU that doesn't support it ? */
lis r3, 0
mtspr SPRN_MMCR0, r3
#endif
/* sanitize MSR */
mfmsr r3
ori r3,r3,MSR_EE|MSR_IP
xori r3,r3,MSR_EE|MSR_IP
sync
isync
mtmsr r3
sync
isync
/* Recover sleep storage */
lis r3,pm_sleep_storage@ha
addi r3,r3,pm_sleep_storage@l
tophys(r3,r3)
lwz r1,0(r3)
/* Invalidate & enable L1 cache, we don't care about
* whatever the ROM may have tried to write to memory
*/
bl __inval_enable_L1
/* Restore the kernel's segment registers before
* we do any r1 memory access as we are not sure they
* are in a sane state above the first 256Mb region
*/
li r0,16 /* load up segment register values */
mtctr r0 /* for context 0 */
lis r3,0x2000 /* Ku = 1, VSID = 0 */
li r4,0
3: mtsrin r3,r4
addi r3,r3,0x111 /* increment VSID */
addis r4,r4,0x1000 /* address of next segment */
bdnz 3b
sync
isync
subi r1,r1,SL_PC
/* Restore various CPU config stuffs */
bl __restore_cpu_setup
/* Restore the BATs, and SDR1. Then we can turn on the MMU. */
lwz r4,SL_SDR1(r1)
mtsdr1 r4
lwz r4,SL_SPRG0(r1)
mtsprg 0,r4
lwz r4,SL_SPRG0+4(r1)
mtsprg 1,r4
lwz r4,SL_SPRG0+8(r1)
mtsprg 2,r4
lwz r4,SL_SPRG0+12(r1)
mtsprg 3,r4
lwz r4,SL_DBAT0(r1)
mtdbatu 0,r4
lwz r4,SL_DBAT0+4(r1)
mtdbatl 0,r4
lwz r4,SL_DBAT1(r1)
mtdbatu 1,r4
lwz r4,SL_DBAT1+4(r1)
mtdbatl 1,r4
lwz r4,SL_DBAT2(r1)
mtdbatu 2,r4
lwz r4,SL_DBAT2+4(r1)
mtdbatl 2,r4
lwz r4,SL_DBAT3(r1)
mtdbatu 3,r4
lwz r4,SL_DBAT3+4(r1)
mtdbatl 3,r4
lwz r4,SL_IBAT0(r1)
mtibatu 0,r4
lwz r4,SL_IBAT0+4(r1)
mtibatl 0,r4
lwz r4,SL_IBAT1(r1)
mtibatu 1,r4
lwz r4,SL_IBAT1+4(r1)
mtibatl 1,r4
lwz r4,SL_IBAT2(r1)
mtibatu 2,r4
lwz r4,SL_IBAT2+4(r1)
mtibatl 2,r4
lwz r4,SL_IBAT3(r1)
mtibatu 3,r4
lwz r4,SL_IBAT3+4(r1)
mtibatl 3,r4
BEGIN_FTR_SECTION
li r4,0
mtspr SPRN_DBAT4U,r4
mtspr SPRN_DBAT4L,r4
mtspr SPRN_DBAT5U,r4
mtspr SPRN_DBAT5L,r4
mtspr SPRN_DBAT6U,r4
mtspr SPRN_DBAT6L,r4
mtspr SPRN_DBAT7U,r4
mtspr SPRN_DBAT7L,r4
mtspr SPRN_IBAT4U,r4
mtspr SPRN_IBAT4L,r4
mtspr SPRN_IBAT5U,r4
mtspr SPRN_IBAT5L,r4
mtspr SPRN_IBAT6U,r4
mtspr SPRN_IBAT6L,r4
mtspr SPRN_IBAT7U,r4
mtspr SPRN_IBAT7L,r4
END_FTR_SECTION_IFSET(CPU_FTR_HAS_HIGH_BATS)
/* Flush all TLBs */
lis r4,0x1000
1: addic. r4,r4,-0x1000
tlbie r4
blt 1b
sync
/* restore the MSR and turn on the MMU */
lwz r3,SL_MSR(r1)
bl pm_turn_on_mmu
/* get back the stack pointer */
tovirt(r1,r1)
/* Restore TB */
li r3,0
mttbl r3
lwz r3,SL_TB(r1)
lwz r4,SL_TB+4(r1)
mttbu r3
mttbl r4
bl do_swsusp2_resume_2
restore_stack:
/* Restore the callee-saved registers and return */
lwz r0,SL_CR(r1)
mtcr r0
lwz r2,SL_R2(r1)
lmw r12,SL_R12(r1)
addi r1,r1,SL_SIZE
lwz r0,4(r1)
mtlr r0
blr
pm_turn_on_mmu:
mflr r4
tovirt(r4,r4)
mtsrr0 r4
mtsrr1 r3
sync
isync
rfi
pm_turn_off_mmu:
mfmsr r3
andi. r0,r3,MSR_DR|MSR_IR /* MMU enabled? */
beqlr
andc r3,r3,r0
mtspr SRR0,r4
mtspr SRR1,r3
sync
rfi
.section ".data.nosave"
origrange:
.long 0
copyrange:
.long 0
origoffset:
.long 0
copyoffset:
.long 0
origpage:
.long 0
copypage:
.long 0
loop:
.long 0
state1:
.long 0
state2:
.long 0
state3:
.long 0
c_loops_per_jiffy_ref:
.long 0
cpu_khz_ref:
.long 0
.section .data
.balign L1_CACHE_LINE_SIZE
pm_sleep_storage:
.long 0
.balign L1_CACHE_LINE_SIZE,0
.text
next prev parent reply other threads:[~2004-01-23 10:31 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-19 2:52 Help port swsusp to ppc Hugang
2004-01-19 3:04 ` Nigel Cunningham
2004-01-19 3:35 ` Benjamin Herrenschmidt
2004-01-19 5:20 ` Nigel Cunningham
2004-01-19 11:39 ` Benjamin Herrenschmidt
2004-01-19 17:56 ` Nigel Cunningham
2004-01-19 22:03 ` Benjamin Herrenschmidt
2004-01-20 20:44 ` Pavel Machek
2004-01-20 21:54 ` Benjamin Herrenschmidt
2004-01-20 22:07 ` Nigel Cunningham
2004-01-20 22:42 ` Pavel Machek
2004-01-22 13:17 ` Hugang
2004-01-22 17:53 ` Nigel Cunningham
2004-01-23 0:15 ` Hugang
2004-01-23 7:12 ` Benjamin Herrenschmidt
2004-01-23 10:30 ` Hugang [this message]
2004-01-24 2:54 ` pmdisk working on ppc (WAS: Help port swsusp to ppc) Benjamin Herrenschmidt
2004-01-24 5:40 ` Hugang
2004-01-24 16:28 ` Colin Leroy
2004-01-24 23:46 ` Benjamin Herrenschmidt
2004-01-25 18:08 ` Colin Leroy
2004-01-26 0:08 ` Benjamin Herrenschmidt
2004-01-26 18:21 ` Colin Leroy
2004-01-26 21:58 ` Benjamin Herrenschmidt
2004-01-26 14:29 ` Guido Guenther
[not found] ` <20040126181004.GB315@elf.ucw.cz>
2004-01-26 22:00 ` Benjamin Herrenschmidt
2004-01-26 22:31 ` Nigel Cunningham
2004-01-28 12:22 ` Hugang
2004-01-28 13:23 ` pmdisk working on ppc (WAS: Help port swsusp to ppc), swsusp2 works Hugang
[not found] ` <20040129012720.1385c41a@localhost>
2004-01-28 19:05 ` Nigel Cunningham
2004-01-28 19:10 ` Hugang
2004-01-29 0:34 ` pmdisk working on ppc (WAS: Help port swsusp to ppc) Benjamin Herrenschmidt
2004-01-29 2:05 ` Hugang
2004-01-29 4:23 ` Benjamin Herrenschmidt
[not found] ` <20040129165119.553403f1@localhost>
2004-01-29 10:29 ` Pavel Machek
2004-01-29 10:50 ` Hugang
2004-01-29 12:12 ` Benjamin Herrenschmidt
2004-01-26 23:21 ` Pavel Machek
2004-01-27 0:12 ` Nigel Cunningham
2004-01-27 7:53 ` Pavel Machek
2004-01-24 4:39 ` Benjamin Herrenschmidt
2004-01-24 7:20 ` Pavel Machek
2004-01-24 9:59 ` pmdisk working on ppc Måns Rullgård
2004-01-19 20:45 ` Help port swsusp to ppc Pavel Machek
2004-01-19 23:38 ` Benjamin Herrenschmidt
2004-01-20 0:04 ` Pavel Machek
2004-01-20 1:06 ` Benjamin Herrenschmidt
2004-01-20 10:02 ` Pavel Machek
2004-01-20 11:25 ` Benjamin Herrenschmidt
2004-01-20 11:44 ` Pavel Machek
2004-01-20 9:53 ` Geert Uytterhoeven
2004-01-20 10:04 ` Pavel Machek
2004-01-20 11:26 ` Benjamin Herrenschmidt
2004-01-20 11:36 ` Pavel Machek
2004-01-20 11:44 ` Benjamin Herrenschmidt
2004-01-20 11:57 ` Pavel Machek
2004-01-20 18:30 ` Nigel Cunningham
2004-01-20 21:43 ` Benjamin Herrenschmidt
2004-01-20 11:22 ` Benjamin Herrenschmidt
2004-01-19 20:40 ` Pavel Machek
2004-01-19 23:40 ` Benjamin Herrenschmidt
2004-01-19 23:59 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040123183030.02fd16d6@localhost \
--to=hugang@soulinfo.com \
--cc=benh@kernel.crashing.org \
--cc=debian-powerpc@lists.debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ncunningham@clear.net.nz \
--cc=ncunningham@users.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox