devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Saravana Kannan <saravanak@google.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sasha Levin <sashal@kernel.org>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Chen-Yu Tsai <wenst@chromium.org>,
	Conor Dooley <conor@kernel.org>
Subject: Re: [PATCH] of: Add Google Juniper to excluded default cells list
Date: Wed, 27 Nov 2024 13:28:27 -0600	[thread overview]
Message-ID: <20241127192827.GA4086536-robh@kernel.org> (raw)
In-Reply-To: <CAL_JsqL6e28pZ9G55Ab6SJO_xNK1R7D-xReC8girvP9VMUk=2Q@mail.gmail.com>

On Mon, Nov 25, 2024 at 09:46:10AM -0600, Rob Herring wrote:
> On Mon, Nov 25, 2024 at 5:32 AM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
> >
> > Google Juniper platforms have a very old bootloader which populates
> > /firmware node without proper address/size-cells leading to warnings:
> >
> >   Missing '#address-cells' in /firmware
> >   WARNING: CPU: 0 PID: 1 at drivers/of/base.c:106 of_bus_n_addr_cells+0x90/0xf0
> >   Modules linked in:
> >   CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.12.0 #1 933ab9971ff4d5dc58cb378a96f64c7f72e3454d
> >   Hardware name: Google juniper sku16 board (DT)
> >   ...
> >   Missing '#size-cells' in /firmware
> >   WARNING: CPU: 0 PID: 1 at drivers/of/base.c:133 of_bus_n_size_cells+0x90/0xf0
> >   Modules linked in:
> >   CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Tainted: G        W          6.12.0 #1 933ab9971ff4d5dc58cb378a96f64c7f72e3454d
> >   Tainted: [W]=WARN
> >   Hardware name: Google juniper sku16 board (DT)
> >
> > The platform won't receive updated bootloader/firmware so add it to
> > excluded platform list to silence the warning.
> 
> I'm interested to know what needs these in /firmware. /firmware is
> supposed to be for things without an MMIO interface. An alternative
> solution is to add the properties. That doesn't require
> CONFIG_OF_DYNAMIC and is often the approach powerpc uses.

Here's the fixup based approach I had in mind. The main possible issue I 
see is it doesn't run until of_core_init() which happens at driver core 
init. 

static void dup_parent_cells(struct device_node *np, const char *cellname)
{
	struct device_node __free(device_node) *parent = of_get_parent(np);
	struct property *prop;

	if (of_property_present(np, cellname))
		return;

	prop = of_find_property(parent, cellname, NULL);
	if (prop)
		prop = __of_prop_dup(prop, GFP_KERNEL);
	if (!prop)
		return;
	of_add_property(np, prop);
}

/*
 * Some Google Chromebooks have MMIO addresses in firmware nodes and fail to
 * populate /firmware node with #address-cells and #size-cells.
 */
static void fixup_firmware_cells(void)
{
	struct device_node __free(device_node) *np = of_find_node_by_path("/firmware");

	if (!np || !of_property_present(np, "ranges"))
		return;

	dup_parent_cells(np, "#size-cells");
	dup_parent_cells(np, "#address-cells");
}

void of_apply_fixups(void)
{
	fixup_firmware_cells();
}

      parent reply	other threads:[~2024-11-27 19:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25 11:31 [PATCH] of: Add Google Juniper to excluded default cells list Krzysztof Kozlowski
2024-11-25 11:38 ` Krzysztof Kozlowski
2024-11-25 12:02   ` AngeloGioacchino Del Regno
2024-11-25 15:46 ` Rob Herring
2024-11-26  3:53   ` Chen-Yu Tsai
2024-11-27 19:28   ` Rob Herring [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=20241127192827.GA4086536-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=conor@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=saravanak@google.com \
    --cc=sashal@kernel.org \
    --cc=wenst@chromium.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).