From nobody Fri May 17 09:18:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86993+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86993+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1645719751; cv=none; d=zohomail.com; s=zohoarc; b=BLsGl2VIAWgzgEWZX/u96Cq3xotmbTfx8z1WPTArI9hbvn6btD94dvN3C2HSkRq4Ih9Lfiv3xXDZMtTzv/GVr/lJMr8jEvTQASys2/aCenMNeZO62BTK3ig8ZDcIMaT7H0yk5+/PhuhRjp2XGar5LAY4EOgynxC5gTVH+U7O2BI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645719751; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=Mb5RdmIJP61wo2stqil0skw+A4mFP2PBb2i60G9fFXM=; b=JpWcuFPg/tsLJfve9uvCmfd5HRJeOpBovhzS7eHWyHTM53qpGw4rdaMNICWMCOMofu2BdKL8vtBhuxXVAHwkxw2P6ZWHfdnC123v9+5DjZw+taQ7qDYH2HHpHgFBStFHVGjwsCBIucod8jK9szCtjA/RKAOdoBKQfSrlZbaNT4Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86993+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 164571975111076.39811688090754; Thu, 24 Feb 2022 08:22:31 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6EB4YY1788612xbgttQOGftM; Thu, 24 Feb 2022 08:22:30 -0800 X-Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by mx.groups.io with SMTP id smtpd.web10.12552.1645719749603592176 for ; Thu, 24 Feb 2022 08:22:29 -0800 X-Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-02.qualcomm.com with ESMTP; 24 Feb 2022 08:22:29 -0800 X-QCInternal: smtphost X-Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg-SD-alpha.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Feb 2022 08:22:29 -0800 X-Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Thu, 24 Feb 2022 08:22:28 -0800 X-Received: from krabica.qualcomm.com (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Thu, 24 Feb 2022 08:22:26 -0800 From: "Tomas Pilar (tpilar)" To: CC: Ray Ni , Ard Biesheuvel , Leif Lindholm , Hao A Wu , Ard Biesheuvel Subject: [edk2-devel] [PATCH v5] MdeModulePkg: Correct high-memory use in NvmExpressDxe Date: Thu, 24 Feb 2022 16:22:19 +0000 Message-ID: <20220224162219.2133918-1-quic_tpilar@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) Precedence: Bulk List-Unsubscribe: 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,quic_tpilar@quicinc.com X-Gm-Message-State: zXqjEYwpy7uYpJOUPC8SZZMwx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1645719750; bh=0PqmnPstXbd+45CG50K0yelW2bUoVsE7pEjM/KLEZ10=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Vk2HUt37sqOOF46tPNPsmTKjRVSbknYKafXSL6RzT5hSOdVycBwnjUOgS6PS3C9e/LP /639VEgs3MpIikjE/Tf42DYCQHCxlfbQO+Hflj84R1EfSoJzhswaBQ1LZI+edZtJ1kv9E hmJ+5u77wHJ42XurZlXC+VgtJrSKGgSnOu8= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1645719751967100001 Content-Type: text/plain; charset="utf-8" Move the logic that stores starting PCI attributes and sets the EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE attribute to DriverBindingStart() before the memory that backs the DMA engine is allocated. This ensures that the DMA-backing memory is not forcibly allocated below 4G in system address map. Otherwise the allocation fails on platforms that do not have any memory below the 4G mark and the drive initialisation fails. Leave the PCI device enabling attribute logic in NvmeControllerInit() to ensure that the device is re-enabled on reset in case it was disabled via PCI attributes. Cc: Ray Ni Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Hao A Wu Reviewed-by: Ard Biesheuvel Signed-off-by: Tomas Pilar Acked-by: Hao A Wu --- MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c | 27 ++++++++++++++++++= ++ MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c | 26 +------------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c b/MdeModulePkg= /Bus/Pci/NvmExpressDxe/NvmExpress.c index 9d40f67e8e..5a1eda8e8d 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c @@ -959,6 +959,33 @@ NvmExpressDriverBindingStart ( goto Exit; } =20 + // + // Save original PCI attributes + // + Status =3D PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationGet, + 0, + &Private->PciAttributes + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Enable 64-bit DMA support in the PCI layer. + // + Status =3D PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationEnable, + EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "NvmExpressDriverBindingStart: failed to enable = 64-bit DMA (%r)\n", Status)); + } + // // 6 x 4kB aligned buffers will be carved out of this buffer. // 1st 4kB boundary is the start of the admin submission queue. diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c b/MdeModule= Pkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c index ac77afe113..d87212ffb2 100644 --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c @@ -728,20 +728,9 @@ NvmeControllerInit ( UINT8 Mn[41]; =20 // - // Save original PCI attributes and enable this controller. + // Enable this controller. // PciIo =3D Private->PciIo; - Status =3D PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationGet, - 0, - &Private->PciAttributes - ); - - if (EFI_ERROR (Status)) { - return Status; - } - Status =3D PciIo->Attributes ( PciIo, EfiPciIoAttributeOperationSupported, @@ -764,19 +753,6 @@ NvmeControllerInit ( return Status; } =20 - // - // Enable 64-bit DMA support in the PCI layer. - // - Status =3D PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE, - NULL - ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_WARN, "NvmeControllerInit: failed to enable 64-bit DMA (= %r)\n", Status)); - } - // // Read the Controller Capabilities register and verify that the NVM com= mand set is supported // --=20 2.30.2 -=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 (#86993): https://edk2.groups.io/g/devel/message/86993 Mute This Topic: https://groups.io/mt/89368607/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-