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.
This commit is contained in:
Tom Rini 2022-04-19 08:14:15 -04:00
commit aec75a3d1d
13 changed files with 31 additions and 21 deletions

View file

@ -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) \

View file

@ -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)) \

View file

@ -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)

View file

@ -8,7 +8,7 @@
SECTIONS
{
. = ALIGN(4);
. = ALIGN(32);
.u_boot_list : {
KEEP(*(SORT(.u_boot_list*)));
}

View file

@ -8,7 +8,7 @@
SECTIONS
{
. = ALIGN(4);
. = ALIGN(32);
.u_boot_list : {
KEEP(*(SORT(.u_boot_list*)));
}

View file

@ -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 :=

View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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)
{

View file

@ -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
*

View file

@ -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)
{

View file

@ -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