]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/NvmExpressDxe: Refine PassThru IO queue creation behavior
authorHao Wu <hao.a.wu@intel.com>
Tue, 23 Oct 2018 12:57:43 +0000 (20:57 +0800)
committerHao Wu <hao.a.wu@intel.com>
Thu, 25 Oct 2018 04:41:37 +0000 (12:41 +0800)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1260

For the PassThru() service of NVM Express Pass Through Protocol, the
current implementation (function NvmExpressPassThru()) will only use the
IO Completion/Submission queues created internally by this driver during
the controller initialization process. Any other IO queues created will
not be consumed.

So the value is little to accept external IO Completion/Submission queue
creation request. This commit will refine the behavior of function
NvmExpressPassThru(), it will only accept driver internal IO queue
creation commands and will return "EFI_UNSUPPORTED" for external ones.

Cc: Jiewen Yao <Jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c

index ad0d9b8966a94fb3e88bd2a982228c7535bf4eb8..fe7d37c118062cee810e024a12e497959d6ddabf 100644 (file)
@@ -3,7 +3,7 @@
   NVM Express specification.\r
 \r
   (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
-  Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -147,6 +147,11 @@ struct _NVME_CONTROLLER_PRIVATE_DATA {
   NVME_CQHDBL                         CqHdbl[NVME_MAX_QUEUES];\r
   UINT16                              AsyncSqHead;\r
 \r
+  //\r
+  // Flag to indicate internal IO queue creation.\r
+  //\r
+  BOOLEAN                             CreateIoQueue;\r
+\r
   UINT8                               Pt[NVME_MAX_QUEUES];\r
   UINT16                              Cid[NVME_MAX_QUEUES];\r
 \r
index 421561f16d6d3bbc18009e8a4f991316ccfadfdc..4a070f3f13367e669e1cb6eb3a8c471490ca7f7e 100644 (file)
@@ -584,6 +584,7 @@ NvmeCreateIoCompletionQueue (
   UINT16                                   QueueSize;\r
 \r
   Status = EFI_SUCCESS;\r
+  Private->CreateIoQueue = TRUE;\r
 \r
   for (Index = 1; Index < NVME_MAX_QUEUES; Index++) {\r
     ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));\r
@@ -627,6 +628,8 @@ NvmeCreateIoCompletionQueue (
     }\r
   }\r
 \r
+  Private->CreateIoQueue = FALSE;\r
+\r
   return Status;\r
 }\r
 \r
@@ -653,6 +656,7 @@ NvmeCreateIoSubmissionQueue (
   UINT16                                   QueueSize;\r
 \r
   Status = EFI_SUCCESS;\r
+  Private->CreateIoQueue = TRUE;\r
 \r
   for (Index = 1; Index < NVME_MAX_QUEUES; Index++) {\r
     ZeroMem (&CommandPacket, sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET));\r
@@ -698,6 +702,8 @@ NvmeCreateIoSubmissionQueue (
     }\r
   }\r
 \r
+  Private->CreateIoQueue = FALSE;\r
+\r
   return Status;\r
 }\r
 \r
index c52e960771eff652fd276a4ad1404c4893aafc0d..78464ff4227edbbcc608a57c4c369388df749ecf 100644 (file)
@@ -587,14 +587,23 @@ NvmExpressPassThru (
   }\r
 \r
   Sq->Prp[0] = (UINT64)(UINTN)Packet->TransferBuffer;\r
-  //\r
-  // If the NVMe cmd has data in or out, then mapping the user buffer to the PCI controller specific addresses.\r
-  // Note here we don't handle data buffer for CreateIOSubmitionQueue and CreateIOCompletionQueue cmds because\r
-  // these two cmds are special which requires their data buffer must support simultaneous access by both the\r
-  // processor and a PCI Bus Master. It's caller's responsbility to ensure this.\r
-  //\r
-  if (((Sq->Opc & (BIT0 | BIT1)) != 0) &&\r
-      !((Packet->QueueType == NVME_ADMIN_QUEUE) && ((Sq->Opc == NVME_ADMIN_CRIOCQ_CMD) || (Sq->Opc == NVME_ADMIN_CRIOSQ_CMD)))) {\r
+  if ((Packet->QueueType == NVME_ADMIN_QUEUE) &&\r
+      ((Sq->Opc == NVME_ADMIN_CRIOCQ_CMD) || (Sq->Opc == NVME_ADMIN_CRIOSQ_CMD))) {\r
+    //\r
+    // Currently, we only use the IO Completion/Submission queues created internally\r
+    // by this driver during controller initialization. Any other IO queues created\r
+    // will not be consumed here. The value is little to accept external IO queue\r
+    // creation requests, so here we will return EFI_UNSUPPORTED for external IO\r
+    // queue creation request.\r
+    //\r
+    if (!Private->CreateIoQueue) {\r
+      DEBUG ((DEBUG_ERROR, "NvmExpressPassThru: Does not support external IO queues creation request.\n"));\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  } else if ((Sq->Opc & (BIT0 | BIT1)) != 0) {\r
+    //\r
+    // If the NVMe cmd has data in or out, then mapping the user buffer to the PCI controller specific addresses.\r
+    //\r
     if (((Packet->TransferLength != 0) && (Packet->TransferBuffer == NULL)) ||\r
         ((Packet->TransferLength == 0) && (Packet->TransferBuffer != NULL))) {\r
       return EFI_INVALID_PARAMETER;\r