lib: utils/regmap: Fix reg_stride calculation in syscon regmap
PATCH 1/1 lib: utils/regmap: Fix reg_stride calculation in syscon regmap
The reg_stride field represents the address stride in bytes between consecutive registers. The Linux kernel regmap framework validates register accesses using IS_ALIGNED(reg, map->reg_stride) as an address alignment check (drivers/base/regmap/regmap.c). The Linux kernel syscon driver (drivers/mfd/syscon.c) sets reg_stride directly to reg_io_width:
syscon_config.reg_stride = reg_io_width;
The current OpenSBI code incorrectly multiplies reg_io_width by 8, converting a byte value to bits. Fix this by using reg_io_width directly as the stride value, consistent with the Linux kernel.
--- lib/utils/regmap/fdt_regmap_syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/utils/regmap/fdt_regmap_syscon.c +1 -1
@@ -190,7 +190,7 @@ static int regmap_syscon_init(const void *fdt, int nodeoff, srm->rmap.id = nodeoff; srm->rmap.reg_shift =0 ; - srm->rmap.reg_stride = srm->reg_io_width *8 ; + srm->rmap.reg_stride = srm->reg_io_width; srm->rmap.reg_base =0 ; srm->rmap.reg_max = size / srm->reg_io_width;switch (srm->reg_io_width) {
Signature · 7 lines
2.43.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Quoted 7 lines · David E. Garcia Porras
The
reg_stridefield represents the address stride in bytes between consecutive registers. The Linux kernel regmap framework validates register accesses usingIS_ALIGNED(reg, map->reg_stride)as an address alignment check (drivers/base/regmap/regmap.c). The Linux kernel syscon driver (drivers/mfd/syscon.c) setsreg_stridedirectly toreg_io_width:
Quoted 7 lines
syscon_config.reg_stride = reg_io_width;The current OpenSBI code incorrectly multiplies
reg_io_widthby 8, converting a byte value to bits. Fix this by usingreg_io_widthdirectly as the stride value, consistent with the Linux kernel.Signed-off-by David E. Garcia Porras <[email protected]>
Fixes tag is missing but I will add this at the time of merging.
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 25 lines
--- lib/utils/regmap/fdt_regmap_syscon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/utils/regmap/fdt_regmap_syscon.c +1
-2@@ -190,7 +190,7 @@ static int regmap_syscon_init(const void *fdt, int nodeoff, srm->rmap.id = nodeoff; srm->rmap.reg_shift =0 ; - srm->rmap.reg_stride = srm->reg_io_width *8 ; + srm->rmap.reg_stride = srm->reg_io_width; srm->rmap.reg_base =0 ; srm->rmap.reg_max = size / srm->reg_io_width;switch (srm->reg_io_width) { --2.43.0
--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi