Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5869056rwb; Mon, 5 Dec 2022 05:18:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf5XT+iIcvZTb2jSTLLH9QvEUCM3/0XGlG/vMYA/n2LEaGsFK0mKT0TB3u59q1E7IO9hilEf X-Received: by 2002:a17:906:40d3:b0:7c0:efba:a8c6 with SMTP id a19-20020a17090640d300b007c0efbaa8c6mr4711311ejk.632.1670246329857; Mon, 05 Dec 2022 05:18:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670246329; cv=none; d=google.com; s=arc-20160816; b=qUaO0/CQwXtb4Hm8CbDgLT3TFk9ZXIZ9YYMQX6lf6a5Lk+ch86+v1FcLbQrkU4OR1i g7DWW1WMxRMgqy6O54m99weR60VTJ211zMFWniQKjwN5iLigGTY4sUS+tHmJ2ZC2oAt+ VO+hL+IsaQifkdgAjIrn7CXJ6pO6w/HX5beZhbcT6J8p7Gj/pwlCHhZ51LwNJYynKIp/ ySMWfLQoEjhug97EQqlc5iSmOsEPz0lwcOcoHIiP6iXsh+fMwEFii4ODB1NFXdq7456s ZIJP++rgNowa5hBRlV9r0B18a3kJ7dQpEAA0OEDzaY0ctji8L6ve6pDrcdbNTyH5fY87 S4mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Skm+LNKckmc6G2Jr5AHkpfAt8qWeTvk3qZKc10iUg4o=; b=Uwz4QZu91FdRqiY/TiJS1uSbIdmaG8u7ngbrXHTuQuWrmvJa2xjvSwWp38jPPmIJyj e1kTVFivwYlrqcMqHk0fjJy+Y8iMv0CtF91URCH20nwwsXK6wvGgp043Tk1z3l2y5ZCj +Dcf6ESA/vW9HgbFE1enyirlinYX+rhqBCJ46Odq37LjU7eqtTtF6gDl1ceoKMcT/8fo vH4uCQVuDh8STm2zPmLtN0vzoB++nZDhiG5YW2mhzRYRuQ8q1XCOLoTkcbCk9LwVRwBp qPJVU54v6M54NpfhEF2y8U2hv/NwAemXafVtssdZBty+I9FMWZ0OvBJpTld5GapcqGTG m73w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u2x4sPJH; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa36-20020a1709076d2400b007ae74740f93si13591514ejc.832.2022.12.05.05.18.29; Mon, 05 Dec 2022 05:18:49 -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; dkim=pass header.i=@linaro.org header.s=google header.b=u2x4sPJH; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbiLEMrY (ORCPT + 82 others); Mon, 5 Dec 2022 07:47:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231928AbiLEMrU (ORCPT ); Mon, 5 Dec 2022 07:47:20 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35D221B7A1 for ; Mon, 5 Dec 2022 04:47:19 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id hd14-20020a17090b458e00b0021909875bccso11179584pjb.1 for ; Mon, 05 Dec 2022 04:47:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Skm+LNKckmc6G2Jr5AHkpfAt8qWeTvk3qZKc10iUg4o=; b=u2x4sPJHmrr8rMTniOlRrg3awbIXBh5A/vu2BxcMk/66ujTOvEAUzX42SzH0/ZBDM5 vkyQf+vzFF5NegAhIJLWVu42vm1bb8mFxxu6sBK700JTfbHMhALKNZF/i1BX/TEdDuMQ 6CAnyUuKz6nG7aMMczjq1g4DvBSK38Wa0RHUCZsuK+iSfjITn/7AKoqbUJ5RkhNUHpXq w5iyv2nkTHknaWsD4dqVWNoO+bYojMw80fKeJ3285ftkm4EN37V7XXuQbrX2c1KqXnf7 3Z7b/3UWNZU6GrXbypmd5DfjrJXyXaOrPkcslW5r7wWhyPwpcKpXw+MRncu0ktpjS+t6 aV0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Skm+LNKckmc6G2Jr5AHkpfAt8qWeTvk3qZKc10iUg4o=; b=er7Ji/0FW2RBGsrobP0ISlCbKyxE2p3UlZFIqYeorKtP4w4vxuACylLSv5Vel8rTB/ 4dIGnMc1dyhE9Lbj/27OogqKysM0DqdcuJT8E8OZnpNENLNKvRXLvxXQRFT82HJooTzH 6pcBt6Bk+XX9fAztCvA7jQwypP36JfbaiUTdSs8I0xF5bQL0ctPL4WNE8arnUWG+Kfss vH4dt2sarXHVln2KYF//WWbZzBJwg+1nii9AM2lJAzr7UHYdFU2sEfjbroTZTta6aiZN IRvaq4itgoMI4UjrsApWrZnp1zsZa24AGwjDNKD7H8yYLpflonn27/3fjjRNFZJAi5Oc nL7g== X-Gm-Message-State: ANoB5pnh0v4Hnu4i8EePhODy5/nxLn6S1MTfZTve38jXfZ7DMC1RcKle WKNZE1Vvs/tooJSvnDksIs72RyMa7BszRbYBd1RQ0g== X-Received: by 2002:a17:90a:ae0f:b0:20d:b124:33b1 with SMTP id t15-20020a17090aae0f00b0020db12433b1mr87301189pjq.202.1670244438668; Mon, 05 Dec 2022 04:47:18 -0800 (PST) MIME-Version: 1.0 References: <5627469.DvuYhMxLoT@kreacher> <4789678.31r3eYUQgx@kreacher> In-Reply-To: From: Ulf Hansson Date: Mon, 5 Dec 2022 13:46:42 +0100 Message-ID: Subject: Re: [PATCH v1 1/2] PM: runtime: Do not call __rpm_callback() from rpm_idle() To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Linux PM , LKML , Tushar Nimkar , Adrian Hunter , Nitin Rawat , Peter Wang , Alan Stern Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 On Mon, 5 Dec 2022 at 13:13, Rafael J. Wysocki wrote: > > On Mon, Dec 5, 2022 at 1:08 PM Ulf Hansson wrote: > > > > On Fri, 2 Dec 2022 at 15:32, Rafael J. Wysocki wrote: > > > > > > 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. > > > > Urgh, that's a nasty bug you are fixing here. Is there perhaps some > > links to some error reports that can make sense to include here? > > There is a bug report, but I have no confirmation that this fix is > sufficient to address it (even though I'm quite confident that it will > be). > > > > > > > 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); > > > > Couldn't we just extend __rpm_callback() to take another in-parameter, > > rather than open-coding the below? > > I'd rather not do that. > > I'd prefer rpm_callback() to be used only in rpm_suspend() and > rpm_resume() where all of the assumptions hold and rpm_idle() really > is a special case. > > And there is not much open-coding here, just the locking part. That and the actual call to the callback. Not much, but still. > > > Note that, __rpm_callback() already uses a "bool use_links" internal > > variable, that indicates whether the device links should be used or > > not. > > Yes, it does, but why does that matter? It means that __rpm_callback() is already prepared to (almost) cover this case. > > > > + 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); > > > > > > > > > Note, it's not a big deal to me, if you feel strongly that your current approach is better, I am fine with that too. Kind regards Uffe