From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.4528.1645777052773133283 for ; Fri, 25 Feb 2022 00:17:32 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=mdzR3NpL; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: hao.a.wu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645777052; x=1677313052; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=kBSTC3pyURzALPT28rsif1oPo3EZh3QPNBKGtyeGZWI=; b=mdzR3NpLWPFIUIL4B9PVSHOCHRgnhPnrRt1UUU5LTS5KOn/0vJHV6xgc hhm4qLP9VgXlfBOSbEFsJn5y8BIbYbfiua6PoPihvZO6hZZ29QXzvI4zM DNk+DVViDSWdjFVUkVNTM9FnZFxkTOTxvZ02ChRDMHLak5SZ5ymwcNqrd ycU8Qes3h4VGuInaGRkJdQ6Mof6SAuo2nCXNBCG3WPr5oFZtaOqr1xsSN PWEIUtDOqPoZRzWFsC352qs6Pxltu+35Dj7Z5s79CXrTTO3vTsYRSDPxU osx8qwOGw8WjpUUagTvjf3SasZhFjCLUupCzSdcyyEHhVS42/55WUsz06 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10268"; a="250030700" X-IronPort-AV: E=Sophos;i="5.90,136,1643702400"; d="scan'208";a="250030700" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2022 00:17:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,136,1643702400"; d="scan'208";a="640038610" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga004.jf.intel.com with ESMTP; 25 Feb 2022 00:17:31 -0800 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 25 Feb 2022 00:17:31 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21 via Frontend Transport; Fri, 25 Feb 2022 00:17:31 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.42) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Fri, 25 Feb 2022 00:17:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B+mxAjZeT9ibGfkmMsFjGZ3QbVqBmLKPNbLyj7+cJ//eT09OOBMV/Lz/LPP40O4DI+Xf4AuLeFKnhxjBfH75mYjADDWV+gfu5qAGlbx0vCXd8g7DlIiiPajs8icmDpz2zPwKYE8NSviyQL26cq/rklax1Q0bLjVTu5ybG3o3ra1tyI8OtStf2iVkGgNXAumOxy3JkFnnmVli5mCY3zPN77gX5euX7urZky6dyRYWbWH6moMz8gSpgXdqFXtqi981qZaOH2Fa8n49YB7ynjcncoWoCUuXeAB1Ch7qmAOhDEm1EDR3lv/oyKqE+g0U1S1YZKVzUJsyNamSWuWy1oJyzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bMWD13O+Rpcz1OkOu654f8H3+h5hm89kGSztjsxg87U=; b=PWSsjDXJIzgt2IHKmOZnvOqGZ4hfD4+77sIxpHoJQaN904UD7TjKJvdfcgZBFzRRSO+5L/YL4Sa7hRsDLTreyxbjGuONWGjUOmxgKnyuIuCnXBPHcNCBUbw+VvBVFvYunIa06K/W7PdwCdCz5uoZl/+LRY+VWvGMAds0w9i/Xyf7FWQgxq9sFdBGA3seL9gTiXO1fe/akcbkzIm1nqpXtXkiyqHYk6GvFyUb6n8uq/C+CTP+Zi38dgbTupTJF8XgoH0EpRCGzVpkj8iFVKY4u5eTEJJKAQhjyWfz8ynYhPevVhpjYhLQdCZtXIybpkyuSZiARBtZugPX+wUyZ5W+xQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from DM6PR11MB4025.namprd11.prod.outlook.com (2603:10b6:5:197::31) by MN2PR11MB4429.namprd11.prod.outlook.com (2603:10b6:208:18b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Fri, 25 Feb 2022 08:17:29 +0000 Received: from DM6PR11MB4025.namprd11.prod.outlook.com ([fe80::2dd0:9ba8:a8c:fc96]) by DM6PR11MB4025.namprd11.prod.outlook.com ([fe80::2dd0:9ba8:a8c:fc96%3]) with mapi id 15.20.5017.026; Fri, 25 Feb 2022 08:17:27 +0000 From: "Wu, Hao A" To: Tomas Pilar , "devel@edk2.groups.io" CC: "Ni, Ray" , Ard Biesheuvel , Leif Lindholm , Ard Biesheuvel Subject: Re: [PATCH v5] MdeModulePkg: Correct high-memory use in NvmExpressDxe Thread-Topic: [PATCH v5] MdeModulePkg: Correct high-memory use in NvmExpressDxe Thread-Index: AQHYKZq/gq8HPJBtjEK+kkFTNVsOAqyj7PTQ Date: Fri, 25 Feb 2022 08:17:26 +0000 Message-ID: References: <20220224162219.2133918-1-quic_tpilar@quicinc.com> In-Reply-To: <20220224162219.2133918-1-quic_tpilar@quicinc.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 27c793a6-c66d-414a-1aea-08d9f83742a7 x-ms-traffictypediagnostic: MN2PR11MB4429:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /b/ZEz6k6XUo8Z0mm9guEyzGfDMM74vMDnHwY4bOJ67sNpruWzTAhARmlWgiqHmlJlIpZFmAm2hu2kzdgg5Yx/i9Bs+m7HXBelmU2jiXC8jT70YnvcR20osithCbh6eonRkEfsyhCJ77ueUQUN5uKwlz+dtGW0WydLpaUuYOTdzdezkwBZylBq9igQuB4c7uhiVTsammWYEiL2wo2HNOSPzWvDSCVS2T1NLEBitB+f1AQLH02lEZIxAZ/ta6/nri5fAhrTzVo3g4MRCB89eE/7onf/Qkd1ajYxeGLIc/dcCrqgl3hD1kQZfMcUOzO3Xl4MzYuG5d4Cgwue2eQv8UtOZT1QPOGeb3zSQaKErphATBWEWEusTjwuC4FIQXu4wxfmFVfaZ9yiaoZAvISz9AUGl5nLEQr/ytsaTgAeGAAteMliNqboqKxSpC8yhRKJ/RG+K1Gl1fm7xePVLpbbv+dM4MX42gv72csn8Yda/kDaY/SJo432jSWnM1haDtSm6AkIABtbs4AYAjtXr6cc1UkCO4qXpoa1JwPSoQRiq0fc1surMqB4FqKGgEr7+ARGiMgvK7jjdS6rt27WCLpLskQj74TFphOgzC78B5VsYZOSmqpsV2fRN5+Ryi+J2TBPypdOSKbxxf3bamuhzxcWGA55R84jr1wlWMARfxVbnXOwFLMS0FSJZjLQyUBVCGpzrYv87A6wAbhyNlOqQpTxx8Yw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4025.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(186003)(110136005)(508600001)(54906003)(71200400001)(86362001)(9686003)(6506007)(83380400001)(26005)(5660300002)(316002)(52536014)(2906002)(66446008)(66946007)(66476007)(64756008)(66556008)(55016003)(33656002)(82960400001)(38070700005)(7696005)(38100700002)(53546011)(76116006)(4326008)(8936002)(8676002)(122000001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?KVHEAqi8t1ZY6/bXQLWpanB3gRVc7ZM7DhTC5xykVejg6ZXLfDLPAM94lCQA?= =?us-ascii?Q?nu6INgC6hrD+wOzabm92KQ+9bMwuTnq65ISemygpATwyrA3RvaR6BP8edwoV?= =?us-ascii?Q?MD7ZgmHUjRBS34tfWJt3+JDYHKq1oI/BD9MTQd8CWBzDw5kVVvdmtK4K2SBn?= =?us-ascii?Q?VIAdyY+Ci/almZFDuDa2op5RsFdeOkEq/q72j9jIiS3+VONXezuoPVyxeo9F?= =?us-ascii?Q?OE3I9l7TVmZFcf2/x6PsF+yPLOFDppDzgkxJNnWQLAOXrdWpFnnhGJ0HwVGh?= =?us-ascii?Q?rCCnRQz1EFFFqITMEtP0YE7wq9y+ID6gOoKaNvbYK2tXxwsVM3ur1J5I3Irh?= =?us-ascii?Q?/MT+WbASqWzIV762CjB73/bV7s6keUtTvRgLIf8IPQRhP8TfFPUlfzscMMb/?= =?us-ascii?Q?H4jSGWJKM981gqandnzWpnP4QwsA4JDy8ogZ3aCoXF6uqw3ziqxGjC0VqIn6?= =?us-ascii?Q?Hk0HxO/MuQ+S7unPQOyti/LQEYKCExwd3ykEudoCRUX4f+aNN99xDUyxGuKO?= =?us-ascii?Q?qtE9HSYRU+EVzzPXKlAACjWjjaLBf+JUipNIWn0FEzGVe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af+KX5ZTjoCZxWtrwQv4vBW+hYHHHnJwpYdKzImnl7NXl4U+b4eP5crD?= =?us-ascii?Q?BVmjweW8Mrur77Od/ImQeFI7YLGZoNJp9ioMXPSu9oUBfwrkcThSyIwejSx7?= =?us-ascii?Q?BAYAHDaOcmTNyz2dBGhsAbXrxn0dGiJjCHmD2CNiBhhjSdtTlxfKHc+rS7ST?= =?us-ascii?Q?467huo6eZZNEDrZEdZ/lQRg=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4025.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27c793a6-c66d-414a-1aea-08d9f83742a7 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Feb 2022 08:17:26.9461 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uaO7ulzkNb57gjZvCT1DVA2kn/Wauw6uaBIGTmtZAuFeZM8z306cMmRNeiCsku8ukcnWtojxrWLcYrDb8/FJUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4429 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Acked-by: Hao A Wu Best Regards, Hao Wu > -----Original Message----- > From: Tomas Pilar > Sent: Friday, February 25, 2022 12:22 AM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Ard Biesheuvel > ; Leif Lindholm ; > Wu, Hao A ; Ard Biesheuvel > Subject: [PATCH v5] MdeModulePkg: Correct high-memory use in > NvmExpressDxe >=20 > 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. >=20 > 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. >=20 > 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. >=20 > Cc: Ray Ni > Cc: Ard Biesheuvel > Cc: Leif Lindholm > Cc: Hao A Wu > Reviewed-by: Ard Biesheuvel > Signed-off-by: Tomas Pilar > --- > MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.c | 27 > ++++++++++++++++++++ > MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c | 26 +------------ > ------ > 2 files changed, 28 insertions(+), 25 deletions(-) >=20 > 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/MdeModulePkg/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 > command set is supported > // > -- > 2.30.2