From patchwork Thu Feb 27 13:56:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1245866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=JwhBYUE6; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48SvNJ2TQ9z9shh for ; Fri, 28 Feb 2020 00:56:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7CAE78050F; Thu, 27 Feb 2020 14:56:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk 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=prevas.dk header.i=@prevas.dk header.b="JwhBYUE6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B269380911; Thu, 27 Feb 2020 14:56:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FORGED_SPF_HELO, SPF_HELO_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0713.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1e::713]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2786380251 for ; Thu, 27 Feb 2020 14:56:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mewh4Oe90Z9wr0X3SzV4T9nzK8DgH4CwWuQpwi3PTHSYRB4FeBuAcwrsC08uKVX56mhxJfQf/f8J8+drRlEeP6AkSZ/+WFTy3MMp8LHqGAGXyTOpL71M2JzMyuV7R+kfrXYJoXwuA73W0LkkbBakbsBSYKJdE1Pr4oJ/gTHno4VUvIF+iNSirnFJDkY/sOQwaMUh9dRndrWsqwKyTxjwAieDiehz47Scz+A/z5fvUmcLYHzPmOdbbrG2Uc3Q8LVSgZYX65DuY3clqk+KElaZqmorcRCsdNd1Ozn51xmTMGLIEqOfdT3PIXO5cfkFzva9UDlCNfQolW0WqenjYQJZvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XC2h/jEK8sDP9sL7bpKbG7dL8HZvYQxrJAfqs64Ldeg=; b=WoUPSL8uW8JtvGJgfdXNrceyYvjjCpQl5BK96YYIRxv5FEJHFsO349YYXvWwRoEKqbV6RpqTLw+7KcJ52ySMKd5rIB0B4F3oxy61iA0kdLEUkisx5ufdj/wYer6QVoAeDyFy1f2lF4IjUVzIugw40qEamf8uYtpXLHL90F5zM+mdCEFbRK0xXNo44Nxgl4EQZ7rTkMxsESUCGs4sgrCNlJjPr+Cg7qPJZQTaKi50WkB4uZAnE82Usk4BbYsiwacGcHcp6vhexoNrvuhbLtkOq1L90WZlKnit8M62ymLj0jciDNt7TWwxzapbRDzDvCXQnaKNdOPltTwkNsIDGBrBRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XC2h/jEK8sDP9sL7bpKbG7dL8HZvYQxrJAfqs64Ldeg=; b=JwhBYUE6wRCYt5t1kDxNTlXNswXIiqP6tcC0m3sX3ZWuNgbZIIi+tJsGP0+wBDMB+FOutGb0OkQOOQZyr+g4hBpHrW6MLTe9A3zvsebzNQ0p7yhYJOplYmvU5wP3hnCAMb/5cBz5W7Q58+hbAotwTiXzhcU/Hf0vUKKCFOfD59I= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB3183.EURPRD10.PROD.OUTLOOK.COM (52.133.244.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14; Thu, 27 Feb 2020 13:56:09 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7%5]) with mapi id 15.20.2772.012; Thu, 27 Feb 2020 13:56:09 +0000 Received: from prevas-ravi.prevas.se (5.186.115.35) by AM5P194CA0007.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2772.14 via Frontend Transport; Thu, 27 Feb 2020 13:56:08 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" CC: Wolfgang Denk , Simon Glass , Joe Hershberger , Rasmus Villemoes Subject: [PATCH 0/4] remove (more) env callback code for SPL Thread-Topic: [PATCH 0/4] remove (more) env callback code for SPL Thread-Index: AQHV7XWpHIo2i9D08kme56L6PG1bJA== Date: Thu, 27 Feb 2020 13:56:09 +0000 Message-ID: <20200227135600.28853-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM5P194CA0007.EURP194.PROD.OUTLOOK.COM (2603:10a6:203:8f::17) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) x-mailer: git-send-email 2.23.0 authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasmus.villemoes@prevas.dk; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [5.186.115.35] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4442e83e-5fbc-428a-5379-08d7bb8ccc24 x-ms-traffictypediagnostic: VI1PR10MB3183: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-forefront-prvs: 03264AEA72 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(396003)(376002)(346002)(39840400004)(136003)(199004)(189003)(5660300002)(64756008)(2616005)(66446008)(8976002)(66556008)(956004)(66946007)(6506007)(66476007)(2906002)(54906003)(71200400001)(8936002)(44832011)(107886003)(86362001)(6486002)(6512007)(186003)(36756003)(8676002)(26005)(81156014)(81166006)(316002)(1076003)(16526019)(478600001)(4326008)(52116002)(6916009); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB3183; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: prevas.dk does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7AiByUTv6kXCy+GEia3bggEajJrwwc0s+7j2pOan9u9RI4r4nHZBSeyJXADp5199fLHLb5igpuWhX+/qBcl2DBSr6Jj2iilrkSupIPXRfoBoBPyIvHYbnqSok8LGEloHGOqauc3kMJh0MhxqBNqSwMMJaDE7CdXyKAW2OYgib/sEtc2+L+V3HQNufbUItFBjiOMwORqgXiCqMxxS/+JTD+vDF+5Qo5wavLQYliy91wNe1LUWUoRxD0QEVNZH/9AUGRVji0kcFe2oauoagWa4hMXNPXxYCwz788OoH4CHaDbQXgfnQaO/jyweatzEVPBkA2uoDJXUGDwUajAZFnfEsVzOm+2rh8BUdo3yZe1Y8cjS04Zu8TsGfSw7HuJDd8ONz2MHXSnp268sw46OQTa5JsUENFbj76rB6fq9C6RJirZN5AfHYAjPgZsvcUD4YaUZ x-ms-exchange-antispam-messagedata: Hr0uizNAN+/uOpopPv72XjazK36ott+2Nw0JCHTVwHSTpPzV4uxCKg3qrf4IgAM3Woq0QAzPabvg321vzkLl05LJKNBApMWRuBGAzEtW2yt3CHDHktIRL3axcPh3aRK/1E9J/T585q3dQxBAU68teA== MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 4442e83e-5fbc-428a-5379-08d7bb8ccc24 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2020 13:56:09.3281 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: PNZ821cRg9BbByuhwBZ4mZkE/bODF3/puW5uw33nj8bPNMwOOL9ydBxvIF8rbVawoRhuxptUhvGo2iDmcek8bdwreWTbNQ9DFwOWqPNPHDY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3183 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean The actual environment callbacks are automatically dropped from an SPL build, but the support code (env/callback.o) for associating a callback to an environment variable is still there. These patches reduce a CONFIG_SPL_ENV_SUPPORT=y SPL image by about 1K (at least for my ppc build), and another ~2K of run-time memory. === Aside: While poking around in this code, I noticed a few somewhat related bugs in callback.o: (1) The caching of env_get(".callbacks") in env_callback_init() is dubious at best: It gets called during the initial import, so env_get ends up calling env_get_f. So either we cache a value of NULL (no .callbacks variable in initial environment), or we cache a value of gd->env_buf. Now, of course env_get_f will soon no longer be used, so there's not a big risk that gd->env_buf will be overwritten, but it's rather fragile. In either case (2), the cache is not invalidated or updated by the on_callbacks() callback associated to .callbacks itself. Finally, (3) with CONFIG_REGEX=y, that on_callbacks() function has the unfortunate effect of removing itself as the callback associated to .callbacks: When .callbacks is initially added to the environment, env_callback_init() correctly associates on_callbacks, because it uses env_attr_lookup() (which is regex-aware) on the ENV_CALLBACK_STATIC_LIST. Now, when .callbacks is set the next time, on_callbacks() is called, starts by clearing all callbacks, including the one for .callbacks. It then tries to initialize them again, but it uses env_attr_walk() (which roughly speaking just splits the given string on , and : and calls back to the user's handler) on ENV_CALLBACK_STATIC_LIST, which means that set_callback() gets called with the string "\.callbacks" - and such a variable does not exist. set_callback() is never called with ".callbacks" as name, so .callbacks (and e.g. eth5addr - anything else which is supposed to be matched by a regex) now no longer has a callback. Perhaps this can all be fixed by just having on_callbacks update the cached static callback_list with value, then do a hwalk_r(&env_htab, env_callback_init) - no need for either set_callback or clear_callback. Rasmus Villemoes (4): env: remove callback.o for an SPL build lib/hashtable.c: create helper for calling env_entry::callback lib/hashtable.c: don't test ->callback in SPL make env_entry::callback conditional on !CONFIG_SPL_BUILD env/Makefile | 2 +- env/callback.c | 2 ++ env/flags.c | 1 - include/env_callback.h | 6 ++++++ include/search.h | 2 ++ lib/hashtable.c | 26 +++++++++++++++++--------- 6 files changed, 28 insertions(+), 11 deletions(-)