aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/hibernate.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-05-15 05:38:48 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-05-17 17:19:19 -0400
commitddeb648708108091a641adad0a438ec4fd8bf190 (patch)
tree722367ce903d362af29898db7c2bc2c1058d80c5 /kernel/power/hibernate.c
parent13e381365614855bf14c8ad68f9b65e3afd3dd2c (diff)
PM / Hibernate: Add sysfs knob to control size of memory for drivers
Martin reports that on his system hibernation occasionally fails due to the lack of memory, because the radeon driver apparently allocates too much of it during the device freeze stage. It turns out that the amount of memory allocated by radeon during hibernation (and presumably during system suspend too) depends on the utilization of the GPU (e.g. hibernating while there are two KDE 4 sessions with compositing enabled causes radeon to allocate more memory than for one KDE 4 session). In principle it should be possible to use image_size to make the memory preallocation mechanism free enough memory for the radeon driver, but in practice it is not easy to guess the right value because of the way the preallocation code uses image_size. For this reason, it seems reasonable to allow users to control the amount of memory reserved for driver allocations made after the hibernate preallocation, which currently is constant and amounts to 1 MB. Introduce a new sysfs file, /sys/power/reserved_size, whose value will be used as the amount of memory to reserve for the post-preallocation reservations made by device drivers, in bytes. For backwards compatibility, set its default (and initial) value to the currently used number (1 MB). References: https://bugzilla.kernel.org/show_bug.cgi?id=34102 Reported-and-tested-by: Martin Steigerwald <Martin@Lichtvoll.de> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'kernel/power/hibernate.c')
-rw-r--r--kernel/power/hibernate.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 50aae660174d..431721313b71 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -982,10 +982,33 @@ static ssize_t image_size_store(struct kobject *kobj, struct kobj_attribute *att
982 982
983power_attr(image_size); 983power_attr(image_size);
984 984
985static ssize_t reserved_size_show(struct kobject *kobj,
986 struct kobj_attribute *attr, char *buf)
987{
988 return sprintf(buf, "%lu\n", reserved_size);
989}
990
991static ssize_t reserved_size_store(struct kobject *kobj,
992 struct kobj_attribute *attr,
993 const char *buf, size_t n)
994{
995 unsigned long size;
996
997 if (sscanf(buf, "%lu", &size) == 1) {
998 reserved_size = size;
999 return n;
1000 }
1001
1002 return -EINVAL;
1003}
1004
1005power_attr(reserved_size);
1006
985static struct attribute * g[] = { 1007static struct attribute * g[] = {
986 &disk_attr.attr, 1008 &disk_attr.attr,
987 &resume_attr.attr, 1009 &resume_attr.attr,
988 &image_size_attr.attr, 1010 &image_size_attr.attr,
1011 &reserved_size_attr.attr,
989 NULL, 1012 NULL,
990}; 1013};
991 1014