summaryrefslogtreecommitdiffstats
path: root/drivers/remoteproc
diff options
context:
space:
mode:
authorSuman Anna <s-anna@ti.com>2015-05-22 16:45:28 -0400
committerOhad Ben-Cohen <ohad@wizery.com>2015-06-17 02:57:12 -0400
commita01f7cd657c95941079d548ef7fbf0cc370c1259 (patch)
tree6e4934670eb2b157dd1e2049180f3d0f8c046aae /drivers/remoteproc
parentfec47d863587c272d6fbf4e50066209c953d5e60 (diff)
remoteproc: add a rproc ops for performing address translation
The rproc_da_to_va API is currently used to perform any device to kernel address translations to meet the different needs of the remoteproc core/drivers (eg: loading). The functionality is achieved within the remoteproc core, and is limited only for carveouts allocated within the core. A new rproc ops, da_to_va, is added to provide flexibility to platform implementations to perform the address translation themselves when the above conditions cannot be met by the implementations. The rproc_da_to_va() API is extended to invoke this ops if present, and fallback to regular processing if the platform implementation cannot provide the translation. This will allow any remoteproc implementations to translate addresses for dedicated memories like internal memories. While at this, also update the rproc_da_to_va() documentation since it is an exported function. Signed-off-by: Suman Anna <s-anna@ti.com> Signed-off-by: Dave Gerlach <d-gerlach@ti.com> Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/remoteproc_core.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index e1a6d693b8bb..b4ab38015cf2 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -137,28 +137,46 @@ static void rproc_disable_iommu(struct rproc *rproc)
137 iommu_domain_free(domain); 137 iommu_domain_free(domain);
138} 138}
139 139
140/* 140/**
141 * rproc_da_to_va() - lookup the kernel virtual address for a remoteproc address
142 * @rproc: handle of a remote processor
143 * @da: remoteproc device address to translate
144 * @len: length of the memory region @da is pointing to
145 *
141 * Some remote processors will ask us to allocate them physically contiguous 146 * Some remote processors will ask us to allocate them physically contiguous
142 * memory regions (which we call "carveouts"), and map them to specific 147 * memory regions (which we call "carveouts"), and map them to specific
143 * device addresses (which are hardcoded in the firmware). 148 * device addresses (which are hardcoded in the firmware). They may also have
149 * dedicated memory regions internal to the processors, and use them either
150 * exclusively or alongside carveouts.
144 * 151 *
145 * They may then ask us to copy objects into specific device addresses (e.g. 152 * They may then ask us to copy objects into specific device addresses (e.g.
146 * code/data sections) or expose us certain symbols in other device address 153 * code/data sections) or expose us certain symbols in other device address
147 * (e.g. their trace buffer). 154 * (e.g. their trace buffer).
148 * 155 *
149 * This function is an internal helper with which we can go over the allocated 156 * This function is a helper function with which we can go over the allocated
150 * carveouts and translate specific device address to kernel virtual addresses 157 * carveouts and translate specific device addresses to kernel virtual addresses
151 * so we can access the referenced memory. 158 * so we can access the referenced memory. This function also allows to perform
159 * translations on the internal remoteproc memory regions through a platform
160 * implementation specific da_to_va ops, if present.
161 *
162 * The function returns a valid kernel address on success or NULL on failure.
152 * 163 *
153 * Note: phys_to_virt(iommu_iova_to_phys(rproc->domain, da)) will work too, 164 * Note: phys_to_virt(iommu_iova_to_phys(rproc->domain, da)) will work too,
154 * but only on kernel direct mapped RAM memory. Instead, we're just using 165 * but only on kernel direct mapped RAM memory. Instead, we're just using
155 * here the output of the DMA API, which should be more correct. 166 * here the output of the DMA API for the carveouts, which should be more
167 * correct.
156 */ 168 */
157void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) 169void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
158{ 170{
159 struct rproc_mem_entry *carveout; 171 struct rproc_mem_entry *carveout;
160 void *ptr = NULL; 172 void *ptr = NULL;
161 173
174 if (rproc->ops->da_to_va) {
175 ptr = rproc->ops->da_to_va(rproc, da, len);
176 if (ptr)
177 goto out;
178 }
179
162 list_for_each_entry(carveout, &rproc->carveouts, node) { 180 list_for_each_entry(carveout, &rproc->carveouts, node) {
163 int offset = da - carveout->da; 181 int offset = da - carveout->da;
164 182
@@ -175,6 +193,7 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
175 break; 193 break;
176 } 194 }
177 195
196out:
178 return ptr; 197 return ptr;
179} 198}
180EXPORT_SYMBOL(rproc_da_to_va); 199EXPORT_SYMBOL(rproc_da_to_va);