diff options
author | Loic Pallardy <loic.pallardy@st.com> | 2018-07-27 09:14:46 -0400 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2018-10-10 01:41:04 -0400 |
commit | ffa5f9c84810ea175226863f66a51bb2d4502f5b (patch) | |
tree | f3885db699034d04bbdb25fed447c458911898ca | |
parent | c874bf59add0e6ed1d5d8c1753b9b66d51e3f640 (diff) |
remoteproc: modify rproc_handle_carveout to support pre-registered region
In current version rproc_handle_carveout() function registers carveout
for allocation.
This patch extends rproc_handle_carveout() function to support
pre-registered region. Match is done on region name, then requested
device address and length are checked.
If match found, pre-registered region is associated with resource
table request.
If no name match found, new carveout is registered for allocation.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index a0a5e32935bc..5abcd27a29f3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
@@ -840,6 +840,29 @@ static int rproc_handle_carveout(struct rproc *rproc, | |||
840 | dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n", | 840 | dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n", |
841 | rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags); | 841 | rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags); |
842 | 842 | ||
843 | /* | ||
844 | * Check carveout rsc already part of a registered carveout, | ||
845 | * Search by name, then check the da and length | ||
846 | */ | ||
847 | carveout = rproc_find_carveout_by_name(rproc, rsc->name); | ||
848 | |||
849 | if (carveout) { | ||
850 | if (carveout->rsc_offset != FW_RSC_ADDR_ANY) { | ||
851 | dev_err(dev, | ||
852 | "Carveout already associated to resource table\n"); | ||
853 | return -ENOMEM; | ||
854 | } | ||
855 | |||
856 | if (rproc_check_carveout_da(rproc, carveout, rsc->da, rsc->len)) | ||
857 | return -ENOMEM; | ||
858 | |||
859 | /* Update memory carveout with resource table info */ | ||
860 | carveout->rsc_offset = offset; | ||
861 | carveout->flags = rsc->flags; | ||
862 | |||
863 | return 0; | ||
864 | } | ||
865 | |||
843 | /* Register carveout in in list */ | 866 | /* Register carveout in in list */ |
844 | carveout = rproc_mem_entry_init(dev, 0, 0, rsc->len, rsc->da, | 867 | carveout = rproc_mem_entry_init(dev, 0, 0, rsc->len, rsc->da, |
845 | rproc_alloc_carveout, | 868 | rproc_alloc_carveout, |
@@ -1120,8 +1143,15 @@ static int rproc_alloc_registered_carveouts(struct rproc *rproc) | |||
1120 | * In this case, the device address and the physical address | 1143 | * In this case, the device address and the physical address |
1121 | * are the same. | 1144 | * are the same. |
1122 | */ | 1145 | */ |
1146 | |||
1147 | /* Use va if defined else dma to generate pa */ | ||
1123 | if (entry->va) | 1148 | if (entry->va) |
1124 | rsc->pa = (u32)rproc_va_to_pa(entry->va); | 1149 | rsc->pa = (u32)rproc_va_to_pa(entry->va); |
1150 | else | ||
1151 | rsc->pa = (u32)entry->dma; | ||
1152 | |||
1153 | rsc->da = entry->da; | ||
1154 | rsc->len = entry->len; | ||
1125 | } | 1155 | } |
1126 | } | 1156 | } |
1127 | 1157 | ||