Skip to content

Commit 6a6bc5e

Browse files
committed
efi/runtime-wrapper: Move workqueue manipulation out of line
JIRA: https://issues.redhat.com/browse/RHEL-22695 Tested: sanity commit c99ba6e Author: Ard Biesheuvel <[email protected]> Date: Sun Jul 2 15:57:13 2023 +0200 efi/runtime-wrapper: Move workqueue manipulation out of line efi_queue_work() is a macro that implements the non-trivial manipulation of the EFI runtime workqueue and completion data structure, most of which is generic, and could be shared between all the users of the macro. So move it out of the macro and into a new helper function. Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Aristeu Rozanski <[email protected]>
1 parent 3a938c2 commit 6a6bc5e

File tree

1 file changed

+33
-28
lines changed

1 file changed

+33
-28
lines changed

drivers/firmware/efi/runtime-wrappers.c

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,34 +123,8 @@ struct efi_runtime_work efi_rts_work;
123123
* thread waits for completion.
124124
*/
125125
#define efi_queue_work(_rts, _args...) \
126-
({ \
127-
efi_rts_work.efi_rts_id = EFI_ ## _rts; \
128-
efi_rts_work.args = &(union efi_rts_args){ ._rts = { _args }}; \
129-
efi_rts_work.status = EFI_ABORTED; \
130-
\
131-
if (!efi_enabled(EFI_RUNTIME_SERVICES)) { \
132-
pr_warn_once("EFI Runtime Services are disabled!\n"); \
133-
efi_rts_work.status = EFI_DEVICE_ERROR; \
134-
goto exit; \
135-
} \
136-
\
137-
init_completion(&efi_rts_work.efi_rts_comp); \
138-
INIT_WORK(&efi_rts_work.work, efi_call_rts); \
139-
\
140-
/* \
141-
* queue_work() returns 0 if work was already on queue, \
142-
* _ideally_ this should never happen. \
143-
*/ \
144-
if (queue_work(efi_rts_wq, &efi_rts_work.work)) \
145-
wait_for_completion(&efi_rts_work.efi_rts_comp); \
146-
else \
147-
pr_err("Failed to queue work to efi_rts_wq.\n"); \
148-
\
149-
WARN_ON_ONCE(efi_rts_work.status == EFI_ABORTED); \
150-
exit: \
151-
efi_rts_work.efi_rts_id = EFI_NONE; \
152-
efi_rts_work.status; \
153-
})
126+
__efi_queue_work(EFI_ ## _rts, \
127+
&(union efi_rts_args){ ._rts = { _args }})
154128

155129
#ifndef arch_efi_save_flags
156130
#define arch_efi_save_flags(state_flags) local_save_flags(state_flags)
@@ -317,6 +291,37 @@ static void efi_call_rts(struct work_struct *work)
317291
complete(&efi_rts_work.efi_rts_comp);
318292
}
319293

294+
static efi_status_t __efi_queue_work(enum efi_rts_ids id,
295+
union efi_rts_args *args)
296+
{
297+
efi_rts_work.efi_rts_id = id;
298+
efi_rts_work.args = args;
299+
efi_rts_work.status = EFI_ABORTED;
300+
301+
if (!efi_enabled(EFI_RUNTIME_SERVICES)) {
302+
pr_warn_once("EFI Runtime Services are disabled!\n");
303+
efi_rts_work.status = EFI_DEVICE_ERROR;
304+
goto exit;
305+
}
306+
307+
init_completion(&efi_rts_work.efi_rts_comp);
308+
INIT_WORK(&efi_rts_work.work, efi_call_rts);
309+
310+
/*
311+
* queue_work() returns 0 if work was already on queue,
312+
* _ideally_ this should never happen.
313+
*/
314+
if (queue_work(efi_rts_wq, &efi_rts_work.work))
315+
wait_for_completion(&efi_rts_work.efi_rts_comp);
316+
else
317+
pr_err("Failed to queue work to efi_rts_wq.\n");
318+
319+
WARN_ON_ONCE(efi_rts_work.status == EFI_ABORTED);
320+
exit:
321+
efi_rts_work.efi_rts_id = EFI_NONE;
322+
return efi_rts_work.status;
323+
}
324+
320325
static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
321326
{
322327
efi_status_t status;

0 commit comments

Comments
 (0)