]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
RDMA/hns: Support drain SQ and RQ
authorChengchang Tang <tangchengchang@huawei.com>
Thu, 8 Jan 2026 11:30:32 +0000 (19:30 +0800)
committerLeon Romanovsky <leon@kernel.org>
Thu, 15 Jan 2026 09:59:53 +0000 (04:59 -0500)
commit354e7a6d448b5744362bf33a24315d4d1d0bb7ef
tree02b53e8e58b1807e7a7dd3aad927c35152be4f18
parent5c3f795d17dc57a58a1fc1c1b449812e26ad85a3
RDMA/hns: Support drain SQ and RQ

Some ULPs, e.g. rpcrdma, rely on drain_qp() to ensure all outstanding
requests are completed before releasing related memory. If drain_qp()
fails, ULPs may release memory directly, and in-flight WRs may later be
flushed after the memory is freed, potentially leading to UAF.

drain_qp() failures can happen when HW enters an error state or is
reset. Add support to drain SQ and RQ in such cases by posting a
fake WR during reset, so the driver can process all remaining WRs in
sequence and generate corresponding completions.

Always invoke comp_handler() in drain process to ensure completions
are not lost under concurrency (e.g. concurrent post_send() and
reset, or QPs created during reset). If the CQ is already processed,
cancel any already scheduled comp_handler() to avoid concurrency
issues.

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20260108113032.856306-1-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hns/hns_roce_hw_v2.c