Skip to contentSkip to conversation

mtd: nand: Add support for reading ooblayout from device tree

PATCH Boris Brezillon 2 participants 6 messages May 12, 2018 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 18 lines · On Sat, 12 May 2018 08:55:40 -0300 Paul Cercueil <[email protected]> wrote:

Hi Boris,

Quoted 15 lines · Boris Brezillon

Hi Paul,

Quoted 3 lines · On Fri, 11 May 2018 23:29:12 +0200 Paul Cercueil <[email protected]> wrote:

By specifying the properties "mtd-oob-ecc" and "mtd-oob-free", it is now possible to specify from devicetree where the ECC data is located inside the OOB region.

Why would we want to do that? I mean, ECC/free regions are ECC controller dependent (and NAND chip dependent for the OOB size part), so there's no reason to describe it in the DT. And more importantly, people are likely to get it wrong.

Quoted 6 lines
Quoted 1 line

I'm curious, why do you need that?

Good question.

The reason is that some SoCs have no ECC controller. The various boards for these SoCs then all use a different layout.

Okay. Still think defining the layouts in the DT is a bad idea. We can add a jz4740 specific property to define the layout id (ingenic,nand-oob-layout = <layout-id>), but not a generic way to define custom layouts for all kind of NAND controller.

Quoted 4 lines

My motivation is to get rid of this (move it to devicetree):
https://elixir.bootlin.com/linux/latest/source/arch/mips/jz4740/board-qi_lb60.c#L93
And enable the support of other boards with custom OOB layouts.

Can you list the different layouts you have? I'm pretty sure there's a pattern. Maybe we can even deduce the layout from the page size or OOB size.

#2 lore raw
Quoted 30 lines · Boris Brezillon
Quoted 27 lines · On Sat, 12 May 2018 08:55:40 -0300 Paul Cercueil <[email protected]> wrote:

Hi Boris,

Quoted 7 lines · Boris Brezillon

Hi Paul,

Quoted 1 line · On Fri, 11 May 2018 23:29:12 +0200 Paul Cercueil <[email protected]> wrote:

By specifying the properties "mtd-oob-ecc" and "mtd-oob-free",

it is

Quoted 1 line
Quoted 1 line

now possible to specify from devicetree where the ECC data is

located

Quoted 4 lines
Quoted 1 line

inside the OOB region.

Why would we want to do that? I mean, ECC/free regions are ECC controller dependent (and NAND chip dependent for the OOB size

part),

Quoted 1 line

so there's no reason to describe it in the DT. And more

importantly,

Quoted 3 lines

people are likely to get it wrong.

I'm curious, why do you need that?

Good question.

Quoted 7 lines
Quoted 2 lines

The reason is that some SoCs have no ECC controller. The various boards for these SoCs then all use a different layout.

Okay. Still think defining the layouts in the DT is a bad idea. We can add a jz4740 specific property to define the layout id (ingenic,nand-oob-layout = <layout-id>), but not a generic way to define custom layouts for all kind of NAND controller.

Okay.

Quoted 9 lines
Quoted 5 lines

My motivation is to get rid of this (move it to devicetree):

https://elixir.bootlin.com/linux/latest/source/arch/mips/jz4740/board-qi_lb60.c#L93
And enable the support of other boards with custom OOB layouts.

Can you list the different layouts you have? I'm pretty sure there's a pattern. Maybe we can even deduce the layout from the page size or OOB size.

This is the other layout I have for another ingenic device:
http://projects.qi-hardware.com/index.php/p/qi-kernel/source/tree/od-2011-09-18/arch/mips/jz4740/board-a320.c#L125

Page size and OOB size are the same between these two devices.

-Paul

#3 lore raw
Quoted 48 lines · On Sat, 12 May 2018 11:38:26 -0300 Paul Cercueil <[email protected]> wrote:
Quoted 30 lines · Boris Brezillon
Quoted 27 lines · On Sat, 12 May 2018 08:55:40 -0300 Paul Cercueil <[email protected]> wrote:

Hi Boris,

Quoted 7 lines · Boris Brezillon

Hi Paul,

Quoted 1 line · On Fri, 11 May 2018 23:29:12 +0200 Paul Cercueil <[email protected]> wrote:

By specifying the properties "mtd-oob-ecc" and "mtd-oob-free",

it is

Quoted 1 line
Quoted 1 line

now possible to specify from devicetree where the ECC data is

located

Quoted 4 lines
Quoted 1 line

inside the OOB region.

Why would we want to do that? I mean, ECC/free regions are ECC controller dependent (and NAND chip dependent for the OOB size

part),

Quoted 1 line

so there's no reason to describe it in the DT. And more

importantly,

Quoted 3 lines

people are likely to get it wrong.

I'm curious, why do you need that?

Good question.

Quoted 7 lines
Quoted 2 lines

The reason is that some SoCs have no ECC controller. The various boards for these SoCs then all use a different layout.

Okay. Still think defining the layouts in the DT is a bad idea. We can add a jz4740 specific property to define the layout id (ingenic,nand-oob-layout = <layout-id>), but not a generic way to define custom layouts for all kind of NAND controller.

Okay.

Quoted 6 lines
Quoted 5 lines

My motivation is to get rid of this (move it to devicetree):

https://elixir.bootlin.com/linux/latest/source/arch/mips/jz4740/board-qi_lb60.c#L93
And enable the support of other boards with custom OOB layouts.

Quoted 8 lines
Quoted 3 lines

Can you list the different layouts you have? I'm pretty sure there's a pattern. Maybe we can even deduce the layout from the page size or OOB size.

This is the other layout I have for another ingenic device:
http://projects.qi-hardware.com/index.php/p/qi-kernel/source/tree/od-2011-09-18/arch/mips/jz4740/board-a320.c#L125

Page size and OOB size are the same between these two devices.

Indeed. Do you know if there are other kind of layouts in the wild? Note that <layout-id> can be a string, so if each each board is defining its own layout, you could specify the board name here. Otherwise, if you just have those 2 patterns, you can just name them "contiguous" and "interleaved".

#4 lore raw
Quoted 14 lines
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines

My motivation is to get rid of this (move it to devicetree):

https://elixir.bootlin.com/linux/latest/source/arch/mips/jz4740/board-qi_lb60.c#L93

Quoted 3 lines
Quoted 1 line

And enable the support of other boards with custom OOB layouts.

Can you list the different layouts you have? I'm pretty sure

there's a

Quoted 1 line

pattern. Maybe we can even deduce the layout from the page size

or OOB

Quoted 1 line

size.

Quoted 7 lines
Quoted 5 lines

This is the other layout I have for another ingenic device:

http://projects.qi-hardware.com/index.php/p/qi-kernel/source/tree/od-2011-09-18/arch/mips/jz4740/board-a320.c#L125

Page size and OOB size are the same between these two devices.

Indeed. Do you know if there are other kind of layouts in the wild?

I'm getting a new board in a few weeks, I'll be able to check that out.

Quoted 4 lines

Note that <layout-id> can be a string, so if each each board is defining its own layout, you could specify the board name here. Otherwise, if you just have those 2 patterns, you can just name them "contiguous" and "interleaved".

I don't like the idea of adding board-specific data inside the driver... I'd prefer to use the method I used in this patch, but inside the jz4740-nand driver, if you're OK with it.

Thanks,
-Paul

#5 lore raw
Quoted 22 lines · On Sat, 12 May 2018 19:42:49 +0200 Paul Cercueil <[email protected]> wrote:
Quoted 12 lines
Quoted 12 lines
Quoted 3 lines
Quoted 3 lines

My motivation is to get rid of this (move it to devicetree):

https://elixir.bootlin.com/linux/latest/source/arch/mips/jz4740/board-qi_lb60.c#L93

Quoted 3 lines
Quoted 1 line

And enable the support of other boards with custom OOB layouts.

Can you list the different layouts you have? I'm pretty sure

there's a

Quoted 1 line

pattern. Maybe we can even deduce the layout from the page size

or OOB

Quoted 1 line

size.

Quoted 7 lines
Quoted 5 lines

This is the other layout I have for another ingenic device:

http://projects.qi-hardware.com/index.php/p/qi-kernel/source/tree/od-2011-09-18/arch/mips/jz4740/board-a320.c#L125

Page size and OOB size are the same between these two devices.

Indeed. Do you know if there are other kind of layouts in the wild?

I'm getting a new board in a few weeks, I'll be able to check that out.

Quoted 8 lines
Quoted 4 lines

Note that <layout-id> can be a string, so if each each board is defining its own layout, you could specify the board name here. Otherwise, if you just have those 2 patterns, you can just name them "contiguous" and "interleaved".

I don't like the idea of adding board-specific data inside the driver... I'd prefer to use the method I used in this patch, but inside the jz4740-nand driver, if you're OK with it.

Please don't. Encoding such detailed description in the DT has almost always proven to be poor choice. Also, people are likely to get it wrong, and then you'll have to fix all DTs, while, with a single unique ID representing the layout, you can
- re-use existing layouts easily without having to describe everything again in the DT
- fix the driver without getting in trouble with people who claim that DT is a stable ABI and don't want to update their DT

So, please just pick user-friendly IDs and add layout definitions in the driver. If you don't want to leak board info in the driver, then don't name the layout with the board name. BTW, I still hope you'll only have 2 kind of layouts (contiguous and interleaved).

#6 lore raw
Quoted 51 lines · Boris Brezillon
Quoted 31 lines · On Sat, 12 May 2018 19:42:49 +0200 Paul Cercueil <[email protected]> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

My motivation is to get rid of this (move it to devicetree):

https://elixir.bootlin.com/linux/latest/source/arch/mips/jz4740/board-qi_lb60.c#L93

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

And enable the support of other boards with custom OOB

layouts.

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Can you list the different layouts you have? I'm pretty sure

there's a

Quoted 1 line

pattern. Maybe we can even deduce the layout from the page

size

Quoted 6 lines
Quoted 6 lines

or OOB

Quoted 1 line

size.

This is the other layout I have for another ingenic device:

http://projects.qi-hardware.com/index.php/p/qi-kernel/source/tree/od-2011-09-18/arch/mips/jz4740/board-a320.c#L125

Quoted 4 lines
Quoted 2 lines

Page size and OOB size are the same between these two devices.

Indeed. Do you know if there are other kind of layouts in the

wild?

I'm getting a new board in a few weeks, I'll be able to check that
out.

Quoted 3 lines

Note that <layout-id> can be a string, so if each each board is defining its own layout, you could specify the board name here. Otherwise, if you just have those 2 patterns, you can just name

Quoted 7 lines

them

Quoted 1 line

"contiguous" and "interleaved".

I don't like the idea of adding board-specific data inside the
driver...
I'd prefer to use the method I used in this patch, but inside the jz4740-nand driver, if you're OK with it.

Please don't. Encoding such detailed description in the DT has almost always proven to be poor choice. Also, people are likely to get it wrong, and then you'll have to fix all DTs, while, with a single unique ID representing the layout, you can
- re-use existing layouts easily without having to describe everything again in the DT
- fix the driver without getting in trouble with people who claim that DT is a stable ABI and don't want to update their DT

Quoted 4 lines

So, please just pick user-friendly IDs and add layout definitions in the driver. If you don't want to leak board info in the driver, then don't name the layout with the board name. BTW, I still hope you'll only have 2 kind of layouts (contiguous and interleaved).

Alright. Thanks for the insights.

-Paul