Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
67fbb3bf
Commit
67fbb3bf
authored
May 23, 2002
by
Pavel Machek
Committed by
Linus Torvalds
May 23, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] swsusp cleanups
These are cleanups. They do not change any code, except killing printk's.
parent
5d652eb5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
104 deletions
+28
-104
Documentation/swsusp.txt
Documentation/swsusp.txt
+0
-1
arch/i386/kernel/acpi_wakeup.S
arch/i386/kernel/acpi_wakeup.S
+0
-5
drivers/acpi/acpi_system.c
drivers/acpi/acpi_system.c
+0
-4
drivers/pci/power.c
drivers/pci/power.c
+2
-2
include/asm-i386/suspend.h
include/asm-i386/suspend.h
+19
-21
kernel/suspend.c
kernel/suspend.c
+7
-71
No files found.
Documentation/swsusp.txt
View file @
67fbb3bf
...
@@ -138,7 +138,6 @@ Things to implement
...
@@ -138,7 +138,6 @@ Things to implement
Not so important ideas for implementing
Not so important ideas for implementing
- If a real time process is running then don't suspend the machine.
- If a real time process is running then don't suspend the machine.
- Is there any sense in compressing the outwritten pages?
- Support for power.conf file as in Solaris, autoshutdown, special
- Support for power.conf file as in Solaris, autoshutdown, special
devicetypes support, maybe in sysctl.
devicetypes support, maybe in sysctl.
- Introduce timeout for SMP locking. But first locking ought to work :O
- Introduce timeout for SMP locking. But first locking ought to work :O
...
...
arch/i386/kernel/acpi_wakeup.S
View file @
67fbb3bf
...
@@ -17,11 +17,6 @@ wakeup_code:
...
@@ -17,11 +17,6 @@ wakeup_code:
cli
cli
cld
cld
#
setup
video
mode
#
movw
$
0x4117
,
%
bx
#
0x4000
for
linear
framebuffer
#
movw
$
0x4f02
,
%
ax
#
int
$
0x10
#
setup
data
segment
#
setup
data
segment
movw
%
cs
,
%
ax
movw
%
cs
,
%
ax
...
...
drivers/acpi/acpi_system.c
View file @
67fbb3bf
...
@@ -272,11 +272,9 @@ acpi_system_suspend(
...
@@ -272,11 +272,9 @@ acpi_system_suspend(
break
;
break
;
}
}
printk
(
"acpi_restore_register_state..."
);
acpi_restore_register_state
();
acpi_restore_register_state
();
restore_flags
(
flags
);
restore_flags
(
flags
);
printk
(
"acpi returning..."
);
return
status
;
return
status
;
}
}
...
@@ -323,9 +321,7 @@ acpi_suspend (
...
@@ -323,9 +321,7 @@ acpi_suspend (
* no matter what.
* no matter what.
*/
*/
acpi_system_restore_state
(
state
);
acpi_system_restore_state
(
state
);
printk
(
"acpi_leave_sleep_state..."
);
acpi_leave_sleep_state
(
state
);
acpi_leave_sleep_state
(
state
);
printk
(
"ook
\n
"
);
/* make sure interrupts are enabled */
/* make sure interrupts are enabled */
ACPI_ENABLE_IRQS
();
ACPI_ENABLE_IRQS
();
...
...
drivers/pci/power.c
View file @
67fbb3bf
...
@@ -110,7 +110,7 @@ static int pci_pm_save_state(u32 state)
...
@@ -110,7 +110,7 @@ static int pci_pm_save_state(u32 state)
return
error
;
return
error
;
}
}
int
pci_pm_suspend
(
u32
state
)
static
int
pci_pm_suspend
(
u32
state
)
{
{
struct
list_head
*
list
;
struct
list_head
*
list
;
struct
pci_bus
*
bus
;
struct
pci_bus
*
bus
;
...
@@ -123,7 +123,7 @@ int pci_pm_suspend(u32 state)
...
@@ -123,7 +123,7 @@ int pci_pm_suspend(u32 state)
return
0
;
return
0
;
}
}
int
pci_pm_resume
(
void
)
static
int
pci_pm_resume
(
void
)
{
{
struct
list_head
*
list
;
struct
list_head
*
list
;
struct
pci_bus
*
bus
;
struct
pci_bus
*
bus
;
...
...
include/asm-i386/suspend.h
View file @
67fbb3bf
...
@@ -209,15 +209,12 @@ static inline void restore_processor_context (void)
...
@@ -209,15 +209,12 @@ static inline void restore_processor_context (void)
/*
/*
* now restore the descriptor tables to their proper values
* now restore the descriptor tables to their proper values
* ltr is done i fix_processor_context().
*/
*/
asm
volatile
(
"lgdt (%0)"
::
"m"
(
saved_context
.
gdt_limit
));
asm
volatile
(
"lgdt (%0)"
::
"m"
(
saved_context
.
gdt_limit
));
asm
volatile
(
"lidt (%0)"
::
"m"
(
saved_context
.
idt_limit
));
asm
volatile
(
"lidt (%0)"
::
"m"
(
saved_context
.
idt_limit
));
asm
volatile
(
"lldt (%0)"
::
"m"
(
saved_context
.
ldt
));
asm
volatile
(
"lldt (%0)"
::
"m"
(
saved_context
.
ldt
));
#if 0
asm volatile ("ltr (%0)" :: "m" (saved_context.tr));
#endif
fix_processor_context
();
fix_processor_context
();
/*
/*
...
@@ -230,7 +227,6 @@ static inline void restore_processor_context (void)
...
@@ -230,7 +227,6 @@ static inline void restore_processor_context (void)
#endif
#endif
#ifdef SUSPEND_C
#ifdef SUSPEND_C
#if 1
/* Local variables for do_magic */
/* Local variables for do_magic */
static
int
loop
__nosavedata
=
0
;
static
int
loop
__nosavedata
=
0
;
static
int
loop2
__nosavedata
=
0
;
static
int
loop2
__nosavedata
=
0
;
...
@@ -269,36 +265,38 @@ static void do_magic(int resume)
...
@@ -269,36 +265,38 @@ static void do_magic(int resume)
/*
/*
* Final function for resuming: after copying the pages to their original
* Final function for resuming: after copying the pages to their original
* position, it restores the register state.
* position, it restores the register state.
*
* What about page tables? Writing data pages may toggle
* accessed/dirty bits in our page tables. That should be no problems
* with 4MB page tables. That's why we require have_pse.
*
* This loops destroys stack from under itself, so it better should
* not use any stack space, itself. When this function is entered at
* resume time, we move stack to _old_ place. This is means that this
* function must use no stack and no local variables in registers,
* until calling restore_processor_context();
*
* Critical section here: noone should touch saved memory after
* do_magic_resume_1; copying works, because nr_copy_pages,
* pagedir_nosave, loop and loop2 are nosavedata.
*/
*/
do_magic_resume_1
();
do_magic_resume_1
();
/* Critical section here: noone should touch memory from now */
/* This works, because nr_copy_pages, pagedir_nosave, loop and loop2 are nosavedata */
for
(
loop
=
0
;
loop
<
nr_copy_pages
;
loop
++
)
{
for
(
loop
=
0
;
loop
<
nr_copy_pages
;
loop
++
)
{
/* You may not call something (like copy_page) here:
/* You may not call something (like copy_page) here: see above */
We may absolutely not use stack at this point */
for
(
loop2
=
0
;
loop2
<
PAGE_SIZE
;
loop2
++
)
{
for
(
loop2
=
0
;
loop2
<
PAGE_SIZE
;
loop2
++
)
{
*
(((
char
*
)((
pagedir_nosave
+
loop
)
->
orig_address
))
+
loop2
)
=
*
(((
char
*
)((
pagedir_nosave
+
loop
)
->
orig_address
))
+
loop2
)
=
*
(((
char
*
)((
pagedir_nosave
+
loop
)
->
address
))
+
loop2
);
*
(((
char
*
)((
pagedir_nosave
+
loop
)
->
address
))
+
loop2
);
__flush_tlb
();
__flush_tlb
();
}
}
}
}
/* FIXME: What about page tables? Writing data pages may toggle
accessed/dirty bits in our page tables. That should be no problems
with 4MB page tables. That's why we require have_pse. */
/* Danger: previous loop probably destroyed our current stack. Better hope it did not use
any stack space, itself.
When this function is entered at resume time, we move stack to _old_ place.
This is means that this function must use no stack and no local variables in registers.
*/
restore_processor_context
();
restore_processor_context
();
/* Ahah, we now run with our old stack, and with registers copied from suspend time */
/* Ahah, we now run with our old stack, and with registers copied from
suspend time */
do_magic_resume_2
();
do_magic_resume_2
();
}
}
#endif
#endif
#endif
kernel/suspend.c
View file @
67fbb3bf
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
* Pavel Machek <pavel@ucw.cz>:
* Pavel Machek <pavel@ucw.cz>:
* Modifications, defectiveness pointing, being with me at the very beginning,
* Modifications, defectiveness pointing, being with me at the very beginning,
* suspend to swap space, stop all tasks.
* suspend to swap space, stop all tasks.
Port to 2.4.18-ac and 2.5.17.
*
*
* Steve Doddi <dirk@loth.demon.co.uk>:
* Steve Doddi <dirk@loth.demon.co.uk>:
* Support the possibility of hardware state restoring.
* Support the possibility of hardware state restoring.
...
@@ -41,8 +41,6 @@
...
@@ -41,8 +41,6 @@
* bdflush from this task. (check apm.c for something similar).
* bdflush from this task. (check apm.c for something similar).
*/
*/
/* FIXME: try to poison to memory */
#include <linux/module.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/mm.h>
#include <linux/swapctl.h>
#include <linux/swapctl.h>
...
@@ -122,7 +120,7 @@ static int pm_suspend_state = 0;
...
@@ -122,7 +120,7 @@ static int pm_suspend_state = 0;
Warning: this is evil. There are actually two pagedirs at time of
Warning: this is evil. There are actually two pagedirs at time of
resume. One is "pagedir_save", which is empty frame allocated at
resume. One is "pagedir_save", which is empty frame allocated at
time of suspend, that must be freed. Second is "pagedir_nosave",
time of suspend, that must be freed. Second is "pagedir_nosave",
allocated at time of resume, that travel
l
s through memory not to
allocated at time of resume, that travels through memory not to
collide with anything.
collide with anything.
*/
*/
static
suspend_pagedir_t
*
pagedir_nosave
__nosavedata
=
NULL
;
static
suspend_pagedir_t
*
pagedir_nosave
__nosavedata
=
NULL
;
...
@@ -143,8 +141,6 @@ union diskpage {
...
@@ -143,8 +141,6 @@ union diskpage {
/*
/*
* XXX: We try to keep some more pages free so that I/O operations succeed
* XXX: We try to keep some more pages free so that I/O operations succeed
* without paging. Might this be more?
* without paging. Might this be more?
*
* [If this is not enough, might it corrupt our data silently?]
*/
*/
#define PAGES_FOR_IO 512
#define PAGES_FOR_IO 512
...
@@ -310,7 +306,6 @@ static __inline__ int fill_suspend_header(struct suspend_header *sh)
...
@@ -310,7 +306,6 @@ static __inline__ int fill_suspend_header(struct suspend_header *sh)
static
void
do_suspend_sync
(
void
)
static
void
do_suspend_sync
(
void
)
{
{
// sync_dev(0); FIXME
while
(
1
)
{
while
(
1
)
{
run_task_queue
(
&
tq_disk
);
run_task_queue
(
&
tq_disk
);
if
(
!
TQ_ACTIVE
(
tq_disk
))
if
(
!
TQ_ACTIVE
(
tq_disk
))
...
@@ -640,7 +635,6 @@ static int prepare_suspend_processes(void)
...
@@ -640,7 +635,6 @@ static int prepare_suspend_processes(void)
MDELAY
(
1000
);
MDELAY
(
1000
);
if
(
freeze_processes
())
{
if
(
freeze_processes
())
{
PRINTS
(
"Not all processes stopped!
\n
"
);
PRINTS
(
"Not all processes stopped!
\n
"
);
// panic("Some processes survived?\n");
thaw_processes
();
thaw_processes
();
return
1
;
return
1
;
}
}
...
@@ -648,54 +642,6 @@ static int prepare_suspend_processes(void)
...
@@ -648,54 +642,6 @@ static int prepare_suspend_processes(void)
return
0
;
return
0
;
}
}
/*
* Free as much memory as possible
*/
static
void
**
eaten_memory
;
static
void
eat_memory
(
void
)
{
int
i
=
0
;
void
**
c
=
eaten_memory
,
*
m
;
printk
(
"Eating pages "
);
while
((
m
=
(
void
*
)
get_free_page
(
GFP_HIGHUSER
)))
{
memset
(
m
,
0
,
PAGE_SIZE
);
eaten_memory
=
m
;
if
(
!
(
i
%
100
))
printk
(
".(%d)"
,
i
);
*
eaten_memory
=
c
;
c
=
eaten_memory
;
i
++
;
#if 1
/* 40000 == 160MB */
/* 10000 for 64MB */
/* 2500 for 16MB */
if
(
i
>
40000
)
break
;
#endif
}
printk
(
"(%dK)
\n
"
,
i
*
4
);
}
static
void
free_memory
(
void
)
{
int
i
=
0
;
void
**
c
=
eaten_memory
,
*
f
;
printk
(
"Freeing pages "
);
while
(
c
)
{
if
(
!
(
i
%
5000
))
printk
(
"."
);
f
=
*
c
;
c
=
*
c
;
if
(
f
)
{
free_page
(
(
long
)
f
);
i
++
;
}
}
printk
(
"(%dK)
\n
"
,
i
*
4
);
eaten_memory
=
NULL
;
}
/*
/*
* Try to free as much memory as possible, but do not OOM-kill anyone
* Try to free as much memory as possible, but do not OOM-kill anyone
*
*
...
@@ -703,16 +649,10 @@ static void free_memory(void)
...
@@ -703,16 +649,10 @@ static void free_memory(void)
*/
*/
static
void
free_some_memory
(
void
)
static
void
free_some_memory
(
void
)
{
{
#if 1
PRINTS
(
"Freeing memory: "
);
PRINTS
(
"Freeing memory: "
);
while
(
try_to_free_pages
(
&
contig_page_data
.
node_zones
[
ZONE_HIGHMEM
],
GFP_KSWAPD
,
0
))
while
(
try_to_free_pages
(
&
contig_page_data
.
node_zones
[
ZONE_HIGHMEM
],
GFP_KSWAPD
,
0
))
printk
(
"."
);
printk
(
"."
);
printk
(
"
\n
"
);
printk
(
"
\n
"
);
#else
printk
(
"Using memeat
\n
"
);
eat_memory
();
free_memory
();
#endif
}
}
/* Make disk drivers accept operations, again */
/* Make disk drivers accept operations, again */
...
@@ -809,7 +749,6 @@ static int suspend_save_image(void)
...
@@ -809,7 +749,6 @@ static int suspend_save_image(void)
*
*
* Following line enforces not writing to disk until we choose.
* Following line enforces not writing to disk until we choose.
*/
*/
suspend_device
=
NODEV
;
/* We do not want any writes, thanx */
drivers_unsuspend
();
drivers_unsuspend
();
spin_unlock_irq
(
&
suspend_pagedir_lock
);
spin_unlock_irq
(
&
suspend_pagedir_lock
);
PRINTS
(
"critical section/: done (%d pages copied)
\n
"
,
nr_copy_pages
);
PRINTS
(
"critical section/: done (%d pages copied)
\n
"
,
nr_copy_pages
);
...
@@ -991,8 +930,7 @@ static void copy_pagedir(suspend_pagedir_t *to, suspend_pagedir_t *from)
...
@@ -991,8 +930,7 @@ static void copy_pagedir(suspend_pagedir_t *to, suspend_pagedir_t *from)
}
}
}
}
#define does_collide(addr) \
#define does_collide(addr) does_collide_order(pagedir_nosave, addr, 0)
does_collide_order(pagedir_nosave, addr, 0)
/*
/*
* Returns true if given address/order collides with any orig_address
* Returns true if given address/order collides with any orig_address
...
@@ -1015,7 +953,6 @@ static int does_collide_order(suspend_pagedir_t *pagedir, unsigned long addr,
...
@@ -1015,7 +953,6 @@ static int does_collide_order(suspend_pagedir_t *pagedir, unsigned long addr,
* We check here that pagedir & pages it points to won't collide with pages
* We check here that pagedir & pages it points to won't collide with pages
* where we're going to restore from the loaded pages later
* where we're going to restore from the loaded pages later
*/
*/
static
int
check_pagedir
(
void
)
static
int
check_pagedir
(
void
)
{
{
int
i
;
int
i
;
...
@@ -1036,15 +973,14 @@ static int check_pagedir(void)
...
@@ -1036,15 +973,14 @@ static int check_pagedir(void)
static
int
relocate_pagedir
(
void
)
static
int
relocate_pagedir
(
void
)
{
{
/*
This is deep magic
/*
We have to avoid recursion (not to overflow kernel stack), and that's why
* We have to avoid recursion (not to overflow kernel stack),
code looks pretty cryptic
* and that's why code looks pretty cryptic
*/
*/
suspend_pagedir_t
*
new_pagedir
,
*
old_pagedir
=
pagedir_nosave
;
suspend_pagedir_t
*
new_pagedir
,
*
old_pagedir
=
pagedir_nosave
;
void
**
eaten_memory
=
NULL
;
void
**
eaten_memory
=
NULL
;
void
**
c
=
eaten_memory
,
*
m
,
*
f
;
void
**
c
=
eaten_memory
,
*
m
,
*
f
;
if
(
!
does_collide_order
(
old_pagedir
,
(
unsigned
long
)
old_pagedir
,
pagedir_order
))
{
if
(
!
does_collide_order
(
old_pagedir
,
(
unsigned
long
)
old_pagedir
,
pagedir_order
))
{
printk
(
"not neccessary
\n
"
);
printk
(
"not neccessary
\n
"
);
return
0
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment