mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/8] state: fix compile warnings for dev_err expansion
@ 2017-07-05 10:56 Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 2/8] common: efi: do not use undefined kconfig option Steffen Trumtrar
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-05 10:56 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Fix the following warnings:

  CC      common/state/backend_format_dtb.o
In file included from include/common.h:33:0,
                 from common/state/backend_format_dtb.c:18:
common/state/backend_format_dtb.c: In function ‘state_backend_format_dtb_verify’:
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 4 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
   (level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
                                                    ^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
  __dev_printf(3, (dev) , format , ## arg)
  ^~~~~~~~~~~~
common/state/backend_format_dtb.c:52:3: note: in expansion of macro ‘dev_err’
   dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
   ^~~~~~~
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 5 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
   (level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
                                                    ^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
  __dev_printf(3, (dev) , format , ## arg)
  ^~~~~~~~~~~~
common/state/backend_format_dtb.c:52:3: note: in expansion of macro ‘dev_err’
   dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
   ^~~~~~~
  CC      common/state/backend_format_raw.o
In file included from include/common.h:33:0,
                 from common/state/backend_format_raw.c:18:
common/state/backend_format_raw.c: In function ‘backend_format_raw_verify’:
include/printk.h:52:52: warning: format ‘%d’ expects argument of type ‘int’, but
argument 4 has type ‘ssize_t {aka long int}’ [-Wformat=]
   (level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
                                                    ^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
  __dev_printf(3, (dev) , format , ## arg)
  ^~~~~~~~~~~~
common/state/backend_format_raw.c:111:3: note: in expansion of macro ‘dev_err’
   dev_err(backend_raw->dev, "Error, buffer length (%d) is shorter than the minimum required header length\n",
   ^~~~~~~
  CC      common/state/backend_storage.o
In file included from common/state/backend_storage.c:24:0:
common/state/backend_storage.c: In function ‘state_storage_mtd_buckets_init’:
include/printk.h:52:52: warning: format ‘%zu’ expects argument of type ‘size_t’,
but argument 5 has type ‘uint32_t {aka unsigned int}’ [-Wformat=]
   (level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
                                                    ^
include/printk.h:63:2: note: in expansion of macro ‘__dev_printf’
  __dev_printf(3, (dev) , format , ## arg)
  ^~~~~~~~~~~~
common/state/backend_storage.c:250:3: note: in expansion of macro ‘dev_err’
   dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %zu\n",
   ^~~~~~~

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/state/backend_format_dtb.c | 2 +-
 common/state/backend_format_raw.c | 2 +-
 common/state/backend_storage.c    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/state/backend_format_dtb.c b/common/state/backend_format_dtb.c
index e88cda499b64..4c9d2eefc780 100644
--- a/common/state/backend_format_dtb.c
+++ b/common/state/backend_format_dtb.c
@@ -49,7 +49,7 @@ static int state_backend_format_dtb_verify(struct state_backend_format *format,
 	size_t len = *lenp;
 
 	if (dtb_len > len) {
-		dev_err(fdtb->dev, "Error, stored DTB length (%d) longer than read buffer (%d)\n",
+		dev_err(fdtb->dev, "Error, stored DTB length (%zd) longer than read buffer (%zd)\n",
 			dtb_len, len);
 		return -EINVAL;
 	}
diff --git a/common/state/backend_format_raw.c b/common/state/backend_format_raw.c
index d76718cf8270..2ba97e08a0ae 100644
--- a/common/state/backend_format_raw.c
+++ b/common/state/backend_format_raw.c
@@ -108,7 +108,7 @@ static int backend_format_raw_verify(struct state_backend_format *format,
 	ssize_t complete_len;
 
 	if (len < format_raw_min_length) {
-		dev_err(backend_raw->dev, "Error, buffer length (%d) is shorter than the minimum required header length\n",
+		dev_err(backend_raw->dev, "Error, buffer length (%zd) is shorter than the minimum required header length\n",
 			len);
 		return -EINVAL;
 	}
diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
index 8d24f7053d3d..91135e99a64f 100644
--- a/common/state/backend_storage.c
+++ b/common/state/backend_storage.c
@@ -247,7 +247,7 @@ static int state_storage_mtd_buckets_init(struct state_backend_storage *storage,
 		end = meminfo->size;
 
 	if (!IS_ALIGNED(storage->offset, meminfo->erasesize)) {
-		dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %zu\n",
+		dev_err(storage->dev, "Offset within the device is not aligned to eraseblocks. Offset is %ld, erasesize %u\n",
 			storage->offset, meminfo->erasesize);
 		return -EINVAL;
 	}
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/8] common: efi: do not use undefined kconfig option
  2017-07-05 10:56 [PATCH 1/8] state: fix compile warnings for dev_err expansion Steffen Trumtrar
@ 2017-07-05 10:56 ` Steffen Trumtrar
  2017-07-05 11:05   ` Lucas Stach
  2017-07-05 10:56 ` [PATCH 3/8] fs: efi: return with correct error code in efifs_stat Steffen Trumtrar
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-05 10:56 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/efi/efi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/common/efi/efi.c b/common/efi/efi.c
index 05c58250f4a7..f924385958e1 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -266,8 +266,7 @@ static int efi_console_init(void)
 
 	add_generic_device("efi-stdio", DEVICE_ID_SINGLE, NULL, 0 , 0, 0, NULL);
 
-	if (IS_ENABLED(CONFIG_ARCH_EFI_REGISTER_COM1))
-		add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT,
+	add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT,
 				&ns16550_plat);
 
 	return 0;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/8] fs: efi: return with correct error code in efifs_stat
  2017-07-05 10:56 [PATCH 1/8] state: fix compile warnings for dev_err expansion Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 2/8] common: efi: do not use undefined kconfig option Steffen Trumtrar
@ 2017-07-05 10:56 ` Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 4/8] devfs-core: add function to find cdev by partuuid Steffen Trumtrar
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-05 10:56 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Instead of erroring out when a file is not present, just return ENOENT if the
file does not exist and let the fs-layer handle the situation correctly.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 fs/efi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/efi.c b/fs/efi.c
index 0c0f52e87c47..85ff914291ed 100644
--- a/fs/efi.c
+++ b/fs/efi.c
@@ -407,9 +407,7 @@ static int efifs_stat(struct device_d *dev, const char *filename, struct stat *s
 
 	efiret = priv->root_dir->open(priv->root_dir, &entry, efi_path, EFI_FILE_MODE_READ, 0ULL);
 	if (EFI_ERROR(efiret)) {
-		pr_err("%s: unable to Open %s: %s\n", __func__, filename,
-				efi_strerror(efiret));
-		ret = -efi_errno(efiret);
+		ret = -ENOENT;
 		goto out_free;
 	}
 
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/8] devfs-core: add function to find cdev by partuuid
  2017-07-05 10:56 [PATCH 1/8] state: fix compile warnings for dev_err expansion Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 2/8] common: efi: do not use undefined kconfig option Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 3/8] fs: efi: return with correct error code in efifs_stat Steffen Trumtrar
@ 2017-07-05 10:56 ` Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 5/8] of: of_path: find device via partuuid Steffen Trumtrar
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-05 10:56 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 fs/devfs-core.c  | 14 ++++++++++++++
 include/driver.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 3368d3ed68bd..be56edd18d80 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -95,6 +95,20 @@ struct cdev *cdev_by_device_node(struct device_node *node)
 	return NULL;
 }
 
+struct cdev *cdev_by_partuuid(const char *partuuid)
+{
+	struct cdev *cdev;
+
+	if (!partuuid)
+		return NULL;
+
+	list_for_each_entry(cdev, &cdev_list, list) {
+		if (!strcmp(cdev->partuuid, partuuid))
+			return cdev;
+	}
+	return NULL;
+}
+
 /**
  * device_find_partition - find a partition belonging to a physical device
  *
diff --git a/include/driver.h b/include/driver.h
index 3d701f24398a..8617872053d8 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -472,6 +472,7 @@ struct cdev *cdev_by_name(const char *filename);
 struct cdev *lcdev_by_name(const char *filename);
 struct cdev *cdev_readlink(struct cdev *cdev);
 struct cdev *cdev_by_device_node(struct device_node *node);
+struct cdev *cdev_by_partuuid(const char *partuuid);
 struct cdev *cdev_open(const char *name, unsigned long flags);
 struct cdev *cdev_create_loop(const char *path, ulong flags);
 void cdev_remove_loop(struct cdev *cdev);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 5/8] of: of_path: find device via partuuid
  2017-07-05 10:56 [PATCH 1/8] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (2 preceding siblings ...)
  2017-07-05 10:56 ` [PATCH 4/8] devfs-core: add function to find cdev by partuuid Steffen Trumtrar
@ 2017-07-05 10:56 ` Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 6/8] efi: efi: load state from devicetree Steffen Trumtrar
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-05 10:56 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

When a node is compatible to a fixed-partitions, support searching the
corresponding device via the partuuid, if it is specified in the devicetree.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 drivers/of/of_path.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
index 334eab841a01..e53041b0a16c 100644
--- a/drivers/of/of_path.c
+++ b/drivers/of/of_path.c
@@ -56,11 +56,26 @@ static int __of_find_path(struct device_node *node, const char *part, char **out
 
 	dev = of_find_device_by_node_path(node->full_name);
 	if (!dev) {
+		int ret;
+		const char *uuid;
 		struct device_node *devnode = node->parent;
 
-		if (of_device_is_compatible(devnode, "fixed-partitions"))
+		if (of_device_is_compatible(devnode, "fixed-partitions")) {
 			devnode = devnode->parent;
 
+			/* when partuuid is specified short-circuit the search for the cdev */
+			ret = of_property_read_string(node, "partuuid", &uuid);
+			if (!ret) {
+				cdev = cdev_by_partuuid(uuid);
+				if (!cdev)
+					return -ENODEV;
+
+				*outpath = basprintf("/dev/%s", cdev->name);
+
+				return 0;
+			}
+		}
+
 		dev = of_find_device_by_node_path(devnode->full_name);
 		if (!dev)
 			return -ENODEV;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 6/8] efi: efi: load state from devicetree
  2017-07-05 10:56 [PATCH 1/8] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (3 preceding siblings ...)
  2017-07-05 10:56 ` [PATCH 5/8] of: of_path: find device via partuuid Steffen Trumtrar
@ 2017-07-05 10:56 ` Steffen Trumtrar
  2017-07-05 12:38   ` Lucas Stach
  2017-07-05 10:56 ` [PATCH 7/8] blspec: skip all devicetree tests if entry doesn't specify one Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 8/8] efi: efi: register barebox-update handler Steffen Trumtrar
  6 siblings, 1 reply; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-05 10:56 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/efi/efi.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/common/efi/efi.c b/common/efi/efi.c
index f924385958e1..cc3051dedae9 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -40,6 +40,8 @@
 #include <efi.h>
 #include <efi/efi.h>
 #include <efi/efi-device.h>
+#include <libfile.h>
+#include <state.h>
 
 efi_runtime_services_t *RT;
 efi_boot_services_t *BS;
@@ -384,6 +386,60 @@ static int efi_postcore_init(void)
 }
 postcore_initcall(efi_postcore_init);
 
+static int efi_late_init(void)
+{
+	char *state_desc;
+	int ret;
+
+	state_desc = xasprintf("/boot/EFI/barebox/state.dtb");
+
+	if (state_desc) {
+		void *fdt;
+		size_t size;
+		struct device_node *root = NULL;
+		struct device_node *np = NULL;
+		struct state *state;
+
+		fdt = read_file(state_desc, &size);
+		if (!fdt) {
+			pr_err("unable to read %s: %s\n", state_desc,
+			       strerror(errno));
+			return -errno;
+		}
+
+		if (file_detect_type(fdt, size) != filetype_oftree) {
+			pr_err("%s is not an oftree file.\n", state_desc);
+			free(fdt);
+			return -EINVAL;
+		}
+
+		root = of_unflatten_dtb(fdt);
+
+		free(fdt);
+
+		if (IS_ERR(root))
+			return PTR_ERR(root);
+
+		of_set_root_node(root);
+
+		np = of_find_node_by_alias(root, "state");
+
+		state = state_new_from_node(np, NULL, 0, 0, false);
+		if (IS_ERR(state))
+			return PTR_ERR(state);
+
+		ret = state_load(state);
+		if (ret)
+			pr_warn("Failed to load persistent state, continuing with defaults, %d\n",
+				ret);
+
+		return 0;
+	}
+
+	return 0;
+}
+late_initcall(efi_late_init);
+
 static int do_efiexit(int argc, char *argv[])
 {
 	return BS->exit(efi_parent_image, EFI_SUCCESS, 0, NULL);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 7/8] blspec: skip all devicetree tests if entry doesn't specify one
  2017-07-05 10:56 [PATCH 1/8] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (4 preceding siblings ...)
  2017-07-05 10:56 ` [PATCH 6/8] efi: efi: load state from devicetree Steffen Trumtrar
@ 2017-07-05 10:56 ` Steffen Trumtrar
  2017-07-05 10:56 ` [PATCH 8/8] efi: efi: register barebox-update handler Steffen Trumtrar
  6 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-05 10:56 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

If the blspec entry does not specify a devicetree to test against,
it doesn't make any sense to check the compatible of the machine or
find the root node.

Instead of first testing the barebox devicetree check if the entry
specifies one.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/blspec.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/blspec.c b/common/blspec.c
index 8132d141ab5c..b258e6600bbe 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -361,6 +361,14 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 	const char *compat;
 	char *filename;
 
+	/* If the entry doesn't specifiy a devicetree we are compatible */
+	devicetree = blspec_entry_var_get(entry, "devicetree");
+	if (!devicetree)
+		return true;
+
+	if (!strcmp(devicetree, "none"))
+		return true;
+
 	/* If we don't have a root node every entry is compatible */
 	barebox_root = of_get_root_node();
 	if (!barebox_root)
@@ -375,14 +383,6 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 	else
 		abspath = "";
 
-	/* If the entry doesn't specifiy a devicetree we are compatible */
-	devicetree = blspec_entry_var_get(entry, "devicetree");
-	if (!devicetree)
-		return true;
-
-	if (!strcmp(devicetree, "none"))
-		return true;
-
 	filename = basprintf("%s/%s", abspath, devicetree);
 
 	fdt = read_file(filename, &size);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 8/8] efi: efi: register barebox-update handler
  2017-07-05 10:56 [PATCH 1/8] state: fix compile warnings for dev_err expansion Steffen Trumtrar
                   ` (5 preceding siblings ...)
  2017-07-05 10:56 ` [PATCH 7/8] blspec: skip all devicetree tests if entry doesn't specify one Steffen Trumtrar
@ 2017-07-05 10:56 ` Steffen Trumtrar
  6 siblings, 0 replies; 11+ messages in thread
From: Steffen Trumtrar @ 2017-07-05 10:56 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 common/efi/efi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/common/efi/efi.c b/common/efi/efi.c
index cc3051dedae9..2c3ad33976c4 100644
--- a/common/efi/efi.c
+++ b/common/efi/efi.c
@@ -42,6 +42,7 @@
 #include <efi/efi-device.h>
 #include <libfile.h>
 #include <state.h>
+#include <bbu.h>
 
 efi_runtime_services_t *RT;
 efi_boot_services_t *BS;
@@ -382,6 +383,9 @@ static int efi_postcore_init(void)
 		free(uuid16);
 	}
 
+	bbu_register_std_file_update("fat", 0,	"/boot/EFI/BOOT/BOOTx64.EFI",
+				     filetype_exe);
+
 	return 0;
 }
 postcore_initcall(efi_postcore_init);
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/8] common: efi: do not use undefined kconfig option
  2017-07-05 10:56 ` [PATCH 2/8] common: efi: do not use undefined kconfig option Steffen Trumtrar
@ 2017-07-05 11:05   ` Lucas Stach
  2017-07-06  7:31     ` Michael Olbrich
  0 siblings, 1 reply; 11+ messages in thread
From: Lucas Stach @ 2017-07-05 11:05 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

Am Mittwoch, den 05.07.2017, 12:56 +0200 schrieb Steffen Trumtrar:
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  common/efi/efi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/common/efi/efi.c b/common/efi/efi.c
> index 05c58250f4a7..f924385958e1 100644
> --- a/common/efi/efi.c
> +++ b/common/efi/efi.c
> @@ -266,8 +266,7 @@ static int efi_console_init(void)
>  
>  	add_generic_device("efi-stdio", DEVICE_ID_SINGLE, NULL, 0 , 0, 0, NULL);
>  
> -	if (IS_ENABLED(CONFIG_ARCH_EFI_REGISTER_COM1))

It seems we lost this option when moving arch/efi to arch/x86. As
unconditionally enabling the serial console may break some boards, the
proper fix should be to bring back the Kconfig option.

> -		add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT,
> +	add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT,
>  				&ns16550_plat);
>  
>  	return 0;



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 6/8] efi: efi: load state from devicetree
  2017-07-05 10:56 ` [PATCH 6/8] efi: efi: load state from devicetree Steffen Trumtrar
@ 2017-07-05 12:38   ` Lucas Stach
  0 siblings, 0 replies; 11+ messages in thread
From: Lucas Stach @ 2017-07-05 12:38 UTC (permalink / raw)
  To: Steffen Trumtrar; +Cc: barebox

Am Mittwoch, den 05.07.2017, 12:56 +0200 schrieb Steffen Trumtrar:
> Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> ---
>  common/efi/efi.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 56 insertions(+)
> 
> diff --git a/common/efi/efi.c b/common/efi/efi.c
> index f924385958e1..cc3051dedae9 100644
> --- a/common/efi/efi.c
> +++ b/common/efi/efi.c
> @@ -40,6 +40,8 @@
>  #include <efi.h>
>  #include <efi/efi.h>
>  #include <efi/efi-device.h>
> +#include <libfile.h>
> +#include <state.h>
>  
>  efi_runtime_services_t *RT;
>  efi_boot_services_t *BS;
> @@ -384,6 +386,60 @@ static int efi_postcore_init(void)
>  }
>  postcore_initcall(efi_postcore_init);
>  
> +static int efi_late_init(void)
> +{
> +	char *state_desc;
> +	int ret;
> +
> +	state_desc = xasprintf("/boot/EFI/barebox/state.dtb");

This might deserve a few sentences in the documentation, instead of
being buried in the code.

> +	if (state_desc) {
> +		void *fdt;
> +		size_t size;
> +		struct device_node *root = NULL;
> +		struct device_node *np = NULL;
> +		struct state *state;
> +
> +		fdt = read_file(state_desc, &size);
> +		if (!fdt) {
> +			pr_err("unable to read %s: %s\n", state_desc,
> +			       strerror(errno));
> +			return -errno;
> +		}
> +
> +		if (file_detect_type(fdt, size) != filetype_oftree) {
> +			pr_err("%s is not an oftree file.\n", state_desc);
> +			free(fdt);
> +			return -EINVAL;
> +		}
> +
> +		root = of_unflatten_dtb(fdt);
> +
> +		free(fdt);
> +
> +		if (IS_ERR(root))
> +			return PTR_ERR(root);
> +
> +		of_set_root_node(root);
> +
> +		np = of_find_node_by_alias(root, "state");
> +
> +		state = state_new_from_node(np, NULL, 0, 0, false);
> +		if (IS_ERR(state))
> +			return PTR_ERR(state);
> +
> +		ret = state_load(state);
> +		if (ret)
> +			pr_warn("Failed to load persistent state, continuing with defaults, %d\n",
> +				ret);
> +
> +		return 0;
> +	}
> +
> +	return 0;
> +}
> +late_initcall(efi_late_init);
> +
>  static int do_efiexit(int argc, char *argv[])
>  {
>  	return BS->exit(efi_parent_image, EFI_SUCCESS, 0, NULL);



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/8] common: efi: do not use undefined kconfig option
  2017-07-05 11:05   ` Lucas Stach
@ 2017-07-06  7:31     ` Michael Olbrich
  0 siblings, 0 replies; 11+ messages in thread
From: Michael Olbrich @ 2017-07-06  7:31 UTC (permalink / raw)
  To: barebox

On Wed, Jul 05, 2017 at 01:05:25PM +0200, Lucas Stach wrote:
> Am Mittwoch, den 05.07.2017, 12:56 +0200 schrieb Steffen Trumtrar:
> > Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> > ---
> >  common/efi/efi.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/common/efi/efi.c b/common/efi/efi.c
> > index 05c58250f4a7..f924385958e1 100644
> > --- a/common/efi/efi.c
> > +++ b/common/efi/efi.c
> > @@ -266,8 +266,7 @@ static int efi_console_init(void)
> >  
> >  	add_generic_device("efi-stdio", DEVICE_ID_SINGLE, NULL, 0 , 0, 0, NULL);
> >  
> > -	if (IS_ENABLED(CONFIG_ARCH_EFI_REGISTER_COM1))
> 
> It seems we lost this option when moving arch/efi to arch/x86. As
> unconditionally enabling the serial console may break some boards, the
> proper fix should be to bring back the Kconfig option.

I think that option is pretty much redundant. This is x86. There is no
device tree to enable devices.
There are only two possible scenarios: use ns16550 or not. Building the
driver and maybe use it does not exist. And we can use
CONFIG_DRIVER_SERIAL_NS16550 to choose.

Somewhat unrelated: I think this driver should be avoided if possible. I'm
quite certain, that the original use-case for this was a bug in barebox and
not a broken EFI serial driver.

Michael

> > -		add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT,
> > +	add_ns16550_device(0, 0x3f8, 0x10, IORESOURCE_IO | IORESOURCE_MEM_8BIT,
> >  				&ns16550_plat);
> >  
> >  	return 0;

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2017-07-06  7:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-05 10:56 [PATCH 1/8] state: fix compile warnings for dev_err expansion Steffen Trumtrar
2017-07-05 10:56 ` [PATCH 2/8] common: efi: do not use undefined kconfig option Steffen Trumtrar
2017-07-05 11:05   ` Lucas Stach
2017-07-06  7:31     ` Michael Olbrich
2017-07-05 10:56 ` [PATCH 3/8] fs: efi: return with correct error code in efifs_stat Steffen Trumtrar
2017-07-05 10:56 ` [PATCH 4/8] devfs-core: add function to find cdev by partuuid Steffen Trumtrar
2017-07-05 10:56 ` [PATCH 5/8] of: of_path: find device via partuuid Steffen Trumtrar
2017-07-05 10:56 ` [PATCH 6/8] efi: efi: load state from devicetree Steffen Trumtrar
2017-07-05 12:38   ` Lucas Stach
2017-07-05 10:56 ` [PATCH 7/8] blspec: skip all devicetree tests if entry doesn't specify one Steffen Trumtrar
2017-07-05 10:56 ` [PATCH 8/8] efi: efi: register barebox-update handler Steffen Trumtrar

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