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 622C57803CD for ; Mon, 26 Feb 2024 15:37:42 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=n3CASDd3hhT1iDnPPc1MVBtUo0lFPoHEjO6PouPSmGU=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1708961861; v=1; b=CdjJ21XqoEoTK07xgGqhOtPX/eN7VkNRNSdWhYmmXm1Yyf+uAi+4Tszd+6+u2HadbXKlbmFl tHsf8vupEVLcOx40MNWVmvl7jc9hpe1pX5ePZFT125U2rayUwxS4TUHHZNO5ypZhZL46CxaS4rg BhXElcHPEAb1C7s/P7IdQ3zE= X-Received: by 127.0.0.2 with SMTP id 7iZyYY7687511xcuBqLRgTVV; Mon, 26 Feb 2024 07:37:41 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.23214.1708961860473704860 for ; Mon, 26 Feb 2024 07:37:40 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-eL3nNPYCPsSulonefdKsQg-1; Mon, 26 Feb 2024 10:37:38 -0500 X-MC-Unique: eL3nNPYCPsSulonefdKsQg-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21A6283B828; Mon, 26 Feb 2024 15:37:38 +0000 (UTC) X-Received: from [10.39.194.99] (unknown [10.39.194.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4838A1C060B1; Mon, 26 Feb 2024 15:37:37 +0000 (UTC) Message-ID: <643d0b1f-1f90-97ea-721d-3462f74d14a1@redhat.com> Date: Mon, 26 Feb 2024 16:37:35 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: Load Serial driver earlier in DXE To: devel@edk2.groups.io, mateusz.albecki@intel.com References: <5971.1708960438578293809@groups.io> From: "Laszlo Ersek" In-Reply-To: <5971.1708960438578293809@groups.io> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 7enZgc0BSSGDFcbAirOxnMoVx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=CdjJ21Xq; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (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 2/26/24 16:13, Albecki, Mateusz wrote: > 1. Using SerialDxe instead of PciSioSerialDxe - from our perspective > the main idea is to avoid maintaining our own implementation of > functions that actually communicate with UART controller. To use > SerialDxe we would have to still maintain our own SerialPortLib that > actually goes and sends data over UART. Also a note on LPSS UART - in > terms of registers it is just a standard UART controller, the only > quirk here is how to access it hence the custom PCI_IO_PROTOCOL > implementation. Is it possible to factor out a common base library class (with just one instance) for accessing an LPSS UART? I guess the PCI B/D/F numbers would have to be passed to the individual functions. Then that library could be used in PciSioSerialDxe, and also in a (thin wrapper) SerialPortLib instance. > > 2. Using ConnectController before BDS - I noticed that the section I > quoted says that BDS will use ConnectController however it doesn't say > that it can't be used outside of that context. I did search the UEFI > spec to see whether it provides additional restrictions and the only > section that elaborates on this is the following: > /"Under the UEFI Driver Model , the act of connecting and > disconnecting drivers from controllers in a platform is under the > platform firmware’s control. This will typically be implemented as > part of the UEFI Boot Manager, but other implementations are possible. > " - from Section 2.5.6 Platform components/ It seems to be rather > permissive when it comes to who and when can call it. > > 3. How to make sure dispatch is early enough and not too late - this > will depend on the overall platform implementation. For our part - we > simply put it into flash as early as we can get away with. Even > apriori section isn't strictly necessary if the platform is > comfortable with relying on the fact that DXE core in MdeModulePkg > dispatches modules in order of their placement in flash(that's not > architectural as far as I know). Other platforms might choose to > introduce explicit depex on gEfiSerialIoProtocolGuid. To reiterate > this is the implementation that works for us in a sense that we get > logs from all modules that change frequently from generation to > generation, I understand that the same might not be true for platforms > other than Intel however I think majority of platforms could still > make at least some use of early UART debugging. > > 4. When exactly do we connect LPSS UART and start logging - we try to > be as early as possible for this interface. We miss all of DXE_CORE > logs(obviously), Pcd.inf and a couple of modules that implement some > of the architectural protocols(from PciSio perspective metronome is > the only actually required as far as we can tell since stall has to > work). > > I also want to note that I get why this is a controversial change. I > didn't realize it earlier but it would be the first DXE_DRIVER in EDK2 > tree that implements driver binding and in general it is strange to > have PCI device driver that could potentially dispatch before PCI bus > driver(however it is worth noting here that PciSioSerialDxe is not > just a PCI driver, it is a combo driver capable of supporting PCI and > SIO). That said I still think EDK2 in general needs a way to support > early device drivers and using DXE_DRIVER seems like the least > invasive idea. We need early drivers not just for debug(although that > is one of the most important use cases I would say) other important > use case is platform management through SMBUS/I2C/other serial > interface which might be required to even be able to enumerate full > PCI hierarchy(for instance some of the PCI slots might be powered down > and you need to power them on sending commands over I2C) or maybe > flash access to EFI variable storage(nothing says that you can't have > it connected to PCI SPI controller) or maybe GPIO control to do any > number of platform specific things. To my eyes, this series saves a bit of refactoring now and the maintenance of a thin wrapper library instance later, in exchange for a very unconventional solution in MdeModulePkg that is not easily reusable by other platforms. I don't like that trade-off; it makes me uncomfortable. If Liming and Mike accept this solution, I won't try to block it. In that case however, please document the design (all we've discussed thus far) in the "PciSioSerialDxeEarly.inf" file, in a (long) series of comments. Thanks Laszlo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115971): https://edk2.groups.io/g/devel/message/115971 Mute This Topic: https://groups.io/mt/104469297/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-