Эх сурвалжийг харах

remoteproc/k3-r5: fix loading into BTCM when using R5 local addresses

A R5F remote processor can access its TCMs either using its local address
views at address 0x0 and/or 0x41010000 depending on the LOCZRAMA setting,
or using the corresponding SoC-bus address views (one-to-one views since
there are no MMUs).

The K3 R5F remoteproc driver provides the translations for the TCMs
through the k3_r5_rproc_da_to_va() function to allow loading into TCMs.
This function is translating the SoC-view addresses just fine, but is
only translating ATCMs at address 0x0 at present. This results in a
failure to load any segments into BTCMs when using the R5 local address
range at 0x41010000. Update the logic in this function to fix these
BTCM load issues.

Fixes: 80d807f572e9 ("remoteproc/k3-r5: add a remoteproc driver for R5F subsystem")
Signed-off-by: Suman Anna <s-anna@ti.com>
Suman Anna 6 жил өмнө
parent
commit
91b50d6d1d

+ 10 - 11
drivers/remoteproc/ti_k3_r5_remoteproc.c

@@ -567,22 +567,21 @@ static void *k3_r5_rproc_da_to_va(struct rproc *rproc, u64 da, int len,
 	if (len <= 0)
 		return NULL;
 
-	/* handle R5-view of ATCM addresses first using address 0 */
-	size = core->mem[0].size;
-	if (da >= 0 && ((da + len) <= size)) {
-		offset = da;
-		va = core->mem[0].cpu_addr + offset;
-		return (__force void *)va;
-	}
-
-	/* handle SoC-view addresses for ATCM and BTCM */
+	/* handle both R5 and SoC views of ATCM and BTCM */
 	for (i = 0; i < core->num_mems; i++) {
 		bus_addr = core->mem[i].bus_addr;
 		dev_addr = core->mem[i].dev_addr;
 		size = core->mem[i].size;
 
-		if (da >= bus_addr &&
-		    ((da + len) <= (bus_addr + size))) {
+		/* handle R5-view addresses of TCMs */
+		if (da >= dev_addr && ((da + len) <= (dev_addr + size))) {
+			offset = da - dev_addr;
+			va = core->mem[i].cpu_addr + offset;
+			return (__force void *)va;
+		}
+
+		/* handle SoC-view addresses of TCMs */
+		if (da >= bus_addr && ((da + len) <= (bus_addr + size))) {
 			offset = da - bus_addr;
 			va = core->mem[i].cpu_addr + offset;
 			return (__force void *)va;