Hi RenĂª,

We independently hit and debugged this exact circular kref leak (introduced
by e85eb5feca8e) on a Snapdragon X Plus (x1p42100 / Purwa, Lenovo
IdeaCentre Mini 01Q8X10) running 7.3.0-38-qcom-x1e while stressing the
Hexagon v73 CDSP with multi-session llama.cpp NPU workloads.

Before applying the fix:
- Whenever a process aborted (SIGABRT/SIGKILL) while holding large
  FASTRPC_IOCTL_MEM_MAP DMA-buf mappings and an interrupted invoke
  (-ERESTARTSYS) left on fl->pending, fastrpc_user_free() never ran.
- ~10 GiB of system RAM remained permanently pinned after process exit,
  and the recycled compute-cb SMMU context bank stayed permanently
  exhausted (all subsequent FASTRPC_IOCTL_MEM_MAP calls failed with
  -ENOMEM until reboot).

After draining fl->pending in fastrpc_device_release() (and moving
fastrpc_session_free(fl->cctx, fl->sctx) into fastrpc_user_free() so the
SMMU context bank is not recycled until fl->maps are actually unmapped):
- Repeated intentional aborts leaked 0.0 GiB of RAM and left compute-cb
  SMMU IOVA completely clean; subsequent HTP0 runs succeeded immediately.

One review note to double-check on v2:
- If an in-flight DSP response is still pending when
fastrpc_device_release()
  returns (holding the last kref on fl until the rpmsg callback/workqueue
  finishes), keeping fastrpc_session_free(cctx, fl->sctx) in
  fastrpc_device_release() can recycle the compute-cb SMMU context bank
  before fastrpc_user_free() unmaps fl->maps. Moving fastrpc_session_free()
  into fastrpc_user_free() (after fl->maps are put) closes that window too.

Thanks for fixing this!

Reply via email to