Skip to content

Commit feae030

Browse files
sumanannaandersson
authored andcommitted
remoteproc/omap: Add a sanity check for DSP boot address alignment
The DSP remote processors on OMAP SoCs require a boot register to be programmed with a boot address, and this boot address needs to be on a 1KB boundary. The current code is simply masking the boot address appropriately without performing any sanity checks before releasing the resets. An unaligned boot address results in an undefined execution behavior and can result in various bus errors like MMU Faults or L3 NoC errors. Such errors are hard to debug and can be easily avoided by adding a sanity check for the alignment before booting a DSP remote processor. Signed-off-by: Suman Anna <[email protected]> Signed-off-by: Tero Kristo <[email protected]> Reviewed-by: Bjorn Andersson <[email protected]> Reviewed-by: Andrew F. Davis <[email protected]> Acked-by: Mathieu Poirier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 7524292 commit feae030

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

drivers/remoteproc/omap_remoteproc.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,23 @@ static void omap_rproc_kick(struct rproc *rproc, int vqid)
121121
* @rproc: handle of a remote processor
122122
*
123123
* Set boot address for a supported DSP remote processor.
124+
*
125+
* Return: 0 on success, or -EINVAL if boot address is not aligned properly
124126
*/
125-
static void omap_rproc_write_dsp_boot_addr(struct rproc *rproc)
127+
static int omap_rproc_write_dsp_boot_addr(struct rproc *rproc)
126128
{
129+
struct device *dev = rproc->dev.parent;
127130
struct omap_rproc *oproc = rproc->priv;
128131
struct omap_rproc_boot_data *bdata = oproc->boot_data;
129132
u32 offset = bdata->boot_reg;
130133

131-
regmap_write(bdata->syscon, offset, rproc->bootaddr);
134+
if (rproc->bootaddr & (SZ_1K - 1)) {
135+
dev_err(dev, "invalid boot address 0x%llx, must be aligned on a 1KB boundary\n",
136+
rproc->bootaddr);
137+
return -EINVAL;
138+
}
139+
140+
return regmap_write(bdata->syscon, offset, rproc->bootaddr);
132141
}
133142

134143
/*
@@ -145,8 +154,11 @@ static int omap_rproc_start(struct rproc *rproc)
145154
int ret;
146155
struct mbox_client *client = &oproc->client;
147156

148-
if (oproc->boot_data)
149-
omap_rproc_write_dsp_boot_addr(rproc);
157+
if (oproc->boot_data) {
158+
ret = omap_rproc_write_dsp_boot_addr(rproc);
159+
if (ret)
160+
return ret;
161+
}
150162

151163
client->dev = dev;
152164
client->tx_done = NULL;

0 commit comments

Comments
 (0)