Commit 13c9f31a authored by Patrick Mochel's avatar Patrick Mochel

[Power Mgmt] Share variables between pmdisk and swsusp.

- In pmdisk, change pm_pagedir_nosave back to pagedir_nosave, and 
  pmdisk_pages back to nr_copy_pages.
- Mark them, and other page count/pagedir variables extern.
- Make sure they're not static in swsusp.
- Remove mention from include/linux/suspend.h, since no one else needs them.
parent 3646a7f9
...@@ -24,7 +24,7 @@ ENTRY(pmdisk_arch_suspend) ...@@ -24,7 +24,7 @@ ENTRY(pmdisk_arch_suspend)
movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx
movl %ecx,%cr3 movl %ecx,%cr3
movl pm_pagedir_nosave,%ebx movl pagedir_nosave,%ebx
xorl %eax, %eax xorl %eax, %eax
xorl %edx, %edx xorl %edx, %edx
.p2align 4,,7 .p2align 4,,7
...@@ -41,7 +41,7 @@ ENTRY(pmdisk_arch_suspend) ...@@ -41,7 +41,7 @@ ENTRY(pmdisk_arch_suspend)
incl %eax incl %eax
addl $16, %edx addl $16, %edx
cmpl pmdisk_pages,%eax cmpl nr_copy_pages,%eax
jb .L1455 jb .L1455
.p2align 4,,7 .p2align 4,,7
.L1453: .L1453:
......
...@@ -45,9 +45,6 @@ extern void drain_local_pages(void); ...@@ -45,9 +45,6 @@ extern void drain_local_pages(void);
/* kernel/power/swsusp.c */ /* kernel/power/swsusp.c */
extern int software_suspend(void); extern int software_suspend(void);
extern unsigned int nr_copy_pages __nosavedata;
extern suspend_pagedir_t *pagedir_nosave __nosavedata;
#else /* CONFIG_SOFTWARE_SUSPEND */ #else /* CONFIG_SOFTWARE_SUSPEND */
static inline int software_suspend(void) static inline int software_suspend(void)
{ {
......
...@@ -47,15 +47,15 @@ extern char __nosave_begin, __nosave_end; ...@@ -47,15 +47,15 @@ extern char __nosave_begin, __nosave_end;
extern int is_head_of_free_region(struct page *); extern int is_head_of_free_region(struct page *);
/* Variables to be preserved over suspend */ /* Variables to be preserved over suspend */
static int pagedir_order_check; extern int pagedir_order_check;
static int nr_copy_pages_check; extern int nr_copy_pages_check;
/* For resume= kernel option */ /* For resume= kernel option */
static char resume_file[256] = CONFIG_PM_DISK_PARTITION; static char resume_file[256] = CONFIG_PM_DISK_PARTITION;
static dev_t resume_device; static dev_t resume_device;
/* Local variables that should not be affected by save */ /* Local variables that should not be affected by save */
unsigned int pmdisk_pages __nosavedata = 0; extern unsigned int nr_copy_pages;
/* Suspend pagedir is allocated before final copy, therefore it /* Suspend pagedir is allocated before final copy, therefore it
must be freed after resume must be freed after resume
...@@ -66,9 +66,9 @@ unsigned int pmdisk_pages __nosavedata = 0; ...@@ -66,9 +66,9 @@ unsigned int pmdisk_pages __nosavedata = 0;
allocated at time of resume, that travels through memory not to allocated at time of resume, that travels through memory not to
collide with anything. collide with anything.
*/ */
suspend_pagedir_t *pm_pagedir_nosave __nosavedata = NULL; extern suspend_pagedir_t *pagedir_nosave;
static suspend_pagedir_t *pagedir_save; extern suspend_pagedir_t *pagedir_save;
static int pagedir_order __nosavedata = 0; extern int pagedir_order;
struct pmdisk_info { struct pmdisk_info {
...@@ -184,13 +184,13 @@ static void free_data(void) ...@@ -184,13 +184,13 @@ static void free_data(void)
swp_entry_t entry; swp_entry_t entry;
int i; int i;
for (i = 0; i < pmdisk_pages; i++) { for (i = 0; i < nr_copy_pages; i++) {
entry = (pm_pagedir_nosave + i)->swap_address; entry = (pagedir_nosave + i)->swap_address;
if (entry.val) if (entry.val)
swap_free(entry); swap_free(entry);
else else
break; break;
(pm_pagedir_nosave + i)->swap_address = (swp_entry_t){0}; (pagedir_nosave + i)->swap_address = (swp_entry_t){0};
} }
} }
...@@ -206,12 +206,12 @@ static int write_data(void) ...@@ -206,12 +206,12 @@ static int write_data(void)
int error = 0; int error = 0;
int i; int i;
printk( "Writing data to swap (%d pages): ", pmdisk_pages ); printk( "Writing data to swap (%d pages): ", nr_copy_pages );
for (i = 0; i < pmdisk_pages && !error; i++) { for (i = 0; i < nr_copy_pages && !error; i++) {
if (!(i%100)) if (!(i%100))
printk( "." ); printk( "." );
error = write_swap_page((pm_pagedir_nosave+i)->address, error = write_swap_page((pagedir_nosave+i)->address,
&((pm_pagedir_nosave+i)->swap_address)); &((pagedir_nosave+i)->swap_address));
} }
printk(" %d Pages done.\n",i); printk(" %d Pages done.\n",i);
return error; return error;
...@@ -239,9 +239,9 @@ static void free_pagedir_entries(void) ...@@ -239,9 +239,9 @@ static void free_pagedir_entries(void)
static int write_pagedir(void) static int write_pagedir(void)
{ {
unsigned long addr = (unsigned long)pm_pagedir_nosave; unsigned long addr = (unsigned long)pagedir_nosave;
int error = 0; int error = 0;
int n = SUSPEND_PD_PAGES(pmdisk_pages); int n = SUSPEND_PD_PAGES(nr_copy_pages);
int i; int i;
pmdisk_info.pagedir_pages = n; pmdisk_info.pagedir_pages = n;
...@@ -282,7 +282,7 @@ static void init_header(void) ...@@ -282,7 +282,7 @@ static void init_header(void)
memcpy(&pmdisk_info.uts,&system_utsname,sizeof(system_utsname)); memcpy(&pmdisk_info.uts,&system_utsname,sizeof(system_utsname));
pmdisk_info.cpus = num_online_cpus(); pmdisk_info.cpus = num_online_cpus();
pmdisk_info.image_pages = pmdisk_pages; pmdisk_info.image_pages = nr_copy_pages;
} }
/** /**
...@@ -396,7 +396,7 @@ static void count_pages(void) ...@@ -396,7 +396,7 @@ static void count_pages(void)
if (saveable(&pfn)) if (saveable(&pfn))
n++; n++;
} }
pmdisk_pages = n; nr_copy_pages = n;
} }
...@@ -424,7 +424,7 @@ static void copy_pages(void) ...@@ -424,7 +424,7 @@ static void copy_pages(void)
p++; p++;
} }
} }
BUG_ON(n != pmdisk_pages); BUG_ON(n != nr_copy_pages);
} }
...@@ -437,7 +437,7 @@ static void free_image_pages(void) ...@@ -437,7 +437,7 @@ static void free_image_pages(void)
struct pbe * p; struct pbe * p;
int i; int i;
for (i = 0, p = pagedir_save; i < pmdisk_pages; i++, p++) { for (i = 0, p = pagedir_save; i < nr_copy_pages; i++, p++) {
ClearPageNosave(virt_to_page(p->address)); ClearPageNosave(virt_to_page(p->address));
free_page(p->address); free_page(p->address);
} }
...@@ -460,13 +460,13 @@ static void calc_order(void) ...@@ -460,13 +460,13 @@ static void calc_order(void)
int diff; int diff;
int order; int order;
order = get_bitmask_order(SUSPEND_PD_PAGES(pmdisk_pages)); order = get_bitmask_order(SUSPEND_PD_PAGES(nr_copy_pages));
pmdisk_pages += 1 << order; nr_copy_pages += 1 << order;
do { do {
diff = get_bitmask_order(SUSPEND_PD_PAGES(pmdisk_pages)) - order; diff = get_bitmask_order(SUSPEND_PD_PAGES(nr_copy_pages)) - order;
if (diff) { if (diff) {
order += diff; order += diff;
pmdisk_pages += 1 << diff; nr_copy_pages += 1 << diff;
} }
} while(diff); } while(diff);
pagedir_order = order; pagedir_order = order;
...@@ -488,7 +488,7 @@ static int alloc_pagedir(void) ...@@ -488,7 +488,7 @@ static int alloc_pagedir(void)
if(!pagedir_save) if(!pagedir_save)
return -ENOMEM; return -ENOMEM;
memset(pagedir_save,0,(1 << pagedir_order) * PAGE_SIZE); memset(pagedir_save,0,(1 << pagedir_order) * PAGE_SIZE);
pm_pagedir_nosave = pagedir_save; pagedir_nosave = pagedir_save;
return 0; return 0;
} }
...@@ -503,7 +503,7 @@ static int alloc_image_pages(void) ...@@ -503,7 +503,7 @@ static int alloc_image_pages(void)
struct pbe * p; struct pbe * p;
int i; int i;
for (i = 0, p = pagedir_save; i < pmdisk_pages; i++, p++) { for (i = 0, p = pagedir_save; i < nr_copy_pages; i++, p++) {
p->address = get_zeroed_page(GFP_ATOMIC | __GFP_COLD); p->address = get_zeroed_page(GFP_ATOMIC | __GFP_COLD);
if(!p->address) if(!p->address)
goto Error; goto Error;
...@@ -529,7 +529,7 @@ static int alloc_image_pages(void) ...@@ -529,7 +529,7 @@ static int alloc_image_pages(void)
static int enough_free_mem(void) static int enough_free_mem(void)
{ {
if(nr_free_pages() < (pmdisk_pages + PAGES_FOR_IO)) { if(nr_free_pages() < (nr_copy_pages + PAGES_FOR_IO)) {
pr_debug("pmdisk: Not enough free pages: Have %d\n", pr_debug("pmdisk: Not enough free pages: Have %d\n",
nr_free_pages()); nr_free_pages());
return 0; return 0;
...@@ -553,7 +553,7 @@ static int enough_swap(void) ...@@ -553,7 +553,7 @@ static int enough_swap(void)
struct sysinfo i; struct sysinfo i;
si_swapinfo(&i); si_swapinfo(&i);
if (i.freeswap < (pmdisk_pages + PAGES_FOR_IO)) { if (i.freeswap < (nr_copy_pages + PAGES_FOR_IO)) {
pr_debug("pmdisk: Not enough swap. Need %ld\n",i.freeswap); pr_debug("pmdisk: Not enough swap. Need %ld\n",i.freeswap);
return 0; return 0;
} }
...@@ -582,12 +582,12 @@ int pmdisk_suspend(void) ...@@ -582,12 +582,12 @@ int pmdisk_suspend(void)
drain_local_pages(); drain_local_pages();
pm_pagedir_nosave = NULL; pagedir_nosave = NULL;
pr_debug("pmdisk: Counting pages to copy.\n" ); pr_debug("pmdisk: Counting pages to copy.\n" );
count_pages(); count_pages();
pr_debug("pmdisk: (pages needed: %d + %d free: %d)\n", pr_debug("pmdisk: (pages needed: %d + %d free: %d)\n",
pmdisk_pages,PAGES_FOR_IO,nr_free_pages()); nr_copy_pages,PAGES_FOR_IO,nr_free_pages());
if (!enough_free_mem()) if (!enough_free_mem())
return -ENOMEM; return -ENOMEM;
...@@ -605,7 +605,7 @@ int pmdisk_suspend(void) ...@@ -605,7 +605,7 @@ int pmdisk_suspend(void)
return error; return error;
} }
nr_copy_pages_check = pmdisk_pages; nr_copy_pages_check = nr_copy_pages;
pagedir_order_check = pagedir_order; pagedir_order_check = pagedir_order;
/* During allocating of suspend pagedir, new cold pages may appear. /* During allocating of suspend pagedir, new cold pages may appear.
...@@ -622,7 +622,7 @@ int pmdisk_suspend(void) ...@@ -622,7 +622,7 @@ int pmdisk_suspend(void)
* touch swap space! Except we must write out our image of course. * touch swap space! Except we must write out our image of course.
*/ */
pr_debug("pmdisk: %d pages copied\n", pmdisk_pages ); pr_debug("pmdisk: %d pages copied\n", nr_copy_pages );
return 0; return 0;
} }
...@@ -657,7 +657,7 @@ static int suspend_save_image(void) ...@@ -657,7 +657,7 @@ static int suspend_save_image(void)
int pmdisk_resume(void) int pmdisk_resume(void)
{ {
BUG_ON (nr_copy_pages_check != pmdisk_pages); BUG_ON (nr_copy_pages_check != nr_copy_pages);
BUG_ON (pagedir_order_check != pagedir_order); BUG_ON (pagedir_order_check != pagedir_order);
/* Even mappings of "global" things (vmalloc) need to be fixed */ /* Even mappings of "global" things (vmalloc) need to be fixed */
...@@ -838,7 +838,7 @@ static int __init check_header(void) ...@@ -838,7 +838,7 @@ static int __init check_header(void)
printk(KERN_ERR "pmdisk: Resume mismatch: %s\n",reason); printk(KERN_ERR "pmdisk: Resume mismatch: %s\n",reason);
return -EPERM; return -EPERM;
} }
pmdisk_pages = pmdisk_info.image_pages; nr_copy_pages = pmdisk_info.image_pages;
return error; return error;
} }
...@@ -854,7 +854,7 @@ static int __init read_pagedir(void) ...@@ -854,7 +854,7 @@ static int __init read_pagedir(void)
addr =__get_free_pages(GFP_ATOMIC, pagedir_order); addr =__get_free_pages(GFP_ATOMIC, pagedir_order);
if (!addr) if (!addr)
return -ENOMEM; return -ENOMEM;
pm_pagedir_nosave = (struct pbe *)addr; pagedir_nosave = (struct pbe *)addr;
pr_debug("pmdisk: Reading pagedir (%d Pages)\n",n); pr_debug("pmdisk: Reading pagedir (%d Pages)\n",n);
...@@ -866,7 +866,7 @@ static int __init read_pagedir(void) ...@@ -866,7 +866,7 @@ static int __init read_pagedir(void)
error = -EFAULT; error = -EFAULT;
} }
if (error) if (error)
free_pages((unsigned long)pm_pagedir_nosave,pagedir_order); free_pages((unsigned long)pagedir_nosave,pagedir_order);
return error; return error;
} }
...@@ -884,8 +884,8 @@ static int __init read_image_data(void) ...@@ -884,8 +884,8 @@ static int __init read_image_data(void)
int error = 0; int error = 0;
int i; int i;
printk( "Reading image data (%d pages): ", pmdisk_pages ); printk( "Reading image data (%d pages): ", nr_copy_pages );
for(i = 0, p = pm_pagedir_nosave; i < pmdisk_pages && !error; i++, p++) { for(i = 0, p = pagedir_nosave; i < nr_copy_pages && !error; i++, p++) {
if (!(i%100)) if (!(i%100))
printk( "." ); printk( "." );
error = read_page(swp_offset(p->swap_address), error = read_page(swp_offset(p->swap_address),
...@@ -913,7 +913,7 @@ static int __init read_suspend_image(void) ...@@ -913,7 +913,7 @@ static int __init read_suspend_image(void)
Done: Done:
return error; return error;
FreePagedir: FreePagedir:
free_pages((unsigned long)pm_pagedir_nosave,pagedir_order); free_pages((unsigned long)pagedir_nosave,pagedir_order);
goto Done; goto Done;
} }
......
...@@ -84,8 +84,8 @@ extern int is_head_of_free_region(struct page *); ...@@ -84,8 +84,8 @@ extern int is_head_of_free_region(struct page *);
spinlock_t suspend_pagedir_lock __nosavedata = SPIN_LOCK_UNLOCKED; spinlock_t suspend_pagedir_lock __nosavedata = SPIN_LOCK_UNLOCKED;
/* Variables to be preserved over suspend */ /* Variables to be preserved over suspend */
static int pagedir_order_check; int pagedir_order_check;
static int nr_copy_pages_check; int nr_copy_pages_check;
static int resume_status; static int resume_status;
static char resume_file[256] = ""; /* For resume= kernel option */ static char resume_file[256] = ""; /* For resume= kernel option */
...@@ -107,8 +107,8 @@ unsigned int nr_copy_pages __nosavedata = 0; ...@@ -107,8 +107,8 @@ unsigned int nr_copy_pages __nosavedata = 0;
MMU hardware. MMU hardware.
*/ */
suspend_pagedir_t *pagedir_nosave __nosavedata = NULL; suspend_pagedir_t *pagedir_nosave __nosavedata = NULL;
static suspend_pagedir_t *pagedir_save; suspend_pagedir_t *pagedir_save;
static int pagedir_order __nosavedata = 0; int pagedir_order __nosavedata = 0;
struct link { struct link {
char dummy[PAGE_SIZE - sizeof(swp_entry_t)]; char dummy[PAGE_SIZE - sizeof(swp_entry_t)];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment