Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1604659rdb; Thu, 25 Jan 2024 00:01:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtChpG0AddjEpdx4NUFTNMev90EtPgiDbAb2Vm15OqHBUFUFX/xK5vgvNw0fVNbZXAjNmz X-Received: by 2002:a92:c08c:0:b0:35f:ea84:831b with SMTP id h12-20020a92c08c000000b0035fea84831bmr695115ile.62.1706169695704; Thu, 25 Jan 2024 00:01:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706169695; cv=pass; d=google.com; s=arc-20160816; b=0jySIOEHTffkVGz0Oj0nXw77fRKq+c/iCnoNGezTkiunx1uTAQw9WgvzxMfFGuGV5g 5GcHHQATnWwqrH3Mvh2zA/IsZFgDey0EHSi0VDulrPoewsYp/OcF8jPeOy5tnNiKn2+d d6ukaT/keh73a4WZJ8KjcddAPgjWQe9dG5Lj+iWXsxWBciczXEBPrGst+XCpfLGU66l0 id72Lo6Rl5oVf9B8ZI0q62y0i7p1lkNokzpBwCypSN2q2MRT9QD3Cg5bOOcfuef9zpK9 2PCRJKCkhrlwuZ+Aogmr0NZuc4Ihbc95cStlPtXsf+AXusIGTgs6F0JqTyGX+6QlUbVh 51iQ== ARC-Message-Signature: i=2; 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=nXvdcLZd1SfmGcStrqpgcktuMp2Hgoy2y+1w+NC34es=; fh=3lCNSO6LQCqhm4IvCPXj5H7Te/C8INRvRb78PtOk2Ps=; b=tkNJO5p7p6zJbFmu7degv7gfCQ7wVBi452Obg4nQMLl8tyHYtYnsOmBS+LfE9si+fa +VadbCBEE6VvB3RLfuLdbo66rX47Bhl2ODI1LjJEoPdekHbsuHIAJOImgsbNwdFe2orw Upn7y4SNT/WoFbRBY2G6VORO8KZlRQzemPplPNvd1Ez4FyVkZ6jdFDl0yLYpaQBn/EYw +GyymQvRFAxN28i3fTyJTLFBvAMhkzooRqr2Pmcug5dg2NqAy8R4Zm9DAYyLTc1RD8bh 2PuagbYIykVUNU0FLS+TZwjb2ptc79C0MoCuKaqMOtC5UR5XEV34o9wnqNNihfPmIQJx z8wQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RxUNIcyd; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-38123-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38123-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id r25-20020a635d19000000b005cd86a1beccsi12645342pgb.593.2024.01.25.00.01.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 00:01:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38123-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RxUNIcyd; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-38123-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38123-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 375B728B6BC for ; Thu, 25 Jan 2024 08:01:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4441317552; Thu, 25 Jan 2024 08:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RxUNIcyd" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.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 DD40E17BA9; Thu, 25 Jan 2024 08:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706169656; cv=none; b=hpRDALAMsj0gzgQADixvOHxrIif20B5aC+6xOqjczQdE6xgzv7wlXMDBO9A2BTtMr1qNrPcauyuA3uXtz2Tzz3A6UHsMabYk8eXCsVbGltxUjjFw/10Zk4nq3u2ORRdXl1EN6voSfu0SyU3l1lmo37/mX+hSsrrAIWx5OsDUX1s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706169656; c=relaxed/simple; bh=F9/G401OlOp2TMBz9e7CH/PQuSGM0woS/H9KkQV4uIY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RTI19pXP9uG1zJy5HThGIPMTMQHTDpD280ZFzYhpS5DEp/+sutyqkyoaypOLbbhCTBUmccKUEA+vpJGWRxGZBsqI+4R2pMAmr/gnpuIqMfFBpHKVdDF33STxyRE0+/DGM4xfRuI8f+E5Lg4SOaGePF/BpgjgxJBqaIhpTWel8xw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RxUNIcyd; arc=none smtp.client-ip=198.175.65.9 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=1706169655; x=1737705655; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=F9/G401OlOp2TMBz9e7CH/PQuSGM0woS/H9KkQV4uIY=; b=RxUNIcydAWnGfHLQYR/+kk7rnLco/rt1XRmXQK6Rr6GFAD8l/mQ1INQM KrLOJYP57vaelYWy3WYppaR5HaNd/2pFomicYJOB6LmePi4tDqlqU4ovL 0l7R4AaWe3SUN9Z1N4Zd+3fHzhrITkkZWm3C+3NVyDjljTWlQC/tiFAT6 jvBkgd9U2Icp0YhYnsGMBD8h47AQl/qdDF3GC1h3cKRkR0pwIHH9p4LgN EhDjdYw/s7k3wNB381oSBQ1nHinJpT1EmD0es+Hpgk97JJGMFndsAFY2e PBj7tQyPWxyaa/2m9td7mA9CraOBT4BNhBp87+PSIUOIVsKHiJqH7LU4i w==; X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="20639198" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="20639198" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:00:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="20975173" Received: from sgruszka-mobl.ger.corp.intel.com (HELO localhost) ([10.252.58.119]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2024 00:00:49 -0800 Date: Thu, 25 Jan 2024 09:00:47 +0100 From: Stanislaw Gruszka To: "Rafael J. Wysocki" Cc: Linux PM , LKML , Ulf Hansson Subject: Re: [PATCH v1 11/12] PM: sleep: Move devices to new lists earlier in each suspend phase Message-ID: References: <5760158.DvuYhMxLoT@kreacher> <3476604.QJadu78ljV@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: <3476604.QJadu78ljV@kreacher> On Mon, Jan 22, 2024 at 12:42:46PM +0100, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > During a system-wide suspend of devices, dpm_noirq_suspend_devices(), > dpm_suspend_late() and dpm_suspend() move devices from one list to > another. They do it with each device after its PM callback in the > given suspend phase has run or has been scheduled for asynchronous > execution, in case it is deleted from the current list in the > meantime. > > However, devices can be moved to a new list before invoking their PM > callbacks (which usually is the case for the devices whose callbacks > are executed asynchronously anyway), because doing so does not affect > the ordering of that list. In either case, each device is moved to > the new list after the previous device has been moved to it or gone > away, and if a device is removed, it does not matter which list it is > in at that point, because deleting an entry from a list does not change > the ordering of the other entries in it. > > Accordingly, modify the functions mentioned above to move devices to > new lists without waiting for their PM callbacks to run regardless of > whether or not they run asynchronously. > > No intentional functional impact. > > Signed-off-by: Rafael J. Wysocki Reviewed-by: Stanislaw Gruszka > --- > drivers/base/power/main.c | 24 +++--------------------- > 1 file changed, 3 insertions(+), 21 deletions(-) > > Index: linux-pm/drivers/base/power/main.c > =================================================================== > --- linux-pm.orig/drivers/base/power/main.c > +++ linux-pm/drivers/base/power/main.c > @@ -1304,18 +1304,12 @@ static int dpm_noirq_suspend_devices(pm_ > while (!list_empty(&dpm_late_early_list)) { > struct device *dev = to_device(dpm_late_early_list.prev); > > + list_move(&dev->power.entry, &dpm_noirq_list); > get_device(dev); > mutex_unlock(&dpm_list_mtx); > > error = device_suspend_noirq(dev); > > - mutex_lock(&dpm_list_mtx); > - > - if (!error && !list_empty(&dev->power.entry)) > - list_move(&dev->power.entry, &dpm_noirq_list); > - > - mutex_unlock(&dpm_list_mtx); > - > put_device(dev); > > mutex_lock(&dpm_list_mtx); > @@ -1486,19 +1480,13 @@ int dpm_suspend_late(pm_message_t state) > while (!list_empty(&dpm_suspended_list)) { > struct device *dev = to_device(dpm_suspended_list.prev); > > + list_move(&dev->power.entry, &dpm_late_early_list); > get_device(dev); > > mutex_unlock(&dpm_list_mtx); > > error = device_suspend_late(dev); > > - mutex_lock(&dpm_list_mtx); > - > - if (!list_empty(&dev->power.entry)) > - list_move(&dev->power.entry, &dpm_late_early_list); > - > - mutex_unlock(&dpm_list_mtx); > - > put_device(dev); > > mutex_lock(&dpm_list_mtx); > @@ -1763,19 +1751,13 @@ int dpm_suspend(pm_message_t state) > while (!list_empty(&dpm_prepared_list)) { > struct device *dev = to_device(dpm_prepared_list.prev); > > + list_move(&dev->power.entry, &dpm_suspended_list); > get_device(dev); > > mutex_unlock(&dpm_list_mtx); > > error = device_suspend(dev); > > - mutex_lock(&dpm_list_mtx); > - > - if (!error && !list_empty(&dev->power.entry)) > - list_move(&dev->power.entry, &dpm_suspended_list); > - > - mutex_unlock(&dpm_list_mtx); > - > put_device(dev); > > mutex_lock(&dpm_list_mtx); > > > >