From: Andrew Davis <afd@ti.com>
To: Nhat Tran <nhat.tranminhk2@gmail.com>
Cc: <nm@ti.com>, <ssantosh@kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-omap@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] soc: ti: wkup_m3_ipc: Use the device's own state in remove()
Date: Thu, 3 Dec 2026 13:21:04 -0600 [thread overview]
Message-ID: <9cded3ed-64a2-4b7a-afd4-8866fa66d1a2@ti.com> (raw)
In-Reply-To: <20261203175232.57338-1-nhat.tranminhk2@gmail.com>
On 12/3/26 11:52 AM, Nhat Tran wrote:
> Dear Andrew,
>
>> Good find, but this fix is incomplete. You'll end up with the same NULL
>> dereference in `wkup_m3_ipc_resume()` should we go into suspend before
>> firmware is loaded, same for debugfs access before firmware.
>
> Thanks, you're right. I tested it on v1 and resume crashes too when
> the firmware is missing.
>
>> The core issue is that `m3_ipc_state` being set is used both to signal
>> the core is available, and access the device structure in functions that
>> can't get it through other means. It would be betterto split these two
>> which also solves the issue here.
>
> I sent v2 with this approach:
> https://lore.kernel.org/r/20261203174139.55646-1-nhat.tranminhk2@gmail.com
>
> I changed a few small things from your diff:
>
>>> struct wkup_m3_ipc *wkup_m3_ipc_get(void)
>>> {
>>> - if (m3_ipc_state)
>>> + if (m3_ipc_state->available)
>>> get_device(m3_ipc_state->dev);
>
> m3_ipc_state can still be NULL here, e.g. if pm33xx probes before
> wkup_m3_ipc. So I kept the NULL check:
>
> if (m3_ipc_state && m3_ipc_state->available)
>
>>> void wkup_m3_ipc_put(struct wkup_m3_ipc *m3_ipc)
>>> {
>>> - if (m3_ipc_state)
>>> + if (m3_ipc_state->available)
>>> put_device(m3_ipc_state->dev);
>>> }
>
> I left put() as it was. It should drop the reference even if the M3 is
> no longer available. Also m3_ipc_state is NULL again after remove(), so
> this would crash if pm33xx is removed after wkup_m3_ipc.
>
>>> @@ -601,7 +601,7 @@ static int wkup_m3_rproc_boot_thread(void *arg)
>>> if (ret)
>>> dev_err(dev, "rproc_boot failed\n");
>>> else
>>> - m3_ipc_state = m3_ipc;
>>> + m3_ipc_state->available = true;
>
> The thread starts before probe sets m3_ipc_state, so I used
> m3_ipc->available here instead.
>
Another option would have been to set m3_ipc_state = m3_ipc;
earlier in probe() so that it would be available before
this thread could be scheduled. But your v2 using m3_ipc
looks fine also.
Andrew
> Best Regards,
> Nhat Tran
prev parent reply other threads:[~2026-12-03 19:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 14:11 Nhat Tran
2026-12-03 15:39 ` Andrew Davis
2026-12-03 17:52 ` Nhat Tran
2026-12-03 19:21 ` Andrew Davis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9cded3ed-64a2-4b7a-afd4-8866fa66d1a2@ti.com \
--to=afd@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=nhat.tranminhk2@gmail.com \
--cc=nm@ti.com \
--cc=ssantosh@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®