Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nhat Tran <nhat.tranminhk2@gmail.com>
To: afd@ti.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: Fri,  4 Dec 2026 00:52:32 +0700	[thread overview]
Message-ID: <20261203175232.57338-1-nhat.tranminhk2@gmail.com> (raw)
In-Reply-To: <cb290ad3-b88b-4917-9561-57948f3ee1da@ti.com>

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.

Best Regards,
Nhat Tran


      reply	other threads:[~2026-12-03 17:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 14:11 [PATCH] soc: ti: wkup_m3_ipc: Use the device's own state in remove() Nhat Tran
2026-12-03 15:39 ` Andrew Davis
2026-12-03 17:52   ` Nhat Tran [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=20261203175232.57338-1-nhat.tranminhk2@gmail.com \
    --to=nhat.tranminhk2@gmail.com \
    --cc=afd@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --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