Skip to content

Commit c9b51a2

Browse files
committed
efi: pstore: move workqueue handling out of efivars
The worker thread that gets kicked off to sync the state of the EFI variable list is only used by the EFI pstore implementation, and is defined in its source file. So let's move its scheduling there as well. Since our efivar_init() scan will bail on duplicate entries, there is no need to disable the workqueue like we did before, so we can run it unconditionally. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 232f4eb commit c9b51a2

3 files changed

Lines changed: 5 additions & 26 deletions

File tree

drivers/firmware/efi/efi-pstore.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module_param_named(pstore_disable, efivars_pstore_disable, bool, 0644);
2121
EFI_VARIABLE_RUNTIME_ACCESS)
2222

2323
static LIST_HEAD(efi_pstore_list);
24+
static DECLARE_WORK(efivar_work, NULL);
2425

2526
static int efi_pstore_open(struct pstore_info *psi)
2627
{
@@ -267,8 +268,9 @@ static int efi_pstore_write(struct pstore_record *record)
267268
ret = efivar_entry_set_safe(efi_name, vendor, PSTORE_EFI_ATTRIBUTES,
268269
preemptible(), record->size, record->psi->buf);
269270

270-
if (record->reason == KMSG_DUMP_OOPS)
271-
efivar_run_worker();
271+
if (record->reason == KMSG_DUMP_OOPS && try_module_get(THIS_MODULE))
272+
if (!schedule_work(&efivar_work))
273+
module_put(THIS_MODULE);
272274

273275
return ret;
274276
};
@@ -412,6 +414,7 @@ static void efi_pstore_update_entries(struct work_struct *work)
412414
}
413415

414416
kfree(entry);
417+
module_put(THIS_MODULE);
415418
}
416419

417420
static __init int efivars_pstore_init(void)

drivers/firmware/efi/vars.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ static struct efivars *__efivars;
3232
*/
3333
static DEFINE_SEMAPHORE(efivars_lock);
3434

35-
static bool efivar_wq_enabled = true;
36-
DECLARE_WORK(efivar_work, NULL);
37-
EXPORT_SYMBOL_GPL(efivar_work);
38-
3935
static bool
4036
validate_device_path(efi_char16_t *var_name, int match, u8 *buffer,
4137
unsigned long len)
@@ -391,13 +387,6 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
391387
size_t i, len8 = len16 / sizeof(efi_char16_t);
392388
char *str8;
393389

394-
/*
395-
* Disable the workqueue since the algorithm it uses for
396-
* detecting new variables won't work with this buggy
397-
* implementation of GetNextVariableName().
398-
*/
399-
efivar_wq_enabled = false;
400-
401390
str8 = kzalloc(len8, GFP_KERNEL);
402391
if (!str8)
403392
return;
@@ -1157,16 +1146,6 @@ struct kobject *efivars_kobject(void)
11571146
}
11581147
EXPORT_SYMBOL_GPL(efivars_kobject);
11591148

1160-
/**
1161-
* efivar_run_worker - schedule the efivar worker thread
1162-
*/
1163-
void efivar_run_worker(void)
1164-
{
1165-
if (efivar_wq_enabled)
1166-
schedule_work(&efivar_work);
1167-
}
1168-
EXPORT_SYMBOL_GPL(efivar_run_worker);
1169-
11701149
/**
11711150
* efivars_register - register an efivars
11721151
* @efivars: efivars to register

include/linux/efi.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,9 +1037,6 @@ bool efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data,
10371037
bool efivar_variable_is_removable(efi_guid_t vendor, const char *name,
10381038
size_t len);
10391039

1040-
extern struct work_struct efivar_work;
1041-
void efivar_run_worker(void);
1042-
10431040
#if defined(CONFIG_EFI_VARS) || defined(CONFIG_EFI_VARS_MODULE)
10441041
int efivars_sysfs_init(void);
10451042

0 commit comments

Comments
 (0)