Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1042108imi; Fri, 1 Jul 2022 01:36:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uCHv+FUkZ8KMYdcipz2xWK0+antchW4KaH2wDBvUj6fy+umGpnmV1C573ALxdvLmhYS29z X-Received: by 2002:a17:902:dacd:b0:16a:4110:22a with SMTP id q13-20020a170902dacd00b0016a4110022amr20251299plx.11.1656664619051; Fri, 01 Jul 2022 01:36:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656664619; cv=none; d=google.com; s=arc-20160816; b=lG8QnSC2trGfnOnmst2cO1sAxlSYmxmcD6bOBJqN3buFOfTJGgWwPICDAHH4z5seuA ZL0dONFWLUljYovTf8jx6JjWG5LYF9EAgDlNfgE08p0i+Tvv4qrutLGsx0yLRDvnqJ7f uJ8kAiCfhH1yAR5VJXD+G/6s/mTbttSnReYHKQjMh5bHE9MnBwXRcBwNWFBesuBttv9A X/TfCnUlYmC0uZQbsCdnnvsBBL89ehwgMZ34f4EqgrZ52hxN2HpjlYHK8NBNmSoeaXM4 ezHrXnH8YovFi4KckhGc762yTvyLwB4ZLW6E56PVYgovMTI6PkWsfCfLuZoc7redg1Qx 05OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DxVyEGDmlBFOtdIPbUr6bLnyi9ayFQslfTGgaZISpPc=; b=ZUvRRxcBQU5jZfwT4VQ84SScAlJdqIX9kJxOUzRL3CcnPYkGFGRM6amI5dIfHkJQ4J upsLFEJ9kfQMHQOmsNyRyne4vharLhgHgVfrCJBbAT7HDcgM6mThs8QdA0DqGbkzZnYu y8s8En6gYai/psPIq6rGzd0OmRIgDjp5M8mxvpIxsmF8Ao8VdsNEf/5zPj91EVZTm9vG 0NUX80CMg6OtZ2TCcoOUoTqw9drPL6+M4j3yuce6auOp7JG1LlSvuVKHrOObAdKAeDBG g1P0bkf4VF6r0LyazHts/C1CjcsJnrqF+OiBXT9/WJGDSEboDmO8/V4sZax1UlCzMdiV zADQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Yj3f8GKf; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r143-20020a632b95000000b0041159a6f9ddsi2200214pgr.503.2022.07.01.01.36.46; Fri, 01 Jul 2022 01:36:59 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Yj3f8GKf; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236505AbiGAIdu (ORCPT + 99 others); Fri, 1 Jul 2022 04:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235407AbiGAIdn (ORCPT ); Fri, 1 Jul 2022 04:33:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADA4B677D3; Fri, 1 Jul 2022 01:33:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1E606B82E4F; Fri, 1 Jul 2022 08:33:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A961C341C6; Fri, 1 Jul 2022 08:33:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656664419; bh=OvGAcIxhYOa5JbVDHlKxCT9h2qhKMwiLkryX0yjrQdM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Yj3f8GKfE/qs0EnDllsntBK0+g/GsTebNwxx69W+K1dpfRPxBQykrYEFzZC+4nHD3 7NrQRNiEHrMW3JHpsebD5zrI18nsjwbTanmZg9VDpUTPPZDA5PxZUUKaGDYTooD3tF XuCgiO7y1g4NBKY01xK9/F7QX1WeyexYqT5Mxnxc= Date: Fri, 1 Jul 2022 10:33:37 +0200 From: Greg Kroah-Hartman To: "Rafael J. Wysocki" Cc: Linux PM , LKML , Ulf Hansson , Peter Wang , Adrian Hunter , Saravana Kannan Subject: Re: [PATCH] PM: runtime: Fix supplier device management during consumer probe Message-ID: References: <4748074.GXAFRqVoOG@kreacher> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4748074.GXAFRqVoOG@kreacher> X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Thu, Jun 30, 2022 at 09:16:41PM +0200, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Because pm_runtime_get_suppliers() bumps up the rpm_active counter > of each device link to a supplier of the given device in addition > to bumping up the supplier's PM-runtime usage counter, a runtime > suspend of the consumer device may case the latter to go down to 0 > when pm_runtime_put_suppliers() is running on a remote CPU. If that > happens after pm_runtime_put_suppliers() has released power.lock for > the consumer device, and a runtime resume of that device takes place > immediately after it, before pm_runtime_put() is called for the > supplier, that pm_runtime_put() call may cause the supplier to be > suspended even though the consumer is active. > > To prevent that from happening, modify pm_runtime_get_suppliers() to > call pm_runtime_get_sync() for the given device's suppliers without > touching the rpm_active counters of the involved device links > Accordingly, modify pm_runtime_put_suppliers() to call pm_runtime_put() > for the given device's suppliers without looking at the rpm_active > counters of the device links at hand. [This is analogous to what > happened before commit 4c06c4e6cf63 ("driver core: Fix possible > supplier PM-usage counter imbalance").] > > Since pm_runtime_get_suppliers() sets supplier_preactivated for each > device link where the supplier's PM-runtime usage counter has been > incremented and pm_runtime_put_suppliers() calls pm_runtime_put() for > the suppliers whose device links have supplier_preactivated set, the > PM-runtime usage counter is balanced for each supplier and this is > independent of the runtime suspend and resume of the consumer device. > > However, in case a device link with DL_FLAG_PM_RUNTIME set is dropped > during the consumer device probe, so pm_runtime_get_suppliers() bumps > up the supplier's PM-runtime usage counter, but it cannot be dropped by > pm_runtime_put_suppliers(), make device_link_release_fn() take care of > that. > > Fixes: 4c06c4e6cf63 ("driver core: Fix possible supplier PM-usage counter imbalance") > Reported-by: Peter Wang > Signed-off-by: Rafael J. Wysocki > --- > drivers/base/core.c | 10 ++++++++++ > drivers/base/power/runtime.c | 14 +------------- > 2 files changed, 11 insertions(+), 13 deletions(-) Reviewed-by: Greg Kroah-Hartman