From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F408315A4 for ; Tue, 7 Nov 2023 15:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QxFz+MoD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A459C433C9; Tue, 7 Nov 2023 15:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699372286; bh=fHECVXCA9kBg7wn2FEewS8EWFTSrhdqoJ78J3M3bsJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QxFz+MoDYwQ1ZBZaBv9yvjCLwkj1DCDB1exuziW7pmj33S19t9ojvRkk+XXm1okIm OdV2xTu8Re3P049soO1UqKrOSwSQ8YRFjqB1w4cMglmbwnpQzRJyW8nhH3uKZdMyzB CJI/WBQsENvWsShNn086O30RJXOZ5ZJlXCpMADvbGjMU/x7g9XK0ISPWwu5bsccPGC c9T3qHqQxWXEd67SfAGK+dOHVtS5e/d/MOCwSYgyuFgpq8M6S+a6N8Pqp/EnfM8Ef+ 6omxXpt7O/Mi6ibW1DRlWnnPVE+C9+jbS8ZbJir8SnankxOFRsJ9ti7td3PblYgq0h bypUStj8blEug== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Longfang Liu , Herbert Xu , Sasha Levin , qianweili@huawei.com, wangzhou1@hisilicon.com, davem@davemloft.net, linux-crypto@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 27/30] crypto: hisilicon/qm - prevent soft lockup in receive loop Date: Tue, 7 Nov 2023 10:50:01 -0500 Message-ID: <20231107155024.3766950-27-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231107155024.3766950-1-sashal@kernel.org> References: <20231107155024.3766950-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.61 Content-Transfer-Encoding: 8bit From: Longfang Liu [ Upstream commit 33fc506d2ac514be1072499a263c3bff8c7c95a0 ] In the scenario where the accelerator business is fully loaded. When the workqueue receiving messages and performing callback processing, there are a large number of messages that need to be received, and there are continuously messages that have been processed and need to be received. This will cause the receive loop here to be locked for a long time. This scenario will cause watchdog timeout problems on OS with kernel preemption turned off. The error logs: watchdog: BUG: soft lockup - CPU#23 stuck for 23s! [kworker/u262:1:1407] [ 1461.978428][ C23] Call trace: [ 1461.981890][ C23] complete+0x8c/0xf0 [ 1461.986031][ C23] kcryptd_async_done+0x154/0x1f4 [dm_crypt] [ 1461.992154][ C23] sec_skcipher_callback+0x7c/0xf4 [hisi_sec2] [ 1461.998446][ C23] sec_req_cb+0x104/0x1f4 [hisi_sec2] [ 1462.003950][ C23] qm_poll_req_cb+0xcc/0x150 [hisi_qm] [ 1462.009531][ C23] qm_work_process+0x60/0xc0 [hisi_qm] [ 1462.015101][ C23] process_one_work+0x1c4/0x470 [ 1462.020052][ C23] worker_thread+0x150/0x3c4 [ 1462.024735][ C23] kthread+0x108/0x13c [ 1462.028889][ C23] ret_from_fork+0x10/0x18 Therefore, it is necessary to add an actively scheduled operation in the while loop to prevent this problem. After adding it, no matter whether the OS turns on or off the kernel preemption function. Neither will cause watchdog timeout issues. Signed-off-by: Longfang Liu Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/hisilicon/qm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 07e1e39a5e378..02f61a4dce09a 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -972,6 +972,8 @@ static void qm_poll_req_cb(struct hisi_qp *qp) qm_db(qm, qp->qp_id, QM_DOORBELL_CMD_CQ, qp->qp_status.cq_head, 0); atomic_dec(&qp->qp_status.used); + + cond_resched(); } /* set c_flag */ -- 2.42.0