From patchwork Mon Jan 22 11:24:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 190116 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2513881dyb; Mon, 22 Jan 2024 03:48:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9dOHYjxhb2CHbfQnxTr4DS5/xCYr2PFU29AnOKzYiQ88JHVQ87QD4bIglWDly65PrPGio X-Received: by 2002:a05:6512:2246:b0:50e:b2f9:e73d with SMTP id i6-20020a056512224600b0050eb2f9e73dmr1830978lfu.95.1705924085393; Mon, 22 Jan 2024 03:48:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705924085; cv=pass; d=google.com; s=arc-20160816; b=AZaDmCHrmCRilo6t07+tGGfcr/bE/YyBxv78TrwaukdIOZSmcXWd0YB4g3EXz3ku67 QZBCH+9vpLlZZCGKbgqbhYG4qp4HkKFs1pF5KqpouO/qzDlyh/GnKeo4vrUTaza0n+Is 4gticQznQqtwVLhZO/uFdHh+Vn6sTtwRZ/vTa4zNGP7bHwJFFXDo+EdVenRed8CLk59l GhRrzt7jhMIogxcdj57jMN97WhpEZVFDM8lNECIlKrSyL1ZxG63p262619klBXhvbjTf JxblzYMiZcmMkj6RgR425JLPrvG9WEfJ23ezENKZBr+TDwl5KTR53zUE7QJvc2cVq7+i 8x2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=GsO9oaQCZbomUIxXwsGLNCUX2wbKl6PMpmx0H/lHxq4=; fh=4LIu5opAwLV7NEWuWaesW8kxXXZagKTitwg1cEZexpE=; b=oosE8LFk1bvQg2+FnUXt0w5ZpLBmM6NX/bS7inkjXv3yWYi3+l2mEm0ZRXthoVQ5U6 0tkwGQNU37VqI4Qu5/d0Hks1RyGB1Ub7aKj2pT9sFDbb1t1tqPI0nbpDdXLrrgQETR5s ijmddAKhmPWYx+THGUoSXPq3daljUlaJI/kumJ9TnIDnJSnwnxtHVOPUxKqePQbTwlGq uhHXyFp1Y1a6nLUSTJmtDUJRXnrD5Hh+melkTx8M4bVmklTU9eFAYkS4A2X+3JwMvRcd d1wimUVHxOhukrLqrL7Fts7gTDAz0+W5kQY4gIE0txzCsRX5yt3qst++UY3V4kjBLCJJ uamQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-32954-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32954-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q19-20020a1709066ad300b00a28e92eafc9si10824388ejs.768.2024.01.22.03.48.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 03:48:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32954-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-32954-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32954-ouuuleilei=gmail.com@vger.kernel.org" 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 033E81F21363 for ; Mon, 22 Jan 2024 11:48:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 403793E47F; Mon, 22 Jan 2024 11:44:35 +0000 (UTC) Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (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 0E6B53CF7C; Mon, 22 Jan 2024 11:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705923873; cv=none; b=qjOSBp6+11rmOymCBTGoHAou7j+fDibLJ4tZ+H7WslDJ5LQOY8QjfcJV6T7y/w2crfF+Nepo4gNx7uaGOyEXTK/Wa9VYUu/Rbo1ICQPSxko9zM5zVfjsdzL0mHEw5r6iMSm0OJRjs8RzckNexukZdwETun3j4Hr9mM7fyk4SY6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705923873; c=relaxed/simple; bh=hzzxCxYHKJlV//EcCCMyFY5XRICC4MkyQFC2eFI+AqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CHR9I3YBdvnm7BzD6tQYw3U8thue/b0X/1RKMvUlJknh9gM2U9qtEWlOv1Gua6+L3IqcZAWEmGMWPTsR13FN1JbgEHDTwQo9YeYApQ/FNHM6zyt85aTdXTM071FtU+yFqg5WFwU4Ccl5bJDWbJ/YbRsb2TCQb9qBSFGXuLwAIaM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.4.0) id c0f29add93c09374; Mon, 22 Jan 2024 12:44:28 +0100 Received: from kreacher.localnet (unknown [195.136.19.94]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 53F7A669540; Mon, 22 Jan 2024 12:44:28 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Ulf Hansson , Stanislaw Gruszka Subject: [PATCH v1 02/12] PM: sleep: Relocate two device PM core functions Date: Mon, 22 Jan 2024 12:24:21 +0100 Message-ID: <4876491.GXAFRqVoOG@kreacher> In-Reply-To: <5760158.DvuYhMxLoT@kreacher> References: <5760158.DvuYhMxLoT@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrvdekiedgfedtucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepgedprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrghdprhgtphhtthhopehsthgrnhhishhlrgifrdhgrhhushiikhgrsehlihhnuhigrdhinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788791053711525709 X-GMAIL-MSGID: 1788791053711525709 From: Rafael J. Wysocki Move is_async() and dpm_async_fn() in the PM core to a more suitable place. No functional impact. Signed-off-by: Rafael J. Wysocki Reviewed-by: Stanislaw Gruszka --- drivers/base/power/main.c | 58 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) Index: linux-pm/drivers/base/power/main.c =================================================================== --- linux-pm.orig/drivers/base/power/main.c +++ linux-pm/drivers/base/power/main.c @@ -578,6 +578,35 @@ bool dev_pm_skip_resume(struct device *d return !dev->power.must_resume; } +static bool is_async(struct device *dev) +{ + return dev->power.async_suspend && pm_async_enabled + && !pm_trace_is_enabled(); +} + +static bool dpm_async_fn(struct device *dev, async_func_t func) +{ + reinit_completion(&dev->power.completion); + + if (is_async(dev)) { + dev->power.async_in_progress = true; + + get_device(dev); + + if (async_schedule_dev_nocall(func, dev)) + return true; + + put_device(dev); + } + /* + * Because async_schedule_dev_nocall() above has returned false or it + * has not been called at all, func() is not running and it is safe to + * update the async_in_progress flag without extra synchronization. + */ + dev->power.async_in_progress = false; + return false; +} + /** * device_resume_noirq - Execute a "noirq resume" callback for given device. * @dev: Device to handle. @@ -664,35 +693,6 @@ Out: } } -static bool is_async(struct device *dev) -{ - return dev->power.async_suspend && pm_async_enabled - && !pm_trace_is_enabled(); -} - -static bool dpm_async_fn(struct device *dev, async_func_t func) -{ - reinit_completion(&dev->power.completion); - - if (is_async(dev)) { - dev->power.async_in_progress = true; - - get_device(dev); - - if (async_schedule_dev_nocall(func, dev)) - return true; - - put_device(dev); - } - /* - * Because async_schedule_dev_nocall() above has returned false or it - * has not been called at all, func() is not running and it is safe to - * update the async_in_progress flag without extra synchronization. - */ - dev->power.async_in_progress = false; - return false; -} - static void async_resume_noirq(void *data, async_cookie_t cookie) { struct device *dev = data;