Skip to content

Commit

Permalink
Merge branch 'release/202302' into release/202302/snpdxe-update
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeLopez333 authored Aug 14, 2023
2 parents 278a941 + ca54cde commit 17a13db
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
43 changes: 39 additions & 4 deletions MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ UINTN mNvmeControllerNumber = 0;
**/
EFI_STATUS
ReadNvmeControllerCapabilities (
IN NVME_CONTROLLER_PRIVATE_DATA *Private,
IN NVME_CAP *Cap
// MU_CHANGE [BEGIN] - Correct Cap parameter modifier
IN NVME_CONTROLLER_PRIVATE_DATA *Private,
OUT NVME_CAP *Cap
// MU_CHANGE [END] - Correct Cap parameter modifier
)
{
EFI_PCI_IO_PROTOCOL *PciIo;
Expand Down Expand Up @@ -743,13 +745,36 @@ NvmeControllerInit (
NVME_AQA Aqa;
NVME_ASQ Asq;
NVME_ACQ Acq;
UINT16 VidDid[2]; // MU_CHANGE - Improve NVMe controller init robustness
UINT8 Sn[21];
UINT8 Mn[41];

// MU_CHANGE [BEGIN] - Improve NVMe controller init robustness
PciIo = Private->PciIo;

//
// Verify the controller is still accessible
//
Status = PciIo->Pci.Read (
PciIo,
EfiPciIoWidthUint16,
PCI_VENDOR_ID_OFFSET,
ARRAY_SIZE (VidDid),
VidDid
);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return EFI_DEVICE_ERROR;
}

if ((VidDid[0] == 0xFFFF) || (VidDid[1] == 0xFFFF)) {
return EFI_DEVICE_ERROR;
}

//
// Enable this controller.
//
PciIo = Private->PciIo;
// MU_CHANGE [END] - Improve NVMe controller init robustness
Status = PciIo->Attributes (
PciIo,
EfiPciIoAttributeOperationSupported,
Expand Down Expand Up @@ -788,7 +813,17 @@ NvmeControllerInit (
//
// Currently the driver only supports 4k page size.
//
ASSERT ((Private->Cap.Mpsmin + 12) <= EFI_PAGE_SHIFT);

// MU_CHANGE [BEGIN] - Improve NVMe controller init robustness

// Currently, this means Cap.Mpsmin must be zero for an EFI_PAGE_SHIFT size of 12.
// ASSERT ((Private->Cap.Mpsmin + 12) <= EFI_PAGE_SHIFT);
if ((Private->Cap.Mpsmin + 12) > EFI_PAGE_SHIFT) {
DEBUG ((DEBUG_ERROR, "NvmeControllerInit: Mpsmin is larger than expected (0x%02x).\n", Private->Cap.Mpsmin));
return EFI_DEVICE_ERROR;
}

// MU_CHANGE [END] - Improve NVMe controller init robustness

Private->Cid[0] = 0;
Private->Cid[1] = 0;
Expand Down
14 changes: 8 additions & 6 deletions MdePkg/Include/IndustryStandard/Nvme.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,25 @@
//
// 3.1.1 Offset 00h: CAP - Controller Capabilities
//
// MU_CHANGE [BEGIN] - Add missing capability descriptions
typedef struct {
UINT16 Mqes; // Maximum Queue Entries Supported
UINT8 Cqr : 1; // Contiguous Queues Required
UINT8 Ams : 2; // Arbitration Mechanism Supported
UINT8 Rsvd1 : 5;
UINT8 To; // Timeout
UINT16 Dstrd : 4;
UINT8 To; // Timeout
UINT16 Dstrd : 4; // Doorbell Stride
UINT16 Nssrs : 1; // NVM Subsystem Reset Supported NSSRS
UINT16 Css : 8; // Command Sets Supported - Bit 37
UINT16 Bps : 1; // Boot Partition Support - Bit 45 in NVMe1.4
UINT16 Rsvd3 : 2;
UINT8 Mpsmin : 4;
UINT8 Mpsmax : 4;
UINT8 Pmrs : 1;
UINT8 Cmbs : 1;
UINT8 Mpsmin : 4; // Memory Page Size Minimum
UINT8 Mpsmax : 4; // Memory Page Size Maximum
UINT8 Pmrs : 1; // Persistent Memory Region Supported
UINT8 Cmbs : 1; // Controller Memory Buffer Supported
UINT8 Rsvd4 : 6;
} NVME_CAP;
// MU_CHANGE [END] - Add missing capability descriptions

//
// 3.1.2 Offset 08h: VS - Version
Expand Down

0 comments on commit 17a13db

Please sign in to comment.