From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.441.1588096001721124973 for ; Tue, 28 Apr 2020 10:46:42 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1AD4FC14; Tue, 28 Apr 2020 10:46:40 -0700 (PDT) Received: from [192.168.1.81] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 557173F305; Tue, 28 Apr 2020 10:46:38 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH edk2-platforms v3 16/24] Silicon/NXP: Add Chassis2 Package To: devel@edk2.groups.io, leif@nuviainc.com, "Pankaj Bansal (OSS)" Cc: Meenakshi Aggarwal , Michael D Kinney , Varun Sethi , Samer El-Haj-Mahmoud , Jon Nettleton , Ard Biesheuvel References: <20200423102714.GW14075@vanye> <20200423115707.GB14075@vanye> <20200423120537.GC14075@vanye> <20200423141842.GF14075@vanye> <20200423152616.GG14075@vanye> <20200424155105.GN14075@vanye> From: "Ard Biesheuvel" Message-ID: Date: Tue, 28 Apr 2020 19:46:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200424155105.GN14075@vanye> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 4/24/20 5:51 PM, Leif Lindholm via groups.io wrote: > On Fri, Apr 24, 2020 at 02:42:13 +0000, Pankaj Bansal (OSS) wrote: >>>>> Why would multiple modules need to initialize the serial port? >>>> >>>> That's how the DebugLib has been designed. >>>> DebugLib is used by all modules to print info on console. >>>> BaseDebugLibSerialPortConstructor calls SerialPortInitialize. >>>> So SerialPortInitialize is called by all the modules. >>> >>> Sure, but the bit where ChassisLib returns the active clock >>> configuration does not need to happen for each initialization. >>> That value can be cached. >> >> The only mechanism I know for passing a cached value between different modules >> is either use PCDs or use HOBs. >> We have already explored both in https://edk2.groups.io/g/devel/message/57254 >> and https://edk2.groups.io/g/devel/message/56530 > > That was discussing what to do with regards to the generic 16550 > driver. If we go with Laszlo's suggestion[1] for a separate > SerialUartClockLib instead of adding a vendor GUID HOB *into the > generic driver*, that does not preclude your using a HOB to cache the > value in your platform code for later use in your own > SerialUartClockLib implementation. > > [1] https://edk2.groups.io/g/devel/message/56767 > Caching using a HOB is a bit problematic, given that SerialPortInitialize() does not honour constructor ordering (it may be called before any of the constructors), and so whether we implement Laszlo's suggestion or not, using a HOB to cache anything that is required to set the correct baud rate is not going to work (given that HobLib may rely on its constructor to be able to access the HOB list) Unfortunately, that leaves us with little else, given that we cannot use global variables either, since BASE libraries may be incorporated into PEIMs that run execute-in-place from ROM. So the bottom line is that we don't have that many options that are actually feasible, and so converging on one of the non-optimal ones is all that we can really hope for at this point. >> Moreover the compiler can optimize the PcdDcfgBigEndian evaluation. >> So no overhead would be observed in evaluating PcdDcfgBigEndian in every call. > > I don't question that, but that was always going to be the case anyway > - especially with LTO. The point is reducing code duplication - > especially for weird and wacky hardware workarounds. > Have to agree here :-)