Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Renê <rene@renesp.com.br>
To: Murali Krishna <muralikrishna2444b@gmail.com>
Cc: anandu.e@oss.qualcomm.com, srini@kernel.org,
	ekansh.gupta@oss.qualcomm.com, arnd@arndb.de,
	gregkh@linuxfoundation.org, jorge.ramirez@oss.qualcomm.com,
	srinivas.kandagatla@oss.qualcomm.com,
	linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 3/3] misc: fastrpc: fix context leak and hang on signal-interrupted invoke
Date: Tue, 24 Nov 2026 16:37:31 +0100	[thread overview]
Message-ID: <e6fd92e5bb6605ff3591c7813ac22055@renesp.com.br> (raw)
In-Reply-To: <20261124144754.99753-1-muralikrishna2444b@gmail.com>

Hi Anandu,

I tested this series on a Qualcomm IQ-8275 EVK (QCS8275), backported to
a 6.18-based kernel. A llama.cpp process using the CDSP was killed
(SIGKILL) with invocations in flight, three times in a row: each time
its ~1.9 GB of DMA buffers were released at close, and the restarted
process got a context bank and loaded the model again without errors.
Without a fix, the buffers stayed attached to the context bank and the
next process failed to map its own.

Tested-by: Renê de Souza Pinto <rene@renesp.com.br>

This also fixes the leak I sent a separate patch ([1], as mentioned by
Murali Krishna), so please consider that one superseded by this series.

[1] 
https://lore.kernel.org/r/20261124122011.2912030-1-rene@renesp.com.br

Thanks,
Renê


On 2026/11/24 15:47, Murali Krishna wrote:
> On Tue, 17 Nov 2026 15:09:47 +0530, Anandu Krishnan E wrote:
>> The same unreachable-orphan problem exists for a timed-out kernel
>> invoke (-ETIMEDOUT, only possible when kernel=true): the bail: path
>> used to unconditionally unlink the context from fl->pending before
>> dropping its reference, even though the DSP may still answer later.
>> Leave it linked on fl->pending in that case instead, so
>> fastrpc_notify_users() can still find and release it if the channel
>> is torn down before that answer arrives.
> 
> I am new to this driver, so please treat this as an observation rather
> than a review. I applied 1/3 and 2/3 to char-misc-next (917fcbf03) and
> read 3/3 against that tree.
> 
> The -ETIMEDOUT claim does check out: fastrpc_wait_for_response() only
> returns it from the kernel branch's wait_for_completion_timeout(), the
> user branch uses wait_for_completion_interruptible(), and
> poll_for_remote_response() converts its own timeout into -EIO.
> 
> My question is what then happens to such a context at fd close.
> 
> Once 1/3 removes the loop in fastrpc_user_free(), no path drains
> fl->pending any more: fastrpc_notify_users() completes the contexts on
> it but neither unlinks them nor drops a reference, and the drain 3/3
> adds to fastrpc_device_release() covers fl->interrupted only. A
> timed-out kernel invoke therefore keeps its worker reference, stays
> linked on fl->pending, and through the fastrpc_user_get() taken in
> fastrpc_context_alloc() keeps fl alive until an SSR runs
> fastrpc_notify_users(). If no SSR ever arrives, nothing releases it.
> 
> The reasoning you already apply to fl->interrupted seems to cover this
> case as well: if fastrpc_release_current_dsp_process() succeeded then
> the DSP is done with the whole process, so a context sitting on
> fl->pending should be equally safe to release. Would it make sense to
> use release_err for both lists?
> 
> What made me look was that fastrpc_release_current_dsp_process() is
> itself a kernel invoke, so it can be the call that times out. In that
> case release_err is non-zero, the fl->interrupted drain deliberately
> keeps the worker references, and that call's own context is also left
> behind on fl->pending -- so fl, its maps and its mmaps all stay
> allocated while fastrpc_session_free() has already marked the session
> reusable.
> 
> That looks close to the behaviour Renê de Souza Pinto reports on
> QCS8275 after an adsprpcd init failure, in a thread where he has since
> offered to test this series on that board:
> 
>   
> https://lore.kernel.org/linux-arm-msm/20261124141843.3967523-1-rene@renesp.com.br/
> 
> If that offer stands, an adsprpcd init failure followed by closing the
> fd might be a useful case to try, since it is exactly the path where
> release_err is non-zero.
> 
> I built 1/3 and 2/3 on char-misc-next with COMPILE_TEST=y under W=1
> with no new warnings. I have not applied 3/3 itself, and I have no
> Qualcomm hardware, so none of this is tested -- it is from reading the
> code only.
> 
> Thanks,
> Murali Krishna

      reply	other threads:[~2026-11-24 15:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  9:39 [PATCH v4 0/3] misc: fastrpc: fix context leak and hang on signal-interrupted invoke Anandu Krishnan E
2026-11-17  9:39 ` [PATCH v4 1/3] misc: fastrpc: remove dead context drain in fastrpc_user_free() Anandu Krishnan E
2026-11-17 15:35   ` Ekansh Gupta
2026-11-17  9:39 ` [PATCH v4 2/3] misc: fastrpc: drop the DSP-response reference on channel removal Anandu Krishnan E
2026-11-17 15:49   ` Ekansh Gupta
2026-11-17  9:39 ` [PATCH v4 3/3] misc: fastrpc: fix context leak and hang on signal-interrupted invoke Anandu Krishnan E
2026-11-24 14:47   ` Murali Krishna
2026-11-24 15:37     ` Renê [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=e6fd92e5bb6605ff3591c7813ac22055@renesp.com.br \
    --to=rene@renesp.com.br \
    --cc=anandu.e@oss.qualcomm.com \
    --cc=arnd@arndb.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ekansh.gupta@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jorge.ramirez@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=muralikrishna2444b@gmail.com \
    --cc=srini@kernel.org \
    --cc=srinivas.kandagatla@oss.qualcomm.com \
    /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