diff options
author | Lokesh Vutla <lokeshvutla@ti.com> | 2019-09-04 16:01:27 +0530 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-10-11 10:07:33 -0400 |
commit | c08eb936263c67312cb55c354277f9dc3433b194 (patch) | |
tree | cae2475d85f59f2b8ba314c553b325e5d8b4bfe8 /drivers/remoteproc/stm32_copro.c | |
parent | 240b93201007183d5fd651a210ddb4c50ee30980 (diff) | |
download | u-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.c | 12 |
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); } |