Skip to content

Commit c99ba6e

Browse files
committed
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 <ardb@kernel.org>
1 parent c7c7bce commit c99ba6e

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
@@ -125,34 +125,8 @@ struct efi_runtime_work efi_rts_work;
125125
* thread waits for completion.
126126
*/
127127
#define efi_queue_work(_rts, _args...) \
128-
({ \
129-
efi_rts_work.efi_rts_id = EFI_ ## _rts; \
130-
efi_rts_work.args = &(union efi_rts_args){ ._rts = { _args }}; \
131-
efi_rts_work.status = EFI_ABORTED; \
132-
\
133-
if (!efi_enabled(EFI_RUNTIME_SERVICES)) { \
134-
pr_warn_once("EFI Runtime Services are disabled!\n"); \
135-
efi_rts_work.status = EFI_DEVICE_ERROR; \
136-
goto exit; \
137-
} \
138-
\
139-
init_completion(&efi_rts_work.efi_rts_comp); \
140-
INIT_WORK(&efi_rts_work.work, efi_call_rts); \
141-
\
142-
/* \
143-
* queue_work() returns 0 if work was already on queue, \
144-
* _ideally_ this should never happen. \
145-
*/ \
146-
if (queue_work(efi_rts_wq, &efi_rts_work.work)) \
147-
wait_for_completion(&efi_rts_work.efi_rts_comp); \
148-
else \
149-
pr_err("Failed to queue work to efi_rts_wq.\n"); \
150-
\
151-
WARN_ON_ONCE(efi_rts_work.status == EFI_ABORTED); \
152-
exit: \
153-
efi_rts_work.efi_rts_id = EFI_NONE; \
154-
efi_rts_work.status; \
155-
})
128+
__efi_queue_work(EFI_ ## _rts, \
129+
&(union efi_rts_args){ ._rts = { _args }})
156130

157131
#ifndef arch_efi_save_flags
158132
#define arch_efi_save_flags(state_flags) local_save_flags(state_flags)
@@ -319,6 +293,37 @@ static void efi_call_rts(struct work_struct *work)
319293
complete(&efi_rts_work.efi_rts_comp);
320294
}
321295

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

0 commit comments

Comments
 (0)