From patchwork Tue Sep 19 13:56:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 113015 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4979064qgf; Tue, 19 Sep 2017 07:21:10 -0700 (PDT) X-Received: by 10.55.10.77 with SMTP id 74mr2144001qkk.226.1505830870048; Tue, 19 Sep 2017 07:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505830870; cv=none; d=google.com; s=arc-20160816; b=Qv/cEjCE+6UPphNFm8xSEfKmqU9n342zU+fd/608nhwviWAuxjrwwxG8OiTLLbGivt k3eZ4wTMDr4e5lMWlCGyWgsZ1D+476VY/aIT5In5IsjJCLyYgVBZlt/AJUzi01/KxgUY JI/LSYetcFKcozOKaf6Zm51qz5+ZPKuvG+YUlqhoIr9D/NcLq5rLCg2AlBPh8/k00Ux9 hYddxhoWyoqGOqFHT9RIuyzIOWKrYML+ZVPNAsZyvvsGUuf9LJGccXxQukt2sisxfGFJ OzI3IDYrQSFA4DDznM24T9CbGqkMynft3nburNq/o/mypidIj1uohWjcAyV97jxUaxJn onyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:delivered-to:arc-authentication-results; bh=vinUrp3jVHK/HD2gwUybwPl9LFFhovd2fF+HoTyGVOg=; b=Zk5R1AfV2gGcIgLZIlQNblIGzChbHm/vvV7+WSORF6epJ3Q9PwQXrGYRRAf64qcjtG PCVPY9FrxbwCPw1w41MhwmtSOFjanoi95p+1wA6lBVmKYEsvE2yFwrz6bG9zKlnzbUQs sl8LYgc4Bmah86bBN4GAObc2yWejU8cahJBqHJZH1P6rfMs8PVwU6IIudLrBYc9uj+Dl OfcFIU+v228nLWg5mttv2SMfmI/RwR5MtG8OqOAIE5KV2LW15i57Gf2RIRbvN8SP2UnK EnSeu9PeyniudOedwRkkUFHlNXGQXE4alokOqK7FeF4Y6bIXRvzKBk80QBUrSB2HFGAE JyWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n42si9399277qtc.308.2017.09.19.07.21.09; Tue, 19 Sep 2017 07:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 63DCA62CE0; Tue, 19 Sep 2017 14:21:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 251F762AE3; Tue, 19 Sep 2017 14:11:31 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1512C62C62; Tue, 19 Sep 2017 14:06:19 +0000 (UTC) Received: from mail-pg0-f41.google.com (mail-pg0-f41.google.com [74.125.83.41]) by lists.linaro.org (Postfix) with ESMTPS id 07A7062B5D for ; Tue, 19 Sep 2017 14:06:01 +0000 (UTC) Received: by mail-pg0-f41.google.com with SMTP id c137so2047354pga.11 for ; Tue, 19 Sep 2017 07:06:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5JbMBHZ8k/ydQ+NS5a/OVPKpqp4HcXKwiu4r/HdDiyE=; b=Qvw8t3jWSUIyJhxuIi1gnP4mQp7MVovJwpFGxMmbVHYV6Z6ivfDMwaZQzTJ+TTTGRC FDut1OiPls0JM0lZgbYYstKhoj1nX9wQwpLnxQaqWPfLRIHd2cPo7p45S2x5VZFXP2af KClUTXANDF4+LvY18kLMsu35d9mGdkpBBbYkWJaKNz7ccgpbNvBAHOz24/fvvwnjpQn9 vPgLvfA0A3b2+FuhbAfwVqFJ4RysnnMHd1mor/PJ3A/ZKIep5panwdeQY4r4YgbMzppD +kLHYwUwSQt5x+5bG5bwLGjEHkv69i9Q1fl/rIEJkZK9rsJX6BvYK+S/Be5huZOPy1UO 2jdg== X-Gm-Message-State: AHPjjUhanRxeJZgiiA7GnNkjP7GHfjQJJ+MPDn2aSEFnPdYWtbbXLQ1q K2ZD912cCRrxoWVW23hN/BK1F0tm X-Google-Smtp-Source: AOwi7QAb0NS+DmzmCC7TLaPp7J+vwhi/N/nJhOJUDq2teW0W6LLUq1ki4LKT5fK/Y58DgOoSS6KcJw== X-Received: by 10.98.68.215 with SMTP id m84mr1430487pfi.85.1505829960221; Tue, 19 Sep 2017 07:06:00 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id 13sm4390439pfm.138.2017.09.19.07.05.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Sep 2017 07:05:59 -0700 (PDT) From: Heyi Guo To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, graeme.gregory@linaro.org Date: Tue, 19 Sep 2017 21:56:32 +0800 Message-Id: <1505829398-52214-27-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505829398-52214-1-git-send-email-heyi.guo@linaro.org> References: <1505829398-52214-1-git-send-email-heyi.guo@linaro.org> Cc: Ming Huang , zhangjinsong2@huawei.com, huangming23@huawei.com, guoheyi@huawei.com, wanghuiqiang@huawei.com Subject: [Linaro-uefi] [linaro-uefi v1 26/32] Hisilicon D03/D05: Enlarge iATU for RP with ARI capable device. X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "For discussions about Linaro-related UEFI development. Not a substitute for edk2-devel." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" From: Ming Huang 1. Because Hi161x chip doesn't support "ARI Forwarding Enable" function, BIOS will enumerate 32 same devices (Device Number 0~31) when attach a Non-ARI capable device in the RP. Hi161x chip will not fix it, need BIOS patch. 2. Just enlarge iatu for those root port with ARI capable device attached, Non-ARI capable device's RP, keep iatu limitation. 3. Remove previous temporary solution as below commit id: "7d157da88852cc91df2b11b10ade2edbbfbe77da" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jason zhang Conflicts: Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c --- .../Drivers/PciHostBridgeDxe/PciHostBridge.c | 1 + .../Drivers/PciHostBridgeDxe/PciHostBridge.h | 4 ++ .../Drivers/PciHostBridgeDxe/PciRootBridgeIo.c | 83 ++++++++++++++++++++-- 3 files changed, 81 insertions(+), 7 deletions(-) // detected multiple times. We work around this by faking absent @@ -2329,3 +2323,78 @@ RootBridgeIoConfiguration ( return EFI_SUCCESS; } +BOOLEAN +PcieCheckAriFwdEn ( + UINTN PciBaseAddr + ) +{ + UINT8 PciPrimaryStatus; + UINT8 CapabilityOffset; + UINT8 CapId; + UINT8 TempData; + + PciPrimaryStatus = MmioRead16 (PciBaseAddr + PCI_PRIMARY_STATUS_OFFSET); + + if (PciPrimaryStatus & EFI_PCI_STATUS_CAPABILITY) { + CapabilityOffset = MmioRead8 (PciBaseAddr + PCI_CAPBILITY_POINTER_OFFSET); + CapabilityOffset &= ~(BIT0 | BIT1); + + while ((CapabilityOffset != 0) && (CapabilityOffset != 0xff)) { + CapId = MmioRead8 (PciBaseAddr + CapabilityOffset); + if (CapId == EFI_PCI_CAPABILITY_ID_PCIEXP) { + break; + } + CapabilityOffset = MmioRead8 (PciBaseAddr + CapabilityOffset + 1); + CapabilityOffset &= ~(BIT0 | BIT1); + } + } else { + PCIE_DEBUG ("[%a:%d] - No PCIE Capability.\n", __FUNCTION__, __LINE__); + return FALSE; + } + + if ((CapabilityOffset == 0xff) || (CapabilityOffset == 0x0)) { + PCIE_DEBUG ("[%a:%d] - No PCIE Capability.\n", __FUNCTION__, __LINE__); + return FALSE; + } + + TempData = MmioRead16 (PciBaseAddr + CapabilityOffset + EFI_PCIE_CAPABILITY_DEVICE_CONTROL_2_OFFSET); + TempData &= EFI_PCIE_CAPABILITY_DEVICE_CAPABILITIES_2_ARI_FORWARDING; + + if (TempData == EFI_PCIE_CAPABILITY_DEVICE_CAPABILITIES_2_ARI_FORWARDING) { + return TRUE; + } else { + return FALSE; + } +} + +VOID +EnlargeAtuConfig0 ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This + ) +{ + UINTN RbPciBase; + UINT64 MemLimit; + LIST_ENTRY *List; + PCI_HOST_BRIDGE_INSTANCE *HostBridgeInstance; + PCI_ROOT_BRIDGE_INSTANCE *RootBridgeInstance; + + PCIE_DEBUG ("In Enlarge RP iatu Config 0.\n"); + + HostBridgeInstance = INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This); + List = HostBridgeInstance->Head.ForwardLink; + + while (List != &HostBridgeInstance->Head) { + PCIE_DEBUG ("HostBridge has data.\n"); + RootBridgeInstance = DRIVER_INSTANCE_FROM_LIST_ENTRY (List); + + RbPciBase = RootBridgeInstance->RbPciBar; + + // Those ARI FWD Enable Root Bridge, need enlarge iatu window. + if (PcieCheckAriFwdEn (RbPciBase)) { + MemLimit = GetPcieCfgAddress (RootBridgeInstance->Ecam, RootBridgeInstance->BusBase + 2, 0, 0, 0) - 1; + MmioWrite32 (RbPciBase + IATU_OFFSET + IATU_VIEW_POINT, 1); + MmioWrite32 (RbPciBase + IATU_OFFSET + IATU_REGION_BASE_LIMIT, (UINT32) MemLimit); + } + List = List->ForwardLink; + } +} diff --git a/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c b/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c index 6ecc1e5..5bc04a2 100644 --- a/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c +++ b/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c @@ -839,6 +839,7 @@ NotifyPhase( case EfiPciHostBridgeEndEnumeration: PCIE_DEBUG("Case EfiPciHostBridgeEndEnumeration\n"); + EnlargeAtuConfig0 (This); break; case EfiPciHostBridgeBeginBusAllocation: diff --git a/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h b/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h index cddda6b..925ed40 100644 --- a/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h +++ b/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h @@ -518,4 +518,8 @@ RootBridgeConstructor ( IN UINT32 Seg ); +VOID +EnlargeAtuConfig0 ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This + ); #endif diff --git a/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c b/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c index 2effd7c..b41dbe2 100644 --- a/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/Chips/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c @@ -14,6 +14,7 @@ **/ #include "PciHostBridge.h" +#include #include #include #include @@ -1770,13 +1771,6 @@ RootBridgeIoPciRead ( return EFI_INVALID_PARAMETER; } - if ((EfiPciAddress->Bus == 0x81) && (PrivateData->MemBase == 0xAA000000) && (EfiPciAddress->Device > 0)) { - return EFI_NOT_FOUND; - } - if ((EfiPciAddress->Bus == 0x91) && (EfiPciAddress->Device > 0)) { - return EFI_NOT_FOUND; - } - // The UEFI PCI enumerator scans for devices at all possible addresses, // and ignores some PCI rules - this results in some hardware being