Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6005389rwb; Mon, 5 Dec 2022 06:54:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4VeT/hxBN8Fe1nnvs7TxyVdb0LUFNGHHLId/mhDWO1wIz3pmoQCddYoKPIR9usUY7XPoIl X-Received: by 2002:a17:902:d58f:b0:189:a6bf:1b27 with SMTP id k15-20020a170902d58f00b00189a6bf1b27mr27184402plh.126.1670252091702; Mon, 05 Dec 2022 06:54:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670252091; cv=none; d=google.com; s=arc-20160816; b=T2K92nfIWusKHZy39AE5ueO/RDxEIwwuylUkNSRcfLHEQlt4yh7VDR8htUQ42Dk7zM +RHLZDSe8Z4xFXXnOLUz9W9D25e5ry/QHYHOHOTNXq5WusrfpiQMY24JNg7ZD8X2WUJa 2EOsP5qWrDIJ1Z7qMoczce8HM5hngJm6pGxekuj0KaVPsBaBb7X3ZkYg/7Os06aQ+tth PaxYfF8v5hHnjfNEuMjG8BO8H4r6PlnGfkcZ2tHdmd2/TTOsN6FywUrjgv/ckDgPi/C8 +cigbKqe6yAYSEqjz75DTyikbNlcuLJPOZBkczPfWEId57PLvkJo9X2UVMrhvXbOiHfh p/Xg== 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; bh=mmxDQWz1OcZRQLIrCnyf8KKp2sa+/PYHinAmiEwEu/g=; b=ecdCNtMZbOEEW1F9PoZO8hiRVbQfvUMszr3/otmjpS6CI47ELgmkWOIa9YEUsat9Gt qy1n99SXkyNeTHAt767oDhK3uUlIxDEUOK43isLmxDjyaUaOMGQvBb5GpmlPffG2sktR o4yZQ88RXExd51w2mXMjfRx11bjNyib7JsaMaeJdORncVUT+vsG8dnUy/+0Nvbt2d24V mYbtIkELAtv6B3RiHuGcoNcuOKHo1RhCMOxuKIMIxqJuDTIuFAhp/rwwwQczmv4Lvo2a 6E74eh5CvBbreFM1TMhQg+vtd2/CLdItnQbTmjyvv9KJSckyMBzzgur928rfL/fS/7tD 2ZpA== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p1-20020a635b01000000b00477b64d8e5csi14970229pgb.160.2022.12.05.06.54.39; Mon, 05 Dec 2022 06:54:51 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231965AbiLEOqM (ORCPT + 81 others); Mon, 5 Dec 2022 09:46:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231516AbiLEOqJ (ORCPT ); Mon, 5 Dec 2022 09:46:09 -0500 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 891191B1EC; Mon, 5 Dec 2022 06:46:06 -0800 (PST) Received: by mail-qt1-f172.google.com with SMTP id jr1so11514357qtb.7; Mon, 05 Dec 2022 06:46:06 -0800 (PST) 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=mmxDQWz1OcZRQLIrCnyf8KKp2sa+/PYHinAmiEwEu/g=; b=FM99B8CouUiddxogTCWpQuQ94b0HLoazU4Kp7W8pEEJZicQYzgBYs1cVLlJU83NILW 6mwhnnDFNWV0qk3qzQk0h9quqR99lVlByWUXSYuKYa5Ch8m1ShgHb+MVltQICFJ0zXGQ IfmYiyRVe7YUSeqF3zL7XavktRG6itll/9JGcf/ut7jHysJwfwCU9ovYFWvNT5+aNtlP 0bUsFUmfWI4ZvHWKe7TpQYF73oGI+SUPyAIujcFUbBYUOFaRKdB4mYPBLU7e0VAjbcqJ H/KfTZPi2BnSnPwK4UydHFHdv39SqFv2bC0VwRkHc7ckMP95OkMwQXSlaZw4BGQsZXbE mw9Q== X-Gm-Message-State: ANoB5pktNt07pTn5oru8uzdHnMviiCjimcT0M3VIw7n/RQAfahN/1PSN sEjwgWotNlkz6V0VG+vFpFy2NKAhpvCkxAC9MSs= X-Received: by 2002:a05:622a:410a:b0:3a5:5987:42c6 with SMTP id cc10-20020a05622a410a00b003a5598742c6mr76491917qtb.147.1670251565666; Mon, 05 Dec 2022 06:46:05 -0800 (PST) MIME-Version: 1.0 References: <5627469.DvuYhMxLoT@kreacher> <4789678.31r3eYUQgx@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 5 Dec 2022 15:45:54 +0100 Message-ID: Subject: Re: [PATCH v1 1/2] PM: runtime: Do not call __rpm_callback() from rpm_idle() To: Adrian Hunter Cc: "Rafael J. Wysocki" , Linux PM , LKML , Tushar Nimkar , "Rafael J. Wysocki" , Nitin Rawat , Peter Wang , Alan Stern , Ulf Hansson Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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, Dec 5, 2022 at 8:45 AM Adrian Hunter wrote: > > On 2/12/22 16:30, 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 > > accross -> across Fixed whey applying the patch. > > 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") > > Reviewed-by: Adrian Hunter Thank you! > > 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); > > > > > > >