From nobody Sun May 5 01:50:01 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+41668+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41668+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1559203039; cv=none; d=zoho.com; s=zohoarc; b=CnjH9hGTCwzQt8ZEN10lNE8CH3XpDXQssIUKFxIMeDxh6/gU29js/prZHayJfASG03FoVjx8NZBHPzxTmkjSQJiIaZltC1VUg1G9y4lIBVMXjnAvKMQOaiCYo/ureEvjB8Dg1rrJIKBGltEm0yjAoZ/DfY988ibQ3c/Kwnl9n6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559203039; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=/L+kbTwAsWh8gXmV/L3GLIJVcfoPWAYs9YCir+76ISY=; b=S9wO0cyGVqqH1ESpxYxoBCvQL1+LU19JUs3gz8OcZTrBy5CzMf49xsz1nnbI8LJm3PZ0G8O9cLfZDCL37peLVk6aT+bQSfuQwtkQ/fjBUxU8vU3ZYQeIwgGa2K02DtTFPBHvqBoAFzFS8/y9tcsNvJo2CYS4Qiz5NNI2srFelzk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41668+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1559203039368916.1978950461803; Thu, 30 May 2019 00:57:19 -0700 (PDT) Return-Path: X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Thu, 30 May 2019 00:57:18 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 00:57:18 -0700 X-ExtLoop1: 1 X-Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.8]) by fmsmga008.fm.intel.com with ESMTP; 30 May 2019 00:57:17 -0700 From: "Wu, Hao A" To: devel@edk2.groups.io Cc: Hao A Wu , Ray Ni , Maggie Chu , Jian J Wang Subject: [edk2-devel] [PATCH v1] MdeModulePkg/AhciPei: Fix device cannot be found in non-S3 path Date: Thu, 30 May 2019 15:57:15 +0800 Message-Id: <20190530075715.1112-1-hao.a.wu@intel.com> Precedence: Bulk List-Unsubscribe: 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,hao.a.wu@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1559203038; bh=Wz+H+p/abIa2ty22vMrVfo5NkbjjNdfkuBM3jYm6DAA=; h=Cc:Date:From:Reply-To:Subject:To; b=BaBW9jV/3X3E917XvogpjxX/VlEyGQ8s6UvmMPAyo0T/DhdD7mf0e3PtJ5KaXvUhbZn 0Y2vJUWHOFs/B38STcslsr3c2zON4urgJvnLXqSl5r98Yp4jXMn5ehEXumzGOszLP7AwW cFzIGjIAIAHlTvAeZxFt7gDAOjw/jAZZAg4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1862 Current implementation of function AhciModeInitialization() has an incorrect assumption that the value in the CAP (offset 00h) register will always be greater than the highest bit set for the value in the PI (offset 0Ch) register. This will lead to an issue that hard disk devices may not be found in the non-S3 boot path for some AHCI controller capabilities. More specifically, variable 'PortInitializeBitMap' will have the value from 'Private->PortBitMap', which will be 0xFFFFFFFF in non-S3 boot path. When the CAP register is of value 0x1 and PI register with value 0x4 (meaning port 2 is available), the current logic will only enumerate port 0. And the device attached behind port 2 will not be enumerated. To address this issue, variable 'PortInitializeBitMap' will now take the bitwise and result between 'Private->PortBitMap' and the value read from the PI register. Please note that there will be no function impact for S3 path, since in this case, the bits being set in 'Private->PortBitMap' will be a subset of the bits being set in the PI register. Their bitwise and operation will still be the value of 'Private->PortBitMap'. Cc: Ray Ni Cc: Maggie Chu Cc: Jian J Wang Signed-off-by: Hao A Wu Reviewed-by: Ray Ni Reviewed-by: Ray Ni ray.ni@intel.com --- MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c b/MdeModulePkg/Bus/Ata= /AhciPei/AhciMode.c index 7287f8290e..8c491bd138 100644 --- a/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c +++ b/MdeModulePkg/Bus/Ata/AhciPei/AhciMode.c @@ -1713,7 +1713,7 @@ AhciModeInitialization ( MaxPortNumber =3D MIN (MaxPortNumber, (UINT8)(UINTN)(HighBitSet32(PortIm= plementBitMap) + 1)); MaxPortNumber =3D MIN (MaxPortNumber, AhciGetNumberOfPortsFromMap (Priva= te->PortBitMap)); =20 - PortInitializeBitMap =3D Private->PortBitMap; + PortInitializeBitMap =3D Private->PortBitMap & PortImplementBitMap; AhciRegisters =3D &Private->AhciRegisters; DeviceIndex =3D 0; // @@ -1721,6 +1721,13 @@ AhciModeInitialization ( // for (PortIndex =3D 1; PortIndex <=3D MaxPortNumber; PortIndex ++) { Status =3D AhciGetPortFromMap (PortInitializeBitMap, PortIndex, &Port); + if (EFI_ERROR (Status)) { + // + // No more available port, just break out of the loop. + // + break; + } + if ((PortImplementBitMap & (BIT0 << Port)) !=3D 0) { // // Initialize FIS Base Address Register and Command List Base Address --=20 2.12.0.windows.1 -=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 (#41668): https://edk2.groups.io/g/devel/message/41668 Mute This Topic: https://groups.io/mt/31866595/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-