From nobody Thu Dec 26 12:59:30 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1505992095357345.62215969398426; Thu, 21 Sep 2017 04:08:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E073D21E1B77C; Thu, 21 Sep 2017 04:04:33 -0700 (PDT) Received: from mail-pg0-x22a.google.com (mail-pg0-x22a.google.com [IPv6:2607:f8b0:400e:c05::22a]) (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 5294321E1B76D for ; Thu, 21 Sep 2017 04:04:33 -0700 (PDT) Received: by mail-pg0-x22a.google.com with SMTP id j70so3331169pgc.10 for ; Thu, 21 Sep 2017 04:07:40 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id x124sm2090762pfx.56.2017.09.21.04.07.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Sep 2017 04:07:39 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8e46iXc6ep15mZMjZv2wcRGzw4WwWoRRZvWIldeYr3A=; b=X2+ORCIWv7rn62evCpjuXhahojbUo/hNeBOPQcZQ1dO/QeJAyCgz7cahvltMXUBMpM 030/8Xsm8mjfwBG77qVY1EF08l0MfcIHEtZ9FTrV+Ku+MQ+q5Y7II7p5aKOXwb5yAQr6 UgrZRRaEmy1cadAi9eHX///5DTRRRqff0m3TI= 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=8e46iXc6ep15mZMjZv2wcRGzw4WwWoRRZvWIldeYr3A=; b=qfcuk/GgaJnMcJf8TTh/6qNPtgreYnLY+QQcp9c5QguBLIp8dQjjGePmQLowjPF+P8 yef43lXMFcmhdpgE7ZfmpS2q2PsYewBYV5LeXqgvT2QeRWvrE3Cmv/q+I6cjavuxhIyE Ic0nC0CyNve3v3kAfoQIVgn4VoQBjhCLf82lMSG5s9MFrRyk2fS8gakbYb9/dusHB9er JF8uR8jz517d+bznH5nYGTRtKkKXMysUYxf6flHyDhQAGZUl48rjMmLA5MdBRLHLq9tC 1s8eyrl4m9ogVbntcmbZYJ+0R3pkMswI+adNKHEMDMZg4ByQd6QjYiSxRGdcI0xYQ61r oIkw== X-Gm-Message-State: AHPjjUibisDnNnoQfQ7rZYZ60n+yZ8PACw7Ax4Uknllqdqrv7Hq0DbWH u3l+ib0ucNBuv3qUAE8G3YzwZw== X-Google-Smtp-Source: AOwi7QCeLP918sy2rnLjrL5hWwC2K+rjoJ0v2PJXJXfYSyOW1Nt0SQd6S9ehmd3Mk/PhPUBESYD9fQ== X-Received: by 10.98.33.134 with SMTP id o6mr5340249pfj.91.1505992059906; Thu, 21 Sep 2017 04:07:39 -0700 (PDT) From: Heyi Guo To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org Date: Thu, 21 Sep 2017 18:59:57 +0800 Message-Id: <1505991597-52989-19-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1505991597-52989-1-git-send-email-heyi.guo@linaro.org> References: <1505991597-52989-1-git-send-email-heyi.guo@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 11/11] Hisilicon D03/D05: Enlarge iATU for RP with ARI capable device. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: huangming23@huawei.com, ard.biesheuvel@linaro.org, zhangjinsong2@huawei.com, Ming Huang , guoheyi@huawei.com, waip23@126.com, wanghuiqiang@huawei.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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.1 Signed-off-by: Jason zhang --- Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c | 1 + Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h | 7 ++ Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c | 79 ++++++++= ++++++++++++ 3 files changed, 87 insertions(+) diff --git a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c b/S= ilicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c index e3d3988..9fa3f84 100644 --- a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c +++ b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.c @@ -839,6 +839,7 @@ NotifyPhase( =20 case EfiPciHostBridgeEndEnumeration: PCIE_DEBUG("Case EfiPciHostBridgeEndEnumeration\n"); + EnlargeAtuConfig0 (This); break; =20 case EfiPciHostBridgeBeginBusAllocation: diff --git a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h b/S= ilicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h index cddda6b..c04361f 100644 --- a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h +++ b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridge.h @@ -401,6 +401,9 @@ PreprocessController ( #define EFI_RESOURCE_NONEXISTENT 0xFFFFFFFFFFFFFFFFULL #define EFI_RESOURCE_LESS 0xFFFFFFFFFFFFFFFEULL =20 +#define INVALID_CAPABILITY_00 0x00 +#define INVALID_CAPABILITY_FF 0xFF +#define PCI_CAPABILITY_POINTER_MASK 0xFC =20 // // Driver Instance Data Prototypes @@ -518,4 +521,8 @@ RootBridgeConstructor ( IN UINT32 Seg ); =20 +VOID +EnlargeAtuConfig0 ( + IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This + ); #endif diff --git a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c b= /Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c index 10d766a..b57bd51 100644 --- a/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c +++ b/Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciRootBridgeIo.c @@ -14,6 +14,7 @@ **/ =20 #include "PciHostBridge.h" +#include #include #include #include @@ -2322,3 +2323,81 @@ RootBridgeIoConfiguration ( return EFI_SUCCESS; } =20 +BOOLEAN +PcieCheckAriFwdEn ( + UINTN PciBaseAddr + ) +{ + UINT8 PciPrimaryStatus; + UINT8 CapabilityOffset; + UINT8 CapId; + UINT8 TempData; + + PciPrimaryStatus =3D MmioRead16 (PciBaseAddr + PCI_PRIMARY_STATUS_OFFSET= ); + + if (PciPrimaryStatus & EFI_PCI_STATUS_CAPABILITY) { + CapabilityOffset =3D MmioRead8 (PciBaseAddr + PCI_CAPBILITY_POINTER_OF= FSET); + CapabilityOffset &=3D PCI_CAPABILITY_POINTER_MASK; + + while ((CapabilityOffset !=3D INVALID_CAPABILITY_00) && (CapabilityOff= set !=3D INVALID_CAPABILITY_FF)) { + CapId =3D MmioRead8 (PciBaseAddr + CapabilityOffset); + if (CapId =3D=3D EFI_PCI_CAPABILITY_ID_PCIEXP) { + break; + } + CapabilityOffset =3D MmioRead8 (PciBaseAddr + CapabilityOffset + 1); + CapabilityOffset &=3D PCI_CAPABILITY_POINTER_MASK; + } + } else { + PCIE_DEBUG ("[%a:%d] - No PCIE Capability.\n", __FUNCTION__, __LINE__); + return FALSE; + } + + if ((CapabilityOffset =3D=3D INVALID_CAPABILITY_FF) || (CapabilityOffset= =3D=3D INVALID_CAPABILITY_00)) { + PCIE_DEBUG ("[%a:%d] - No PCIE Capability.\n", __FUNCTION__, __LINE__); + return FALSE; + } + + TempData =3D MmioRead16 (PciBaseAddr + CapabilityOffset + + EFI_PCIE_CAPABILITY_DEVICE_CONTROL_2_OFFSET); + TempData &=3D EFI_PCIE_CAPABILITY_DEVICE_CAPABILITIES_2_ARI_FORWARDING; + + if (TempData =3D=3D EFI_PCIE_CAPABILITY_DEVICE_CAPABILITIES_2_ARI_FORWAR= DING) { + 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 =3D INSTANCE_FROM_RESOURCE_ALLOCATION_THIS (This); + List =3D HostBridgeInstance->Head.ForwardLink; + + while (List !=3D &HostBridgeInstance->Head) { + PCIE_DEBUG ("HostBridge has data.\n"); + RootBridgeInstance =3D DRIVER_INSTANCE_FROM_LIST_ENTRY (List); + + RbPciBase =3D RootBridgeInstance->RbPciBar; + + // Those ARI FWD Enable Root Bridge, need enlarge iatu window. + if (PcieCheckAriFwdEn (RbPciBase)) { + MemLimit =3D 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, (UINT= 32) MemLimit); + } + List =3D List->ForwardLink; + } +} --=20 1.9.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel