diff options
Diffstat (limited to 'kernel/power/swsusp.c')
-rw-r--r-- | kernel/power/swsusp.c | 57 |
1 files changed, 2 insertions, 55 deletions
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index e1ab28b9b217..a456ffe7a3c8 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c | |||
@@ -629,59 +629,6 @@ int swsusp_resume(void) | |||
629 | } | 629 | } |
630 | 630 | ||
631 | /** | 631 | /** |
632 | * On resume, for storing the PBE list and the image, | ||
633 | * we can only use memory pages that do not conflict with the pages | ||
634 | * which had been used before suspend. | ||
635 | * | ||
636 | * We don't know which pages are usable until we allocate them. | ||
637 | * | ||
638 | * Allocated but unusable (ie eaten) memory pages are marked so that | ||
639 | * swsusp_free() can release them | ||
640 | */ | ||
641 | |||
642 | unsigned long get_safe_page(gfp_t gfp_mask) | ||
643 | { | ||
644 | unsigned long m; | ||
645 | |||
646 | do { | ||
647 | m = get_zeroed_page(gfp_mask); | ||
648 | if (m && PageNosaveFree(virt_to_page(m))) | ||
649 | /* This is for swsusp_free() */ | ||
650 | SetPageNosave(virt_to_page(m)); | ||
651 | } while (m && PageNosaveFree(virt_to_page(m))); | ||
652 | if (m) { | ||
653 | /* This is for swsusp_free() */ | ||
654 | SetPageNosave(virt_to_page(m)); | ||
655 | SetPageNosaveFree(virt_to_page(m)); | ||
656 | } | ||
657 | return m; | ||
658 | } | ||
659 | |||
660 | /** | ||
661 | * check_pagedir - We ensure here that pages that the PBEs point to | ||
662 | * won't collide with pages where we're going to restore from the loaded | ||
663 | * pages later | ||
664 | */ | ||
665 | |||
666 | static int check_pagedir(struct pbe *pblist) | ||
667 | { | ||
668 | struct pbe *p; | ||
669 | |||
670 | /* This is necessary, so that we can free allocated pages | ||
671 | * in case of failure | ||
672 | */ | ||
673 | for_each_pbe (p, pblist) | ||
674 | p->address = 0UL; | ||
675 | |||
676 | for_each_pbe (p, pblist) { | ||
677 | p->address = get_safe_page(GFP_ATOMIC); | ||
678 | if (!p->address) | ||
679 | return -ENOMEM; | ||
680 | } | ||
681 | return 0; | ||
682 | } | ||
683 | |||
684 | /** | ||
685 | * swsusp_pagedir_relocate - It is possible, that some memory pages | 632 | * swsusp_pagedir_relocate - It is possible, that some memory pages |
686 | * occupied by the list of PBEs collide with pages where we're going to | 633 | * occupied by the list of PBEs collide with pages where we're going to |
687 | * restore from the loaded pages later. We relocate them here. | 634 | * restore from the loaded pages later. We relocate them here. |
@@ -990,7 +937,7 @@ static int read_suspend_image(void) | |||
990 | int error = 0; | 937 | int error = 0; |
991 | struct pbe *p; | 938 | struct pbe *p; |
992 | 939 | ||
993 | if (!(p = alloc_pagedir(nr_copy_pages))) | 940 | if (!(p = alloc_pagedir(nr_copy_pages, GFP_ATOMIC, 0))) |
994 | return -ENOMEM; | 941 | return -ENOMEM; |
995 | 942 | ||
996 | if ((error = read_pagedir(p))) | 943 | if ((error = read_pagedir(p))) |
@@ -1003,7 +950,7 @@ static int read_suspend_image(void) | |||
1003 | 950 | ||
1004 | /* Allocate memory for the image and read the data from swap */ | 951 | /* Allocate memory for the image and read the data from swap */ |
1005 | 952 | ||
1006 | error = check_pagedir(pagedir_nosave); | 953 | error = alloc_data_pages(pagedir_nosave, GFP_ATOMIC, 1); |
1007 | 954 | ||
1008 | if (!error) | 955 | if (!error) |
1009 | error = data_read(pagedir_nosave); | 956 | error = data_read(pagedir_nosave); |