linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Frank Rowand <frowand.list@gmail.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Saravana Kannan <saravanak@google.com>
Cc: Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	NXP Linux Team <linux-imx@nxp.com>, Wolfram Sang <wsa@kernel.org>,
	Rob Herring <robh+dt@kernel.org>, Mark Brown <broonie@kernel.org>,
	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
Subject: Re: [PATCH v2] treewide: Fix instantiation of devices in DT overlays
Date: Wed, 29 Mar 2023 11:06:50 -0500	[thread overview]
Message-ID: <a2086a3f-e4c7-5bbf-a24c-522d6723a043@gmail.com> (raw)
In-Reply-To: <240155f20aae47e9f7461e2b7416120ba6238886.1679650087.git.geert+renesas@glider.be>

On 3/24/23 04:30, Geert Uytterhoeven wrote:
> When loading a DT overlay that creates a device, the device is not
> instantiated, unless the DT overlay is unloaded and reloaded again.

Can you elaborate on why this is?  What the relevant code paths are?

> 
> Saravana explains:
>   Basically for all overlays (I hope the function is only used for
>   overlays) we assume all nodes are NOT devices until they actually
>   get added as a device.
> 
> Based on a patch by Saravana Kannan, which covered only platform and spi
> devices.


> 
> Fixes: 4a032827daa89350 ("of: property: Simplify of_link_to_phandle()")

From a quick scan of the fixed commit, I don't see how that commit caused the problem.
Can you give a quick clue?  (The clue does not need to be added to the commit message,
but please at least put it below the "---" if there are additional versions of this
patch.)

> Link: https://lore.kernel.org/r/CAGETcx_+rhHvaC_HJXGrr5_WAd2+k5f=rWYnkCZ6z5bGX-wj4w@mail.gmail.com
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Acked-by: Mark Brown <broonie@kernel.org>
> ---
> v2:
>   - Add Acked-by,
>   - Drop RFC.
> ---
>  drivers/bus/imx-weim.c    | 1 +
>  drivers/i2c/i2c-core-of.c | 1 +
>  drivers/of/dynamic.c      | 1 +
>  drivers/of/platform.c     | 1 +
>  drivers/spi/spi.c         | 1 +
>  5 files changed, 5 insertions(+)
> 
> diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c
> index 36d42484142aede2..898e23a4231400fa 100644
> --- a/drivers/bus/imx-weim.c
> +++ b/drivers/bus/imx-weim.c
> @@ -329,6 +329,7 @@ static int of_weim_notify(struct notifier_block *nb, unsigned long action,
>  				 "Failed to setup timing for '%pOF'\n", rd->dn);
>  
>  		if (!of_node_check_flag(rd->dn, OF_POPULATED)) {
> +			rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;
>  			if (!of_platform_device_create(rd->dn, NULL, &pdev->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..303f9003562eed3d 100644
> --- a/drivers/i2c/i2c-core-of.c
> +++ b/drivers/i2c/i2c-core-of.c
> @@ -178,6 +178,7 @@ static int of_i2c_notify(struct notifier_block *nb, unsigned long action,
>  			return NOTIFY_OK;
>  		}
>  
> +		rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;
>  		client = 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 = np->parent->child;
>  	np->parent->child = np;
>  	of_node_clear_flag(np, OF_DETACHED);
> +	np->fwnode.flags |= FWNODE_FLAG_NOT_DEVICE;
>  }
>  
>  /**
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index b2bd2e783445dd78..17c92cbfb62ee3ef 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -737,6 +737,7 @@ static int of_platform_notify(struct notifier_block *nb,
>  		if (of_node_check_flag(rd->dn, OF_POPULATED))
>  			return NOTIFY_OK;
>  
> +		rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;
>  		/* pdev_parent may be NULL when no bus platform device */
>  		pdev_parent = of_find_device_by_node(rd->dn->parent);
>  		pdev = of_platform_device_create(rd->dn, NULL,
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 8e8af148b1dc371e..66ac67580d2a473b 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -4527,6 +4527,7 @@ static int of_spi_notify(struct notifier_block *nb, unsigned long action,
>  			return NOTIFY_OK;
>  		}
>  
> +		rd->dn->fwnode.flags &= ~FWNODE_FLAG_NOT_DEVICE;
>  		spi = of_register_spi_device(ctlr, rd->dn);
>  		put_device(&ctlr->dev);
>  


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-03-29 16:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24  9:30 [PATCH v2] treewide: Fix instantiation of devices in DT overlays Geert Uytterhoeven
2023-03-27  2:52 ` Frank Rowand
2023-03-27  3:02 ` Shawn Guo
2023-03-27  8:54   ` Ivan Bornyakov
2023-03-29 16:06 ` Frank Rowand [this message]
2023-03-29 16:49   ` Geert Uytterhoeven
2023-03-29 19:01 ` Wolfram Sang
2023-03-29 19:47 ` Saravana Kannan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a2086a3f-e4c7-5bbf-a24c-522d6723a043@gmail.com \
    --to=frowand.list@gmail.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=saravanak@google.com \
    --cc=shawnguo@kernel.org \
    --cc=wsa@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).