All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ansuel Smith <ansuelsmth@gmail.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
	devicetree@vger.kernel.org, Vignesh Raghavendra <vigneshr@ti.com>,
	Boris Brezillon <bbrezillon@kernel.org>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	linux-mtd@lists.infradead.org,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH v2 1/3] mtd: partitions: ofpart: skip subnodes parse with compatible
Date: Tue, 2 Mar 2021 05:50:07 +0100	[thread overview]
Message-ID: <YD3D/zwfLlRITdHj@Ansuel-xps.localdomain> (raw)
In-Reply-To: <d504a4df-b1f7-b7c9-e62a-599d114d8a18@gmail.com>

On Tue, Mar 02, 2021 at 05:53:54PM +0100, Rafał Miłecki wrote:
> On 16.02.2021 22:26, Ansuel Smith wrote:
> > If a partitions structure is not used, parse direct subnodes as
> > fixed-partitions only if a compatible is not found or is of type
> > fixed-partition. A parser can be used directly on the subnode and
> > subnodes should not be parsed as fixed-partitions by default.
> > 
> > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > ---
> >   drivers/mtd/parsers/ofpart.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/mtd/parsers/ofpart.c b/drivers/mtd/parsers/ofpart.c
> > index daf507c123e6..4b363dd0311c 100644
> > --- a/drivers/mtd/parsers/ofpart.c
> > +++ b/drivers/mtd/parsers/ofpart.c
> > @@ -50,6 +50,11 @@ static int parse_fixed_partitions(struct mtd_info *master,
> >   			 master->name, mtd_node);
> >   		ofpart_node = mtd_node;
> >   		dedicated = false;
> > +
> > +		/* Skip parsing direct subnodes if a compatible is found and is not fixed-partitions */
> > +		if (node_has_compatible(ofpart_node) &&
> > +		    !of_device_is_compatible(ofpart_node, "fixed-partitions"))
> > +			return 0;
> >   	} else if (!of_device_is_compatible(ofpart_node, "fixed-partitions")) {
> >   		/* The 'partitions' subnode might be used by another parser */
> >   		return 0;
> 
> I admit I'm not familiar with the old binding, so let me know if my
> understanding is incorrect.
> 
> It seems to me however that your change will break parsing in cases
> like:
> 
> spi-flash@0 {
> 	compatible = "jedec,spi-nor";
> 	reg = <0x0>;
> 
> 	partition@0 {
> 		label = "bootloader";
> 		reg = <0x0 0x100000>;
> 	};
> };
> 
> nandcs@0 {
> 	compatible = "brcm,nandcs";
> 	reg = <0>;
> 
> 	partition@0 {
> 		label = "bootloader";
> 		reg = <0x0000000 0x10000>;
> 	};
> };
> 
> Did we ever use "fixed-partitions" without partitions { } subnode?

Hi, very good point. You are right and I didin't think about this case.
I don't want to assume false statement, but since the ofpart parser and
the partitions structure should have been pushed at the same time, there
shouldn't be any use of "fixed-partitions" without partitions { }
subnodes. With this assumtion, the current implementation looks to be the 
cleanest way to skip parsing. (if the parsing is dubious, don't parse at
all... The idea was that)
The hacky and IMHO dirty way to solve this is add a bool to directly
skip the subnode parsing and check for that. Something like
"no-fixed-partition" that would disable the ofnode parser with no
partitions { } subnode would accomplish the same result of this patch
and keep compatibility with nodes scheme you pointed out.


WARNING: multiple messages have this Message-ID (diff)
From: Ansuel Smith <ansuelsmth@gmail.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
	devicetree@vger.kernel.org, Vignesh Raghavendra <vigneshr@ti.com>,
	Boris Brezillon <bbrezillon@kernel.org>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	linux-mtd@lists.infradead.org,
	Miquel Raynal <miquel.raynal@bootlin.com>
Subject: Re: [PATCH v2 1/3] mtd: partitions: ofpart: skip subnodes parse with compatible
Date: Tue, 2 Mar 2021 05:50:07 +0100	[thread overview]
Message-ID: <YD3D/zwfLlRITdHj@Ansuel-xps.localdomain> (raw)
In-Reply-To: <d504a4df-b1f7-b7c9-e62a-599d114d8a18@gmail.com>

On Tue, Mar 02, 2021 at 05:53:54PM +0100, Rafał Miłecki wrote:
> On 16.02.2021 22:26, Ansuel Smith wrote:
> > If a partitions structure is not used, parse direct subnodes as
> > fixed-partitions only if a compatible is not found or is of type
> > fixed-partition. A parser can be used directly on the subnode and
> > subnodes should not be parsed as fixed-partitions by default.
> > 
> > Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> > ---
> >   drivers/mtd/parsers/ofpart.c | 5 +++++
> >   1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/mtd/parsers/ofpart.c b/drivers/mtd/parsers/ofpart.c
> > index daf507c123e6..4b363dd0311c 100644
> > --- a/drivers/mtd/parsers/ofpart.c
> > +++ b/drivers/mtd/parsers/ofpart.c
> > @@ -50,6 +50,11 @@ static int parse_fixed_partitions(struct mtd_info *master,
> >   			 master->name, mtd_node);
> >   		ofpart_node = mtd_node;
> >   		dedicated = false;
> > +
> > +		/* Skip parsing direct subnodes if a compatible is found and is not fixed-partitions */
> > +		if (node_has_compatible(ofpart_node) &&
> > +		    !of_device_is_compatible(ofpart_node, "fixed-partitions"))
> > +			return 0;
> >   	} else if (!of_device_is_compatible(ofpart_node, "fixed-partitions")) {
> >   		/* The 'partitions' subnode might be used by another parser */
> >   		return 0;
> 
> I admit I'm not familiar with the old binding, so let me know if my
> understanding is incorrect.
> 
> It seems to me however that your change will break parsing in cases
> like:
> 
> spi-flash@0 {
> 	compatible = "jedec,spi-nor";
> 	reg = <0x0>;
> 
> 	partition@0 {
> 		label = "bootloader";
> 		reg = <0x0 0x100000>;
> 	};
> };
> 
> nandcs@0 {
> 	compatible = "brcm,nandcs";
> 	reg = <0>;
> 
> 	partition@0 {
> 		label = "bootloader";
> 		reg = <0x0000000 0x10000>;
> 	};
> };
> 
> Did we ever use "fixed-partitions" without partitions { } subnode?

Hi, very good point. You are right and I didin't think about this case.
I don't want to assume false statement, but since the ofpart parser and
the partitions structure should have been pushed at the same time, there
shouldn't be any use of "fixed-partitions" without partitions { }
subnodes. With this assumtion, the current implementation looks to be the 
cleanest way to skip parsing. (if the parsing is dubious, don't parse at
all... The idea was that)
The hacky and IMHO dirty way to solve this is add a bool to directly
skip the subnode parsing and check for that. Something like
"no-fixed-partition" that would disable the ofnode parser with no
partitions { } subnode would accomplish the same result of this patch
and keep compatibility with nodes scheme you pointed out.


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-03-02 20:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-16 21:26 [PATCH v2 0/3] Implement nvmem support for mtd Ansuel Smith
2021-02-16 21:26 ` Ansuel Smith
2021-02-16 21:26 ` [PATCH v2 1/3] mtd: partitions: ofpart: skip subnodes parse with compatible Ansuel Smith
2021-02-16 21:26   ` Ansuel Smith
2021-03-02 16:53   ` Rafał Miłecki
2021-03-02 16:53     ` Rafał Miłecki
2021-03-02  4:50     ` Ansuel Smith [this message]
2021-03-02  4:50       ` Ansuel Smith
2021-02-16 21:26 ` [PATCH v2 2/3] mtd: core: add nvmem-partitions compatible to parse mtd as nvmem cells Ansuel Smith
2021-02-16 21:26   ` Ansuel Smith
2021-03-03  8:01   ` Rafał Miłecki
2021-03-03  8:01     ` Rafał Miłecki
2021-02-16 21:26 ` [PATCH v2 3/3] dt-bindings: mtd: Document use of nvmem-partitions compatible Ansuel Smith
2021-02-16 21:26   ` Ansuel Smith
2021-03-03 10:01   ` Rafał Miłecki
2021-03-03 10:01     ` Rafał Miłecki
2021-03-05 22:23     ` Rob Herring
2021-03-05 22:23       ` Rob Herring
2021-03-08  9:45       ` Rafał Miłecki
2021-03-08  9:45         ` Rafał Miłecki
2021-03-08  9:48   ` Rafał Miłecki
2021-03-08  9:48     ` Rafał Miłecki
2021-03-07 17:04     ` Ansuel Smith
2021-03-07 17:04       ` Ansuel Smith
2021-03-08 13:28       ` Rafał Miłecki
2021-03-08 13:28         ` Rafał Miłecki
2021-03-08 13:32       ` Rafał Miłecki
2021-03-08 13:32         ` Rafał Miłecki

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=YD3D/zwfLlRITdHj@Ansuel-xps.localdomain \
    --to=ansuelsmth@gmail.com \
    --cc=bbrezillon@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=zajec5@gmail.com \
    /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.