2021-08-10 09:09:35

by Joakim Zhang

[permalink] [raw]
Subject: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property

Introduce "reverse-data" property for nvmem provider to reverse buffer.

Signed-off-by: Joakim Zhang <[email protected]>
---
Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
index b8dc3d2b6e92..bc745083fc64 100644
--- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
+++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
@@ -61,6 +61,11 @@ patternProperties:
description:
Size in bit within the address range specified by reg.

+ reverse-data:
+ $ref: /schemas/types.yaml#/definitions/flag
+ description:
+ Reverse the data that read from the storage device.
+
required:
- reg

--
2.17.1


2021-08-10 16:42:09

by Jan Lübbe

[permalink] [raw]
Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property

On Tue, 2021-08-10 at 15:35 +0800, Joakim Zhang wrote:
> Introduce "reverse-data" property for nvmem provider to reverse buffer.
>
> Signed-off-by: Joakim Zhang <[email protected]>
> ---
> Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> index b8dc3d2b6e92..bc745083fc64 100644
> --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> @@ -61,6 +61,11 @@ patternProperties:
> description:
> Size in bit within the address range specified by reg.
>
> + reverse-data:
> + $ref: /schemas/types.yaml#/definitions/flag
> + description:
> + Reverse the data that read from the storage device.

I'd prefer if it was more explicit that the *bytes* will be reversed. Otherwise
a reader might think that this is reversing on the *bit* level.

Jan

> +
> required:
> - reg
>

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

2021-08-11 08:11:13

by Joakim Zhang

[permalink] [raw]
Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property



> -----Original Message-----
> From: Joakim Zhang <[email protected]>
> Sent: 2021??8??11?? 16:05
> To: Jan L??bbe <[email protected]>; [email protected];
> [email protected]; [email protected]
> Cc: [email protected]; dl-linux-imx <[email protected]>;
> [email protected]; [email protected]
> Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> property
>
>
> > -----Original Message-----
> > From: Jan L??bbe <[email protected]>
> > Sent: 2021??8??10?? 23:14
> > To: Joakim Zhang <[email protected]>;
> > [email protected]; [email protected];
> > [email protected]
> > Cc: [email protected]; dl-linux-imx <[email protected]>;
> > [email protected]; [email protected]
> > Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> > property
> >
> > On Tue, 2021-08-10 at 15:35 +0800, Joakim Zhang wrote:
> > > Introduce "reverse-data" property for nvmem provider to reverse buffer.
> > >
> > > Signed-off-by: Joakim Zhang <[email protected]>
> > > ---
> > > Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > index b8dc3d2b6e92..bc745083fc64 100644
> > > --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > @@ -61,6 +61,11 @@ patternProperties:
> > > description:
> > > Size in bit within the address range specified by reg.
> > >
> > > + reverse-data:
> > > + $ref: /schemas/types.yaml#/definitions/flag
> > > + description:
> > > + Reverse the data that read from the storage device.
> >
> > I'd prefer if it was more explicit that the *bytes* will be reversed.
> > Otherwise a reader might think that this is reversing on the *bit* level.
>
> Make sense, how about 'reverse-byte-order'?

Sorry, 'reverse-bytes-order'.

Best Regards,
Joakim Zhang
> Best Regards,
> Joakim Zhang
> > Jan
> >
> > > +
> > > required:
> > > - reg
> > >
> >
> > --
> > Pengutronix e.K. |
> > |
> > Steuerwalder Str. 21 |
> > https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.p
> > e
> >
> ngutronix.de%2F&amp;data=04%7C01%7Cqiangqing.zhang%40nxp.com%7C79
> >
> 3a60188540455919b608d95c118878%7C686ea1d3bc2b4c6fa92cd99c5c30163
> >
> 5%7C0%7C0%7C637642052637994749%7CUnknown%7CTWFpbGZsb3d8eyJWI
> >
> joiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1
> >
> 000&amp;sdata=S27O8AV8lRvGxyEutJl6Uh4AjbArD%2BkvQl%2FI05ZU1P8%3D
> > &amp;reserved=0 |
> > 31137 Hildesheim, Germany | Phone:
> +49-5121-206917-0
> > |
> > Amtsgericht Hildesheim, HRA 2686 | Fax:
> > +49-5121-206917-5555 |

2021-08-11 08:13:30

by Joakim Zhang

[permalink] [raw]
Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property


> -----Original Message-----
> From: Jan L??bbe <[email protected]>
> Sent: 2021??8??10?? 23:14
> To: Joakim Zhang <[email protected]>;
> [email protected]; [email protected]; [email protected]
> Cc: [email protected]; dl-linux-imx <[email protected]>;
> [email protected]; [email protected]
> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> property
>
> On Tue, 2021-08-10 at 15:35 +0800, Joakim Zhang wrote:
> > Introduce "reverse-data" property for nvmem provider to reverse buffer.
> >
> > Signed-off-by: Joakim Zhang <[email protected]>
> > ---
> > Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > index b8dc3d2b6e92..bc745083fc64 100644
> > --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > @@ -61,6 +61,11 @@ patternProperties:
> > description:
> > Size in bit within the address range specified by reg.
> >
> > + reverse-data:
> > + $ref: /schemas/types.yaml#/definitions/flag
> > + description:
> > + Reverse the data that read from the storage device.
>
> I'd prefer if it was more explicit that the *bytes* will be reversed. Otherwise a
> reader might think that this is reversing on the *bit* level.

Make sense, how about 'reverse-byte-order'?

Best Regards,
Joakim Zhang
> Jan
>
> > +
> > required:
> > - reg
> >
>
> --
> Pengutronix e.K. |
> |
> Steuerwalder Str. 21 |
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pe
> ngutronix.de%2F&amp;data=04%7C01%7Cqiangqing.zhang%40nxp.com%7C79
> 3a60188540455919b608d95c118878%7C686ea1d3bc2b4c6fa92cd99c5c30163
> 5%7C0%7C0%7C637642052637994749%7CUnknown%7CTWFpbGZsb3d8eyJWI
> joiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1
> 000&amp;sdata=S27O8AV8lRvGxyEutJl6Uh4AjbArD%2BkvQl%2FI05ZU1P8%3D
> &amp;reserved=0 |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0
> |
> Amtsgericht Hildesheim, HRA 2686 | Fax:
> +49-5121-206917-5555 |

2021-08-11 09:09:32

by Jan Lübbe

[permalink] [raw]
Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property

On Wed, 2021-08-11 at 08:06 +0000, Joakim Zhang wrote:
>
> > -----Original Message-----
> > From: Joakim Zhang <[email protected]>
> > Sent: 2021年8月11日 16:05
> > To: Jan Lübbe <[email protected]>; [email protected];
> > [email protected]; [email protected]
> > Cc: [email protected]; dl-linux-imx <[email protected]>;
> > [email protected]; [email protected]
> > Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> > property
> >
> >
> > > -----Original Message-----
> > > From: Jan Lübbe <[email protected]>
> > > Sent: 2021年8月10日 23:14
> > > To: Joakim Zhang <[email protected]>;
> > > [email protected]; [email protected];
> > > [email protected]
> > > Cc: [email protected]; dl-linux-imx <[email protected]>;
> > > [email protected]; [email protected]
> > > Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> > > property
> > >
> > > On Tue, 2021-08-10 at 15:35 +0800, Joakim Zhang wrote:
> > > > Introduce "reverse-data" property for nvmem provider to reverse buffer.
> > > >
> > > > Signed-off-by: Joakim Zhang <[email protected]>
> > > > ---
> > > > Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
> > > > 1 file changed, 5 insertions(+)
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > > b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > > index b8dc3d2b6e92..bc745083fc64 100644
> > > > --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > > +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > > @@ -61,6 +61,11 @@ patternProperties:
> > > > description:
> > > > Size in bit within the address range specified by reg.
> > > >
> > > > + reverse-data:
> > > > + $ref: /schemas/types.yaml#/definitions/flag
> > > > + description:
> > > > + Reverse the data that read from the storage device.
> > >
> > > I'd prefer if it was more explicit that the *bytes* will be reversed.
> > > Otherwise a reader might think that this is reversing on the *bit* level.
> >
> > Make sense, how about 'reverse-byte-order'?
>
> Sorry, 'reverse-bytes-order'.

'reverse-byte-order' sounds better to me, but I'm not a native English speaker.
I'd be fine with either, though.

Thanks
Jan

2021-08-11 10:18:47

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property



On 10/08/2021 08:35, Joakim Zhang wrote:
> Introduce "reverse-data" property for nvmem provider to reverse buffer.
>
> Signed-off-by: Joakim Zhang <[email protected]>
> ---
> Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> index b8dc3d2b6e92..bc745083fc64 100644
> --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> @@ -61,6 +61,11 @@ patternProperties:
> description:
> Size in bit within the address range specified by reg.
>
> + reverse-data:
> + $ref: /schemas/types.yaml#/definitions/flag
> + description:
> + Reverse the data that read from the storage device.
> +

This new property is only going to solve one of the reverse order issue
here.
If I remember correctly we have mac-address stored in various formats
ex: from old thread I can see

Type 1: Octets in ASCII without delimiters. (Swapped/non-Swapped)
Type 2: Octets in ASCII with delimiters like (":", ",", ".", "-"... so
on) (Swapped/non-Swapped)
Type 3: Is the one which stores mac address in Type1/2 but this has to
be incremented to be used on other instances of eth.
Type 4: Octets as bytes/u8, swapped/non-swapped

I think its right time to consider adding compatibles to nvmem-cells to
be able to specify encoding information and handle post processing.


Lets see what Rob would say on this approach.


--srini

> required:
> - reg
>
>

2021-08-17 19:59:47

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property

On Wed, Aug 11, 2021 at 11:16:49AM +0100, Srinivas Kandagatla wrote:
>
>
> On 10/08/2021 08:35, Joakim Zhang wrote:
> > Introduce "reverse-data" property for nvmem provider to reverse buffer.
> >
> > Signed-off-by: Joakim Zhang <[email protected]>
> > ---
> > Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > index b8dc3d2b6e92..bc745083fc64 100644
> > --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > @@ -61,6 +61,11 @@ patternProperties:
> > description:
> > Size in bit within the address range specified by reg.
> > + reverse-data:
> > + $ref: /schemas/types.yaml#/definitions/flag
> > + description:
> > + Reverse the data that read from the storage device.
> > +
>
> This new property is only going to solve one of the reverse order issue
> here.
> If I remember correctly we have mac-address stored in various formats ex:
> from old thread I can see
>
> Type 1: Octets in ASCII without delimiters. (Swapped/non-Swapped)
> Type 2: Octets in ASCII with delimiters like (":", ",", ".", "-"... so on)
> (Swapped/non-Swapped)
> Type 3: Is the one which stores mac address in Type1/2 but this has to be
> incremented to be used on other instances of eth.
> Type 4: Octets as bytes/u8, swapped/non-swapped
>
> I think its right time to consider adding compatibles to nvmem-cells to be
> able to specify encoding information and handle post processing.

Yes. Trying to handle this with never ending new properties will end up
with a mess. At some point, you just need code to parse the data.

Rob

2021-08-18 07:56:03

by Joakim Zhang

[permalink] [raw]
Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property


> -----Original Message-----
> From: Rob Herring <[email protected]>
> Sent: 2021??8??18?? 3:58
> To: Srinivas Kandagatla <[email protected]>
> Cc: Joakim Zhang <[email protected]>; [email protected];
> [email protected]; dl-linux-imx <[email protected]>;
> [email protected]; [email protected]
> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> property
>
> On Wed, Aug 11, 2021 at 11:16:49AM +0100, Srinivas Kandagatla wrote:
> >
> >
> > On 10/08/2021 08:35, Joakim Zhang wrote:
> > > Introduce "reverse-data" property for nvmem provider to reverse buffer.
> > >
> > > Signed-off-by: Joakim Zhang <[email protected]>
> > > ---
> > > Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > index b8dc3d2b6e92..bc745083fc64 100644
> > > --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > @@ -61,6 +61,11 @@ patternProperties:
> > > description:
> > > Size in bit within the address range specified by reg.
> > > + reverse-data:
> > > + $ref: /schemas/types.yaml#/definitions/flag
> > > + description:
> > > + Reverse the data that read from the storage device.
> > > +
> >
> > This new property is only going to solve one of the reverse order
> > issue here.
> > If I remember correctly we have mac-address stored in various formats ex:
> > from old thread I can see
> >
> > Type 1: Octets in ASCII without delimiters. (Swapped/non-Swapped) Type
> > 2: Octets in ASCII with delimiters like (":", ",", ".", "-"... so on)
> > (Swapped/non-Swapped)
> > Type 3: Is the one which stores mac address in Type1/2 but this has to
> > be incremented to be used on other instances of eth.
> > Type 4: Octets as bytes/u8, swapped/non-swapped
> >
> > I think its right time to consider adding compatibles to nvmem-cells
> > to be able to specify encoding information and handle post processing.
>
> Yes. Trying to handle this with never ending new properties will end up with a
> mess. At some point, you just need code to parse the data.

Thanks, Rob.

Hi Srinivas,

Do you plan to implement it?

Or need me follow up? If yes, please input your insights to point me how to work for it.

Thanks.

Best Regards,
Joakim Zhang
> Rob

2021-08-24 06:33:41

by Joakim Zhang

[permalink] [raw]
Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property


Hi Srinivas,

> > > > --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > > +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> > > > @@ -61,6 +61,11 @@ patternProperties:
> > > > description:
> > > > Size in bit within the address range specified by
> reg.
> > > > + reverse-data:
> > > > + $ref: /schemas/types.yaml#/definitions/flag
> > > > + description:
> > > > + Reverse the data that read from the storage device.
> > > > +
> > >
> > > This new property is only going to solve one of the reverse order
> > > issue here.
> > > If I remember correctly we have mac-address stored in various formats ex:
> > > from old thread I can see
> > >
> > > Type 1: Octets in ASCII without delimiters. (Swapped/non-Swapped)
> > > Type
> > > 2: Octets in ASCII with delimiters like (":", ",", ".", "-"... so
> > > on)
> > > (Swapped/non-Swapped)
> > > Type 3: Is the one which stores mac address in Type1/2 but this has
> > > to be incremented to be used on other instances of eth.
> > > Type 4: Octets as bytes/u8, swapped/non-swapped
> > >
> > > I think its right time to consider adding compatibles to nvmem-cells
> > > to be able to specify encoding information and handle post processing.
> >
> > Yes. Trying to handle this with never ending new properties will end
> > up with a mess. At some point, you just need code to parse the data.
>
> Thanks, Rob.
>
> Hi Srinivas,
>
> Do you plan to implement it?
>
> Or need me follow up? If yes, please input your insights to point me how to
> work for it.

Any comments?

Best Regards,
Joakim Zhang

2021-09-03 13:52:42

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property

Hi Joakim,

On 18/08/2021 08:54, Joakim Zhang wrote:
>
>> -----Original Message-----
>> From: Rob Herring <[email protected]>
>> Sent: 2021??8??18?? 3:58
>> To: Srinivas Kandagatla <[email protected]>
>> Cc: Joakim Zhang <[email protected]>; [email protected];
>> [email protected]; dl-linux-imx <[email protected]>;
>> [email protected]; [email protected]
>> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
>> property
>>
>> On Wed, Aug 11, 2021 at 11:16:49AM +0100, Srinivas Kandagatla wrote:
>>>
>>>
>>> On 10/08/2021 08:35, Joakim Zhang wrote:
>>>> Introduce "reverse-data" property for nvmem provider to reverse buffer.
>>>>
>>>> Signed-off-by: Joakim Zhang <[email protected]>
>>>> ---
>>>> Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
>>>> 1 file changed, 5 insertions(+)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
>>>> b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
>>>> index b8dc3d2b6e92..bc745083fc64 100644
>>>> --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
>>>> +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
>>>> @@ -61,6 +61,11 @@ patternProperties:
>>>> description:
>>>> Size in bit within the address range specified by reg.
>>>> + reverse-data:
>>>> + $ref: /schemas/types.yaml#/definitions/flag
>>>> + description:
>>>> + Reverse the data that read from the storage device.
>>>> +
>>>
>>> This new property is only going to solve one of the reverse order
>>> issue here.
>>> If I remember correctly we have mac-address stored in various formats ex:
>>> from old thread I can see
>>>
>>> Type 1: Octets in ASCII without delimiters. (Swapped/non-Swapped) Type
>>> 2: Octets in ASCII with delimiters like (":", ",", ".", "-"... so on)
>>> (Swapped/non-Swapped)
>>> Type 3: Is the one which stores mac address in Type1/2 but this has to
>>> be incremented to be used on other instances of eth.
>>> Type 4: Octets as bytes/u8, swapped/non-swapped
>>>
>>> I think its right time to consider adding compatibles to nvmem-cells
>>> to be able to specify encoding information and handle post processing.
>>
>> Yes. Trying to handle this with never ending new properties will end up with a
>> mess. At some point, you just need code to parse the data.
>
> Thanks, Rob.
>
> Hi Srinivas,
>
Firstly Sorry for taking so long to reply as I was on vacation.

> Do you plan to implement it?

No, Am not planning to do this. But am happy to walk-thru the ideas that
I have.

>
> Or need me follow up? If yes, please input your insights to point me how to work for it.

Do we have some kind of meta data/information in nvmem memory to
indicate the storage encoding?

Am I correct to say that this is only issue with mac-address nvmem cell?

Irrespective of where this encoding info comes from we have 2 options.

Option 1: Add callback to handle mac-address post-processing with in the
provider driver.

Pros:
- It can deal with vendor specific non-standard encodings, and code is
mostly with-in vendor specific nvmem provider driver and bindings.
- will keep nvmem core simple w.r.t handling data.

Cons:
- provider driver implement callback and new bindings.
- might need to add a nvmem-cell-type binding to be able differentiate
the cell types and handle post-processing.

Option 2: nvmem core handles the post processing.

Pros:
- provider driver does not need to implement callbacks

Cons:
- We have to find a way to define vendor specific non-standard encoding
information in generic bindings which is going to be a challenge and
high chance of ending up in to much of clutter in generic bindings.

Finally, The way I look at this is that once we start adding
post-processing in nvmem core then we might endup with code that will
not be really used for most of the usecases and might endup with cases
that might not be possible to handle in the core.


Does Option 1 work for you?

--srini

>
> Thanks.
>
> Best Regards,
> Joakim Zhang
>> Rob

2021-09-06 09:00:46

by Joakim Zhang

[permalink] [raw]
Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property


Hi Srinivas,

> -----Original Message-----
> From: Srinivas Kandagatla <[email protected]>
> Sent: 2021??9??3?? 20:38
> To: Joakim Zhang <[email protected]>; Rob Herring
> <[email protected]>
> Cc: [email protected]; [email protected]; dl-linux-imx
> <[email protected]>; [email protected];
> [email protected]
> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> property
>
> Hi Joakim,
>
> On 18/08/2021 08:54, Joakim Zhang wrote:
> >
> >> -----Original Message-----
> >> From: Rob Herring <[email protected]>
> >> Sent: 2021??8??18?? 3:58
> >> To: Srinivas Kandagatla <[email protected]>
> >> Cc: Joakim Zhang <[email protected]>; [email protected];
> >> [email protected]; dl-linux-imx <[email protected]>;
> >> [email protected]; [email protected]
> >> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> >> property
> >>
> >> On Wed, Aug 11, 2021 at 11:16:49AM +0100, Srinivas Kandagatla wrote:
> >>>
> >>>
> >>> On 10/08/2021 08:35, Joakim Zhang wrote:
> >>>> Introduce "reverse-data" property for nvmem provider to reverse buffer.
> >>>>
> >>>> Signed-off-by: Joakim Zhang <[email protected]>
> >>>> ---
> >>>> Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
> >>>> 1 file changed, 5 insertions(+)
> >>>>
> >>>> diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> >>>> b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> >>>> index b8dc3d2b6e92..bc745083fc64 100644
> >>>> --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> >>>> +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
> >>>> @@ -61,6 +61,11 @@ patternProperties:
> >>>> description:
> >>>> Size in bit within the address range specified by
> reg.
> >>>> + reverse-data:
> >>>> + $ref: /schemas/types.yaml#/definitions/flag
> >>>> + description:
> >>>> + Reverse the data that read from the storage device.
> >>>> +
> >>>
> >>> This new property is only going to solve one of the reverse order
> >>> issue here.
> >>> If I remember correctly we have mac-address stored in various formats ex:
> >>> from old thread I can see
> >>>
> >>> Type 1: Octets in ASCII without delimiters. (Swapped/non-Swapped)
> >>> Type
> >>> 2: Octets in ASCII with delimiters like (":", ",", ".", "-"... so
> >>> on)
> >>> (Swapped/non-Swapped)
> >>> Type 3: Is the one which stores mac address in Type1/2 but this has
> >>> to be incremented to be used on other instances of eth.
> >>> Type 4: Octets as bytes/u8, swapped/non-swapped
> >>>
> >>> I think its right time to consider adding compatibles to nvmem-cells
> >>> to be able to specify encoding information and handle post processing.
> >>
> >> Yes. Trying to handle this with never ending new properties will end
> >> up with a mess. At some point, you just need code to parse the data.
> >
> > Thanks, Rob.
> >
> > Hi Srinivas,
> >
> Firstly Sorry for taking so long to reply as I was on vacation.
>
> > Do you plan to implement it?
>
> No, Am not planning to do this. But am happy to walk-thru the ideas that I
> have.
>
> >
> > Or need me follow up? If yes, please input your insights to point me how to
> work for it.
>
> Do we have some kind of meta data/information in nvmem memory to indicate
> the storage encoding?

No, none of these.

> Am I correct to say that this is only issue with mac-address nvmem cell?

I think, yes.

> Irrespective of where this encoding info comes from we have 2 options.
>
> Option 1: Add callback to handle mac-address post-processing with in the
> provider driver.

Sorry, I am not very familiar with nvmem framework, what's this "callback" mean?
Do you also want to introduce a common callback for different vendor drivers to
work for mac-address post-processing? Extend the " struct nvmem_config"?

> Pros:
> - It can deal with vendor specific non-standard encodings, and code is mostly
> with-in vendor specific nvmem provider driver and bindings.
> - will keep nvmem core simple w.r.t handling data.
>
> Cons:
> - provider driver implement callback and new bindings.
> - might need to add a nvmem-cell-type binding to be able differentiate the cell
> types and handle post-processing.

Ahhh, I am not quite understand how to implement for it? Could you please give some
draft hints?

If we extend the struct nvmem_config, add a callback to handle mac address, how can we
determine which is the mac-address device node? There is no device node info from .reg_read
callback.

> Option 2: nvmem core handles the post processing.
>
> Pros:
> - provider driver does not need to implement callbacks
>
> Cons:
> - We have to find a way to define vendor specific non-standard encoding
> information in generic bindings which is going to be a challenge and high chance
> of ending up in to much of clutter in generic bindings.
>
> Finally, The way I look at this is that once we start adding post-processing in
> nvmem core then we might endup with code that will not be really used for
> most of the usecases and might endup with cases that might not be possible to
> handle in the core.
>
>
> Does Option 1 work for you?

Yes, I also prefer to implement it in specific driver, as you mention above, these code are for
very rarely use cases.

If we chose Option 1, I want to implement it totally in specific driver(imx-ocotp.c), and I have a draft,
could it be acdeptable?

--- a/drivers/nvmem/imx-ocotp.c
+++ b/drivers/nvmem/imx-ocotp.c
@@ -76,6 +76,8 @@
#define IMX_OCOTP_WR_UNLOCK 0x3E770000
#define IMX_OCOTP_READ_LOCKED_VAL 0xBADABADA

+#define IMX_OCOTP_MAC_MAX 0x2 /* The maximum numbers of MAC instance */
+
static DEFINE_MUTEX(ocotp_mutex);

struct ocotp_priv {
@@ -93,11 +95,18 @@ struct ocotp_ctrl_reg {
u32 bm_rel_shadows;
};

+struct mac_config {
+ u32 offset;
+ u32 size;
+ bool reverse_byte;
+};
+
struct ocotp_params {
unsigned int nregs;
unsigned int bank_address_words;
void (*set_timing)(struct ocotp_priv *priv);
struct ocotp_ctrl_reg ctrl;
+ struct mac_config mac[IMX_OCOTP_MAC_MAX];
};

static int imx_ocotp_wait_for_busy(struct ocotp_priv *priv, u32 flags)
@@ -211,6 +220,20 @@ static int imx_ocotp_read(void *context, unsigned int offset,
}

index = offset % 4;
+
+ /* Handle MAC address reverse byte if required */
+ for (i = 0; i < IMX_OCOTP_MAC_MAX; i++) {
+ if (offset == priv->params->mac[i].offset &&
+ bytes == priv->params->mac[i].size &&
+ priv->params->mac[i].reverse_byte) {
+ u8 *org = &p[index];
+ int j;
+
+ for (j = 0; j < bytes/2; j++)
+ swap(org[j], org[bytes-j-1]);
+ }
+ }
+
memcpy(val, &p[index], bytes);

read_end:
@@ -556,6 +579,12 @@ static const struct ocotp_params imx8mp_params = {
.bank_address_words = 0,
.set_timing = imx_ocotp_set_imx6_timing,
.ctrl = IMX_OCOTP_BM_CTRL_8MP,
+ .mac[0].offset = 0x90,
+ .mac[0].size = 6,
+ .mac[0].reverse_byte = true,
+ .mac[1].offset = 0x96,
+ .mac[1].size = 6,
+ .mac[1].reverse_byte = true,
};

static const struct of_device_id imx_ocotp_dt_ids[] = {


Best Regards,
Joakim Zhang

2021-09-07 10:14:52

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property

Hi Joakim,


On 06/09/2021 09:58, Joakim Zhang wrote:
>
> Hi Srinivas,
>
>> -----Original Message-----
>> From: Srinivas Kandagatla <[email protected]>
>> Sent: 2021??9??3?? 20:38
>> To: Joakim Zhang <[email protected]>; Rob Herring
>> <[email protected]>
>> Cc: [email protected]; [email protected]; dl-linux-imx
>> <[email protected]>; [email protected];
>> [email protected]
>> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
>> property
>>
>> Hi Joakim,
>>
>> On 18/08/2021 08:54, Joakim Zhang wrote:
>>>
>>>> -----Original Message-----
>>>> From: Rob Herring <[email protected]>
>>>> Sent: 2021??8??18?? 3:58
>>>> To: Srinivas Kandagatla <[email protected]>
>>>> Cc: Joakim Zhang <[email protected]>; [email protected];
>>>> [email protected]; dl-linux-imx <[email protected]>;
>>>> [email protected]; [email protected]
>>>> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
>>>> property
>>>>
>>>> On Wed, Aug 11, 2021 at 11:16:49AM +0100, Srinivas Kandagatla wrote:
>>>>>
>>>>>
>>>>> On 10/08/2021 08:35, Joakim Zhang wrote:
>>>>>> Introduce "reverse-data" property for nvmem provider to reverse buffer.
>>>>>>
>>>>>> Signed-off-by: Joakim Zhang <[email protected]>
>>>>>> ---
>>>>>> Documentation/devicetree/bindings/nvmem/nvmem.yaml | 5 +++++
>>>>>> 1 file changed, 5 insertions(+)
>>>>>>
>>>>>> diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
>>>>>> b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
>>>>>> index b8dc3d2b6e92..bc745083fc64 100644
>>>>>> --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
>>>>>> +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
>>>>>> @@ -61,6 +61,11 @@ patternProperties:
>>>>>> description:
>>>>>> Size in bit within the address range specified by
>> reg.
>>>>>> + reverse-data:
>>>>>> + $ref: /schemas/types.yaml#/definitions/flag
>>>>>> + description:
>>>>>> + Reverse the data that read from the storage device.
>>>>>> +
>>>>>
>>>>> This new property is only going to solve one of the reverse order
>>>>> issue here.
>>>>> If I remember correctly we have mac-address stored in various formats ex:
>>>>> from old thread I can see
>>>>>
>>>>> Type 1: Octets in ASCII without delimiters. (Swapped/non-Swapped)
>>>>> Type
>>>>> 2: Octets in ASCII with delimiters like (":", ",", ".", "-"... so
>>>>> on)
>>>>> (Swapped/non-Swapped)
>>>>> Type 3: Is the one which stores mac address in Type1/2 but this has
>>>>> to be incremented to be used on other instances of eth.
>>>>> Type 4: Octets as bytes/u8, swapped/non-swapped
>>>>>
>>>>> I think its right time to consider adding compatibles to nvmem-cells
>>>>> to be able to specify encoding information and handle post processing.
>>>>
>>>> Yes. Trying to handle this with never ending new properties will end
>>>> up with a mess. At some point, you just need code to parse the data.
>>>
>>> Thanks, Rob.
>>>
>>> Hi Srinivas,
>>>
>> Firstly Sorry for taking so long to reply as I was on vacation.
>>
>>> Do you plan to implement it?
>>
>> No, Am not planning to do this. But am happy to walk-thru the ideas that I
>> have.
>>
>>>
>>> Or need me follow up? If yes, please input your insights to point me how to
>> work for it.
>>
>> Do we have some kind of meta data/information in nvmem memory to indicate
>> the storage encoding?
>
> No, none of these.
>
>> Am I correct to say that this is only issue with mac-address nvmem cell?
>
> I think, yes.
>
>> Irrespective of where this encoding info comes from we have 2 options.
>>
>> Option 1: Add callback to handle mac-address post-processing with in the
>> provider driver.
>
> Sorry, I am not very familiar with nvmem framework, what's this "callback" mean?
> Do you also want to introduce a common callback for different vendor drivers to
> work for mac-address post-processing? Extend the " struct nvmem_config"?
>
>> Pros:
>> - It can deal with vendor specific non-standard encodings, and code is mostly
>> with-in vendor specific nvmem provider driver and bindings.
>> - will keep nvmem core simple w.r.t handling data.
>>
>> Cons:
>> - provider driver implement callback and new bindings.
>> - might need to add a nvmem-cell-type binding to be able differentiate the cell
>> types and handle post-processing.
>
> Ahhh, I am not quite understand how to implement for it? Could you please give some
> draft hints?
>
> If we extend the struct nvmem_config, add a callback to handle mac address, how can we
> determine which is the mac-address device node? There is no device node info from .reg_read
> callback.


I have pushed some nvmem core patches which are just compile tested to
https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git/log/?h=topic/post-processing

This should provide the callback hook I was talking about.

Can you take a look at them and let me know if it works for you.

I have also added some test changes to imx provider driver as well,
which you might have to take a closer look to get it working.

You need to look at adding/changing two things:

1. setting reverse_mac_address flag in imx driver.
Does IMX always has mac-address reversed? if yes then we do not need
any new bindings for imx nvmem provider, if no we might need to add some
kind of flag to indicate this.

2. In imx devicetree for mac-address nvmem cell make sure you add

cell-type = <NVMEM_CELL_TYPE_MAC_ADDRESS>;




>
>> Option 2: nvmem core handles the post processing.
>>
>> Pros:
>> - provider driver does not need to implement callbacks
>>
>> Cons:
>> - We have to find a way to define vendor specific non-standard encoding
>> information in generic bindings which is going to be a challenge and high chance
>> of ending up in to much of clutter in generic bindings.
>>
>> Finally, The way I look at this is that once we start adding post-processing in
>> nvmem core then we might endup with code that will not be really used for
>> most of the usecases and might endup with cases that might not be possible to
>> handle in the core.
>>
>>
>> Does Option 1 work for you?
>
> Yes, I also prefer to implement it in specific driver, as you mention above, these code are for
> very rarely use cases.
>
> If we chose Option 1, I want to implement it totally in specific driver(imx-ocotp.c), and I have a draft,
> could it be acdeptable?
Yes, this is the direction, however we need a proper callback to do
this. And offset information is still comes from Device tree.


Have a look at the patches pushed into topic/post-processing branch.

--srini
>
> --- a/drivers/nvmem/imx-ocotp.c
> +++ b/drivers/nvmem/imx-ocotp.c
> @@ -76,6 +76,8 @@
> #define IMX_OCOTP_WR_UNLOCK 0x3E770000
> #define IMX_OCOTP_READ_LOCKED_VAL 0xBADABADA
>
> +#define IMX_OCOTP_MAC_MAX 0x2 /* The maximum numbers of MAC instance */
> +
> static DEFINE_MUTEX(ocotp_mutex);
>
> struct ocotp_priv {
> @@ -93,11 +95,18 @@ struct ocotp_ctrl_reg {
> u32 bm_rel_shadows;
> };
>
> +struct mac_config {
> + u32 offset;
> + u32 size;
> + bool reverse_byte;
> +};
> +
> struct ocotp_params {
> unsigned int nregs;
> unsigned int bank_address_words;
> void (*set_timing)(struct ocotp_priv *priv);
> struct ocotp_ctrl_reg ctrl;
> + struct mac_config mac[IMX_OCOTP_MAC_MAX];
> };
>
> static int imx_ocotp_wait_for_busy(struct ocotp_priv *priv, u32 flags)
> @@ -211,6 +220,20 @@ static int imx_ocotp_read(void *context, unsigned int offset,
> }
>
> index = offset % 4;
> +
> + /* Handle MAC address reverse byte if required */
> + for (i = 0; i < IMX_OCOTP_MAC_MAX; i++) {
> + if (offset == priv->params->mac[i].offset &&
> + bytes == priv->params->mac[i].size &&
> + priv->params->mac[i].reverse_byte) {
> + u8 *org = &p[index];
> + int j;
> +
> + for (j = 0; j < bytes/2; j++)
> + swap(org[j], org[bytes-j-1]);
> + }
> + }
> +
> memcpy(val, &p[index], bytes);
>
> read_end:
> @@ -556,6 +579,12 @@ static const struct ocotp_params imx8mp_params = {
> .bank_address_words = 0,
> .set_timing = imx_ocotp_set_imx6_timing,
> .ctrl = IMX_OCOTP_BM_CTRL_8MP,
> + .mac[0].offset = 0x90,
> + .mac[0].size = 6,
> + .mac[0].reverse_byte = true,
> + .mac[1].offset = 0x96,
> + .mac[1].size = 6,
> + .mac[1].reverse_byte = true,
> };
>
> static const struct of_device_id imx_ocotp_dt_ids[] = {
>
>
> Best Regards,
> Joakim Zhang
>

2021-09-08 07:15:51

by Joakim Zhang

[permalink] [raw]
Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property


Hi Srinivas,

[...]
> I have pushed some nvmem core patches which are just compile tested to
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
> el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fsrini%2Fnvmem.git%2Flog%
> 2F%3Fh%3Dtopic%2Fpost-processing&amp;data=04%7C01%7Cqiangqing.zhan
> g%40nxp.com%7Cadfa3ba63c634937876308d971e7e71f%7C686ea1d3bc2b4c6
> fa92cd99c5c301635%7C0%7C0%7C637666063097239185%7CUnknown%7CT
> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ
> XVCI6Mn0%3D%7C1000&amp;sdata=W9yAnGm9rYzlSZuAAGiN4VHUtKYUTt9S
> oyGQ9QsY7fI%3D&amp;reserved=0
>
> This should provide the callback hook I was talking about.

Thanks a lot! Yes, this could be more common, vendors can parse their mac
address for different encoding style, also can extend for other cases.

> Can you take a look at them and let me know if it works for you.

There are some small issues need to be update:
1) https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git/commit/?h=topic/post-processing&id=624f2cc99b48bbfe05c11e58fb73f84abb1a646e
of_get_property() can't get the cell value, so I change to of_property_read_s32()
2) https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git/commit/?h=topic/post-processing&id=a424302c7b15da41e1e8de56b0c78021b9a96c1e
if (!nvmem->cell_post_process) {} should be if (nvmem->cell_post_process) {}, if we have this callback, we need do the post-processing.

> I have also added some test changes to imx provider driver as well, which you
> might have to take a closer look to get it working.
>
> You need to look at adding/changing two things:
>
> 1. setting reverse_mac_address flag in imx driver.
> Does IMX always has mac-address reversed? if yes then we do not need
> any new bindings for imx nvmem provider, if no we might need to add some
> kind of flag to indicate this.

No, it's depend on how to program the effuse.
To avoid introducing consumer property in devicetree, I prefer to move reverse_mac_address
flag into ocotp_params struct, since each platforms has their own, it's easy to indicate this. I tried
it, and works.

> 2. In imx devicetree for mac-address nvmem cell make sure you add
>
> cell-type = <NVMEM_CELL_TYPE_MAC_ADDRESS>;
>
>
>
>
> >
> >> Option 2: nvmem core handles the post processing.
> >>
> >> Pros:
> >> - provider driver does not need to implement callbacks
> >>
> >> Cons:
> >> - We have to find a way to define vendor specific non-standard
> >> encoding information in generic bindings which is going to be a
> >> challenge and high chance of ending up in to much of clutter in generic
> bindings.
> >>
> >> Finally, The way I look at this is that once we start adding
> >> post-processing in nvmem core then we might endup with code that will
> >> not be really used for most of the usecases and might endup with
> >> cases that might not be possible to handle in the core.
> >>
> >>
> >> Does Option 1 work for you?
> >
> > Yes, I also prefer to implement it in specific driver, as you mention
> > above, these code are for very rarely use cases.
> >
> > If we chose Option 1, I want to implement it totally in specific
> > driver(imx-ocotp.c), and I have a draft, could it be acdeptable?
> Yes, this is the direction, however we need a proper callback to do this. And
> offset information is still comes from Device tree.
>
>
> Have a look at the patches pushed into topic/post-processing branch.

I have improved this patch set according above comments and tested it. Also rebase to
the nvmem/for-next branch.

I plan to keep you as the nvmem part author and send out this patch set with dts changes. If it's fine for you?

Best Regards,
Joakim Zhang

2021-09-08 09:00:14

by Joakim Zhang

[permalink] [raw]
Subject: RE: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property


Hi Srinivas,

> -----Original Message-----
> From: Srinivas Kandagatla <[email protected]>
> Sent: 2021??9??8?? 16:49
> To: Joakim Zhang <[email protected]>; Rob Herring
> <[email protected]>
> Cc: [email protected]; [email protected]; dl-linux-imx
> <[email protected]>; [email protected];
> [email protected]
> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
> property
>
>
>
> On 08/09/2021 08:14, Joakim Zhang wrote:
> >
> > Hi Srinivas,
> >
> > [...]
> >> I have pushed some nvmem core patches which are just compile tested
> >> to
> >> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
> >> .kern%2F&amp;data=04%7C01%7Cqiangqing.zhang%40nxp.com%7Cb8b85
> eab6bc34
> >>
> 917b86e08d972a57dee%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%
> 7C6376
> >>
> 66877370588296%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLC
> JQIjoiV2
> >>
> luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=diFgK2ufOUK
> eXwd
> >> 0Ez8pCFjCUH8rXz5jfW7io8KDKmw%3D&amp;reserved=0
> >>
> el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fsrini%2Fnvmem.git%2Flog%
> >>
> 2F%3Fh%3Dtopic%2Fpost-processing&amp;data=04%7C01%7Cqiangqing.zhan
> >>
> g%40nxp.com%7Cadfa3ba63c634937876308d971e7e71f%7C686ea1d3bc2b4c6
> >>
> fa92cd99c5c301635%7C0%7C0%7C637666063097239185%7CUnknown%7CT
> >>
> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ
> >>
> XVCI6Mn0%3D%7C1000&amp;sdata=W9yAnGm9rYzlSZuAAGiN4VHUtKYUTt9S
> >> oyGQ9QsY7fI%3D&amp;reserved=0
> >>
> >> This should provide the callback hook I was talking about.
> >
> > Thanks a lot! Yes, this could be more common, vendors can parse their
> > mac address for different encoding style, also can extend for other cases.
>
> Yes, that is the idea,
> >
> >> Can you take a look at them and let me know if it works for you.
> >
> > There are some small issues need to be update:
> > 1)
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
> el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fsrini%2Fnvmem.git%2Fcom
> mit%2F%3Fh%3Dtopic%2Fpost-processing%26id%3D624f2cc99b48bbfe05c11e
> 58fb73f84abb1a646e&amp;data=04%7C01%7Cqiangqing.zhang%40nxp.com%
> 7Cb8b85eab6bc34917b86e08d972a57dee%7C686ea1d3bc2b4c6fa92cd99c5c3
> 01635%7C0%7C0%7C637666877370598253%7CUnknown%7CTWFpbGZsb3d8e
> yJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D
> %7C1000&amp;sdata=APDzSbLob%2FRiZyyhU7VAhoUEAmSG95NsilQDQ53Hbf
> A%3D&amp;reserved=0
> > of_get_property() can't get the cell value, so I change to
> > of_property_read_s32()
> > 2)
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
> el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fsrini%2Fnvmem.git%2Fcom
> mit%2F%3Fh%3Dtopic%2Fpost-processing%26id%3Da424302c7b15da41e1e8d
> e56b0c78021b9a96c1e&amp;data=04%7C01%7Cqiangqing.zhang%40nxp.com
> %7Cb8b85eab6bc34917b86e08d972a57dee%7C686ea1d3bc2b4c6fa92cd99c5c
> 301635%7C0%7C0%7C637666877370598253%7CUnknown%7CTWFpbGZsb3d8
> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D
> %7C1000&amp;sdata=5E49DVzkpBVdkA4a%2B9tMXN%2B6k%2BG%2B3rQuVJ
> qTUgdbmKU%3D&amp;reserved=0
> > if (!nvmem->cell_post_process) {} should be if (nvmem->cell_post_process)
> {}, if we have this callback, we need do the post-processing.
> >
> I have pushed these changes now to the branch.
>
> >> I have also added some test changes to imx provider driver as well,
> >> which you might have to take a closer look to get it working.
> >>
> >> You need to look at adding/changing two things:
> >>
> >> 1. setting reverse_mac_address flag in imx driver.
> >> Does IMX always has mac-address reversed? if yes then we do not need
> >> any new bindings for imx nvmem provider, if no we might need to add
> >> some kind of flag to indicate this.
> >
> > No, it's depend on how to program the effuse.
> > To avoid introducing consumer property in devicetree, I prefer to move
> > reverse_mac_address flag into ocotp_params struct, since each
> > platforms has their own, it's easy to indicate this. I tried it, and
> > works. >
>
> As long as provider can figure out how the efuse is programmed then it is fine
> with me.
>
>
> >> 2. In imx devicetree for mac-address nvmem cell make sure you add
> >>
> >> cell-type = <NVMEM_CELL_TYPE_MAC_ADDRESS>;
> >>
> >>
> >>
> >>
> >>>
> >>>> Option 2: nvmem core handles the post processing.
> >>>>
> >>>> Pros:
> >>>> - provider driver does not need to implement callbacks
> >>>>
> >>>> Cons:
> >>>> - We have to find a way to define vendor specific non-standard
> >>>> encoding information in generic bindings which is going to be a
> >>>> challenge and high chance of ending up in to much of clutter in generic
> >> bindings.
> >>>>
> >>>> Finally, The way I look at this is that once we start adding
> >>>> post-processing in nvmem core then we might endup with code that will
> >>>> not be really used for most of the usecases and might endup with
> >>>> cases that might not be possible to handle in the core.
> >>>>
> >>>>
> >>>> Does Option 1 work for you?
> >>>
> >>> Yes, I also prefer to implement it in specific driver, as you mention
> >>> above, these code are for very rarely use cases.
> >>>
> >>> If we chose Option 1, I want to implement it totally in specific
> >>> driver(imx-ocotp.c), and I have a draft, could it be acdeptable?
> >> Yes, this is the direction, however we need a proper callback to do this. And
> >> offset information is still comes from Device tree.
> >>
> >>
> >> Have a look at the patches pushed into topic/post-processing branch.
> >
> > I have improved this patch set according above comments and tested it. Also
> rebase to
> > the nvmem/for-next branch.
> >
> > I plan to keep you as the nvmem part author and send out this patch set with
> dts changes. If it's fine for you?
>
> Yes please, can you pick the new patches from the branch before you send
> the series out.

As you define the type variable is "int", so had better use of_property_read_s32(), instead if of_property_read_u32(), right?

Best Regards,
Joakim Zhang

2021-09-08 09:23:21

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property



On 08/09/2021 09:57, Joakim Zhang wrote:
>
> Hi Srinivas,
>
>> -----Original Message-----
>> From: Srinivas Kandagatla <[email protected]>
>> Sent: 2021??9??8?? 16:49
>> To: Joakim Zhang <[email protected]>; Rob Herring
>> <[email protected]>
>> Cc: [email protected]; [email protected]; dl-linux-imx
>> <[email protected]>; [email protected];
>> [email protected]
>> Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data"
>> property
>>
>>
>>
>> On 08/09/2021 08:14, Joakim Zhang wrote:
>>>
>>> Hi Srinivas,
>>>
>>> [...]
>>>> I have pushed some nvmem core patches which are just compile tested
>>>> to
>>>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
>>>> .kern%2F&amp;data=04%7C01%7Cqiangqing.zhang%40nxp.com%7Cb8b85
>> eab6bc34
>>>>
>> 917b86e08d972a57dee%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%
>> 7C6376
>>>>
>> 66877370588296%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLC
>> JQIjoiV2
>>>>
>> luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=diFgK2ufOUK
>> eXwd
>>>> 0Ez8pCFjCUH8rXz5jfW7io8KDKmw%3D&amp;reserved=0
>>>>
>> el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fsrini%2Fnvmem.git%2Flog%
>>>>
>> 2F%3Fh%3Dtopic%2Fpost-processing&amp;data=04%7C01%7Cqiangqing.zhan
>>>>
>> g%40nxp.com%7Cadfa3ba63c634937876308d971e7e71f%7C686ea1d3bc2b4c6
>>>>
>> fa92cd99c5c301635%7C0%7C0%7C637666063097239185%7CUnknown%7CT
>>>>
>> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ
>>>>
>> XVCI6Mn0%3D%7C1000&amp;sdata=W9yAnGm9rYzlSZuAAGiN4VHUtKYUTt9S
>>>> oyGQ9QsY7fI%3D&amp;reserved=0
>>>>
>>>> This should provide the callback hook I was talking about.
>>>
>>> Thanks a lot! Yes, this could be more common, vendors can parse their
>>> mac address for different encoding style, also can extend for other cases.
>>
>> Yes, that is the idea,
>>>
>>>> Can you take a look at them and let me know if it works for you.
>>>
>>> There are some small issues need to be update:
>>> 1)
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
>> el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fsrini%2Fnvmem.git%2Fcom
>> mit%2F%3Fh%3Dtopic%2Fpost-processing%26id%3D624f2cc99b48bbfe05c11e
>> 58fb73f84abb1a646e&amp;data=04%7C01%7Cqiangqing.zhang%40nxp.com%
>> 7Cb8b85eab6bc34917b86e08d972a57dee%7C686ea1d3bc2b4c6fa92cd99c5c3
>> 01635%7C0%7C0%7C637666877370598253%7CUnknown%7CTWFpbGZsb3d8e
>> yJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D
>> %7C1000&amp;sdata=APDzSbLob%2FRiZyyhU7VAhoUEAmSG95NsilQDQ53Hbf
>> A%3D&amp;reserved=0
>>> of_get_property() can't get the cell value, so I change to
>>> of_property_read_s32()
>>> 2)
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
>> el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fsrini%2Fnvmem.git%2Fcom
>> mit%2F%3Fh%3Dtopic%2Fpost-processing%26id%3Da424302c7b15da41e1e8d
>> e56b0c78021b9a96c1e&amp;data=04%7C01%7Cqiangqing.zhang%40nxp.com
>> %7Cb8b85eab6bc34917b86e08d972a57dee%7C686ea1d3bc2b4c6fa92cd99c5c
>> 301635%7C0%7C0%7C637666877370598253%7CUnknown%7CTWFpbGZsb3d8
>> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D
>> %7C1000&amp;sdata=5E49DVzkpBVdkA4a%2B9tMXN%2B6k%2BG%2B3rQuVJ
>> qTUgdbmKU%3D&amp;reserved=0
>>> if (!nvmem->cell_post_process) {} should be if (nvmem->cell_post_process)
>> {}, if we have this callback, we need do the post-processing.
>>>
>> I have pushed these changes now to the branch.
>>
>>>> I have also added some test changes to imx provider driver as well,
>>>> which you might have to take a closer look to get it working.
>>>>
>>>> You need to look at adding/changing two things:
>>>>
>>>> 1. setting reverse_mac_address flag in imx driver.
>>>> Does IMX always has mac-address reversed? if yes then we do not need
>>>> any new bindings for imx nvmem provider, if no we might need to add
>>>> some kind of flag to indicate this.
>>>
>>> No, it's depend on how to program the effuse.
>>> To avoid introducing consumer property in devicetree, I prefer to move
>>> reverse_mac_address flag into ocotp_params struct, since each
>>> platforms has their own, it's easy to indicate this. I tried it, and
>>> works. >
>>
>> As long as provider can figure out how the efuse is programmed then it is fine
>> with me.
>>
>>
>>>> 2. In imx devicetree for mac-address nvmem cell make sure you add
>>>>
>>>> cell-type = <NVMEM_CELL_TYPE_MAC_ADDRESS>;
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>>> Option 2: nvmem core handles the post processing.
>>>>>>
>>>>>> Pros:
>>>>>> - provider driver does not need to implement callbacks
>>>>>>
>>>>>> Cons:
>>>>>> - We have to find a way to define vendor specific non-standard
>>>>>> encoding information in generic bindings which is going to be a
>>>>>> challenge and high chance of ending up in to much of clutter in generic
>>>> bindings.
>>>>>>
>>>>>> Finally, The way I look at this is that once we start adding
>>>>>> post-processing in nvmem core then we might endup with code that will
>>>>>> not be really used for most of the usecases and might endup with
>>>>>> cases that might not be possible to handle in the core.
>>>>>>
>>>>>>
>>>>>> Does Option 1 work for you?
>>>>>
>>>>> Yes, I also prefer to implement it in specific driver, as you mention
>>>>> above, these code are for very rarely use cases.
>>>>>
>>>>> If we chose Option 1, I want to implement it totally in specific
>>>>> driver(imx-ocotp.c), and I have a draft, could it be acdeptable?
>>>> Yes, this is the direction, however we need a proper callback to do this. And
>>>> offset information is still comes from Device tree.
>>>>
>>>>
>>>> Have a look at the patches pushed into topic/post-processing branch.
>>>
>>> I have improved this patch set according above comments and tested it. Also
>> rebase to
>>> the nvmem/for-next branch.
>>>
>>> I plan to keep you as the nvmem part author and send out this patch set with
>> dts changes. If it's fine for you?
>>
>> Yes please, can you pick the new patches from the branch before you send
>> the series out.
>
> As you define the type variable is "int", so had better use of_property_read_s32(), instead if of_property_read_u32(), right?

We should probably make that u32, as we are not expecting any negative
range.

I tried to fix this in new patches.

--srini
>
> Best Regards,
> Joakim Zhang
>

2021-09-08 10:04:53

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH V1 1/4] bindings: nvmem: introduce "reverse-data" property



On 08/09/2021 08:14, Joakim Zhang wrote:
>
> Hi Srinivas,
>
> [...]
>> I have pushed some nvmem core patches which are just compile tested to
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kern
>> el.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fsrini%2Fnvmem.git%2Flog%
>> 2F%3Fh%3Dtopic%2Fpost-processing&amp;data=04%7C01%7Cqiangqing.zhan
>> g%40nxp.com%7Cadfa3ba63c634937876308d971e7e71f%7C686ea1d3bc2b4c6
>> fa92cd99c5c301635%7C0%7C0%7C637666063097239185%7CUnknown%7CT
>> WFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJ
>> XVCI6Mn0%3D%7C1000&amp;sdata=W9yAnGm9rYzlSZuAAGiN4VHUtKYUTt9S
>> oyGQ9QsY7fI%3D&amp;reserved=0
>>
>> This should provide the callback hook I was talking about.
>
> Thanks a lot! Yes, this could be more common, vendors can parse their mac
> address for different encoding style, also can extend for other cases.

Yes, that is the idea,
>
>> Can you take a look at them and let me know if it works for you.
>
> There are some small issues need to be update:
> 1) https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git/commit/?h=topic/post-processing&id=624f2cc99b48bbfe05c11e58fb73f84abb1a646e
> of_get_property() can't get the cell value, so I change to of_property_read_s32()
> 2) https://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git/commit/?h=topic/post-processing&id=a424302c7b15da41e1e8de56b0c78021b9a96c1e
> if (!nvmem->cell_post_process) {} should be if (nvmem->cell_post_process) {}, if we have this callback, we need do the post-processing.
>
I have pushed these changes now to the branch.

>> I have also added some test changes to imx provider driver as well, which you
>> might have to take a closer look to get it working.
>>
>> You need to look at adding/changing two things:
>>
>> 1. setting reverse_mac_address flag in imx driver.
>> Does IMX always has mac-address reversed? if yes then we do not need
>> any new bindings for imx nvmem provider, if no we might need to add some
>> kind of flag to indicate this.
>
> No, it's depend on how to program the effuse.
> To avoid introducing consumer property in devicetree, I prefer to move reverse_mac_address
> flag into ocotp_params struct, since each platforms has their own, it's easy to indicate this. I tried
> it, and works. >

As long as provider can figure out how the efuse is programmed then it
is fine with me.


>> 2. In imx devicetree for mac-address nvmem cell make sure you add
>>
>> cell-type = <NVMEM_CELL_TYPE_MAC_ADDRESS>;
>>
>>
>>
>>
>>>
>>>> Option 2: nvmem core handles the post processing.
>>>>
>>>> Pros:
>>>> - provider driver does not need to implement callbacks
>>>>
>>>> Cons:
>>>> - We have to find a way to define vendor specific non-standard
>>>> encoding information in generic bindings which is going to be a
>>>> challenge and high chance of ending up in to much of clutter in generic
>> bindings.
>>>>
>>>> Finally, The way I look at this is that once we start adding
>>>> post-processing in nvmem core then we might endup with code that will
>>>> not be really used for most of the usecases and might endup with
>>>> cases that might not be possible to handle in the core.
>>>>
>>>>
>>>> Does Option 1 work for you?
>>>
>>> Yes, I also prefer to implement it in specific driver, as you mention
>>> above, these code are for very rarely use cases.
>>>
>>> If we chose Option 1, I want to implement it totally in specific
>>> driver(imx-ocotp.c), and I have a draft, could it be acdeptable?
>> Yes, this is the direction, however we need a proper callback to do this. And
>> offset information is still comes from Device tree.
>>
>>
>> Have a look at the patches pushed into topic/post-processing branch.
>
> I have improved this patch set according above comments and tested it. Also rebase to
> the nvmem/for-next branch.
>
> I plan to keep you as the nvmem part author and send out this patch set with dts changes. If it's fine for you?

Yes please, can you pick the new patches from the branch before you send
the series out.

--srini
>
> Best Regards,
> Joakim Zhang
>