Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp107796rwl; Thu, 30 Mar 2023 12:56:04 -0700 (PDT) X-Google-Smtp-Source: AKy350bR2GFM5bioe24Afz+UxBFI7UCWYGFEEtubW8f439UGScoP9M5bc5BkwDzMlMiZcQoTxh9Y X-Received: by 2002:a17:906:74c6:b0:8f0:ba09:4abe with SMTP id z6-20020a17090674c600b008f0ba094abemr3193916ejl.2.1680206164118; Thu, 30 Mar 2023 12:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680206164; cv=none; d=google.com; s=arc-20160816; b=n7W01o2wIniTB+hzadU86kyhYCgn+p2EaCzvLxk0kHi2RLhKdS/xgwEnpCyfyIwmEi LVfn8mJmw7BNJIeMI1icEw/8nxFTKEXuyw9amf0IHnaV7IwfoHKv+iqNSvxofE/8CepC U7m7EJR11beSNqB1h1wFpGh7uGawtW/UEgydFVFDx+ehTBzmXkwq4XycKEZpTm5aoKzb EXAo2tZdZVRBnXddd0uejQTV785XTujlx54zrxEcjznAU+xT623V4z1uUYkKT4tAEcwl f/gkxxUaWmcWzh8Vkzq5D0vZ+H3l/CxpqsnSADfrz6QTGiiwvPUDOafC25YkDysDxT7e v8uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=G0C8x1Qfu5NpmV+FfqktLcV4MhMy0ca1jPVOTkp3rFw=; b=vH7ZyVt0XV0dsrXY3b6NSGTfn603uDJypTRjn6Evbkq072tttE0AqzeEjQVUIwAmOV N9+lnNjSkBBEzITJkGIPjzRdt7bCXC/SnXsHOIncWqjJZ5JrcK3hzGwItmV371D+gH73 e/v95WIPI9QrOcXlDwzfd64X47Er1OMrp1dkbovVLeqbRuQ9DrZTGI2GOkxjZPCfswI8 0paXSTkdT5pkvX3isUNVZWE9ySV8keLGkmwEaNEt3+PQGeQUYw9yVw2RgoJHWN2WiTst xI6qbNXj0Ghkm4LSF3ta0uCDWr1qR4phZX1l3FE6lTegCyxe3m75nbQZo0dssmtVkze3 wUAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=AZaQzujq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m19-20020a1709061ed300b008e3da5c56f4si341449ejj.485.2023.03.30.12.55.39; Thu, 30 Mar 2023 12:56:04 -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=@google.com header.s=20210112 header.b=AZaQzujq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231655AbjC3TzH (ORCPT + 99 others); Thu, 30 Mar 2023 15:55:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231698AbjC3TzF (ORCPT ); Thu, 30 Mar 2023 15:55:05 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FBFC10273 for ; Thu, 30 Mar 2023 12:54:58 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id y35so12074663pgl.4 for ; Thu, 30 Mar 2023 12:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680206098; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=G0C8x1Qfu5NpmV+FfqktLcV4MhMy0ca1jPVOTkp3rFw=; b=AZaQzujqtCMFP3dj9NurzoSLTd7YNlA3x4AvbFl6yNXyvTRSrt8hxNQo76+F2XX8b2 GiyK3MF/+nNhJRwOwEBGYQFoskDRxy+Tz723ASGyytzdZ+oev8f+5Yc3/7Fg830AP+r+ oKJW/+Aq3gSB6SnmxzdzyfTvtw8sklU+CP3wKXnWh4y1CcCV2YzERiZl+0E8GvcdXFUf KJj6XYN/ZiY/xdk34WYL58bZ2XB2cbuQG8LtXKH5yXwqhPivJg7qH1+EWG2q0xJXbEVK 5+KSa+2TJVgg0I7AfAJYSqxYYWFB0c8msazPYhaaaLVL8i5lXmhzYMS5YqEqzde5c5mc 6Ydw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680206098; h=content-transfer-encoding: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=G0C8x1Qfu5NpmV+FfqktLcV4MhMy0ca1jPVOTkp3rFw=; b=VfSk5vnAnNcynI8xz/qTCIhrnDe8cL0kq8LatU7rua55dF59aVNw608qIXFJcUKlhq fe1ahNlG7nvupDrEWt3l7o6UKm8/ceW88QkDaf1uHDk0NK2pCj2LFZlMx0taxXpawlKW hUDBGvsZDfe7a990RQPumEmT1rFTKFjf1oJnVluD8dYAz9pLyJZFEePHf/1ictqhn8MP oFnEdfULn32AAmy32iC4xIRlJSm8NaicXBtM7PcvOzKnE9WlBZZSLCL+EKkM9HOWHqOJ d7O6XFgpC2SLASF5X87e0SMXLod8HnuxpDlEfHV4dTcX5FyRhFvP0fYXqmWrgBV3P37X Cvcg== X-Gm-Message-State: AAQBX9fHx0AgqflKUyzPInKhDv+uHxzwdgZKxf+4dGsqfNrXcFNaw/xE irzHfw+IG2fTB2YO+5L8L0T9nLnKpeJHIt1ikQNfbQ== X-Received: by 2002:a63:1b61:0:b0:50c:2b1:7a8f with SMTP id b33-20020a631b61000000b0050c02b17a8fmr2203806pgm.6.1680206097475; Thu, 30 Mar 2023 12:54:57 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Saravana Kannan Date: Thu, 30 Mar 2023 12:54:21 -0700 Message-ID: Subject: Re: [PATCH v3] treewide: Fix probing of devices in DT overlays To: geert+renesas@glider.be Cc: Greg Kroah-Hartman , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Wolfram Sang , Rob Herring , Frank Rowand , Mark Brown , Ivan Bornyakov , linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable 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, Mar 30, 2023 at 6:26=E2=80=AFAM Geert Uytterhoeven wrote: > > When loading a DT overlay that creates a device, the device is not > probed, unless the DT overlay is unloaded and reloaded again. > > After the recent refactoring to improve fw_devlink, it no longer depends > on the "compatible" property to identify which device tree nodes will > become struct devices. fw_devlink now picks up dangling consumers > (consumers pointing to descendent device tree nodes of a device that > aren't converted to child devices) when a device is successfully bound > to a driver. See __fw_devlink_pickup_dangling_consumers(). > > However, during DT overlay, a device's device tree node can have > sub-nodes added/removed without unbinding/rebinding the driver. This > difference in behavior between the normal device instantiation and > probing flow vs. the DT overlay flow has a bunch of implications that > are pointed out elsewhere[1]. One of them is that the fw_devlink logic > to pick up dangling consumers is never exercised. > > This patch solves the fw_devlink issue by marking all DT nodes added by > DT overlays with FWNODE_FLAG_NOT_DEVICE (fwnode that won't become > device), and by clearing the flag when a struct device is actually > created for the DT node. This way, fw_devlink knows not to have > consumers waiting on these newly added DT nodes, and to propagate the > dependency to an ancestor DT node that has the corresponding struct > device. > > Based on a patch by Saravana Kannan, which covered only platform and spi > devices. Doesn't make sense to give a Reviewed-by to something I partially wrote, so= : Acked-by: Saravana Kannan Thanks for making sure this is fixed Geert! -Saravana > > [1] https://lore.kernel.org/r/CAGETcx_bkuFaLCiPrAWCPQz+w79ccDp6=3D9e881qm= K=3Dvx3hBMyg@mail.gmail.com > > Fixes: 4a032827daa89350 ("of: property: Simplify of_link_to_phandle()") > Link: https://lore.kernel.org/r/CAGETcx_+rhHvaC_HJXGrr5_WAd2+k5f=3DrWYnkC= Z6z5bGX-wj4w@mail.gmail.com > Signed-off-by: Geert Uytterhoeven > Acked-by: Mark Brown > Acked-by: Wolfram Sang # for I2C > --- > v3: > - Add Acked-by, > - s/instantiate/probe/, > - Improve commit description, > - Add comment before clearing FWNODE_FLAG_NOT_DEVICE, > > v2: > - Add Acked-by, > - Drop RFC. > --- > drivers/bus/imx-weim.c | 6 ++++++ > drivers/i2c/i2c-core-of.c | 5 +++++ > drivers/of/dynamic.c | 1 + > drivers/of/platform.c | 5 +++++ > drivers/spi/spi.c | 5 +++++ > 5 files changed, 22 insertions(+) > > diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c > index 36d42484142aede2..cf463c1d2102c6fb 100644 > --- a/drivers/bus/imx-weim.c > +++ b/drivers/bus/imx-weim.c > @@ -329,6 +329,12 @@ static int of_weim_notify(struct notifier_block *nb,= unsigned long action, > "Failed to setup timing for '%pOF'\n", r= d->dn); > > if (!of_node_check_flag(rd->dn, OF_POPULATED)) { > + /* > + * Clear the flag before adding the device so tha= t > + * fw_devlink doesn't skip adding consumers to th= is > + * device. > + */ > + rd->dn->fwnode.flags &=3D ~FWNODE_FLAG_NOT_DEVICE= ; > if (!of_platform_device_create(rd->dn, NULL, &pde= v->dev)) { > dev_err(&pdev->dev, > "Failed to create child device '%= pOF'\n", > diff --git a/drivers/i2c/i2c-core-of.c b/drivers/i2c/i2c-core-of.c > index aa93467784c29c89..5c137638689799c8 100644 > --- a/drivers/i2c/i2c-core-of.c > +++ b/drivers/i2c/i2c-core-of.c > @@ -178,6 +178,11 @@ static int of_i2c_notify(struct notifier_block *nb, = unsigned long action, > return NOTIFY_OK; > } > > + /* > + * Clear the flag before adding the device so that fw_dev= link > + * doesn't skip adding consumers to this device. > + */ > + rd->dn->fwnode.flags &=3D ~FWNODE_FLAG_NOT_DEVICE; > client =3D of_i2c_register_device(adap, rd->dn); > if (IS_ERR(client)) { > dev_err(&adap->dev, "failed to create client for = '%pOF'\n", > diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c > index 07d93753b12f5f4d..e311d406b1705306 100644 > --- a/drivers/of/dynamic.c > +++ b/drivers/of/dynamic.c > @@ -226,6 +226,7 @@ static void __of_attach_node(struct device_node *np) > np->sibling =3D np->parent->child; > np->parent->child =3D np; > of_node_clear_flag(np, OF_DETACHED); > + np->fwnode.flags |=3D FWNODE_FLAG_NOT_DEVICE; > } > > /** > diff --git a/drivers/of/platform.c b/drivers/of/platform.c > index b2bd2e783445dd78..78ae8418744905c9 100644 > --- a/drivers/of/platform.c > +++ b/drivers/of/platform.c > @@ -737,6 +737,11 @@ static int of_platform_notify(struct notifier_block = *nb, > if (of_node_check_flag(rd->dn, OF_POPULATED)) > return NOTIFY_OK; > > + /* > + * Clear the flag before adding the device so that fw_dev= link > + * doesn't skip adding consumers to this device. > + */ > + rd->dn->fwnode.flags &=3D ~FWNODE_FLAG_NOT_DEVICE; > /* pdev_parent may be NULL when no bus platform device */ > pdev_parent =3D of_find_device_by_node(rd->dn->parent); > pdev =3D of_platform_device_create(rd->dn, NULL, > diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c > index 37a7be6c5a44c8f9..a12420e28640bbd4 100644 > --- a/drivers/spi/spi.c > +++ b/drivers/spi/spi.c > @@ -4504,6 +4504,11 @@ static int of_spi_notify(struct notifier_block *nb= , unsigned long action, > return NOTIFY_OK; > } > > + /* > + * Clear the flag before adding the device so that fw_dev= link > + * doesn't skip adding consumers to this device. > + */ > + rd->dn->fwnode.flags &=3D ~FWNODE_FLAG_NOT_DEVICE; > spi =3D of_register_spi_device(ctlr, rd->dn); > put_device(&ctlr->dev); > > -- > 2.34.1 >