linux-yocto/drivers/firmware
Sudeep Holla 31405510a4 firmware: arm_ffa: Replace mutex with rwlock to avoid sleep in atomic context
commit 9ca7a42122 upstream.

The current use of a mutex to protect the notifier hashtable accesses
can lead to issues in the atomic context. It results in the below
kernel warnings:

  |  BUG: sleeping function called from invalid context at kernel/locking/mutex.c:258
  |  in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 9, name: kworker/0:0
  |  preempt_count: 1, expected: 0
  |  RCU nest depth: 0, expected: 0
  |  CPU: 0 UID: 0 PID: 9 Comm: kworker/0:0 Not tainted 6.14.0 #4
  |  Workqueue: ffa_pcpu_irq_notification notif_pcpu_irq_work_fn
  |  Call trace:
  |   show_stack+0x18/0x24 (C)
  |   dump_stack_lvl+0x78/0x90
  |   dump_stack+0x18/0x24
  |   __might_resched+0x114/0x170
  |   __might_sleep+0x48/0x98
  |   mutex_lock+0x24/0x80
  |   handle_notif_callbacks+0x54/0xe0
  |   notif_get_and_handle+0x40/0x88
  |   generic_exec_single+0x80/0xc0
  |   smp_call_function_single+0xfc/0x1a0
  |   notif_pcpu_irq_work_fn+0x2c/0x38
  |   process_one_work+0x14c/0x2b4
  |   worker_thread+0x2e4/0x3e0
  |   kthread+0x13c/0x210
  |   ret_from_fork+0x10/0x20

To address this, replace the mutex with an rwlock to protect the notifier
hashtable accesses. This ensures that read-side locking does not sleep and
multiple readers can acquire the lock concurrently, avoiding unnecessary
contention and potential deadlocks. Writer access remains exclusive,
preserving correctness.

This change resolves warnings from lockdep about potential sleep in
atomic context.

Cc: Jens Wiklander <jens.wiklander@linaro.org>
Reported-by: Jérôme Forissier <jerome.forissier@linaro.org>
Closes: https://github.com/OP-TEE/optee_os/issues/7394
Fixes: e0573444ed ("firmware: arm_ffa: Add interfaces to request notification callbacks")
Message-Id: <20250528-ffa_notif_fix-v1-3-5ed7bc7f8437@arm.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-07-10 16:04:44 +02:00
..
arm_ffa firmware: arm_ffa: Replace mutex with rwlock to avoid sleep in atomic context 2025-07-10 16:04:44 +02:00
arm_scmi firmware: arm_scmi: Ensure that the message-id supports fastchannel 2025-06-27 11:11:22 +01:00
broadcom
cirrus firmware: cs_dsp: Ensure cs_dsp_load[_coeff]() returns 0 on success 2025-04-10 14:39:32 +02:00
efi efi/libstub: Describe missing 'out' parameter in efi_load_initrd 2025-06-19 15:31:48 +02:00
google firmware: google: Unregister driver_info on failure 2024-12-05 14:01:16 +01:00
imx firmware: imx-scu: fix OF node leak in .probe() 2025-03-28 22:03:24 +01:00
meson firmware: meson_sm: add missing MODULE_DESCRIPTION() macro 2024-06-24 10:08:53 +02:00
microchip firmware: microchip: auto-update: fix poll_complete() to not report spurious timeout errors 2024-10-17 17:13:30 +01:00
psci firmware: psci: Fix refcount leak in psci_dt_init 2025-06-19 15:31:37 +02:00
qcom firmware: qcom: uefisecapp: fix efivars registration race 2025-03-28 22:03:30 +01:00
smccc arm64: smccc: Remove broken support for SMCCCv1.3 SVE discard hint 2024-11-07 11:18:52 +00:00
tegra firmware: tegra: bpmp: Use scoped device node handling to simplify error paths 2024-08-27 15:58:38 +02:00
xilinx firmware: xilinx: Dont send linux address to get fpga config get status 2025-05-29 11:02:47 +02:00
arm_scpi.c firmware: arm_scpi: Check the DVFS OPP count returned by the firmware 2024-12-05 14:01:34 +01:00
arm_sdei.c firmware: SDEI: Allow sdei initialization without ACPI_APEI_GHES 2025-06-19 15:31:38 +02:00
dmi_scan.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
dmi-id.c firmware: dmi-id: add a release callback function 2024-04-08 09:34:24 +02:00
dmi-sysfs.c
edd.c
iscsi_ibft_find.c
iscsi_ibft.c iscsi_ibft: Fix UBSAN shift-out-of-bounds warning in ibft_attr_show_nic() 2025-03-22 12:54:14 -07:00
Kconfig firmware: SDEI: Allow sdei initialization without ACPI_APEI_GHES 2025-06-19 15:31:38 +02:00
Makefile Core: 2024-01-12 13:54:25 -08:00
memmap.c
mtk-adsp-ipc.c firmware: mtk-adsp-ipc: Convert to platform remove callback returning void 2024-01-04 17:01:14 +01:00
qemu_fw_cfg.c fw_cfg: Constify struct kobj_type 2024-09-25 07:07:44 -04:00
raspberrypi.c firmware: raspberrypi: Improve timeout warning 2024-08-13 13:21:28 -07:00
stratix10-rsu.c firmware: stratix10-rsu: Convert to platform remove callback returning void 2024-01-04 17:01:15 +01:00
stratix10-svc.c firmware: stratix10-svc: Add of_platform_default_populate() 2025-05-02 07:59:10 +02:00
sysfb_simplefb.c firmware/sysfb: Set firmware-framebuffer parent device 2024-02-14 10:09:17 +01:00
sysfb.c sysfb: Fix screen_info type check for VGA 2025-06-27 11:11:23 +01:00
ti_sci.c firmware: ti_sci: Unconditionally register reset handler 2024-04-09 11:05:10 -05:00
ti_sci.h firmware: ti_sci: fix TISCI protocol URL link 2024-06-27 17:44:48 -05:00
trusted_foundations.c
turris-mox-rwtm.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00