public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Pavel Machek <pavel@ucw.cz>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	kernel list <linux-kernel@vger.kernel.org>,
	Linux-pm mailing list <linux-pm@lists.osdl.org>
Subject: Re: [rft] s2ram wakeup moves to .c, could fix few machines
Date: Fri, 8 Feb 2008 23:01:51 +0100	[thread overview]
Message-ID: <200802082301.51582.rjw@sisk.pl> (raw)
In-Reply-To: <20080208215809.GN12923@elf.ucw.cz>

On Friday, 8 of February 2008, Pavel Machek wrote:
> Hi!
> 
> Rafael, this is for you.

Thanks.

> My cleanups, relative to your cleanup patch. You may need manual patching
> around rep/stosd.

OK, I'll try to merge it.

Rafael


> diff --git a/arch/x86/kernel/acpi/realmode/Makefile b/arch/x86/kernel/acpi/realmode/Makefile
> index b239f0f..0e4742b 100644
> --- a/arch/x86/kernel/acpi/realmode/Makefile
> +++ b/arch/x86/kernel/acpi/realmode/Makefile
> @@ -46,7 +46,10 @@ KBUILD_AFLAGS	:= $(KBUILD_CFLAGS) -D__AS
>  WAKEUP_OBJS = $(addprefix $(obj)/,$(wakeup-y))
>  
>  LDFLAGS_wakeup.elf	:= -T
> -$(obj)/wakeup.elf: $(src)/wakeup.ld $(WAKEUP_OBJS) FORCE
> +
> +CPPFLAGS_wakeup.lds += -P -C
> +
> +$(obj)/wakeup.elf: $(src)/wakeup.lds $(WAKEUP_OBJS) FORCE
>  	$(call if_changed,ld)
>  
>  OBJCOPYFLAGS_wakeup.bin	:= -O binary
> diff --git a/arch/x86/kernel/acpi/realmode/wakeup.S b/arch/x86/kernel/acpi/realmode/wakeup.S
> index 26145c0..edff763 100644
> --- a/arch/x86/kernel/acpi/realmode/wakeup.S
> +++ b/arch/x86/kernel/acpi/realmode/wakeup.S
> @@ -56,14 +56,6 @@ _start:
>  	cmpl	$0x65a22c82, %eax
>  	jne	bogus_real_magic
>  
> -	/* Zero the bss */
> -	xorl	%eax, %eax
> -	movw	$__bss_start, %di
> -	movw	$__bss_end + 3, %cx
> -	subw	%di, %cx
> -	shrw	$2, %cx
> -	rep; stosl
> -
>  	/* Call the C code */
>  	calll	main
>  
> diff --git a/arch/x86/kernel/acpi/realmode/wakeup.h b/arch/x86/kernel/acpi/realmode/wakeup.h
> index 4a26e27..6a49435 100644
> --- a/arch/x86/kernel/acpi/realmode/wakeup.h
> +++ b/arch/x86/kernel/acpi/realmode/wakeup.h
> @@ -6,12 +6,11 @@
>  #ifndef ARCH_X86_KERNEL_ACPI_RM_WAKEUP_H
>  #define ARCH_X86_KERNEL_ACPI_RM_WAKEUP_H
>  
> +#ifndef __ASSEMBLY__
>  #include <linux/types.h>
>  
>  /* This must match data at wakeup.S */
>  struct wakeup_header {
> -	u16 entry;		/* unused */
> -	u16 total;		/* unused */
>  	u16 video_mode;		/* Video mode number */
>  	u16 _jmp1;
>  	u32 pmode_entry;	/* Protected mode resume point */
> @@ -27,5 +26,10 @@ struct wakeup_header {
>  	u16 trampoline_segment;
>  	u32 signature;		/* To check we have correct structure */
>  } __attribute__((__packed__));
> +#endif
> +
> +#define HEADER_OFFSET 0x3f00
> +#define WAKEUP_SIZE   0x4000
> +
>  
>  #endif /* ARCH_X86_KERNEL_ACPI_RM_WAKEUP_H */
> diff --git a/arch/x86/kernel/acpi/realmode/wakeup.ld b/arch/x86/kernel/acpi/realmode/wakeup.ld
> deleted file mode 100644
> index 5dff2f0..0000000
> --- a/arch/x86/kernel/acpi/realmode/wakeup.ld
> +++ /dev/null
> @@ -1,51 +0,0 @@
> -/*
> - * wakeup.ld
> - *
> - * Linker script for the real-mode wakeup code
> - */
> -OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
> -OUTPUT_ARCH(i386)
> -ENTRY(_start)
> -
> -SECTIONS
> -{
> -	. = 0x3f00;
> -	.header		: { *(.header) }
> -
> -	. = 0;
> -	.text		: { *(.text*) }
> -
> -	. = ALIGN(16);
> -	.rodata		: { *(.rodata*) }
> -
> -	.videocards	: {
> -		video_cards = .;
> -		*(.videocards)
> -		video_cards_end = .;
> -	}
> -
> -	. = ALIGN(16);
> -	.data		: { *(.data*) }
> -
> -	.signature	: {
> -		end_signature = .;
> -		LONG(0x65a22c82)
> -	}
> -
> -	. = ALIGN(16);
> -	.bss		:
> -	{
> -		__bss_start = .;
> -		*(.bss)
> -		__bss_end = .;
> -	}
> -
> -	. = ALIGN(16);
> -	_end = .;
> -
> -	/DISCARD/ : { *(.note*) }
> -
> -	/* Adjust this as appropriate */
> -	/* This allows 4 pages (16K) */
> -	. = ASSERT(_end <= 0x4000, "Wakeup too big!");
> -}
> diff --git a/arch/x86/kernel/acpi/realmode/wakeup.lds.S b/arch/x86/kernel/acpi/realmode/wakeup.lds.S
> new file mode 100644
> index 0000000..22fab6c
> --- /dev/null
> +++ b/arch/x86/kernel/acpi/realmode/wakeup.lds.S
> @@ -0,0 +1,61 @@
> +/*
> + * wakeup.ld
> + *
> + * Linker script for the real-mode wakeup code
> + */
> +#undef i386
> +#include "wakeup.h"
> +
> +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
> +OUTPUT_ARCH(i386)
> +ENTRY(_start)
> +
> +SECTIONS
> +{
> +	. = HEADER_OFFSET;
> +	.header : {
> +		 *(.header)
> +	}
> +
> +	. = 0;
> +	.text : {
> +		 *(.text*)
> +	}
> +
> +	. = ALIGN(16);
> +	.rodata : {
> +		*(.rodata*)
> +	}
> +
> +	.videocards : {
> +		video_cards = .;
> +		*(.videocards)
> +		video_cards_end = .;
> +	}
> +
> +	. = ALIGN(16);
> +	.data : {
> +		 *(.data*)
> +	}
> +
> +	.signature : {
> +		end_signature = .;
> +		LONG(0x65a22c82)
> +	}
> +
> +	. = ALIGN(16);
> +	.bss :	{
> +		__bss_start = .;
> +		*(.bss)
> +		__bss_end = .;
> +	}
> +
> +	. = ALIGN(16);
> +	_end = .;
> +
> +	/DISCARD/ : {
> +		*(.note*)
> +	}
> +
> +	. = ASSERT(_end <= WAKEUP_SIZE, "Wakeup too big!");
> +}
> diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
> index 1b282b1..561565e 100644
> --- a/arch/x86/kernel/acpi/sleep.c
> +++ b/arch/x86/kernel/acpi/sleep.c
> @@ -53,9 +53,9 @@ int acpi_save_state_mem(void)
>  		       "S3 disabled\n");
>  		return -ENOMEM;
>  	}
> -	memcpy((void *)acpi_realmode, &wakeup_code_start, 4*PAGE_SIZE);
> +	memcpy((void *)acpi_realmode, &wakeup_code_start, WAKEUP_SIZE);
>  
> -	header = (struct wakeup_header *)(acpi_realmode + 0x3f00);
> +	header = (struct wakeup_header *)(acpi_realmode + HEADER_OFFSET);
>  	if (header->signature != 0x51ee1111) {
>  		printk(KERN_ERR "wakeup header does not match\n");
>  		return -EINVAL;
> @@ -111,13 +111,13 @@ void acpi_restore_state_mem(void)
>   */
>  void __init acpi_reserve_bootmem(void)
>  {
> -	if ((&wakeup_code_end - &wakeup_code_start) > PAGE_SIZE*4) {
> +	if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
>  		printk(KERN_ERR
>  		       "ACPI: Wakeup code way too big, S3 disabled.\n");
>  		return;
>  	}
>  
> -	acpi_realmode = (unsigned long)alloc_bootmem_low(PAGE_SIZE*4);
> +	acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
>  
>  	if (!acpi_realmode) {
>  		printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
> 
> 



-- 
"Premature optimization is the root of all evil." - Donald Knuth

  reply	other threads:[~2008-02-08 22:01 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-05 19:06 [rft] s2ram wakeup moves to .c, could fix few machines Pavel Machek
2008-02-06  1:27 ` Rafael J. Wysocki
2008-02-06  1:36   ` H. Peter Anvin
2008-02-06  1:42     ` Rafael J. Wysocki
2008-02-06  1:51       ` H. Peter Anvin
2008-02-06  1:56         ` Rafael J. Wysocki
2008-02-06 11:29         ` Pavel Machek
2008-02-14  2:54         ` Bill Davidsen
2008-02-06 23:48   ` Rafael J. Wysocki
2008-02-07 22:12     ` Rafael J. Wysocki
2008-02-07 22:28       ` Sam Ravnborg
2008-02-07 22:34         ` H. Peter Anvin
2008-02-08 21:31         ` Pavel Machek
2008-02-08 21:34         ` Pavel Machek
2008-02-08 21:41         ` Pavel Machek
2008-02-08 21:47           ` Sam Ravnborg
2008-02-08 21:49         ` Pavel Machek
2008-02-07 22:28       ` Pavel Machek
2008-02-07 22:40         ` Rafael J. Wysocki
2008-02-07 22:44           ` H. Peter Anvin
2008-02-07 22:53             ` Rafael J. Wysocki
2008-02-07 22:45           ` H. Peter Anvin
2008-02-07 22:49             ` Pavel Machek
2008-02-08 21:13           ` Pavel Machek
2008-02-08 21:41             ` Maxim Levitsky
2008-02-08 21:51               ` Pavel Machek
2008-02-07 22:46         ` H. Peter Anvin
2008-02-07 22:51           ` Pavel Machek
2008-02-07 23:09             ` Rafael J. Wysocki
2008-02-07 22:57           ` Rafael J. Wysocki
2008-02-07 23:14             ` H. Peter Anvin
2008-02-08 21:35               ` Pavel Machek
2008-02-07 22:38       ` H. Peter Anvin
2008-02-07 23:06         ` Rafael J. Wysocki
2008-02-07 23:13           ` H. Peter Anvin
2008-02-07 23:35           ` Pavel Machek
2008-02-07 23:36             ` Rafael J. Wysocki
2008-02-07 23:41               ` Pavel Machek
2008-02-07 23:42             ` H. Peter Anvin
2008-02-08  7:04               ` Pavel Machek
2008-02-08  7:40                 ` H. Peter Anvin
2008-02-08 16:23                 ` Rafael J. Wysocki
2008-02-08 21:00                   ` Pavel Machek
2008-02-08 21:02                     ` H. Peter Anvin
2008-02-08 21:09                       ` Pavel Machek
2008-02-08 21:18                         ` H. Peter Anvin
2008-02-08 21:20                     ` [linux-pm] " Alan Stern
2008-02-08 21:23                       ` Pavel Machek
2008-02-08 21:27                         ` H. Peter Anvin
2008-02-08 21:31                           ` Pavel Machek
2008-02-08 21:56                             ` Rafael J. Wysocki
2008-02-08 21:59                               ` Pavel Machek
2008-02-08 21:56         ` Pavel Machek
2008-02-08 21:58         ` Pavel Machek
2008-02-08 22:01           ` Rafael J. Wysocki [this message]
2008-02-08 22:08             ` Pavel Machek
2008-02-09  0:18               ` Rafael J. Wysocki
2008-02-09  0:32                 ` H. Peter Anvin
2008-02-09 13:48                   ` Rafael J. Wysocki
2008-02-10 21:14                   ` Pavel Machek
2008-02-10 21:21                     ` Sam Ravnborg
2008-02-06 23:37 ` Rafael J. Wysocki

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=200802082301.51582.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.osdl.org \
    --cc=pavel@ucw.cz \
    /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