Skip to contentSkip to conversation

Deprecating reserve-map in favor of properties

DISCUSSION Benjamin Herrenschmidt 4 participants 6 messages Sep 20, 2012 – Nov 15, 2012 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hi folks !

The reserve map is, imho, my biggest mistake when coming up with the FDT format.

The main problem is that it doesn't survive the transition via a real Open Firmware interface. There is no practical way to indicate reserved regions of memory accross in that case, unless you have an OS that is nice enough to try to keep OF alive and accomodate its advertised "available" properties, but that's typically not the case of Linux on ppc.

So I would like to propose that we add a new "better" way to convey reserved memory information, via properties in the tree.

I originally though of having these in the "memory" nodes themselves but this can be tricky on machines that have multiple nodes (ie, NUMA generally means a memory node per NUMA node) since the reserved regions can spawn accross nodes and I don't want to complicate FW life too much by requiring breaking them up in that case.

So what about something at the root of the tree:

reserved-ranges: An array of ranges of reserved memory

reserved-names: A list of zero terminated strings, one for each entry in the reserved-ranges array, providing optional "names" for the reserved ranges.

The idea here is that we could have well defined names (using a similar prefix we use for properties) such as linux,initrd, which indicates clearly to the kernel that the only reason that range is reserved is because it contains an initrd (ie, it can be freed once that's been extracted).

It would also be generally handy in case a reserved area is meant to be used by a specific driver, such as an in-memory framebuffer pre-initialized by the firmware. The generic memory management code doesn't need to know, but later on, the gfx driver can pick it up easily provided the name is part of the binding for that device.

Any objection ? If none, I'll cook up a patch to add support for it (at least on powerpc :-)

Cheers,
Ben.

#1 lore raw
Quoted 41 lines · Benjamin Herrenschmidt

Hi folks !

The reserve map is, imho, my biggest mistake when coming up with the FDT format.

The main problem is that it doesn't survive the transition via a real Open Firmware interface. There is no practical way to indicate reserved regions of memory accross in that case, unless you have an OS that is nice enough to try to keep OF alive and accomodate its advertised "available" properties, but that's typically not the case of Linux on ppc.

So I would like to propose that we add a new "better" way to convey reserved memory information, via properties in the tree.

I originally though of having these in the "memory" nodes themselves but this can be tricky on machines that have multiple nodes (ie, NUMA generally means a memory node per NUMA node) since the reserved regions can spawn accross nodes and I don't want to complicate FW life too much by requiring breaking them up in that case.

So what about something at the root of the tree:

reserved-ranges: An array of ranges of reserved memory

reserved-names: A list of zero terminated strings, one for each entry in the reserved-ranges array, providing optional "names" for the reserved ranges.

The idea here is that we could have well defined names (using a similar prefix we use for properties) such as linux,initrd, which indicates clearly to the kernel that the only reason that range is reserved is because it contains an initrd (ie, it can be freed once that's been extracted).

It would also be generally handy in case a reserved area is meant to be used by a specific driver, such as an in-memory framebuffer pre-initialized by the firmware. The generic memory management code doesn't need to know, but later on, the gfx driver can pick it up easily provided the name is part of the binding for that device.

Quoted 5 lines

Any objection ? If none, I'll cook up a patch to add support for it (at least on powerpc :-)

Cheers,
Ben.

If you do this, please update the code in dtc/libfdt to construct the new nodes. We use this in u-boot to reserve kernel, dtb, initrd, etc regions. So would be nice to have drop in replacement code that could use same APIs if possible.

- k

A message that is not in the archive (sent off-list or not yet received): 8C5A5EB8-6CD7-4E35-AACF-A2CC04CDBE48-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org

#3 lore raw
Quoted 4 lines · Kumar Gala

If you do this, please update the code in dtc/libfdt to construct the new nodes. We use this in u-boot to reserve kernel, dtb, initrd, etc regions. So would be nice to have drop in replacement code that could use same APIs if possible.

The kernel would of course still understand the reserve map and I don't intend to remove it from the header immediately, so I think that can stay.... unless we make it a function of the version.

It's non-trivial to make the same (stateless) API in libfdt deal with setting properties. I'd rather avoid that problem initially by not changing the blob format, keeping the reserve map around for "legacy" purposes and simply making the kernel capable of understanding the properties.

Cheers,
Ben.

#4 lore raw
In reply to Benjamin Herrenschmidt
Quoted 21 lines · Benjamin Herrenschmidt

Hi folks !

The reserve map is, imho, my biggest mistake when coming up with the FDT format.

The main problem is that it doesn't survive the transition via a real Open Firmware interface. There is no practical way to indicate reserved regions of memory accross in that case, unless you have an OS that is nice enough to try to keep OF alive and accomodate its advertised "available" properties, but that's typically not the case of Linux on ppc.

So I would like to propose that we add a new "better" way to convey reserved memory information, via properties in the tree.

I originally though of having these in the "memory" nodes themselves but this can be tricky on machines that have multiple nodes (ie, NUMA generally means a memory node per NUMA node) since the reserved regions can spawn accross nodes and I don't want to complicate FW life too much by requiring breaking them up in that case.

Quoted 7 lines

So what about something at the root of the tree:

reserved-ranges: An array of ranges of reserved memory

reserved-names: A list of zero terminated strings, one for each entry in the reserved-ranges array, providing optional "names" for the reserved ranges.

I think this makes sense. Cyril and I are just talking about what he needs. He wants to set aside per-device reserved regions and would like to have the ability to reference a particular reserved region from a device node, probably with a phandle. I like the look of the reserved-{ranges,names} properties in the root, but I see the argument that it isn't very flexible. What about something like this:

reserved-memory {
        reserved@0x10000000 { reg = <0x10000000 0x08000000>; };
        reserved@0x01000000 { reg = <0x01000000 0x00200000>; };
}

The node name of the child nodes could be different of course.

Quoted 7 lines

The idea here is that we could have well defined names (using a similar prefix we use for properties) such as linux,initrd, which indicates clearly to the kernel that the only reason that range is reserved is because it contains an initrd (ie, it can be freed once that's been extracted).

Quoted 5 lines

It would also be generally handy in case a reserved area is meant to be used by a specific driver, such as an in-memory framebuffer pre-initialized by the firmware. The generic memory management code doesn't need to know, but later on, the gfx driver can pick it up easily provided the name is part of the binding for that device.

Right, that would work also even though I prefer phandle references in general. Is it conceivable that additional data would want to be attached to a particular reserved region?

g.

A message that is not in the archive (sent off-list or not yet received): CACxGe6sAXBJ9KkA8Urioe-VsbaLUO+=C_tb1vU+i_VKuedi=eg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 7 lines · Grant Likely

I think this makes sense. Cyril and I are just talking about what he needs. He wants to set aside per-device reserved regions and would like to have the ability to reference a particular reserved region from a device node, probably with a phandle. I like the look of the reserved-{ranges,names} properties in the root, but I see the argument that it isn't very flexible. What about something like this:

Quoted 6 lines
reserved-memory {
        reserved@0x10000000 { reg = <0x10000000 0x08000000>; };
        reserved@0x01000000 { reg = <0x01000000 0x00200000>; };
}

The node name of the child nodes could be different of course.

I'm not that fan of different nodes, especially nodes with nodes in them for that purpose. Seems overkill.

Can't he reference reserved entries as <phandle>,<index> pairs ?

I still think a single property would do fine. We could mandate those be in the respective "memory" nodes but them you have potentially to break up reserved regions if you have multiple memory nodes (NUMA) etc...

I'd vote for the simpler approach here...

Quoted 12 lines
Quoted 11 lines

The idea here is that we could have well defined names (using a similar prefix we use for properties) such as linux,initrd, which indicates clearly to the kernel that the only reason that range is reserved is because it contains an initrd (ie, it can be freed once that's been extracted).

It would also be generally handy in case a reserved area is meant to be used by a specific driver, such as an in-memory framebuffer pre-initialized by the firmware. The generic memory management code doesn't need to know, but later on, the gfx driver can pick it up easily provided the name is part of the binding for that device.

Quoted 3 lines

Right, that would work also even though I prefer phandle references in general. Is it conceivable that additional data would want to be attached to a particular reserved region?

phandle references and names aren't exclusive from each other. The name remains a useful diagnostic tool.

If you want additional data, make a node somewhere to represent that region along with its additional data, that node can have a reference to the reserved map entry.

I'd keep the reserve map itself simple. It's a "synthetic property" a bit like the memory nodes. IE. The "memory" nodes don't have to represent physical memory controllers & DIMMs. They represent the overall view of memory by the CPUs. You can represent the MCs and the DIMMs elsewhere in the SoC node.

Cheers,
Ben.

#7 lore raw
Quoted 14 lines · Benjamin Herrenschmidt
Quoted 12 lines · Grant Likely

I think this makes sense. Cyril and I are just talking about what he needs. He wants to set aside per-device reserved regions and would like to have the ability to reference a particular reserved region from a device node, probably with a phandle. I like the look of the reserved-{ranges,names} properties in the root, but I see the argument that it isn't very flexible. What about something like this:

reserved-memory {
        reserved@0x10000000 { reg = <0x10000000 0x08000000>; };
        reserved@0x01000000 { reg = <0x01000000 0x00200000>; };
}
Quoted 6 lines
Quoted 1 line

The node name of the child nodes could be different of course.

I'm not that fan of different nodes, especially nodes with nodes in them for that purpose. Seems overkill.

Can't he reference reserved entries as <phandle>,<index> pairs ?

That would work too.

Quoted 3 lines

I still think a single property would do fine. We could mandate those be in the respective "memory" nodes but them you have potentially to break up reserved regions if you have multiple memory nodes (NUMA) etc...

It makes sense to me for the reserved ranges to be kept with the memory nodes themselves, even if it does mean that sometimes they need to be split up for multiple memory nodes.

Quoted 11 lines
Quoted 3 lines

Right, that would work also even though I prefer phandle references in general. Is it conceivable that additional data would want to be attached to a particular reserved region?

phandle references and names aren't exclusive from each other. The name remains a useful diagnostic tool.

If you want additional data, make a node somewhere to represent that region along with its additional data, that node can have a reference to the reserved map entry.

Quoted 5 lines

I'd keep the reserve map itself simple. It's a "synthetic property" a bit like the memory nodes. IE. The "memory" nodes don't have to represent physical memory controllers & DIMMs. They represent the overall view of memory by the CPUs. You can represent the MCs and the DIMMs elsewhere in the SoC node.

okay.

g.