* [PATCH] soc: ti: wkup_m3_ipc: Fix race condition with rproc_boot
@ 2019-12-12 4:03 Dave Gerlach
2019-12-17 18:25 ` Tony Lindgren
0 siblings, 1 reply; 4+ messages in thread
From: Dave Gerlach @ 2019-12-12 4:03 UTC (permalink / raw)
To: Tony Lindgren, Santosh Shilimkar
Cc: linux-arm-kernel, linux-kernel, linux-omap, Dave Gerlach, Suman Anna
Any user of wkup_m3_ipc calls wkup_m3_ipc_get to get a handle and this
checks the value of the static variable m3_ipc_state to see if the
wkup_m3 is ready. Currently this is populated during probe before
rproc_boot has been called, meaning there is a window of time that
wkup_m3_ipc_get can return a valid handle but the wkup_m3 itself is not
ready, leading to invalid IPC calls to the wkup_m3 and system
instability.
To avoid this, move the population of the m3_ipc_state variable until
after rproc_boot has succeeded to guarantee a valid and usable handle
is always returned.
Reported-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
---
drivers/soc/ti/wkup_m3_ipc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c
index 378369d9364a..e9ece45d7a33 100644
--- a/drivers/soc/ti/wkup_m3_ipc.c
+++ b/drivers/soc/ti/wkup_m3_ipc.c
@@ -419,6 +419,8 @@ static void wkup_m3_rproc_boot_thread(struct wkup_m3_ipc *m3_ipc)
ret = rproc_boot(m3_ipc->rproc);
if (ret)
dev_err(dev, "rproc_boot failed\n");
+ else
+ m3_ipc_state = m3_ipc;
do_exit(0);
}
@@ -505,8 +507,6 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
goto err_put_rproc;
}
- m3_ipc_state = m3_ipc;
-
return 0;
err_put_rproc:
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: ti: wkup_m3_ipc: Fix race condition with rproc_boot
2019-12-12 4:03 [PATCH] soc: ti: wkup_m3_ipc: Fix race condition with rproc_boot Dave Gerlach
@ 2019-12-17 18:25 ` Tony Lindgren
2019-12-17 18:32 ` santosh.shilimkar
0 siblings, 1 reply; 4+ messages in thread
From: Tony Lindgren @ 2019-12-17 18:25 UTC (permalink / raw)
To: Dave Gerlach
Cc: Santosh Shilimkar, linux-arm-kernel, linux-kernel, linux-omap,
Suman Anna
Hi,
* Dave Gerlach <d-gerlach@ti.com> [191211 20:02]:
> Any user of wkup_m3_ipc calls wkup_m3_ipc_get to get a handle and this
> checks the value of the static variable m3_ipc_state to see if the
> wkup_m3 is ready. Currently this is populated during probe before
> rproc_boot has been called, meaning there is a window of time that
> wkup_m3_ipc_get can return a valid handle but the wkup_m3 itself is not
> ready, leading to invalid IPC calls to the wkup_m3 and system
> instability.
>
> To avoid this, move the population of the m3_ipc_state variable until
> after rproc_boot has succeeded to guarantee a valid and usable handle
> is always returned.
Santosh, do you want me to pick this one into my fixes branch?
Regards,
Tony
> Reported-by: Suman Anna <s-anna@ti.com>
> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> ---
> drivers/soc/ti/wkup_m3_ipc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c
> index 378369d9364a..e9ece45d7a33 100644
> --- a/drivers/soc/ti/wkup_m3_ipc.c
> +++ b/drivers/soc/ti/wkup_m3_ipc.c
> @@ -419,6 +419,8 @@ static void wkup_m3_rproc_boot_thread(struct wkup_m3_ipc *m3_ipc)
> ret = rproc_boot(m3_ipc->rproc);
> if (ret)
> dev_err(dev, "rproc_boot failed\n");
> + else
> + m3_ipc_state = m3_ipc;
>
> do_exit(0);
> }
> @@ -505,8 +507,6 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
> goto err_put_rproc;
> }
>
> - m3_ipc_state = m3_ipc;
> -
> return 0;
>
> err_put_rproc:
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: ti: wkup_m3_ipc: Fix race condition with rproc_boot
2019-12-17 18:25 ` Tony Lindgren
@ 2019-12-17 18:32 ` santosh.shilimkar
2019-12-17 18:35 ` Tony Lindgren
0 siblings, 1 reply; 4+ messages in thread
From: santosh.shilimkar @ 2019-12-17 18:32 UTC (permalink / raw)
To: Tony Lindgren
Cc: Dave Gerlach, Santosh Shilimkar, linux-arm-kernel, linux-kernel,
linux-omap, Suman Anna
On 12/17/19 10:25 AM, Tony Lindgren wrote:
> Hi,
>
> * Dave Gerlach <d-gerlach@ti.com> [191211 20:02]:
>> Any user of wkup_m3_ipc calls wkup_m3_ipc_get to get a handle and this
>> checks the value of the static variable m3_ipc_state to see if the
>> wkup_m3 is ready. Currently this is populated during probe before
>> rproc_boot has been called, meaning there is a window of time that
>> wkup_m3_ipc_get can return a valid handle but the wkup_m3 itself is not
>> ready, leading to invalid IPC calls to the wkup_m3 and system
>> instability.
>>
>> To avoid this, move the population of the m3_ipc_state variable until
>> after rproc_boot has succeeded to guarantee a valid and usable handle
>> is always returned.
>
> Santosh, do you want me to pick this one into my fixes branch?
>
Sure, go ahead.
Acked-by: Santosh Shilimkar <ssantosh@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] soc: ti: wkup_m3_ipc: Fix race condition with rproc_boot
2019-12-17 18:32 ` santosh.shilimkar
@ 2019-12-17 18:35 ` Tony Lindgren
0 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2019-12-17 18:35 UTC (permalink / raw)
To: santosh.shilimkar
Cc: Dave Gerlach, Santosh Shilimkar, linux-arm-kernel, linux-kernel,
linux-omap, Suman Anna
* santosh.shilimkar@oracle.com <santosh.shilimkar@oracle.com> [191217 18:33]:
> On 12/17/19 10:25 AM, Tony Lindgren wrote:
> > Hi,
> >
> > * Dave Gerlach <d-gerlach@ti.com> [191211 20:02]:
> > > Any user of wkup_m3_ipc calls wkup_m3_ipc_get to get a handle and this
> > > checks the value of the static variable m3_ipc_state to see if the
> > > wkup_m3 is ready. Currently this is populated during probe before
> > > rproc_boot has been called, meaning there is a window of time that
> > > wkup_m3_ipc_get can return a valid handle but the wkup_m3 itself is not
> > > ready, leading to invalid IPC calls to the wkup_m3 and system
> > > instability.
> > >
> > > To avoid this, move the population of the m3_ipc_state variable until
> > > after rproc_boot has succeeded to guarantee a valid and usable handle
> > > is always returned.
> >
> > Santosh, do you want me to pick this one into my fixes branch?
> >
> Sure, go ahead.
>
> Acked-by: Santosh Shilimkar <ssantosh@kernel.org>
OK thanks applying into fixes.
Tony
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-12-17 18:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12 4:03 [PATCH] soc: ti: wkup_m3_ipc: Fix race condition with rproc_boot Dave Gerlach
2019-12-17 18:25 ` Tony Lindgren
2019-12-17 18:32 ` santosh.shilimkar
2019-12-17 18:35 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).