From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id AC6189412B9 for ; Mon, 11 Sep 2023 09:26:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=qmgjwlgZ4kYBYJ+Q5Hm0ZaHn/LiKHLM8eWZ4DEG91Bg=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1694424410; v=1; b=f1RKRV1lC+un4MSIVTXdLDbCSUnCfJjs9pGcof4iYPY/nOv6kX8NtoXsAlK9Wi6JT2VslScB P1WYGa67L/OM8Gt+GQJORSHIYMQMHyVlbHB/LiHwgfV5tQ7s5cHT2Mzd/JnJeWK0iq50iUNpp0+ bXLLUsxTgbkAphSGIUd8IdRY= X-Received: by 127.0.0.2 with SMTP id fw07YY7687511xHayNOiHxq2; Mon, 11 Sep 2023 02:26:50 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.54662.1694424409392929909 for ; Mon, 11 Sep 2023 02:26:49 -0700 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D309E61017 for ; Mon, 11 Sep 2023 09:26:48 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 440FCC433C9 for ; Mon, 11 Sep 2023 09:26:48 +0000 (UTC) X-Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2bcd7a207f7so66315941fa.3 for ; Mon, 11 Sep 2023 02:26:48 -0700 (PDT) X-Gm-Message-State: LZbWs5AQGCBcOXhDOjx5ObU2x7686176AA= X-Google-Smtp-Source: AGHT+IE4c7ZYeOHWtrZyu1YtegXqU0G0QZnx8UIiO4irqT39efxhM2pdI/92TxBoNLxBTDXs7R0wSZKJ4lXYi+Vfh0w= X-Received: by 2002:a2e:80c6:0:b0:2ba:8127:a2c3 with SMTP id r6-20020a2e80c6000000b002ba8127a2c3mr7648476ljg.34.1694424406437; Mon, 11 Sep 2023 02:26:46 -0700 (PDT) MIME-Version: 1.0 References: <27912.1694092220075253890@groups.io> <1e6f37af-f407-43f2-aa14-9c5de85eb404@linux.microsoft.com> <343d24ed-12e4-6f9f-c726-5ce616c75738@redhat.com> In-Reply-To: From: "Ard Biesheuvel" Date: Mon, 11 Sep 2023 11:26:35 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH v1 1/1] ArmVirtPkg: Enable Early Serial For DxeCore To: devel@edk2.groups.io, lersek@redhat.com Cc: Sean Brogan , osde@linux.microsoft.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ardb@kernel.org List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=f1RKRV1l; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Mon, 11 Sept 2023 at 07:30, Laszlo Ersek wrote: > > On 9/8/23 01:58, Sean Brogan wrote: > > > > On 9/7/2023 1:54 PM, Laszlo Ersek wrote: > >> On 9/7/23 19:50, Sean Brogan wrote: > >>> I would argue that by declaring that your library class supports type > >>> DXE_CORE (or any core type) that you have declared you understand the > >>> uniqueness of the environment and have accounted for it. > >>> > >>> For instances that support DXE_CORE or MM_CORE module types we often = use > >>> a global variable (to the library) to determine if the init routine h= as > >>> been completed. This does require a single byte check on each serial > >>> message write (hot path) but given all the code on that path this is = not > >>> noticeable in performance measurements. In the case below this patt= ern > >>> could be used by the FdtPL011SerialPortLib to detect if it's init > >>> routine has been called. > >> Good point, but then I still claim that the "init check in each API" > >> should be done in a dedicated "DxeCoreDebugLibSerialPort" instance, an= d > >> not in a SerialPortLib instance. Here's why: > >> > >> (1) The SerialPortLib *class* requires SerialPortInitialize() to be > >> called before the other APIs. > > > > Where do you see this? Looking at the file here: > > edk2/MdePkg/Include/Library/SerialPortLib.h at master =C2=B7 tianocore/= edk2 > > (github.com) > > I don't see that. I don't necessarily disagree with you bu= t I am just trying to find out where this is documented. > > I consider this an implicit requirement, from the first two sentences > (and from the fact that the function is declared at the top of the > header) -- "Initialize the serial device hardware. If no initialization > is required, then return RETURN_SUCCESS." > Agreed. Even if the header file does not spell it out literally, it is implied: SerialPortInitialize() needs to be implemented even if no initialization is required, in which case the routine does nothing before returning SUCCESS. So the caller cannot distinguish a library class implementation that requires initialization from one that does not, and it can only assume that calling SerialPortInitialize() is needed before using any other part of the API. -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108481): https://edk2.groups.io/g/devel/message/108481 Mute This Topic: https://groups.io/mt/101203427/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-