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 BD0C8ECAAD3 for ; Wed, 31 Aug 2022 09:13:15 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 37F6C8455B; Wed, 31 Aug 2022 11:13:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="cbSrry7k"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 32A0E8489D; Wed, 31 Aug 2022 11:13:11 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 810AE82A4B for ; Wed, 31 Aug 2022 11:13:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CD193619DA; Wed, 31 Aug 2022 09:13:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB897C433D6; Wed, 31 Aug 2022 09:13:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661937186; bh=ndaoR1ry0nBgVnSdBB9/0oh96WoImxzPbL+4aENGNSQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cbSrry7kDrpv+ydgaReQWDkC/Zz8cskRTPl0UhIS96pXx9iHhU6RQZJ9P+KyeiZQ9 jbTl0EZBV0+iszTol2iL80uWCb/IspH1lVssws1oH2jcyunRFN1jSEW/ZeGJftl2rl +Xd6Cqah4EOEeNKmcQ+yHydEXWirSpynC1Hwlxd04rgBJfMckt+uqWgjEYosBe22yq tWAQl3Ewc7evDsOA19Oct3/Bau31RKgPXHlrWMA+H3PiD8Ngvi5k8QHRxltmPg0EGw Y/+cRskXenS/FTuivRNUalDMAvUQT9iJH79kvKQMh2RgIu95kVIb9rR2RXuwa4cDTx LtkSDOP0tZXyg== Received: by pali.im (Postfix) id 6CFBC855; Wed, 31 Aug 2022 11:13:02 +0200 (CEST) Date: Wed, 31 Aug 2022 11:13:02 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Simon Glass Cc: Tom Rini , U-Boot Mailing List Subject: Re: [PATCH v2 2/6] console: Implement flush() function Message-ID: <20220831091302.g65ajndqlioj35vu@pali> References: <20220811123925.23981-3-pali@kernel.org> <20220811144953.vjcobevwf5o2syg4@pali> <20220812090130.2wcjq2u3qndma3ig@pali> <20220812151704.wa3n2jaugsd5h3c7@pali> <20220825142027.76yo7eyg6md6u7r4@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 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.6 at phobos.denx.de X-Virus-Status: Clean On Thursday 25 August 2022 09:08:18 Simon Glass wrote: > Hi Pali, > > On Thu, 25 Aug 2022 at 08:20, Pali Rohár wrote: > > > > On Friday 12 August 2022 20:21:00 Simon Glass wrote: > > > Hi Pali, > > > > > > On Fri, 12 Aug 2022 at 09:17, Pali Rohár wrote: > > > > > > > > On Friday 12 August 2022 09:11:10 Simon Glass wrote: > > > > > Hi Pali, > > > > > > > > > > On Fri, 12 Aug 2022 at 03:01, Pali Rohár wrote: > > > > > > > > > > > > On Thursday 11 August 2022 18:08:46 Simon Glass wrote: > > > > > > > Hi Pali, > > > > > > > > > > > > > > On Thu, 11 Aug 2022 at 08:50, Pali Rohár wrote: > > > > > > > > > > > > > > > > On Thursday 11 August 2022 08:47:50 Simon Glass wrote: > > > > > > > > > > diff --git a/include/stdio_dev.h b/include/stdio_dev.h > > > > > > > > > > index 270fa2729fb2..06278366ae88 100644 > > > > > > > > > > --- a/include/stdio_dev.h > > > > > > > > > > +++ b/include/stdio_dev.h > > > > > > > > > > @@ -37,6 +37,10 @@ struct stdio_dev { > > > > > > > > > > void (*putc)(struct stdio_dev *dev, const char c); > > > > > > > > > > /* To put a string (accelerator) */ > > > > > > > > > > void (*puts)(struct stdio_dev *dev, const char *s); > > > > > > > > > > +#ifdef CONFIG_CONSOLE_FLUSH_SUPPORT > > > > > > > > > > > > > > > > > > I'd argue it isn't worth the #ifdef and we might as well have this > > > > > > > > > member here always. Then you can drop some #ifdefs from your code. > > > > > > > > > > > > > > > > But then it will increase binary code size. > > > > > > > > > > > > > > Using the member will increase code size. But I think the only place > > > > > > > you need an #ifdef for that is when you include it in the driver > > > > > > > struct. You can use __maybe_unused in the other place. > > > > > > > > > > > > > > Having the member will only increase memory usage, not code size. > > > > > > > > > > > > But static memory structures are part of the u-boot.bin binary and also > > > > > > their usage increase code size (required copy, etc...), so at the end it > > > > > > increase code size. > > > > > > > > > > From what I understand stdio_dev is allocated at runtime in BSS: > > > > > > > > > > struct stdio_dev *stdio_devices[] = { NULL, NULL, NULL }; > > > > > > > > > > (the NULL stuff should not be there, but does nothing, I believe) > > > > > > > > > > So long as no code accesses your new member, then it should only > > > > > affect the BSS size. > > > > > > > > Code of course has to access new member. How otherwise would be able to > > > > call that new callbacks? E.g. all new code in patch 2/6 or 3/6. > > > > > > Yes, see below. Also, do check whether it actually adds code or not. > > > > > > > > > > > > If you are very worried about it, you could use the technique in > > > > > asm-generic/global_data.h to avoid #ifdefs in the C code: > > > > > > > > > > #ifdef CONFIG_GENERATE_ACPI_TABLE > > > > > #define gd_acpi_start() gd->acpi_start > > > > > #define gd_set_acpi_start(addr) gd->acpi_start = addr > > > > > #else > > > > > #define gd_acpi_start() 0UL > > > > > #define gd_set_acpi_start(addr) > > > > > #endif > > > > > > > > > > Regards, > > > > > Simon > > > > > > Regards, > > > Simon > > > > But in this case, it is needed to introduce a new special macro and hide > > assigning code into it. In my opinion such macro with side effect and > > worse than writing it explicitly - open coded to show what the code is > > doing. > > You can use an inline function if you prefer. But it has still same issue, hiding conditional logic indirectly to additional file. Some members would be assigned directly via = operator and some via macro/inlinefunction is inconsistent. > My main objection is to adding #ifdefs to C files. They are OK (for > now) in driver struct declarations, where some members are optional. > But I think it is worth going to some lengths to avoid them elsewhere. > > +Tom Rini for thoughts on this > > Regards, > SImon Any comments on this?