From patchwork Sun Jun 21 11:20:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 6652521 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2BEA69F46A for ; Sun, 21 Jun 2015 11:21:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F6D0206A7 for ; Sun, 21 Jun 2015 11:21:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DF7C206D5 for ; Sun, 21 Jun 2015 11:21:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754324AbbFULVj (ORCPT ); Sun, 21 Jun 2015 07:21:39 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:34524 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753891AbbFULVc (ORCPT ); Sun, 21 Jun 2015 07:21:32 -0400 Received: by wgfq1 with SMTP id q1so73694697wgf.1; Sun, 21 Jun 2015 04:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=4XQHaTZmwQL/RBdCOEyemDZfDbyW3GG/K/BAdJVCNkc=; b=h0CKLJghrceAJpfr3B01rKFI+MhPrcyz20cSKpFtfS6HVTvHFkxVs6tKn4Lq57Pi6s 9NEebrIRmUDuPlIgkjsjPKm3zpsnZ/EaQUyFTz6a14lUVvcqACkK13OOWGnQ+F2QYO+m NCYbu0RtcPS+Xj9/+Y/UO/sQo5WWbdxstQ8glLYziXgJhprv6jkQikQUrDl7ISpjhnc6 KbBhrZcfuJg27vw/Y0Yf0cGwqLM6HY/Vj5Wz5VEoxWE0jvJZh60zuffK+6jkuHzqfyDv XqWuHDPza3CLRXO3usmUhdytCqP7bUz63W+CB/tYwwDdiIYE/nRMZAZdQViYvnJowZVX 4FqA== X-Received: by 10.194.178.201 with SMTP id da9mr41836780wjc.139.1434885690930; Sun, 21 Jun 2015 04:21:30 -0700 (PDT) Received: from Pali-Latitude.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPSA id f8sm12001411wiy.7.2015.06.21.04.21.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jun 2015 04:21:30 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Alasdair Kergon , Mike Snitzer , Neil Brown , "Rafael J. Wysocki" , Len Brown , Pavel Machek Cc: dm-devel@redhat.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH v2 1/3] PM suspend/hibernate: Call notifier after freezing processes Date: Sun, 21 Jun 2015 13:20:32 +0200 Message-Id: <1434885634-19895-2-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1434885634-19895-1-git-send-email-pali.rohar@gmail.com> References: <1428254419-7334-1-git-send-email-pali.rohar@gmail.com> <1434885634-19895-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To prevent race conditions on userspace processes with I/O some taks must be called after processes are freezed. This patch adds new events which are delivered by pm_notifier_call_chain() after freezing processes when doing suspend or hibernate action. Signed-off-by: Pali Rohár --- include/linux/suspend.h | 2 ++ kernel/power/hibernate.c | 2 ++ kernel/power/suspend.c | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/suspend.h b/include/linux/suspend.h index 5efe743..bc743c8 100644 --- a/include/linux/suspend.h +++ b/include/linux/suspend.h @@ -368,6 +368,8 @@ static inline bool hibernation_available(void) { return false; } #define PM_POST_SUSPEND 0x0004 /* Suspend finished */ #define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */ #define PM_POST_RESTORE 0x0006 /* Restore failed */ +#define PM_HIBERNATION_AFTER_FREEZE 0x0007 /* After hibernation freeze */ +#define PM_SUSPEND_AFTER_FREEZE 0x0008 /* After suspend freeze */ extern struct mutex pm_mutex; diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 2329daa..184f7ee 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -671,6 +671,8 @@ int hibernate(void) if (error) goto Exit; + pm_notifier_call_chain(PM_HIBERNATION_AFTER_FREEZE); + lock_device_hotplug(); /* Allocate memory management structures */ error = create_basic_memory_bitmaps(); diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 8d7a1ef..ba2a945 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -277,8 +277,10 @@ static int suspend_prepare(suspend_state_t state) trace_suspend_resume(TPS("freeze_processes"), 0, true); error = suspend_freeze_processes(); trace_suspend_resume(TPS("freeze_processes"), 0, false); - if (!error) + if (!error) { + pm_notifier_call_chain(PM_SUSPEND_AFTER_FREEZE); return 0; + } suspend_stats.failed_freeze++; dpm_save_failed_step(SUSPEND_FREEZE);