From f996295045137ae5260eb68becf0e554281fb7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Tue, 14 Feb 2023 23:34:27 +0100 Subject: [PATCH] kboot: Split dt_device_set_reserved_mem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make dt_device_set_reserved_mem take in an explicit iova instead of reading it off from a DART. Add a separate 'from_dart' variety of the function for getting the iova from DART. Signed-off-by: Martin PoviĊĦer --- src/kboot.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index 2357d5d1..3ef79efa 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -1125,15 +1125,11 @@ static u64 dart_get_mapping(dart_dev_t *dart, const char *path, u64 paddr, size_ return iova; } -static int dt_device_set_reserved_mem(int node, dart_dev_t *dart, const char *name, - uint32_t phandle, u64 paddr, u64 size) +static int dt_device_set_reserved_mem(int node, const char *name, uint32_t phandle, u64 iova, + u64 size) { int ret; - u64 iova = dart_get_mapping(dart, name, paddr, size); - if (DART_IS_ERR(iova)) - bail("ADT: no mapping found for '%s' 0x%012lx iova:0x%08lx)\n", name, paddr, iova); - ret = fdt_appendprop_u32(dt, node, "iommu-addresses", phandle); if (ret != 0) bail("DT: could not append phandle '%s.compatible' property: %d\n", name, ret); @@ -1149,6 +1145,16 @@ static int dt_device_set_reserved_mem(int node, dart_dev_t *dart, const char *na return 0; } +static int dt_device_set_reserved_mem_from_dart(int node, dart_dev_t *dart, const char *name, + uint32_t phandle, u64 paddr, u64 size) +{ + u64 iova = dart_get_mapping(dart, name, paddr, size); + if (DART_IS_ERR(iova)) + bail("ADT: no mapping found for '%s' 0x%012lx iova:0x%08lx)\n", name, paddr, iova); + + return dt_device_set_reserved_mem(node, name, phandle, iova, size); +} + static int dt_get_or_add_reserved_mem(const char *node_name, const char *compat, u64 paddr, size_t size) { @@ -1320,20 +1326,20 @@ static int dt_add_reserved_regions(const char *dcp_alias, const char *disp_alias uint32_t mem_phandle = fdt_get_phandle(dt, mem_node); if (maps[i].map_dcp && dart_dcp) { - ret = dt_device_set_reserved_mem(mem_node, dart_dcp, node_name, dcp_phandle, - region[i].paddr, region[i].size); + ret = dt_device_set_reserved_mem_from_dart(mem_node, dart_dcp, node_name, dcp_phandle, + region[i].paddr, region[i].size); if (ret != 0) goto err; } if (maps[i].map_disp && dart_disp) { - ret = dt_device_set_reserved_mem(mem_node, dart_disp, node_name, disp_phandle, - region[i].paddr, region[i].size); + ret = dt_device_set_reserved_mem_from_dart(mem_node, dart_disp, node_name, disp_phandle, + region[i].paddr, region[i].size); if (ret != 0) goto err; } if (maps[i].map_piodma && dart_piodma) { - ret = dt_device_set_reserved_mem(mem_node, dart_piodma, node_name, piodma_phandle, - region[i].paddr, region[i].size); + ret = dt_device_set_reserved_mem_from_dart( + mem_node, dart_piodma, node_name, piodma_phandle, region[i].paddr, region[i].size); if (ret != 0) goto err; }