From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF50BC432BE for ; Tue, 31 Aug 2021 22:47:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7D196103D for ; Tue, 31 Aug 2021 22:47:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240665AbhHaWsS (ORCPT ); Tue, 31 Aug 2021 18:48:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238552AbhHaWsR (ORCPT ); Tue, 31 Aug 2021 18:48:17 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CECC1C061760 for ; Tue, 31 Aug 2021 15:47:21 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id k65so1369197yba.13 for ; Tue, 31 Aug 2021 15:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/zrrWu3vyZW/zYrRbYJvlBVVQeFSlAL8q0o+fZ41WYo=; b=Bcv/iQ909ld9LZrqWRLP3Rtu9r8i6QUWzOktnuuGS3/2SjjZvDuwXpvSLSGnDz/y4J ZBWF3SmMQRUIUeuQTucLNQyEsrIzFmhD2HMZjebZPnUDdf88Uz97hLjpV5B1a0caFgN2 PHRi/xtklW4zzZgRVJxpRkQDv3s2mfAtsXHraoeaRZqbCaU3GNlWX1LWj2zxvDZQD5sL ZWwa4pxfHI2d/+GlEnfmFhUJpf2LMW64aATeRyH51uOgk7RcESwOVKj2pFS+0vDez6C6 YwsIMNfK59uZuriv29WaQpAMK3QIv4AB7z9N27Hd2gA6zAaWMbFsq7GYE2nXvpsWI9jH jvKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/zrrWu3vyZW/zYrRbYJvlBVVQeFSlAL8q0o+fZ41WYo=; b=o6IPrgt5z3fC8lA5xgxx/Yyh5AzRmsw93r3yEYC0sLsOefh1rv5zNtnBBkQVsPPh28 kvGsJmG4M5Zkb7/NuieIL/p6ojPfW02+eaev0OGPQ9/LWr+wZfBvD8i+WmortR8aTsL8 rE6e3uoxhFrCjI0X9/zhINFiQh4nmNoUy/ZuhfIUsURwVQTjkovKdyx/wI0/91uUetJ+ BuwGMJ/1LyBoFu+lMmPvsjRqo+UoUb+qd122iw7uPu3vBeKhBeBztVr6tnOpc5H/ByE5 HV4Vx9QJ5jwwB2H11S8Kiq5zmGLjSne5sPUeUvGwnacvL3WA0lBBkA7STV93fyf5JKcQ 241g== X-Gm-Message-State: AOAM532E0qab8x50giESz3MUIWIEAOyo2lEIgmN3dGAKF14ATRIFyoIQ skkaUdDh43abdl7gesAq/QdsmjY6yrsUhf/CJHvr8fMF0YMmNg== X-Google-Smtp-Source: ABdhPJxxMUxoFE7oLhACb3rJ3U1OAxHhXTAmtgpJpd5QqtINesrpTxsSkzeI6UNbEuFYIHJ6yFg/FYdWYgePuorb7Uc= X-Received: by 2002:a25:d213:: with SMTP id j19mr34806819ybg.20.1630450040916; Tue, 31 Aug 2021 15:47:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Saravana Kannan Date: Tue, 31 Aug 2021 15:46:44 -0700 Message-ID: Subject: Re: [RFD] drivers: base: A driver's ->sync_state() callback don't get called To: Ulf Hansson Cc: "Rafael J. Wysocki" , Stephen Boyd , Rob Herring , John Stultz , Greg Kroah-Hartman , Linux PM , Linux Kernel Mailing List , DTML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 31, 2021 at 9:59 AM Saravana Kannan wrote: > > On Tue, Aug 31, 2021 at 6:56 AM Ulf Hansson wrote: > > > > Hi Saravana, Rafael, Stephen, > > > > I have observed an issue with a driver's ->sync_state() callback that > > doesn't get called, even if consumers/supplier device links conditions > > should have been satisfied. I have narrowed down the problem, but I am > > not sure what is the best solution to fix it, hence I am turning to > > you for some discussion/advice. > > > > I have two test platform drivers, one that matches on the > > "test,pm-domains-test" compatible string (this driver also has the > > ->sync_state() callback assigned) and another driver that matches on > > "test,runtime-pm-test". > > > > This is the relevant part in my DTS file: > > > > pm_domain_test { > > compatible = "test,pm-domains-test"; > > > > pdParent: power-domain-parent { > > #power-domain-cells = <0>; > > }; > > > > pdChild: power-domain-child { > > #power-domain-cells = <0>; > > power-domains = <&pdParent>; > > }; > > }; > > > > soctest: soctest { > > compatible = "simple-bus"; > > > > rpmtest0 { > > compatible = "test,runtime-pm-test"; > > power-domains = <&pdParent>; > > }; > > }; > > > > During boot the fw_devlinks are being created and their corresponding > > links. With some debug enabled this shows some of the interesting > > parts that are being printed to the log: > > > > [ 0.041539] device: 'pm_domain_test': device_add > > [ 0.041629] OF: Not linking pm_domain_test to pm_domain_test - is descendant > > [ 0.041718] device: 'soctest': device_add > > [ 0.041803] OF: Linking rpmtest0 (consumer) to pm_domain_test (supplier) > > [ 0.041829] device: 'platform:pm_domain_test--platform:soctest': device_add > > [ 0.041892] platform soctest: Linked as a sync state only consumer > > to pm_domain_test > > [ 0.041957] OF: create child: /soctest/rpmtest0 > > [ 0.041995] device: 'soctest:rpmtest0': device_add > > [ 0.042072] device: > > 'platform:pm_domain_test--platform:soctest:rpmtest0': device_add > > [ 0.042132] devices_kset: Moving soctest:rpmtest0 to end of list > > [ 0.042141] platform soctest:rpmtest0: Linked as a consumer to pm_domain_test > > > > The interesting thing here is the "sync state only" link that gets > > created. I assume there are good reasons for creating this link, even > > if I fail to understand exactly why. > > In general there's a good reason for creating these links from parent > devices of the consumer to the supplier. It is documented in the code > under __fw_devlink_link_to_consumers(). > > /* > * If consumer device is not available yet, make a "proxy" > * SYNC_STATE_ONLY link from the consumer's parent device to > * the supplier device. This is necessary to make sure the > * supplier doesn't get a sync_state() callback before the real > * consumer can create a device link to the supplier. > * > * This proxy link step is needed to handle the case where the > * consumer's parent device is added before the supplier. > */ > > and under __fw_devlink_link_to_suppliers(). > > /* > * Make "proxy" SYNC_STATE_ONLY device links to represent the needs of > * all the descendants. This proxy link step is needed to handle the > * case where the supplier is added before the consumer's parent device > * (@dev). > */ > > > > > > In any case, the sync state only link never gets dropped, which I > > assume is because there is no driver getting bound for the "soctest" > > device (it has only the "simple-bus" compatible). > > Yeah, you've identified the problem correctly. I've been thinking > about this possibility (and all the side effects a fix might have). I > can send out a fix for this soon (within a week or so). > > > In other words, it doesn't matter that both the rpmtest0 and the > > pm_domain_test devices are probed, thus satisfying the > > supplier/consumer conditions, the ->sync_state() callback doesn't get > > called anyway. > > > > Can you perhaps help to point me in a direction of how to best fix this problem? > > I hope you are okay with me sending a fix. Ulf, Could you give this a shot please? https://lore.kernel.org/lkml/20210831224510.703253-1-saravanak@google.com/T/#u -Saravana