From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F00FC433F5 for ; Sun, 27 Mar 2022 20:26:55 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 87F3783966; Sun, 27 Mar 2022 22:26:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="NZydJSvc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E9CF8395A; Sun, 27 Mar 2022 22:26:48 +0200 (CEST) Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5CDC5836A9 for ; Sun, 27 Mar 2022 22:26:41 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-pf1-x42e.google.com with SMTP id w7so8122503pfu.11 for ; Sun, 27 Mar 2022 13:26:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=T20REaPE8/siTvZP40qvXOoCPf2fwSdtGTceDjxf71A=; b=NZydJSvcY6c+fZd7ZV0QtxkuKYZjdp488Bc4hzJ7CyCVD0c7T7ujOkZmdYO3kYGOoo YYEqx9iUTEXiEgOYEY7Ya8Ggmqj3iWYovqgmSNqcSbfm07Zm1wHrCpvo7Vbz2Urh2qnW o1xbK8HfqCgJ2wTZG2QiJLocJDyopwihP3zvI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=T20REaPE8/siTvZP40qvXOoCPf2fwSdtGTceDjxf71A=; b=telgu5l3l3TZ91Zokl14bIIC8nB2cf1TCQIchHpgPX6wM/ZQflUJPkklCKShJC647V RAgnZioS0RMWMn/RT0YlX/EpR6k0mDRX1vO3ywPH/Ya0FR/YX5aI80R+JFO+P+5+5n+1 TukbotFZ5Qu38uNu/OLPp4U8INZonHtRy3KByxFlXNb1O82FXTkdDKpNN39uG4d9fBR2 Dh69TA9eLnFyAz84fI1MMbjZmOwUyL4PucQcZzjcP/AyQ+AbqohQjlh+PvTc7yPvdf0n qwk3PcxEkEqM2Y59VoIPuvfmaZdHCGLn9OOPU8Wa9sk/7zNFtzAHHg+szyQA7gCcpfpc RIug== X-Gm-Message-State: AOAM530GVzBAlYJP3/nXyfhc3ogiTy/sj2dJKRJxiM++C3XnDIyUD353 p+OblbbI7R+D73gJ9zOMqqqJiwRI3V88Dg== X-Google-Smtp-Source: ABdhPJyQVh+jO/D2SAOFVIaAXPKDJiI6k4NbLrfC7da+6cFIItvZD5XYCMUs4VNmEMvygbTHYCAbCg== X-Received: by 2002:a65:6a46:0:b0:37f:ef34:7b8e with SMTP id o6-20020a656a46000000b0037fef347b8emr7555180pgu.503.1648412799248; Sun, 27 Mar 2022 13:26:39 -0700 (PDT) Received: from localhost.localdomain (118-93-105-181.dsl.dyn.ihug.co.nz. [118.93.105.181]) by smtp.gmail.com with ESMTPSA id k3-20020a056a00168300b004f7e60da26csm13915466pfc.182.2022.03.27.13.26.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Mar 2022 13:26:38 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Sean Anderson , =?UTF-8?q?Marek=20Beh=C3=BAn?= , U-Boot Custodians , Tom Rini , Simon Glass , AKASHI Takahiro , Alexandru Gagniuc , Bin Meng , Dario Binacchi , Ilias Apalodimas , Joel Peshkin , Marek Vasut , Masahiro Yamada , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Patrick Delaunay , Pavel Herrmann , Rasmus Villemoes , Ricardo Salveti , Stefan Roese , Ye Li Subject: [PATCH 00/10] dm: Experiments for reducing SPL memory usage Date: Sun, 27 Mar 2022 14:26:12 -0600 Message-Id: <20220327202622.3438333-1-sjg@chromium.org> X-Mailer: git-send-email 2.35.1.1021.g381101b075-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean This series explores using the (not yet applied) tag support in driver model to reduce memory usage in SPL. This is particularly important on 64-bit machines, which use a ridiculously large 8 bytes for each pointer into what what is sometimes only 64KB of available memory. The primary focus of this series is struct udevice, which can be shrunk in various ways: - Including devres_head only when DEVRES is enabled (i.e. not in SPL) - Using tags instead of pointers for attached data like plat_, priv_ and driver_data - Using singly linked lists, currently not supported in U-Boot - Using a table index for the driver pointer and uclass pointer Together these bring the size of struct udevice down from 0xa0 (160) bytes to 0x30 (48) bytes. Another option is to drop the device name, although this is a pain for debugging. It would also be possible to implement doubly linked lists with a 16-bit index into malloc space, in SPL, thus reducing the overhead in each node from 16 bytes to 2, or just using a fixed-size list for each data structure, since the number of items is quite limited in SPL. To implement the tag side of things, functions like dev_set_parent_priv() need to be modified to call dev_tag_set_ptr(), and dev_get_parent_priv() needs to call dev_tag_get_ptr(). Note there has been some previous work: - tiny-dm analysis[1] which we decided was too disruptive - build-time instantiation, to reduce SPL code size[2]. [1] https://patchwork.ozlabs.org/project/uboot/cover/20200702211004.1491489-1-sjg@chromium.org/ [2] https://u-boot.readthedocs.io/en/latest/develop/driver-model/of-plat.html#build-time-instantiation AKASHI Takahiro (1): RFC: dm: add tag support Simon Glass (9): Makefile: v2 Allow LTO to be disabled for a build sandbox: Correct loss of early output in SPL Makefile: Drop a stale comment about linking Makefile: Avoid resetting link flags in config.mk sandbox: Allow link flags to be given sandbox: Align linker lists to a 32-byte boundary dm: core: Allow devres to be disabled in SPL dm: core: Deal with a wrinkle with linker lists WIP: dm: core: Add a command to calculate memory usage Makefile | 22 ++-- arch/arm/config.mk | 4 +- arch/arm/include/asm/global_data.h | 2 +- arch/sandbox/config.mk | 4 +- arch/sandbox/cpu/os.c | 2 +- arch/sandbox/cpu/u-boot-spl.lds | 2 +- arch/sandbox/cpu/u-boot.lds | 2 +- cmd/dm.c | 15 ++- common/spl/spl.c | 9 ++ config.mk | 1 - doc/build/gcc.rst | 17 +++ drivers/core/Makefile | 4 +- drivers/core/device.c | 70 +++++++++++- drivers/core/dump.c | 73 +++++++++++++ drivers/core/root.c | 63 ++++++++++- drivers/core/tag.c | 168 +++++++++++++++++++++++++++++ include/asm-generic/global_data.h | 4 + include/dm/device-internal.h | 6 +- include/dm/device.h | 16 ++- include/dm/devres.h | 4 +- include/dm/root.h | 45 ++++++++ include/dm/tag.h | 126 ++++++++++++++++++++++ include/dm/util.h | 9 ++ scripts/Makefile.spl | 2 +- test/dm/Makefile | 2 +- 25 files changed, 640 insertions(+), 32 deletions(-) create mode 100644 drivers/core/tag.c create mode 100644 include/dm/tag.h -- 2.35.1.1021.g381101b075-goog