kboot: Split dt_device_set_reserved_mem

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 <povik@cutebit.org>
This commit is contained in:
Martin Povišer 2023-02-14 23:34:27 +01:00
parent 5ad92458b7
commit f996295045

View file

@ -1125,15 +1125,11 @@ static u64 dart_get_mapping(dart_dev_t *dart, const char *path, u64 paddr, size_
return iova; return iova;
} }
static int dt_device_set_reserved_mem(int node, dart_dev_t *dart, const char *name, static int dt_device_set_reserved_mem(int node, const char *name, uint32_t phandle, u64 iova,
uint32_t phandle, u64 paddr, u64 size) u64 size)
{ {
int ret; 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); ret = fdt_appendprop_u32(dt, node, "iommu-addresses", phandle);
if (ret != 0) if (ret != 0)
bail("DT: could not append phandle '%s.compatible' property: %d\n", name, ret); 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; 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, static int dt_get_or_add_reserved_mem(const char *node_name, const char *compat, u64 paddr,
size_t size) 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); uint32_t mem_phandle = fdt_get_phandle(dt, mem_node);
if (maps[i].map_dcp && dart_dcp) { if (maps[i].map_dcp && dart_dcp) {
ret = dt_device_set_reserved_mem(mem_node, dart_dcp, node_name, dcp_phandle, ret = dt_device_set_reserved_mem_from_dart(mem_node, dart_dcp, node_name, dcp_phandle,
region[i].paddr, region[i].size); region[i].paddr, region[i].size);
if (ret != 0) if (ret != 0)
goto err; goto err;
} }
if (maps[i].map_disp && dart_disp) { if (maps[i].map_disp && dart_disp) {
ret = dt_device_set_reserved_mem(mem_node, dart_disp, node_name, disp_phandle, ret = dt_device_set_reserved_mem_from_dart(mem_node, dart_disp, node_name, disp_phandle,
region[i].paddr, region[i].size); region[i].paddr, region[i].size);
if (ret != 0) if (ret != 0)
goto err; goto err;
} }
if (maps[i].map_piodma && dart_piodma) { if (maps[i].map_piodma && dart_piodma) {
ret = dt_device_set_reserved_mem(mem_node, dart_piodma, node_name, piodma_phandle, ret = dt_device_set_reserved_mem_from_dart(
region[i].paddr, region[i].size); mem_node, dart_piodma, node_name, piodma_phandle, region[i].paddr, region[i].size);
if (ret != 0) if (ret != 0)
goto err; goto err;
} }