From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
conor+dt@kernel.org, frowand.list@gmail.com,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
isaacmanjarres@google.com, rmk+kernel@armlinux.org.uk,
hdegoede@redhat.com, ulf.hansson@linaro.org, rafael@kernel.org,
Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH V2] of/platform: increase refcount of fwnode
Date: Fri, 18 Aug 2023 13:51:42 +0300 [thread overview]
Message-ID: <ZN9NPiOscOPXJom+@smile.fi.intel.com> (raw)
In-Reply-To: <20230818015932.2650041-1-peng.fan@oss.nxp.com>
On Fri, Aug 18, 2023 at 09:59:32AM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> commit 0f8e5651095b
> ("of/platform: Propagate firmware node by calling device_set_node()")
> use of_fwnode_handle to replace of_node_get, which introduces a side
> effect that the refcount is not increased. Then the out of tree
> jailhouse hypervisor enable/disable test will trigger kernel dump in
> of_overlay_remove, with the following sequence
> "
> of_changeset_revert(&overlay_changeset);
> of_changeset_destroy(&overlay_changeset);
> of_overlay_remove(&overlay_id);
> "
>
> So increase the refcount to avoid issues.
...
> This patch also release the refcount when releasing amba device to avoid
> refcount leakage.
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -528,6 +528,7 @@ static void amba_device_release(struct device *dev)
> {
> struct amba_device *d = to_amba_device(dev);
>
> + of_node_put(d->dev.of_node);
> if (d->res.parent)
> release_resource(&d->res);
> mutex_destroy(&d->periphid_lock);
As I said, this change should be in a separate patch with the correct Fixes tag.
> index 267d8c9a5612..d328bbb679c7 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -175,7 +175,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
> }
>
> /* setup generic device info */
> - device_set_node(&dev->dev, of_fwnode_handle(np));
> + device_set_node(&dev->dev, of_fwnode_handle(of_node_get(np)));
> dev->dev.parent = parent ? : &platform_bus;
>
> if (bus_id)
> @@ -273,7 +273,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
> dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
>
> /* setup generic device info */
> - device_set_node(&dev->dev, of_fwnode_handle(node));
> + device_set_node(&dev->dev, of_fwnode_handle(of_node_get(node)));
> dev->dev.parent = parent ? : &platform_bus;
> dev->dev.platform_data = platform_data;
> if (bus_id)
Without AMBA changes,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
thank you for fixing this!
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2023-08-18 10:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-18 1:59 [PATCH V2] of/platform: increase refcount of fwnode Peng Fan (OSS)
2023-08-18 10:51 ` Andy Shevchenko [this message]
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=ZN9NPiOscOPXJom+@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=hdegoede@redhat.com \
--cc=isaacmanjarres@google.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=rafael@kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
--cc=robh+dt@kernel.org \
--cc=ulf.hansson@linaro.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