From patchwork Wed Mar 28 17:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Limonciello, Mario" X-Patchwork-Id: 10313639 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A9866600F6 for ; Wed, 28 Mar 2018 17:01:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B67F2981E for ; Wed, 28 Mar 2018 17:01:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 901E5298B2; Wed, 28 Mar 2018 17:01:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AABA2981E for ; Wed, 28 Mar 2018 17:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753098AbeC1RBc (ORCPT ); Wed, 28 Mar 2018 13:01:32 -0400 Received: from esa7.dell-outbound.iphmx.com ([68.232.153.96]:27321 "EHLO esa7.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752853AbeC1RBb (ORCPT ); Wed, 28 Mar 2018 13:01:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1522255929; x=1553791929; h=from:to:cc:subject:date:message-id; bh=Pdf1jDdhKe4r6tcaKFJMPH/TaK2kqkvPuD9uezpnuo4=; b=JFlLpdSW6O7jt1CwqH0R3Jg9xnFAewfSzPizcCGylMHcUFpJktWoYs4H b+FTjFIL1caEyokI9FXMO25jqRIXcUxK1R6UzfA7Zdfxr+15Wgc5lD5ff 3QKBrcBVZQifJxvz+2zijWKbxE0jq+3fCjCIpmFz8S8cRmY6GIC9mYPbF U=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2G4AAC1ybtamMmZ6ERdHAEBAQQBAQoBA?= =?us-ascii?q?YURKItcjQGDA5JKgXoLhQSEDyE0GAECAQEBAQEBAgECEAEBAQEBCAsLBigvgjg?= =?us-ascii?q?ig0wvIG8ThQ6uDohGgimHXoFUP4NihGYbhXACjFCKYwiBX4xJAowvj3eBJRyCC?= =?us-ascii?q?3CDEoIujj1RjSoqghwBAQ?= X-IPAS-Result: =?us-ascii?q?A2G4AAC1ybtamMmZ6ERdHAEBAQQBAQoBAYURKItcjQGDA5J?= =?us-ascii?q?KgXoLhQSEDyE0GAECAQEBAQEBAgECEAEBAQEBCAsLBigvgjgig0wvIG8ThQ6uD?= =?us-ascii?q?ohGgimHXoFUP4NihGYbhXACjFCKYwiBX4xJAowvj3eBJRyCC3CDEoIujj1RjSo?= =?us-ascii?q?qghwBAQ?= Received: from esa1.dell-outbound2.iphmx.com ([68.232.153.201]) by esa7.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2018 11:52:08 -0500 Received: from ausxippc110.us.dell.com ([143.166.85.200]) by esa1.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2018 22:57:33 +0600 X-LoopCount0: from 10.208.86.39 X-IronPort-AV: E=Sophos;i="5.48,372,1517896800"; d="scan'208";a="637271539" X-DLP: DLP_GlobalPCIDSS From: Mario Limonciello To: "Rafael J . Wysocki" Cc: linux-acpi@vger.kernel.org, LKML , Mario Limonciello Subject: [PATCH v3 1/2] power/hibernate: Make passing hibernate offsets more friendly Date: Wed, 28 Mar 2018 12:01:09 -0500 Message-Id: <1522256470-2825-1-git-send-email-mario.limonciello@dell.com> X-Mailer: git-send-email 2.7.4 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently the only way to specify a hibernate offset for a swap file is on the kernel command line. Add a new /sys/power/resume_offset that lets userspace specify the offset and disk to use when initiating a hibernate cycle. Signed-off-by: Mario Limonciello --- Changes from v2: * Cast the output for sector_t when printing * Fix a compilation problem with i386 due to different size of sector_t Documentation/ABI/testing/sysfs-power | 14 ++++++++++++++ Documentation/power/swsusp.txt | 10 +++++++++- kernel/power/hibernate.c | 24 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power index 1e0d1da..2f813d6 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power @@ -287,3 +287,17 @@ Description: Writing a "1" to this file enables the debug messages and writing a "0" (default) to it disables them. Reads from this file return the current value. + +What: /sys/power/resume_offset +Date: April 2018 +Contact: Mario Limonciello +Description: + This file is used for telling the kernel an offset into a disk + to use when hibernating the system such as with a swap file. + + Reads from this file will display the current offset + the kernel will be using on the next hibernation + attempt. + + Using this sysfs file will override any values that were + set using the kernel command line for disk offset. \ No newline at end of file diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt index 9f2f942..cc87adf 100644 --- a/Documentation/power/swsusp.txt +++ b/Documentation/power/swsusp.txt @@ -24,8 +24,16 @@ Some warnings, first. * see the FAQ below for details. (This is not true for more traditional * power states like "standby", which normally don't turn USB off.) +Swap partition: You need to append resume=/dev/your_swap_partition to kernel command -line. Then you suspend by +line or specify it using /sys/power/resume. + +Swap file: +If using a swapfile you can also specify a resume offset using +resume_offset= on the kernel command line or specify it +in /sys/power/resume_offset. + +After preparing then you suspend by echo shutdown > /sys/power/disk; echo disk > /sys/power/state diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index a5c36e9..d58fad3d 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -1061,6 +1061,29 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, power_attr(resume); +static ssize_t resume_offset_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sprintf(buf, "%llu\n", (unsigned long long)swsusp_resume_block); +} + +static ssize_t resume_offset_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, + size_t n) +{ + unsigned long long offset; + int rc; + + rc = kstrtoull(buf, 0, &offset); + if (rc) + return rc; + swsusp_resume_block = offset; + + return n; +} + +power_attr(resume_offset); + static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -1106,6 +1129,7 @@ power_attr(reserved_size); static struct attribute * g[] = { &disk_attr.attr, + &resume_offset_attr.attr, &resume_attr.attr, &image_size_attr.attr, &reserved_size_attr.attr,