remoteproc: pru: Fix and cleanup firmware interrupt mapping logic
authorSuman Anna <s-anna@ti.com>
Wed, 7 Apr 2021 15:56:41 +0000 (10:56 -0500)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Tue, 13 Apr 2021 20:43:38 +0000 (15:43 -0500)
commit880a66e026fbe6a17cd59fe0ee942bbad62a6c26
tree8d6a0d0941589ef87b13b059f830713890bcd248
parent1fe72bcfac087dba5ab52778e0646ed9e145cd32
remoteproc: pru: Fix and cleanup firmware interrupt mapping logic

The PRU firmware interrupt mappings are configured and unconfigured in
.start() and .stop() callbacks respectively using the variables 'evt_count'
and a 'mapped_irq' pointer. These variables are modified only during these
callbacks but are not re-initialized/reset properly during unwind or
failure paths. These stale values caused a kernel crash while stopping a
PRU remoteproc running a different firmware with no events on a subsequent
run after a previous run that was running a firmware with events.

Fix this crash by ensuring that the evt_count is 0 and the mapped_irq
pointer is set to NULL in pru_dispose_irq_mapping(). Also, reset these
variables properly during any failures in the .start() callback. While
at this, the pru_dispose_irq_mapping() callsites are all made to look
the same, moving any conditional logic to inside the function.

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Fixes: c75c9fdac66e ("remoteproc: pru: Add support for PRU specific interrupt configuration")
Reported-by: Vignesh Raghavendra <vigneshr@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
Link: https://lore.kernel.org/r/20210407155641.5501-4-s-anna@ti.com
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/remoteproc/pru_rproc.c