Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2211747rwb; Fri, 2 Dec 2022 06:59:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf6BPBpBFWLUMjmuHh/lY7SqTM74IAkwu7N4OeSz47ToTRjY5eyF3Em0Jtgvq6l4ggue5mW6 X-Received: by 2002:a05:6402:538e:b0:468:ea55:ab40 with SMTP id ew14-20020a056402538e00b00468ea55ab40mr618321edb.323.1669993192176; Fri, 02 Dec 2022 06:59:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669993192; cv=none; d=google.com; s=arc-20160816; b=oVlZ44gaVjYnUjHlz7ziK+23uwauqzGhSshPyehoDES1JTjGR/6uKv+brYtH34jqoB mLMTVIOgV4aIpgodOPdypQ47nBOZoxEepVvxEd3vL2X6w3AhldwMwoZ/EzX41WSOK+h2 QUl/zQh62VWg/M3hMiwfJAMi8p1V83H+1ATaDZc+CfdnWsHxvUD/i5LNKUZ5yv4UvZ++ Eh0iyacy1h8OQBAOtUfK+s6Xd7g3q+qWSxoLxs9UslkKPZSgh8DPXDsa/XexaHi7pQE2 gVDBlmMHHIBPLUuMh+0BUV8Jo0FR+36uLLfXjiBTDEKkTA+zddAa20FmwP4pYZyGMsDq t9tA== 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; bh=uYImmGz6c2BoRJMxsvQqO7u7u33JkfRH06waTIgLros=; b=eLtSe0ygX4XHQ9pQbeSDpPdyhDAe0pyh0Nomh2KjGC4AXK50+ITApGq8wPIimAssuR AIvFBi/sfDKL8006DgkGkx1WRG+mjrrmOKkJ6fZMia/z2HS2x+OhWU9g8NYmh/hff/yJ DxIUvqvKDWaDtszmnu1RZKrU2OJnHtVHHIsV7j//qDubpbvrqsGP5XoxBuOnl7Ih8kXS Kq1shTk/LAJI4/pF2Kwd5uD7kx3DGEYq5uAo3H6qaUUBl7PhO1mJP18ksb7/NUXI0NXV 8RLMc04Xn3RercNeLpXFpZL92T9XjVqAMZlZBaVoQIVCAYuGX5Qmxtd9mfIP9cKflxgO Vfdw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg33-20020a170907972100b007a8beb3aa4csi6576179ejc.872.2022.12.02.06.59.31; Fri, 02 Dec 2022 06:59:52 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233470AbiLBOc3 (ORCPT + 82 others); Fri, 2 Dec 2022 09:32:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233172AbiLBOc1 (ORCPT ); Fri, 2 Dec 2022 09:32:27 -0500 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90EC4DC852; Fri, 2 Dec 2022 06:32:26 -0800 (PST) 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.1.0) id 260a5e6107349a30; Fri, 2 Dec 2022 15:32:25 +0100 Received: from kreacher.localnet (unknown [213.134.188.181]) (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 v370.home.net.pl (Postfix) with ESMTPSA id 0C9072602969; Fri, 2 Dec 2022 15:32:23 +0100 (CET) Authentication-Results: v370.home.net.pl; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: v370.home.net.pl; spf=fail smtp.mailfrom=rjwysocki.net From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Tushar Nimkar , Adrian Hunter , "Rafael J. Wysocki" , Nitin Rawat , Peter Wang , Alan Stern , Ulf Hansson Subject: [PATCH v1 1/2] PM: runtime: Do not call __rpm_callback() from rpm_idle() Date: Fri, 02 Dec 2022 15:30:28 +0100 Message-ID: <4789678.31r3eYUQgx@kreacher> In-Reply-To: <5627469.DvuYhMxLoT@kreacher> References: <5627469.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.188.181 X-CLIENT-HOSTNAME: 213.134.188.181 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrtdekgdegvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekkedrudekudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukeekrddukedupdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeelpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepqhhuihgtpghtnhhimhhkrghrsehquhhitghinhgtrdgtohhmpdhrtghpthhtoheprggurhhirghnrdhhuhhnthgvrhesihhnthgvlhdrtghomhdprhgtphht thhopehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepqhhuihgtpghnihhtihhrrgifrgesqhhuihgtihhntgdrtghomhdprhgtphhtthhopehpvghtvghrrdifrghnghesmhgvughirghtvghkrdgtohhmpdhrtghpthhtohepshhtvghrnhesrhhofihlrghnugdrhhgrrhhvrghrugdrvgguuhdprhgtphhtthhopehulhhfrdhhrghnshhsohhnsehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=9 Fuz1=9 Fuz2=9 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 From: Rafael J. Wysocki Calling __rpm_callback() from rpm_idle() after adding device links support to the former is a clear mistake. Not only it causes rpm_idle() to carry out unnecessary actions, but it is also against the assumption regarding the stability of PM-runtime status accross __rpm_callback() invocations, because rpm_suspend() and rpm_resume() may run in parallel with __rpm_callback() when it is called by rpm_idle() and the device's PM-runtime status can be updated by any of them. Fixes: 21d5c57b3726 ("PM / runtime: Use device links") Signed-off-by: Rafael J. Wysocki --- drivers/base/power/runtime.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) Index: linux-pm/drivers/base/power/runtime.c =================================================================== --- linux-pm.orig/drivers/base/power/runtime.c +++ linux-pm/drivers/base/power/runtime.c @@ -484,7 +484,17 @@ static int rpm_idle(struct device *dev, dev->power.idle_notification = true; - retval = __rpm_callback(callback, dev); + if (dev->power.irq_safe) + spin_unlock(&dev->power.lock); + else + spin_unlock_irq(&dev->power.lock); + + retval = callback(dev); + + if (dev->power.irq_safe) + spin_lock(&dev->power.lock); + else + spin_lock_irq(&dev->power.lock); dev->power.idle_notification = false; wake_up_all(&dev->power.wait_queue);