WSL2-Linux-Kernel/drivers/crypto/qat/qat_common
Giovanni Cabiddu a2ae48bd82 crypto: qat - fix deadlock in backlog processing
[ Upstream commit 203b01001c4d741205b9c329acddc5193ed56fbd ]

If a request has the flag CRYPTO_TFM_REQ_MAY_BACKLOG set, the function
qat_alg_send_message_maybacklog(), enqueues it in a backlog list if
either (1) there is already at least one request in the backlog list, or
(2) the HW ring is nearly full or (3) the enqueue to the HW ring fails.
If an interrupt occurs right before the lock in qat_alg_backlog_req() is
taken and the backlog queue is being emptied, then there is no request
in the HW queues that can trigger a subsequent interrupt that can clear
the backlog queue. In addition subsequent requests are enqueued to the
backlog list and not sent to the hardware.

Fix it by holding the lock while taking the decision if the request
needs to be included in the backlog queue or not. This synchronizes the
flow with the interrupt handler that drains the backlog queue.

For performance reasons, the logic has been changed to try to enqueue
first without holding the lock.

Fixes: 3868238397 ("crypto: qat - add backlog mechanism")
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Closes: https://lore.kernel.org/all/af9581e2-58f9-cc19-428f-6f18f1f83d54@redhat.com/T/
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-20 11:08:24 +01:00
..
Makefile crypto: qat - refactor submission logic 2022-07-29 17:25:27 +02:00
adf_accel_devices.h crypto: qat - increase size of buffers 2023-11-20 11:08:22 +01:00
adf_accel_engine.c crypto: qat - target fw images to specific AEs 2020-11-20 14:45:34 +11:00
adf_admin.c crypto: qat - remove cast for mailbox CSR 2020-11-13 20:38:43 +11:00
adf_aer.c crypto: qat - fix a typo in a comment 2021-08-21 15:44:54 +08:00
adf_cfg.c crypto: qat - change return value in adf_cfg_key_val_get() 2020-10-30 17:34:59 +11:00
adf_cfg.h crypto: qat - convert to SPDX License Identifiers 2020-06-18 17:19:44 +10:00
adf_cfg_common.h crypto: qat - add qat_4xxx driver 2020-11-20 14:45:34 +11:00
adf_cfg_strings.h crypto: qat - allow for instances in different banks 2020-10-30 17:35:01 +11:00
adf_cfg_user.h crypto: qat - replace user types with kernel ABI __u types 2020-06-18 17:26:42 +10:00
adf_common_drv.h crypto: qat - replace get_current_node() with numa_node_id() 2023-07-23 13:47:16 +02:00
adf_ctl_drv.c crypto: qat - ratelimit invalid ioctl message and print the invalid cmd 2021-06-28 11:28:08 +08:00
adf_dev_mgr.c crypto: qat - fix excluded_middle.cocci warnings 2020-11-27 17:13:41 +11:00
adf_gen2_hw_data.c crypto: qat - set COMPRESSION capability for QAT GEN2 2022-06-09 10:23:05 +02:00
adf_gen2_hw_data.h crypto: qat - set COMPRESSION capability for QAT GEN2 2022-06-09 10:23:05 +02:00
adf_gen4_hw_data.c crypto: qat - enable detection of accelerators hang 2021-04-16 21:16:34 +10:00
adf_gen4_hw_data.h crypto: qat - fix default value of WDT timer 2022-10-26 12:35:24 +02:00
adf_hw_arbiter.c crypto: qat - configure arbiter mapping based on engines enabled 2021-01-14 17:10:26 +11:00
adf_init.c crypto: qat - power up 4xxx device 2021-11-18 19:16:25 +01:00
adf_isr.c crypto: qat - protect interrupt mask CSRs with a spinlock 2021-08-21 15:44:56 +08:00
adf_pf2vf_msg.c crypto: qat - fix undetected PFVF timeout in ACK loop 2022-01-27 11:03:17 +01:00
adf_pf2vf_msg.h crypto: qat - rename compatibility version definition 2021-08-21 15:44:55 +08:00
adf_sriov.c crypto: qat - remove intermediate tasklet for vf2pf 2021-08-21 15:44:55 +08:00
adf_transport.c crypto: qat - add backlog mechanism 2022-07-29 17:25:27 +02:00
adf_transport.h crypto: qat - add backlog mechanism 2022-07-29 17:25:27 +02:00
adf_transport_access_macros.h crypto: qat - remove hardcoded bank irq clear flag mask 2020-10-30 17:34:57 +11:00
adf_transport_debug.c crypto: qat - increase size of buffers 2023-11-20 11:08:22 +01:00
adf_transport_internal.h crypto: qat - add backlog mechanism 2022-07-29 17:25:27 +02:00
adf_vf2pf_msg.c crypto: qat - fix naming for init/shutdown VF to PF notifications 2021-08-21 15:44:56 +08:00
adf_vf_isr.c crypto: qat - disregard spurious PFVF interrupts 2021-11-18 19:16:31 +01:00
icp_qat_fw.h crypto: qat - replace user types with kernel ABI __u types 2020-06-18 17:26:42 +10:00
icp_qat_fw_init_admin.h crypto: qat - rename ME in AE 2020-10-30 17:34:49 +11:00
icp_qat_fw_la.h crypto: qat - add AES-CTR support for QAT GEN4 devices 2020-12-11 21:54:15 +11:00
icp_qat_fw_loader_handle.h crypto: qat - check MMP size before writing to the SRAM 2021-05-28 14:20:40 +08:00
icp_qat_fw_pke.h crypto: qat - replace user types with kernel ABI __u types 2020-06-18 17:26:42 +10:00
icp_qat_hal.h crypto: qat - add gen4 firmware loader 2020-11-13 20:38:55 +11:00
icp_qat_hw.h crypto: qat - add AES-CTR support for QAT GEN4 devices 2020-12-11 21:54:15 +11:00
icp_qat_uclo.h crypto: qat - add gen4 firmware loader 2020-11-13 20:38:55 +11:00
qat_algs.c crypto: qat - replace get_current_node() with numa_node_id() 2023-07-23 13:47:16 +02:00
qat_algs_send.c crypto: qat - fix deadlock in backlog processing 2023-11-20 11:08:24 +01:00
qat_algs_send.h crypto: qat - add backlog mechanism 2022-07-29 17:25:27 +02:00
qat_asym_algs.c crypto: qat - unmap buffers before free for RSA 2023-07-23 13:47:16 +02:00
qat_crypto.c crypto: qat - re-enable registration of algorithms 2022-07-29 17:25:28 +02:00
qat_crypto.h crypto: qat - honor CRYPTO_TFM_REQ_MAY_SLEEP flag 2023-07-23 13:47:15 +02:00
qat_hal.c crypto: qat - check return code of qat_hal_rd_rel_reg() 2021-05-28 14:20:40 +08:00
qat_uclo.c crypto: qat - remove unused macro in FW loader 2021-05-28 14:20:40 +08:00