Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp889773rdd; Wed, 10 Jan 2024 02:37:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IERTT5k7sGBjZ5vVL6tWFAZ9IAS4e/pT/0OmXmF0EXcq/C1NMijj525ty+2wStddLS+G1Gn X-Received: by 2002:a50:d649:0:b0:553:45c8:b1dd with SMTP id c9-20020a50d649000000b0055345c8b1ddmr305959edj.43.1704883071742; Wed, 10 Jan 2024 02:37:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704883071; cv=none; d=google.com; s=arc-20160816; b=yW5ThhpCzYa2VW441aLQ+3j+WiB0J+ga3c4tWa9hdEwp7QoXcjzImnjEVpid7cEM75 DaIMYp3Qh0xE6Mk0al6D5mIrI/SOuzliVmG6bzXUbn2AgCkgsmbLFOqQPy15OseDzOe1 b2hg7Yew8udW7pbK0+N2N1lSd9dBcEZj6KkD5ug3jhbqZxaze4fUsYNC/w9UQIDbi7/k ITeVIu9NH45S8BOMmnRrSc+giyIk5urZY/x049nIFKwo3Dcj0WtM9cGw0MS0aXWGDb/r HCkpmZU7vknpLumpkE+pJd2V+ymDJ2NZ7bbkBBbAamQWmPb3ssiLB/JShLICMAKaagQ7 SQkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=u4kWt7hugZlhCyOqMe7z2wdD27tFmoPSDaO6tn2welE=; fh=2R9ZkrpOsBR67je5wJTJJotRbuOLfj/YkdJtzq1djJg=; b=h7l/+Bj3rfFjSKzoR+RWtgZsdSd08d9WtSHHKgOOQsRKbj0tKAYQLKKvg+bEheqaj8 crQYqnExG6eQGr/VLc/mqC4dC26pYX6TQgsfb6Rq3mdXO/+LQaedRJ2hThgNGKQEwtCp 5eNzoP2kZD7n2KP2vPkk6yf0BLOXQgC1vZWn39xy9eZJxjUDJ67m9XHHnlHWRAp3qjQJ 686S17Y+mJyyYJgKsh+0QKg44bMfJLIfF89VHl1zuy/kFzOLZEA/O87OdUoVHkWTGUDY MtNloU5l0Tm+B++DY/R7pVfVD65cUROCZjhiae5a7TtTwIFui2SwZ3ZjUMuTFnszdlxR RlPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C0EmWP7u; spf=pass (google.com: domain of linux-kernel+bounces-22001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x1-20020a05640226c100b00555562da7casi1667437edd.634.2024.01.10.02.37.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 02:37:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=C0EmWP7u; spf=pass (google.com: domain of linux-kernel+bounces-22001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7FF0A1F247B8 for ; Wed, 10 Jan 2024 10:37:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 31B16405C5; Wed, 10 Jan 2024 10:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="C0EmWP7u" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6E384176B; Wed, 10 Jan 2024 10:37:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704883060; x=1736419060; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/a07s3zLy6oSxp+NJcNrTR33vSL3+Fp4s3fo+xpFY40=; b=C0EmWP7u6MVg7k6DOpxiMy+28mKaZ31btfYxlVZWsuzAkI/hCUTbAKFW K63jSY67IByQfW4ZjfQUQS1EFkQICth+CMvZ8jxGeaHQo1fVzClaPl5yy wtDw7foyu3BhgfEPuR7iuaotORd+rgPLUnmq21WPqHDnaJmOJQ1TWMRjf dL0qOclwmXhsZDLObpPyFhQngnugrJiOhW0k6AbbpzRg2NuuleKEvH10G NTAavgJ1pfOox1H8guKo3ogDve853+fXNVcj6OztN/4Qen4vcXxJIed9L e+JzjDuOcXAqNUDDsBcsdPG6+zAGY2QlF1b24tFYrK+xFZ1lua0q6rTRl Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="5252325" X-IronPort-AV: E=Sophos;i="6.04,184,1695711600"; d="scan'208";a="5252325" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 02:37:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="785563231" X-IronPort-AV: E=Sophos;i="6.04,184,1695711600"; d="scan'208";a="785563231" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.252.37.8]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 02:37:38 -0800 Date: Wed, 10 Jan 2024 11:37:36 +0100 From: Stanislaw Gruszka To: "Rafael J. Wysocki" Cc: Linux PM , Ulf Hansson , LKML Subject: Re: [PATCH v1] PM: sleep: Restore asynchronous device resume optimization Message-ID: References: <10423008.nUPlyArG6x@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <10423008.nUPlyArG6x@kreacher> On Tue, Jan 09, 2024 at 05:59:22PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Before commit 7839d0078e0d ("PM: sleep: Fix possible deadlocks in core > system-wide PM code"), the resume of devices that were allowed to resume > asynchronously was scheduled before starting the resume of the other > devices, so the former did not have to wait for the latter unless > functional dependencies were present. > > Commit 7839d0078e0d removed that optimization in order to address a > correctness issue, but it can be restored with the help of a new device > power management flag, so do that now. > > Signed-off-by: Rafael J. Wysocki > --- > > I said I'd probably do this in 6.9, but then I thought more about it > and now I think it would be nice to have 6.8-rc1 without a suspend > performance regression and the change is relatively straightforward, > so here it goes. > > --- > drivers/base/power/main.c | 117 +++++++++++++++++++++++++--------------------- > include/linux/pm.h | 1 > 2 files changed, 65 insertions(+), 53 deletions(-) > > Index: linux-pm/include/linux/pm.h > =================================================================== > --- linux-pm.orig/include/linux/pm.h > +++ linux-pm/include/linux/pm.h > @@ -681,6 +681,7 @@ struct dev_pm_info { > bool wakeup_path:1; > bool syscore:1; > bool no_pm_callbacks:1; /* Owned by the PM core */ > + bool in_progress:1; /* Owned by the PM core */ > unsigned int must_resume:1; /* Owned by the PM core */ > unsigned int may_skip_resume:1; /* Set by subsystems */ Not related to the patch, just question: why some types here are unsigned int :1 others bool :1 ? > * dpm_resume_early - Execute "early resume" callbacks for all devices. > * @state: PM transition of the system being carried out. > @@ -845,18 +845,28 @@ void dpm_resume_early(pm_message_t state > mutex_lock(&dpm_list_mtx); > pm_transition = state; > > + /* > + * Trigger the resume of "async" devices upfront so they don't have to > + * wait for the "non-async" ones they don't depend on. > + */ > + list_for_each_entry(dev, &dpm_late_early_list, power.entry) > + dpm_async_fn(dev, async_resume_early); > + > while (!list_empty(&dpm_late_early_list)) { > dev = to_device(dpm_late_early_list.next); > - get_device(dev); > list_move_tail(&dev->power.entry, &dpm_suspended_list); > > - mutex_unlock(&dpm_list_mtx); > + if (!dev->power.in_progress) { I would consider different naming just to make clear this is regarding async call, in_progress looks too generic for me. Fine if you think otherwise, in general patch LGTM: Reviewed-by: Stanislaw Gruszka