Commit 129c668
committed
firmware: arm_ffa: Replace mutex with rwlock to avoid sleep in atomic context
JIRA: https://issues.redhat.com/browse/RHEL-102692
commit 9ca7a42
Author: Sudeep Holla <sudeep.holla@arm.com>
Date: Wed, 28 May 2025 09:49:43 +0100
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: OP-TEE/optee_os#7394
Fixes: e057344 ("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: Marcin Juszkiewicz <mjuszkiewicz@redhat.com>
Message-ID: <d2632a513f05ec79f4fffa92d618792eb3cea12f.1752653152.git.mjuszkiewicz@redhat.com>
Message-ID: <b4e3e2e1248ca9909bdea280d9009bdb659d0c81.1752659027.git.mjuszkiewicz@redhat.com>1 parent a4db2f7 commit 129c668
1 file changed
+11
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
1289 | 1289 | | |
1290 | 1290 | | |
1291 | 1291 | | |
1292 | | - | |
| 1292 | + | |
1293 | 1293 | | |
1294 | 1294 | | |
1295 | 1295 | | |
1296 | 1296 | | |
1297 | | - | |
| 1297 | + | |
1298 | 1298 | | |
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
1302 | 1302 | | |
1303 | 1303 | | |
1304 | | - | |
| 1304 | + | |
1305 | 1305 | | |
1306 | 1306 | | |
1307 | 1307 | | |
| |||
1341 | 1341 | | |
1342 | 1342 | | |
1343 | 1343 | | |
1344 | | - | |
| 1344 | + | |
1345 | 1345 | | |
1346 | 1346 | | |
1347 | 1347 | | |
| |||
1361 | 1361 | | |
1362 | 1362 | | |
1363 | 1363 | | |
1364 | | - | |
| 1364 | + | |
1365 | 1365 | | |
1366 | 1366 | | |
1367 | 1367 | | |
| |||
1407 | 1407 | | |
1408 | 1408 | | |
1409 | 1409 | | |
1410 | | - | |
| 1410 | + | |
1411 | 1411 | | |
1412 | | - | |
| 1412 | + | |
1413 | 1413 | | |
1414 | 1414 | | |
1415 | 1415 | | |
| |||
1447 | 1447 | | |
1448 | 1448 | | |
1449 | 1449 | | |
1450 | | - | |
| 1450 | + | |
1451 | 1451 | | |
1452 | | - | |
| 1452 | + | |
1453 | 1453 | | |
1454 | 1454 | | |
1455 | 1455 | | |
| |||
1974 | 1974 | | |
1975 | 1975 | | |
1976 | 1976 | | |
1977 | | - | |
| 1977 | + | |
1978 | 1978 | | |
1979 | 1979 | | |
1980 | 1980 | | |
| |||
0 commit comments