From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-x231.google.com (mail-io0-x231.google.com [IPv6:2607:f8b0:4001:c06::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C082881F16 for ; Wed, 7 Dec 2016 01:43:27 -0800 (PST) Received: by mail-io0-x231.google.com with SMTP id a124so701956195ioe.2 for ; Wed, 07 Dec 2016 01:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=YUEqraYYNoLV5AkYyJi67TGrmuJtsYUmvC9odfguDMU=; b=VvJwNpMwiefBU5KeTGtq3K0w8y/msKGGHmSznYtgs0XKJYJ5/UpkXIqSq936NgY0N/ rYWgKfM/sSJk1ljNQzFgsrgWvuEtr5rnuPF8SXdntMqHCxby9x2VVfFQx4ueTXPlTWnW ET9r2eU8D0nxZJv/RictBc0ONSlAA9UAiCU/w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=YUEqraYYNoLV5AkYyJi67TGrmuJtsYUmvC9odfguDMU=; b=RP9wxQsoP73zh6pNEBUp9AKwe1nzhPmoLRHpc/K+H3i3468neDr/GGLMFVfnMxkNnH c2x850Myn8ALCZgqEwOWANKzkekrQXHU4T0N84IqgSEoDVWS2oVPT23qugrl0LlDfpnx BnQGgiVWwjxArZWZ2TrMWKkm7ST0Mq8D8ucT/3lL7vWOTIxM5qP48qwUzZUGQCBN+iMs 7ceNDkfSsfEGtZqmQMS6chQKrFpidtG8yeOGSsfA6qtVIytVc7TtZMcFdaLl0j6S0B14 Lvjg3tBdb9WKqytiR+IKhxpwUDWkBEGQzJ0shHRufo9AP80qzLA7KuVCy/8KgGzVyWKp ZVJQ== X-Gm-Message-State: AKaTC00XXHcG/aoZH8ejWogeMIt1ki3DNdV0Ugi74osq5rWGEO9X002Ay8slcba3HJ3W3NgJg6PH30AGsF+6nJ3B X-Received: by 10.107.18.39 with SMTP id a39mr53188120ioj.45.1481103806884; Wed, 07 Dec 2016 01:43:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.198.67 with HTTP; Wed, 7 Dec 2016 01:43:26 -0800 (PST) In-Reply-To: <1480952122-27937-1-git-send-email-ard.biesheuvel@linaro.org> References: <1480952122-27937-1-git-send-email-ard.biesheuvel@linaro.org> From: Ard Biesheuvel Date: Wed, 7 Dec 2016 09:43:26 +0000 Message-ID: To: "edk2-devel@lists.01.org" , Leif Lindholm , Ruiyu Ni Cc: Marcin Wojtas , "Gao, Liming" , "Tian, Feng" , Ard Biesheuvel Subject: Re: [PATCH v5 0/5] MdeModulePkg: add support for non-discoverable devices X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Dec 2016 09:43:28 -0000 Content-Type: text/plain; charset=UTF-8 On 5 December 2016 at 15:35, Ard Biesheuvel wrote: > The rationale for this series is the fact that many ARM platforms implement > some form of PCI 'emulation', to allow non-discoverable devices that implement > standardized host controller interfaces (i.e., EHCI, AHCI) to be controlled by > the generic EDK2 drivers, which are layered on top of the PCI I/O protocols > (even though the respective host controller specifications don't mandate that) > > There are a couple of problems with that approach: > - Most implementations are based on the original code created for BeagleBoard, > which is a 32-bit platform. Unlike x86, which usually does not perform PCI > DMA above 4 GB, the ARM ecosystem is much more heterogeneous, and platforms > that have memory both above and below the 4 GB mark may ship with, e.g., EHCI > controllers that do not implement 64-bit DMA addressing. > - Implementations depend on the DmaLib library class in EmbeddedPkg, of which > coherent and non-coherent implementations exists. However, both types of > devices may appear on a single platform, requiring several instances of the > same driver. > - Existing implementations do not follow the UEFI driver model, but instantiate > a fixed number of PCI I/O protocol handles, and bring up all the devices when > doing so. However, the UEFI philosophy is to only instantiate (and thus > initialize) devices that are involved in booting. > > So instead, let's define a base protocol that simply asserts the presence of > a certain kind of device at a certain memory offset, allowing platforms to > instantiate any number of these statically, and leave it to post-DXE driver > dispatch to actually bind the drivers as usual. This is implemented in patch #1. > Note that it includes an AMBA device type, which we intend to use in the future > to move ARM AMBA drivers to the UEFI driver model as well (i.e., LCD controller, > SD/MMC controller) > > Patch #2 implements a utility library to register non-discoverable devices. > > Patch #3 implements the UEFI driver that instantiates PCI I/O protocol handles > for non-discoverable devices that we know can be driven by a generic driver in > EDK2. The initial version implements coherent DMA only. > All, I am going to go ahead and push patches #1 - #3, given that they are reviewed by Ray, and that we have other work that depends on it, for Marvell and AMD Seattle As far as the remaining patches are concerned: only patch #4 needs a R-b from Ray, patch #5 is good to go but depends on #4 Thanks, Ard. > Patch #4 implements non-coherent DMA for the driver added in patch #3. > > Patch #5 is included for reference. It ports the BeagleBoard platform to the > new driver stack. > > Changes in v5: > - replaced open coded 64-bit shift with RShiftU64() (#3) > - several fixes for NonCoherentAllocateBuffer() > - moved misplaced list head initialization from #3 to #4 > - added Ray's Reviewed-by to patches #1 to #3 > - added Marcin's Tested-by to patches #1 to #4 > > Branch can be found here > https://git.linaro.org/people/ard.biesheuvel/uefi-next.git/log/?h=non-discoverable-pci-v5 > > Changes in v4: > - use GUIDs to describe the type of device (AHCI, EHCI, etc), rathen than en > enum, to make the protocol more flexible and futureproof > - revert special handling of SDHCI, which does not map cleanly onto a single > PCI device (SDHCI-PCI may expose several slots, each of which is a full > fledged implementation of the SDHCI spec, but the EDK2 SDHCI driver does > not model those as a bus) > - don't treat 64-bit BARs as 2 logical BARs > > Branch can be found here > https://git.linaro.org/people/ard.biesheuvel/uefi-next.git/log/?h=non-discoverable-pci-v4 > > Changes in v3: > - Modified the base protocol to describe any number of resources using ACPI > resource descriptors. The current crop of targeted peripherals does not > require that, but it allows for much more flexibility in the future. This > also means that the MMIO region sizes are no longer hard-coded base on the > controller type (EHCI, AHCI, etc) but need to be declared when the devices > are registered. > - Update the registration library API to allow multiple MMIO regions to be > declared. > - When performing uncached allocations, record the original memory region > attributes so we can restore them correctly on free. > - Some fixes in the 4GB boundary checks for Map/Unmap > - Rename gNonDiscoverableDeviceProtocolGuid to > gEdkiiNonDiscoverableDeviceProtocolGuid > > > Ard Biesheuvel (5): > MdeModulePkg: introduce non-discoverable device protocol > MdeModulePkg: introduce helper library to register non-discoverable > devices > MdeModulePkg: implement generic PCI I/O driver for non-discoverable > devices > MdeModulePkg/NonDiscoverablePciDeviceDxe: add support for non-coherent > DMA > Omap35xxPkg/PciEmulation: port to new non-discoverable device > infrastructure > > BeagleBoardPkg/BeagleBoardPkg.dsc | 2 + > BeagleBoardPkg/BeagleBoardPkg.fdf | 1 + > MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c | 75 ++ > MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c | 235 ++++ > MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf | 54 + > MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c | 1121 ++++++++++++++++++++ > MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.h | 113 ++ > MdeModulePkg/Include/Guid/NonDiscoverableDevice.h | 58 + > MdeModulePkg/Include/Library/NonDiscoverableDeviceRegistrationLib.h | 62 ++ > MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h | 77 ++ > MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c | 204 ++++ > MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf | 46 + > MdeModulePkg/MdeModulePkg.dec | 18 + > MdeModulePkg/MdeModulePkg.dsc | 3 + > Omap35xxPkg/Omap35xxPkg.dsc | 2 +- > Omap35xxPkg/PciEmulation/PciEmulation.c | 578 +--------- > Omap35xxPkg/PciEmulation/PciEmulation.h | 292 ----- > Omap35xxPkg/PciEmulation/PciEmulation.inf | 16 +- > Omap35xxPkg/PciEmulation/PciRootBridgeIo.c | 306 ------ > 19 files changed, 2102 insertions(+), 1161 deletions(-) > create mode 100644 MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/ComponentName.c > create mode 100644 MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.c > create mode 100644 MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf > create mode 100644 MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.c > create mode 100644 MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceIo.h > create mode 100644 MdeModulePkg/Include/Guid/NonDiscoverableDevice.h > create mode 100644 MdeModulePkg/Include/Library/NonDiscoverableDeviceRegistrationLib.h > create mode 100644 MdeModulePkg/Include/Protocol/NonDiscoverableDevice.h > create mode 100644 MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.c > create mode 100644 MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf > delete mode 100644 Omap35xxPkg/PciEmulation/PciEmulation.h > delete mode 100644 Omap35xxPkg/PciEmulation/PciRootBridgeIo.c > > -- > 2.7.4 >