devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafał Miłecki" <zajec5@gmail.com>
To: Rob Herring <robh@kernel.org>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Ansuel Smith <ansuelsmth@gmail.com>
Subject: Re: of_platform_populate() for address-less nodes (OF: Bad cell count for ...)
Date: Fri, 15 Jul 2022 17:16:38 +0200	[thread overview]
Message-ID: <2fff1d95-c257-2756-ff63-5efe7b3c528c@gmail.com> (raw)
In-Reply-To: <CAL_Jsq+o27gCfzJH39ct8rRSY2nGgLpzNuw71aqBHQK62iAf+A@mail.gmail.com>

On 15.07.2022 17:02, Rob Herring wrote:
> On Fri, Jul 15, 2022 at 5:59 AM Rafał Miłecki <zajec5@gmail.com> wrote:
>>
>> I need Linux to support MTD partitions drivers. They should get probed
>> for MTD partitions, access it, do their stuff. Random example:
>>
>> partitions {
>>          compatible = "fixed-partitions";
>>          #address-cells = <1>;
>>          #size-cells = <1>;
>>
>>          partition@0 {
>>                  compatible = "u-boot,bootloader";
>>                  label = "loader";
>>                  reg = <0x0 0x100000>;
>>          };
>>
>>          partition@100000 {
>>                  compatible = "u-boot,env";
>>                  label = "image";
>>                  reg = <0x100000 0x100000>;
>>          };
>> };
>>
>> (please don't confuse them with parsers which are MTD internals)
>>
>>
>> To support that I added of_platform_populate() calls, see commit
>> bcdf0315a61a2 ("mtd: call of_platform_populate() for MTD partitions"):
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bcdf0315a61a29eb753a607d3a85a4032de72d94
>>
>>
>> The problem I just noticed is it triggers errors like:
>> OF: Bad cell count for /bus@ff800000/nand-controller@1800/nand@0/partitions
>>
>> It comes from (forward-trace):
>> of_platform_populate()
>> of_platform_bus_create()
>> of_platform_device_create_pdata()
>> of_device_alloc()
>> of_address_to_resource()
>> of_address_to_resource()
>> __of_address_to_resource()
>> of_translate_address()
>> __of_translate_address()
>> OF_CHECK_COUNTS()
>> pr_err()
>>
>>
>> It's caused by "partitions" node having 1 address cell and 0 size cells.
>> It's a consequence of inheriting sizes from NAND CS:
>>
>> nand-controller@1800 {
>>          ...
>>
>>          #address-cells = <1>;
>>          #size-cells = <0>;
>>
>>          nand@0 {
>>                  compatible = "brcm,nandcs";
>>                  reg = <0>;
>>
>>                  partitions {
>>                          ...
>>                  };
>>          };
>> };
>>
>>
>> Is that something that can / should be fixed in OF implementation?
>>
>> I don't think I should assign sizes to "partitions" node as it doesn't
>> use "reg" at all. All "reg" in "partitions" subnodes contain flash
>> relative offsets and they should not be translated.
> 
> Yes, you should. The parent node of a node with 'reg' must have
> #address-cells and #size-cells. Simple as that.

For "parent node of a node with 'reg'" it's obvious. We have a different
case here though.

Please take one more look. Node named "partitions" does not have "reg".
That is what I don't have #foo-cells in the nand@0.

A complete example:

nand-controller@1800 {
	...

	#address-cells = <1>;
	#size-cells = <0>;

	nand@0 {
		compatible = "brcm,nandcs";
		reg = <0>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				compatible = "u-boot,bootloader";
				label = "loader";
				reg = <0x0 0x100000>;
			};

			partition@100000 {
				compatible = "u-boot,env";
				label = "image";
				reg = <0x100000 0x100000>;
			};
		};
	};
};



> It is 'ranges' that determines if addresses are translatable or not.


  reply	other threads:[~2022-07-15 15:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15 11:59 of_platform_populate() for address-less nodes (OF: Bad cell count for ...) Rafał Miłecki
2022-07-15 15:02 ` Rob Herring
2022-07-15 15:16   ` Rafał Miłecki [this message]
2022-07-15 19:49     ` Rob Herring

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=2fff1d95-c257-2756-ff63-5efe7b3c528c@gmail.com \
    --to=zajec5@gmail.com \
    --cc=ansuelsmth@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@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).