aboutsummaryrefslogtreecommitdiff
path: root/drivers/remoteproc/stm32_copro.c
diff options
context:
space:
mode:
authorLokesh Vutla <lokeshvutla@ti.com>2019-09-04 16:01:27 +0530
committerTom Rini <trini@konsulko.com>2019-10-11 10:07:33 -0400
commitc08eb936263c67312cb55c354277f9dc3433b194 (patch)
treecae2475d85f59f2b8ba314c553b325e5d8b4bfe8 /drivers/remoteproc/stm32_copro.c
parent240b93201007183d5fd651a210ddb4c50ee30980 (diff)
downloadu-boot-c08eb936263c67312cb55c354277f9dc3433b194.zip
u-boot-c08eb936263c67312cb55c354277f9dc3433b194.tar.gz
u-boot-c08eb936263c67312cb55c354277f9dc3433b194.tar.bz2
remoteproc: ops: Add elf section size as input parameter to device_to_virt api
Introduce a new parameter "size" that accepts size of the region to remoteproc ops callback device_to_virt(). This can enforce more checks on the region that device_to_virt() is dealing with. Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Tested-by: Fabien Dessenne <fabien.dessenne@st.com> Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com>
Diffstat (limited to 'drivers/remoteproc/stm32_copro.c')
-rw-r--r--drivers/remoteproc/stm32_copro.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/remoteproc/stm32_copro.c b/drivers/remoteproc/stm32_copro.c
index ad941f6..71895da 100644
--- a/drivers/remoteproc/stm32_copro.c
+++ b/drivers/remoteproc/stm32_copro.c
@@ -107,11 +107,13 @@ static int stm32_copro_set_hold_boot(struct udevice *dev, bool hold)
* stm32_copro_device_to_virt() - Convert device address to virtual address
* @dev: corresponding STM32 remote processor device
* @da: device address
+ * @size: Size of the memory region @da is pointing to
* @return converted virtual address
*/
-static void *stm32_copro_device_to_virt(struct udevice *dev, ulong da)
+static void *stm32_copro_device_to_virt(struct udevice *dev, ulong da,
+ ulong size)
{
- fdt32_t in_addr = cpu_to_be32(da);
+ fdt32_t in_addr = cpu_to_be32(da), end_addr;
u64 paddr;
paddr = dev_translate_dma_address(dev, &in_addr);
@@ -120,6 +122,12 @@ static void *stm32_copro_device_to_virt(struct udevice *dev, ulong da)
return NULL;
}
+ end_addr = cpu_to_be32(da + size - 1);
+ if (dev_translate_dma_address(dev, &end_addr) == OF_BAD_ADDR) {
+ dev_err(dev, "Unable to convert address %ld\n", da + size - 1);
+ return NULL;
+ }
+
return phys_to_virt(paddr);
}