From patchwork Sun Apr 5 17:20:17 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: 6162531 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 37656BF4A6 for ; Sun, 5 Apr 2015 17:21:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54DEF20426 for ; Sun, 5 Apr 2015 17:21:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6A6C520435 for ; Sun, 5 Apr 2015 17:21:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbbDERVB (ORCPT ); Sun, 5 Apr 2015 13:21:01 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:36165 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752528AbbDERUz (ORCPT ); Sun, 5 Apr 2015 13:20:55 -0400 Received: by wizk4 with SMTP id k4so12949638wiz.1; Sun, 05 Apr 2015 10:20:54 -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=2XE5Qus0DTuR/APbGjmvSeAdSkIqzzv1T/IVAVYqOM8=; b=LXDnaeQBv/k85693P2UkdIoQaObAuMb1qZk052+GJ8w4oxX8DSB9FVGhWIqxC5InlX x1NoaQcgmDXi4AnJWBBdTs98MJ6VzoU1AI7TXB++FLjlGKqJ3/uE115BYpuEF4HyyARj b2AbUTcrccDCv2kalmf9kLw+3R3AToYPE5FYohNnZ0ucfzcKoemXoUCzKbiCYwxFfV/Y gBGvRanJNN3yOYngik1+1hg/ncWyAgAk8EaD9HGPvivlMovEAnNLj+F0W5BQU+2lSvTK eXqQw0RjpWSRQAtGCL8i8FFuOEPk9yZdgcK9ZbhC4K+XMwQV+0YWE0fm/yKnVpnLOQOm +AVQ== X-Received: by 10.194.23.39 with SMTP id j7mr24429015wjf.9.1428254453996; Sun, 05 Apr 2015 10:20:53 -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 wo10sm3060881wjb.35.2015.04.05.10.20.52 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 05 Apr 2015 10:20:53 -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 1/3] PM suspend/hibernate: Call notifier after freezing processes Date: Sun, 5 Apr 2015 19:20:17 +0200 Message-Id: <1428254419-7334-2-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1428254419-7334-1-git-send-email-pali.rohar@gmail.com> References: <1428254419-7334-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=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 b7d6b3a..1776938 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -268,8 +268,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);