aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-04-19 08:14:15 -0400
committerTom Rini <trini@konsulko.com>2022-04-19 08:14:15 -0400
commitaec75a3d1d8ad9268881c8e9d03bc205b5063848 (patch)
tree3a1b5cdaf53927f248bace6f6face7155788687f
parent9859465bfe838bc8264d45e1a1bed847bba74bad (diff)
parentcdd73e7215b838095984f02554fc1bc4186124af (diff)
downloadu-boot-aec75a3d1d8ad9268881c8e9d03bc205b5063848.zip
u-boot-aec75a3d1d8ad9268881c8e9d03bc205b5063848.tar.gz
u-boot-aec75a3d1d8ad9268881c8e9d03bc205b5063848.tar.bz2
Merge branch '2022-04-18-dm-reducing-spl-memory-usage'
- Assorted DM cleanups from Simon. This results in some noticeable binary size savings in SPL.
-rw-r--r--Makefile4
-rw-r--r--arch/sandbox/config.mk4
-rw-r--r--arch/sandbox/cpu/os.c2
-rw-r--r--arch/sandbox/cpu/u-boot-spl.lds2
-rw-r--r--arch/sandbox/cpu/u-boot.lds2
-rw-r--r--config.mk1
-rw-r--r--drivers/core/Makefile2
-rw-r--r--drivers/core/device.c5
-rw-r--r--drivers/core/root.c8
-rw-r--r--include/dm/device-internal.h6
-rw-r--r--include/dm/device.h10
-rw-r--r--include/dm/devres.h4
-rw-r--r--test/dm/Makefile2
13 files changed, 31 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 9b25536..7937a4c 100644
--- a/Makefile
+++ b/Makefile
@@ -1785,10 +1785,6 @@ quiet_cmd_u-boot__ ?= LTO $@
-Wl,-Map,u-boot.map; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
else
-# Note: Linking efi-x86_app64 causes a segfault in the linker at present
-# when using x86_64-linux-gnu-ld.bfd
-# For now, disable --whole-archive which makes things link, although not
-# correctly
quiet_cmd_u-boot__ ?= LD $@
cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \
-T u-boot.lds $(u-boot-init) \
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 2b1b657..02a3ba0 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -16,7 +16,7 @@ PLATFORM_CPPFLAGS += $(shell $(SDL_CONFIG) --cflags)
endif
cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
- $(LTO_FINAL_LDFLAGS) \
+ $(KBUILD_LDFLAGS:%=-Wl,%)$(LTO_FINAL_LDFLAGS) \
-Wl,--whole-archive \
$(u-boot-main) \
$(u-boot-keep-syms-lto) \
@@ -24,7 +24,7 @@ cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \
$(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map
cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \
- $(LTO_FINAL_LDFLAGS) \
+ $(KBUILD_LDFLAGS:%=-Wl,%) $(LTO_FINAL_LDFLAGS) \
$(patsubst $(obj)/%,%,$(u-boot-spl-init)) \
-Wl,--whole-archive \
$(patsubst $(obj)/%,%,$(u-boot-spl-main)) \
diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index d83c862..5ea5417 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -644,7 +644,7 @@ int os_get_filesize(const char *fname, long long *size)
void os_putc(int ch)
{
- fputc(ch, stdout);
+ os_write(1, &ch, 1);
}
void os_puts(const char *str)
diff --git a/arch/sandbox/cpu/u-boot-spl.lds b/arch/sandbox/cpu/u-boot-spl.lds
index 6754f4e..206e265 100644
--- a/arch/sandbox/cpu/u-boot-spl.lds
+++ b/arch/sandbox/cpu/u-boot-spl.lds
@@ -8,7 +8,7 @@
SECTIONS
{
- . = ALIGN(4);
+ . = ALIGN(32);
.u_boot_list : {
KEEP(*(SORT(.u_boot_list*)));
}
diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds
index 6d71061..92e834a 100644
--- a/arch/sandbox/cpu/u-boot.lds
+++ b/arch/sandbox/cpu/u-boot.lds
@@ -8,7 +8,7 @@
SECTIONS
{
- . = ALIGN(4);
+ . = ALIGN(32);
.u_boot_list : {
KEEP(*(SORT(.u_boot_list*)));
}
diff --git a/config.mk b/config.mk
index 2595aed..b915c29 100644
--- a/config.mk
+++ b/config.mk
@@ -12,7 +12,6 @@
# If we did not have Tegra SoCs, build system would be much simpler...)
PLATFORM_RELFLAGS :=
PLATFORM_CPPFLAGS :=
-KBUILD_LDFLAGS :=
LDFLAGS_FINAL :=
LDFLAGS_STANDALONE :=
OBJCOPYFLAGS :=
diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index 3742e75..7099073 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -4,7 +4,7 @@
obj-y += device.o fdtaddr.o lists.o root.o uclass.o util.o tag.o
obj-$(CONFIG_$(SPL_TPL_)ACPIGEN) += acpi.o
-obj-$(CONFIG_DEVRES) += devres.o
+obj-$(CONFIG_$(SPL_TPL_)DEVRES) += devres.o
obj-$(CONFIG_$(SPL_)DM_DEVICE_REMOVE) += device-remove.o
obj-$(CONFIG_$(SPL_)SIMPLE_BUS) += simple-bus.o
obj-$(CONFIG_SIMPLE_PM_BUS) += simple-pm-bus.o
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 1b356f1..3ab2583 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -68,7 +68,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
INIT_LIST_HEAD(&dev->sibling_node);
INIT_LIST_HEAD(&dev->child_head);
INIT_LIST_HEAD(&dev->uclass_node);
-#ifdef CONFIG_DEVRES
+#if CONFIG_IS_ENABLED(DEVRES)
INIT_LIST_HEAD(&dev->devres_head);
#endif
dev_set_plat(dev, plat);
@@ -1186,7 +1186,8 @@ int dev_enable_by_path(const char *path)
static struct udevice_rt *dev_get_rt(const struct udevice *dev)
{
struct udevice *base = ll_entry_start(struct udevice, udevice);
- int idx = dev - base;
+ uint each_size = dm_udevice_size();
+ int idx = ((void *)dev - (void *)base) / each_size;
struct udevice_rt *urt = gd_dm_udevice_rt() + idx;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 86b3884..e09c12f 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -136,12 +136,18 @@ static int dm_setup_inst(void)
if (CONFIG_IS_ENABLED(OF_PLATDATA_RT)) {
struct udevice_rt *urt;
+ void *start, *end;
+ int each_size;
void *base;
int n_ents;
uint size;
/* Allocate the udevice_rt table */
- n_ents = ll_entry_count(struct udevice, udevice);
+ each_size = dm_udevice_size();
+ start = ll_entry_start(struct udevice, udevice);
+ end = ll_entry_end(struct udevice, udevice);
+ size = end - start;
+ n_ents = size / each_size;
urt = calloc(n_ents, sizeof(struct udevice_rt));
if (!urt)
return log_msg_ret("urt", -ENOMEM);
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index e24b033..94844d3 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -397,7 +397,7 @@ fdt_addr_t simple_bus_translate(struct udevice *dev, fdt_addr_t addr);
#define DM_UCLASS_ROOT_S_NON_CONST (((gd_t *)gd)->uclass_root_s)
/* device resource management */
-#ifdef CONFIG_DEVRES
+#if CONFIG_IS_ENABLED(DEVRES)
/**
* devres_release_probe - Release managed resources allocated after probing
@@ -417,7 +417,7 @@ void devres_release_probe(struct udevice *dev);
*/
void devres_release_all(struct udevice *dev);
-#else /* ! CONFIG_DEVRES */
+#else /* ! DEVRES */
static inline void devres_release_probe(struct udevice *dev)
{
@@ -427,7 +427,7 @@ static inline void devres_release_all(struct udevice *dev)
{
}
-#endif /* ! CONFIG_DEVRES */
+#endif /* DEVRES */
static inline int device_notify(const struct udevice *dev, enum event_t type)
{
diff --git a/include/dm/device.h b/include/dm/device.h
index cb52a09..e0f86f5 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -184,7 +184,7 @@ struct udevice {
#if CONFIG_IS_ENABLED(OF_REAL)
ofnode node_;
#endif
-#ifdef CONFIG_DEVRES
+#if CONFIG_IS_ENABLED(DEVRES)
struct list_head devres_head;
#endif
#if CONFIG_IS_ENABLED(DM_DMA)
@@ -192,6 +192,14 @@ struct udevice {
#endif
};
+static inline int dm_udevice_size(void)
+{
+ if (CONFIG_IS_ENABLED(OF_PLATDATA_RT))
+ return ALIGN(sizeof(struct udevice), CONFIG_LINKER_LIST_ALIGN);
+
+ return sizeof(struct udevice);
+}
+
/**
* struct udevice_rt - runtime information set up by U-Boot
*
diff --git a/include/dm/devres.h b/include/dm/devres.h
index 0ab277e..697534a 100644
--- a/include/dm/devres.h
+++ b/include/dm/devres.h
@@ -30,7 +30,7 @@ struct devres_stats {
int total_size;
};
-#ifdef CONFIG_DEVRES
+#if CONFIG_IS_ENABLED(DEVRES)
#ifdef CONFIG_DEBUG_DEVRES
void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
@@ -207,7 +207,7 @@ void devm_kfree(struct udevice *dev, void *ptr);
/* Get basic stats on allocations */
void devres_get_stats(const struct udevice *dev, struct devres_stats *stats);
-#else /* ! CONFIG_DEVRES */
+#else /* ! DEVRES */
static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
{
diff --git a/test/dm/Makefile b/test/dm/Makefile
index d46552f..9a1a904 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -32,7 +32,7 @@ obj-$(CONFIG_CLK) += clk.o clk_ccf.o
obj-$(CONFIG_CPU) += cpu.o
obj-$(CONFIG_CROS_EC) += cros_ec.o
obj-$(CONFIG_PWM_CROS_EC) += cros_ec_pwm.o
-obj-$(CONFIG_DEVRES) += devres.o
+obj-$(CONFIG_$(SPL_TPL_)DEVRES) += devres.o
obj-$(CONFIG_DMA) += dma.o
obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi_host.o
obj-$(CONFIG_DM_DSA) += dsa.o