Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4975555rwl; Mon, 10 Apr 2023 21:24:14 -0700 (PDT) X-Google-Smtp-Source: AKy350Yas1I8LtAeR4upWr35NcEkeQ/Q/OxxVnI8Yz2uJZOnsvtYEzbfuxHncC8PBITVvQFVqwO4 X-Received: by 2002:a50:fc06:0:b0:504:99d1:68b4 with SMTP id i6-20020a50fc06000000b0050499d168b4mr6123927edr.34.1681187054605; Mon, 10 Apr 2023 21:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681187054; cv=none; d=google.com; s=arc-20160816; b=btFwBR568DbWVnf/E82KoOH0GmhkTNwff/EWceHQJedpF3uzUwLH0Cvmz5B8nEdiPK bup9lFmcCojLXYC/2vqUhAjoLtMQbxNZ5ygblBKMmj5LyWvGTvtEzYEmTZoVH7jUTUEc h3tYf4dPxjQYLP8PfwQUAEakjFE/TeNr/ct7yr3+RvHF35gXQSbl2YqAjFSZAXDC1LpO ECOCCYYe2XAjZHTaGiDYH/4kCFMO/IEvCJs6EadqVhlZktrYnND51mDU4AyR2OXh202Z Rw/LRB7aALDDcyKBG8d7nc/PRmd0UKhSryVSCoK9ey8TXUvuMY5bpSEvARYrkwlrQ8y3 2CpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i2ZNWN5md8UKSdF61yXIVZYbqFNdJUEUOybDUNUU2MU=; b=Hme5FdA+d3v8p5Zj17tvqy89hEBZq1zxn4M/UlLonitjfdPeDo0Mu/z8F7hZilUapv NcCk8v2oY761Ugkk8OkfYhPWD7vI4w1S2ASyLi/jj49vmwfivVkabBvenbxBmfS6PqHo 3bWpExpgJwwXmsPRxEO6dNqiuv44aLue3P33wH17iXkLYXdI9ZJcDAbnje+USOAow9EW qtDE7z+S1DhlKLZ4IzPWztcXj8iaFE3VfOUn8fFPqwF0xFw2CbsBvG73lAh8vP3/BtvW /Twt5qcpN1l1g4mteFrL/40/gXR98bZST5CKMB2CIxA5NSqv3G3iV9pKnZwezG/Sn92s PAmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jMhxbaYM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020aa7d604000000b005024e71ba26si7132737edr.447.2023.04.10.21.23.49; Mon, 10 Apr 2023 21:24:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jMhxbaYM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230077AbjDKEXP (ORCPT + 99 others); Tue, 11 Apr 2023 00:23:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229694AbjDKEXN (ORCPT ); Tue, 11 Apr 2023 00:23:13 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD1752D57; Mon, 10 Apr 2023 21:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681186989; x=1712722989; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cuh+cpF2Dbk1u6YNouEfBinVXPTes5iWxZU0sb3auIQ=; b=jMhxbaYMOxIjOzIyXSxILRSiUCC3dUS1bkyGiA2gDaVFDOnzA1NUCr4a TWbhEhk/gKmVP0HfK0pyoWx8UN427/5NdUKmh+Yrtyzi5LLHF0goORLsK Bb4zwDzyPT5SslerckEqfH19tJyZuCNtSCoqj2z0W8685nuNutOoKsJfS MRAEvPxWaW7Jykoxcd0eDmHHzG9SfN4Ci4MrEj1VGFQo55NjYPUulicn5 IN3eghm+LkZFEp0n+BtyDqq+QAzoRUdev/lhCcj7jhP5ZBQa7HLAzxt82 qHy4U7sJyeqNaJFAUkdM476EJo4XAr5C6/wZCHanDhjdBf/8qaJkdg+l3 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="341010195" X-IronPort-AV: E=Sophos;i="5.98,335,1673942400"; d="scan'208";a="341010195" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2023 21:23:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="721045427" X-IronPort-AV: E=Sophos;i="5.98,335,1673942400"; d="scan'208";a="721045427" Received: from chenyu-dev.sh.intel.com ([10.239.158.170]) by orsmga001.jf.intel.com with ESMTP; 10 Apr 2023 21:23:07 -0700 From: Chen Yu To: "Rafael J. Wysocki" , Len Brown Cc: Ye Bin , Pavankumar Kondeti , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH v2 1/2] PM: hibernate: Turn snapshot_test into global variable Date: Tue, 11 Apr 2023 20:18:55 +0800 Message-Id: <198a54f0c749dcfc7e857fe33e13f514431ede24.1681186310.git.yu.c.chen@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is need to check snapshot_test and open block device in different mode, so as to avoid the race condition. No functional changes intended. Suggested-by: Pavankumar Kondeti Signed-off-by: Chen Yu --- kernel/power/hibernate.c | 7 ++++++- kernel/power/power.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 793c55a2becb..aa551b093c3f 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -64,6 +64,7 @@ enum { static int hibernation_mode = HIBERNATION_SHUTDOWN; bool freezer_test_done; +bool snapshot_test; static const struct platform_hibernation_ops *hibernation_ops; @@ -716,7 +717,6 @@ static int load_image_and_restore(void) */ int hibernate(void) { - bool snapshot_test = false; unsigned int sleep_flags; int error; @@ -744,6 +744,9 @@ int hibernate(void) if (error) goto Exit; + /* protected by system_transition_mutex */ + snapshot_test = false; + lock_device_hotplug(); /* Allocate memory management structures */ error = create_basic_memory_bitmaps(); @@ -940,6 +943,8 @@ static int software_resume(void) */ mutex_lock_nested(&system_transition_mutex, SINGLE_DEPTH_NESTING); + snapshot_test = false; + if (swsusp_resume_device) goto Check_image; diff --git a/kernel/power/power.h b/kernel/power/power.h index b4f433943209..b83c8d5e188d 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -59,6 +59,7 @@ asmlinkage int swsusp_save(void); /* kernel/power/hibernate.c */ extern bool freezer_test_done; +extern bool snapshot_test; extern int hibernation_snapshot(int platform_mode); extern int hibernation_restore(int platform_mode); -- 2.25.1