lkml.org 
[lkml]   [2022]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subject[RFC PATCH 0/2] Add nvmem support for dynamic partitions
Date
This very small series comes to fix the very annyoing problem of
partitions declared by parser at runtime NOT supporting nvmem cells
definition.

The current implementation is very generic. The idea is to provide an of
node if defined for everyone and not strictly limit this to nvmem stuff.
But still the actual change is done only for nvmem-cells mtd. (just to
make sure) This can totally change and be limited to restore the old
mtd_get_of_node and add a function just to fix the problem with nvmem.

The idea here is that a user can still use these dynamic parsers
instead of declaring a fixed-partition and also declare how nvmem-cells
are defined for the partition.
This live with the assumption that dynamic partition have always the
same name and they are known. (this is the case for smem partition that
would require a bootloader reflash to change and for parsers like
cmdlinepart where the name is always the same.)
With this assumption, it's easy to fix this problem. Just introduce a
new partition node that will declare just these special partition.
Mtdcore then will check if these special declaration are present and
connect the dynamic partition with the of node present in the dts. Nvmem
will automagically fin the ofnode and cells will be works based on the
data provided by the parser.

The initial idea was to create a special nvmem driver with a special
compatible where a user would declare the mtd partition name and this
driver would search it and register the nvmem cells but that became
difficult really fast, mtd notifier system is problematic for this kind
of stuff. So here is the better implementation. A variant of this is
already tested on openwrt where we have devices that use cmdlinepart.
(that current variant have defined in the dts the exact copy of
cmdlinepart in the fixed-partition scheme and we patched the cmdlinepart
parser to scan this fixed-partition node (that is ignored as cmdlinepart
have priority) and connect the dynamic partition with the dts node)

I provided an example of this in the documentation commit.
In short the dynamic-partitions node is defined at the same level of the
partitions node. The partition in the "dynamic-partitions" node require
to have the same label of the dynamic-partition that will be created at
runtime and then a user can use the usual nvmem-cells way to declare
nvmem cells. Only the needed partition has to be declared, all the other
dynamic-partitions can be ignored.

I currently tested this on my device that have smem and the
gmac driver use nvmem to get the mac-address. This works correctly and
the same address is provided.

I hope we find a solution to this problem as currently we are trying to
transition to nvmem and we found this limitation. This seems to be a
good solution that doesn't looks to be too much of an hack.

Ansuel Smith (2):
dt-bindings: mtd: partitions: Document new dynamic-partitions node
mtd: core: introduce of support for dynamic partitions

.../mtd/partitions/dynamic-partitions.yaml | 59 +++++++++++++++++++
drivers/mtd/mtdcore.c | 45 ++++++++++++++
include/linux/mtd/mtd.h | 6 +-
3 files changed, 105 insertions(+), 5 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mtd/partitions/dynamic-partitions.yaml

--
2.33.1

\
 
 \ /
  Last update: 2022-01-20 21:27    [W:0.419 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site