public inbox for linux-efi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] x86/efi: autoload efivars
@ 2014-07-09 10:39 Lee, Chun-Yi
       [not found] ` <1404902369-19434-1-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Lee, Chun-Yi @ 2014-07-09 10:39 UTC (permalink / raw)
  To: Matt Fleming
  Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA, Lee, Chun-Yi, Ben Hutchings

The original patch is from Ben Hutchings's contribution to debian
kernel. Got Ben's permission to remove the code of efi-pstore.c and
send to linux-efi:
https://github.com/BlankOn/linux-debian/blob/master/debian/patches/features/all/efi-autoload-efivars.patch

efivars is generally useful to have on EFI systems, and in some cases
it may be impossible to load it after a kernel upgrade in order to
complete a boot loader update. At the same time we don't want to waste
memory on non-EFI systems by making them built-in.

Instead, give them module aliases as if they are platform drivers, and
register a corresponding platform device whenever EFI runtime services
are available.  This should trigger udev to load them.

v2:
Moving platform device register code to drivers/firmware/efi/efi.c
ARM64 folks could also benefit from it.

Cc: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
Cc: Matt Fleming <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Lee, Chun-Yi <jlee-IBi9RG/b67k@public.gmane.org>
---
 drivers/firmware/efi/efi.c     | 15 +++++++++++++++
 drivers/firmware/efi/efivars.c |  1 +
 2 files changed, 16 insertions(+)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index eff1a2f..6fee86b 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -23,6 +23,7 @@
 #include <linux/of.h>
 #include <linux/of_fdt.h>
 #include <linux/io.h>
+#include <linux/platform_device.h>
 
 struct efi __read_mostly efi = {
 	.mps        = EFI_INVALID_TABLE_ADDR,
@@ -321,6 +322,20 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
 	return 0;
 }
 
+#ifdef CONFIG_EFI_VARS_MODULE
+static int __init efi_load_efivars(void)
+{
+	struct platform_device *pdev;
+
+	if (!efi_enabled(EFI_RUNTIME_SERVICES))
+		return 0;
+
+	pdev = platform_device_register_simple("efivars", 0, NULL, 0);
+	return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
+}
+device_initcall(efi_load_efivars);
+#endif
+
 #ifdef CONFIG_EFI_PARAMS_FROM_FDT
 
 #define UEFI_PARAM(name, prop, field)			   \
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index 463c565..f256ecd 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch-DYMqY+WieiM@public.gmane.org>");
 MODULE_DESCRIPTION("sysfs interface to EFI Variables");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(EFIVARS_VERSION);
+MODULE_ALIAS("platform:efivars");
 
 LIST_HEAD(efivar_sysfs_list);
 EXPORT_SYMBOL_GPL(efivar_sysfs_list);
-- 
1.8.4.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] x86/efi: autoload efivars
       [not found] ` <1404902369-19434-1-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
@ 2014-07-10 18:25   ` Matt Fleming
  0 siblings, 0 replies; 2+ messages in thread
From: Matt Fleming @ 2014-07-10 18:25 UTC (permalink / raw)
  To: Lee, Chun-Yi
  Cc: Matt Fleming, linux-efi-u79uwXL29TY76Z2rM5mHXA, Lee, Chun-Yi,
	Ben Hutchings

On Wed, 09 Jul, at 06:39:29PM, Lee, Chun-Yi wrote:
> The original patch is from Ben Hutchings's contribution to debian
> kernel. Got Ben's permission to remove the code of efi-pstore.c and
> send to linux-efi:
> https://github.com/BlankOn/linux-debian/blob/master/debian/patches/features/all/efi-autoload-efivars.patch
> 
> efivars is generally useful to have on EFI systems, and in some cases
> it may be impossible to load it after a kernel upgrade in order to
> complete a boot loader update. At the same time we don't want to waste
> memory on non-EFI systems by making them built-in.
> 
> Instead, give them module aliases as if they are platform drivers, and
> register a corresponding platform device whenever EFI runtime services
> are available.  This should trigger udev to load them.
> 
> v2:
> Moving platform device register code to drivers/firmware/efi/efi.c
> ARM64 folks could also benefit from it.
> 
> Cc: Ben Hutchings <ben-/+tVBieCtBitmTQ+vhA3Yw@public.gmane.org>
> Cc: Matt Fleming <matt.fleming-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Lee, Chun-Yi <jlee-IBi9RG/b67k@public.gmane.org>
> ---
>  drivers/firmware/efi/efi.c     | 15 +++++++++++++++
>  drivers/firmware/efi/efivars.c |  1 +
>  2 files changed, 16 insertions(+)

Thanks, applied.

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-10 18:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-09 10:39 [PATCH v2] x86/efi: autoload efivars Lee, Chun-Yi
     [not found] ` <1404902369-19434-1-git-send-email-jlee-IBi9RG/b67k@public.gmane.org>
2014-07-10 18:25   ` Matt Fleming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox