public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ncunningham@users.sourceforge.net, Hugang <hugang@soulinfo.com>,
	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: Tue, 20 Jan 2004 21:44:07 +0100	[thread overview]
Message-ID: <20040120204407.GA9749@elf.ucw.cz> (raw)
In-Reply-To: <1074549790.10595.55.camel@gaston>

Hi!

> > On Tue, 2004-01-20 at 00:39, Benjamin Herrenschmidt wrote:
> > > I see no reason why this would be needed on ppc, only the last step,
> > > that is the actual CPU state save, should matter.
> > 
> > Besides saving the CPU state, the code copies the original kernel back.
> > It sort of defeats the purpose to remove that code :>
> 
> Ok, you mean copying the memory pages back down ? That should be done
> with hand-made assembly or C code located specifically elsewhere then.
> I do not want to see any kind of this ugly C-generated assembly in
> arch/ppc.

FYI, this is that "ugly C-generated assembly" we are talking about. I
do not think it is so bad.

.text

/* Originally gcc generated, modified by hand */

#include <linux/linkage.h>
#include <asm/segment.h>
#include <asm/page.h>

	.text

ENTRY(do_magic)
	pushl %ebx
	cmpl $0,8(%esp)
	jne .L1450
	call do_magic_suspend_1
	call save_processor_state

	movl %esp, saved_context_esp
	movl %eax, saved_context_eax
	movl %ebx, saved_context_ebx
	movl %ecx, saved_context_ecx
	movl %edx, saved_context_edx
	movl %ebp, saved_context_ebp
	movl %esi, saved_context_esi
	movl %edi, saved_context_edi
	pushfl ; popl saved_context_eflags

	call do_magic_suspend_2
	jmp .L1449
	.p2align 4,,7
.L1450:
	movl $swapper_pg_dir-__PAGE_OFFSET,%ecx
	movl %ecx,%cr3

	call do_magic_resume_1
	movl $0,loop
	cmpl $0,nr_copy_pages
	je .L1453
	.p2align 4,,7
.L1455:
	movl $0,loop2
	.p2align 4,,7
.L1459:
	movl pagedir_nosave,%ecx
	movl loop,%eax
	movl loop2,%edx
	sall $4,%eax
	movl 4(%ecx,%eax),%ebx
	movl (%ecx,%eax),%eax
	movb (%edx,%eax),%al
	movb %al,(%edx,%ebx)
	movl %cr3, %eax;              
	movl %eax, %cr3;  # flush TLB 

	movl loop2,%eax
	leal 1(%eax),%edx
	movl %edx,loop2
	movl %edx,%eax
	cmpl $4095,%eax
	jbe .L1459
	movl loop,%eax
	leal 1(%eax),%edx
	movl %edx,loop
	movl %edx,%eax
	cmpl nr_copy_pages,%eax
	jb .L1455
	.p2align 4,,7
.L1453:
	movl $__USER_DS,%eax

	movw %ax, %ds
	movw %ax, %es
	movl saved_context_esp, %esp
	movl saved_context_ebp, %ebp
	movl saved_context_eax, %eax
	movl saved_context_ebx, %ebx
	movl saved_context_ecx, %ecx
	movl saved_context_edx, %edx
	movl saved_context_esi, %esi
	movl saved_context_edi, %edi
	call restore_processor_state
	pushl saved_context_eflags ; popfl
	call do_magic_resume_2
.L1449:
	popl %ebx
	ret

       .section .data.nosave
loop:
       .quad 0
loop2:
       .quad 0
       .previous


> > It is a well defined interface: a section of memory marked nosave, with
> > variables given the matching attribute. Not my idea, by the way. If you
> > have a problem, you should be taking it up with Pavel or Linus. We
> > should also note that the interface can't be too well defined - there
> > has to be room for development over time.
> 
> Still... That makes assumptions about how it's located and organised
> that plain wrong (c). Please get rid of that, at least I won't let a
> PPC

FYI, there are exactly 6 variables in "nosave" section. Two loop
variables you can see in above code, one spinlock, number of pages to
save, pointer to directory of pages to be copied, and its length.

I could probably move spinlock and length of pgdir out of there...

> > Yes. we device_suspend. Regarding the similarities with kexec, I fully
> > agree. In fact, there is also LKCD to think off. There should be a
> > synergy here.
> 
> device_suspend is, imho, hairy too. We have some semantics that need
> cleanup here, I'll have to talk to Patrick about them. Putting devices
> to an idle state is what you need and what kexec need, and doesn't mean
> putting them to _sleep_. Or maybe we could pass a specific state to

Okay, I can agree that putting them into sleep is not ideal [it
puzzles users, at least]. But it is quite simple and should work
okay. I do not want another round of device_suspend changes in
2.6.X... [Well, perhaps if it was done in right&compatible way (tm),
it would be acceptable...]
								Pavel
-- 
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]

  reply	other threads:[~2004-01-20 20:45 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 [this message]
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
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=20040120204407.GA9749@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=benh@kernel.crashing.org \
    --cc=debian-powerpc@lists.debian.org \
    --cc=hugang@soulinfo.com \
    --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