From: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
To: "Uwe Kleine-König"
<u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Cc: Yves-Alexis Perez
<corsac-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org>,
devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
entwicklung-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Subject: Re: [PATCH] overlay: ensure that existing phandles are not overwritten
Date: Sun, 7 May 2023 19:25:04 +1000 [thread overview]
Message-ID: <ZFducBimOTs/fqNZ@yekko> (raw)
In-Reply-To: <20230428180906.vb4i7447u4uvuhpn-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2270 bytes --]
On Fri, Apr 28, 2023 at 08:09:06PM +0200, Uwe Kleine-König wrote:
> Hello,
>
> On Wed, Apr 26, 2023 at 12:02:31PM +0200, Uwe Kleine-König wrote:
> > -static int overlay_adjust_node_phandles(void *fdto, int node,
> > - uint32_t delta)
> > +static int overlay_adjust_node_phandles(void *fdto, int nodeo,
> > + uint32_t delta, void *fdtbase, int basenode, uint32_t *phandlemap)
> > {
> > - int child;
> > + int childo;
> > int ret;
> > + const fdt32_t *phandlebase;
> > + int phandlebaselen;
> >
> > - ret = overlay_phandle_add_offset(fdto, node, "phandle", delta);
> > - if (ret && ret != -FDT_ERR_NOTFOUND)
> > - return ret;
> > + /*
> > + * If the base fdt has a phandle already reuse the value to not break
> > + * references that already exist in the base fdt.
> > + */
> > + if (fdtbase) {
> > + phandlebase = fdt_getprop(fdtbase, basenode, "phandle", &phandlebaselen);
> > + if (!phandlebase && phandlebaselen != -FDT_ERR_NOTFOUND)
> > + return phandlebaselen;
> > + if (!phandlebase) {
> > + phandlebase = fdt_getprop(fdtbase, basenode, "linux,phandle", &phandlebaselen);
> > + if (!phandlebase && phandlebaselen != -FDT_ERR_NOTFOUND)
> > + return phandlebaselen;
> > + }
> > + if (phandlebase && phandlebaselen != sizeof(*phandlebase))
> > + return -FDT_ERR_BADPHANDLE;
> > + }
> >
> > - ret = overlay_phandle_add_offset(fdto, node, "linux,phandle", delta);
> > - if (ret && ret != -FDT_ERR_NOTFOUND)
> > - return ret;
> > + if (fdtbase && phandlebase) {
> > + ret = overlay_phandle_set(fdto, nodeo, "phandle", fdt32_to_cpu(*phandlebase), phandlemap);
>
> Compiling that on Ubuntu stable emits a warning here that phandlebase
> might be uninitialized (see
> https://github.com/ukleinek/dtc/actions/runs/4831386302/jobs/8608771064).
>
> While looking into that, I think the code is correct, but can be
> simplified by using fdt_get_phandle() instead of open coding it. I'll
> rework the code and test a bit more. So please don't apply this version
> of the patch.
Ok, will do.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2023-05-07 9:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 10:02 [PATCH] overlay: ensure that existing phandles are not overwritten Uwe Kleine-König
[not found] ` <20230426100231.484497-1-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2023-04-28 18:09 ` Uwe Kleine-König
[not found] ` <20230428180906.vb4i7447u4uvuhpn-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2023-05-07 9:25 ` David Gibson [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=ZFducBimOTs/fqNZ@yekko \
--to=david-xt8fgy+axnrb3ne2bgzf6laj5h9x9tb+@public.gmane.org \
--cc=corsac-8fiUuRrzOP0dnm+yROfE0A@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=entwicklung-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.