From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 322102116821B for ; Tue, 23 Oct 2018 21:09:05 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2018 21:09:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,418,1534834800"; d="scan'208";a="85095712" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga006.jf.intel.com with ESMTP; 23 Oct 2018 21:09:05 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 Oct 2018 21:09:05 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 Oct 2018 21:09:04 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.117]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.214]) with mapi id 14.03.0415.000; Wed, 24 Oct 2018 12:09:01 +0800 From: "Ni, Ruiyu" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Yao, Jiewen" , "Zeng, Star" Thread-Topic: [PATCH v2 3/3] MdeModulePkg/NvmExpressDxe: Refine PassThru IO queue creation behavior Thread-Index: AQHUaze1xiQri4EzVUCn9zXoh2bTV6UtyAUA Date: Wed, 24 Oct 2018 04:08:13 +0000 Deferred-Delivery: Wed, 24 Oct 2018 04:09:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BED0261@SHSMSX104.ccr.corp.intel.com> References: <20181024011952.20404-1-hao.a.wu@intel.com> <20181024011952.20404-4-hao.a.wu@intel.com> In-Reply-To: <20181024011952.20404-4-hao.a.wu@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 3/3] MdeModulePkg/NvmExpressDxe: Refine PassThru IO queue creation behavior X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Oct 2018 04:09:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni Thanks/Ray > -----Original Message----- > From: Wu, Hao A > Sent: Wednesday, October 24, 2018 9:20 AM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Yao, Jiewen ; > Ni, Ruiyu ; Zeng, Star > Subject: [PATCH v2 3/3] MdeModulePkg/NvmExpressDxe: Refine PassThru > IO queue creation behavior >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D1260 >=20 > 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 b= e > consumed. >=20 > 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 creati= on > commands and will return "EFI_UNSUPPORTED" for external ones. >=20 > Cc: Jiewen Yao > Cc: Ruiyu Ni > Cc: Star Zeng > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu > --- > MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h | 7 +++++- > MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c | 6 +++++ > MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 25 > +++++++++++++------- > 3 files changed, 29 insertions(+), 9 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h > b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h > index ad0d9b8966..fe7d37c118 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h > +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpress.h > @@ -3,7 +3,7 @@ > NVM Express specification. >=20 > (C) Copyright 2016 Hewlett Packard Enterprise Development LP
> - Copyright (c) 2013 - 2017, Intel Corporation. All rights reserved.
> + Copyright (c) 2013 - 2018, Intel Corporation. All rights > + reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD > License > which accompanies this distribution. The full text of the license may= be > found at @@ -147,6 +147,11 @@ struct > _NVME_CONTROLLER_PRIVATE_DATA { > NVME_CQHDBL CqHdbl[NVME_MAX_QUEUES]; > UINT16 AsyncSqHead; >=20 > + // > + // Flag to indicate internal IO queue creation. > + // > + BOOLEAN CreateIoQueue; > + > UINT8 Pt[NVME_MAX_QUEUES]; > UINT16 Cid[NVME_MAX_QUEUES]; >=20 > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c > b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c > index 421561f16d..4a070f3f13 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c > +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressHci.c > @@ -584,6 +584,7 @@ NvmeCreateIoCompletionQueue ( > UINT16 QueueSize; >=20 > Status =3D EFI_SUCCESS; > + Private->CreateIoQueue =3D TRUE; >=20 > for (Index =3D 1; Index < NVME_MAX_QUEUES; Index++) { > ZeroMem (&CommandPacket, > sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET)); > @@ -627,6 +628,8 @@ NvmeCreateIoCompletionQueue ( > } > } >=20 > + Private->CreateIoQueue =3D FALSE; > + > return Status; > } >=20 > @@ -653,6 +656,7 @@ NvmeCreateIoSubmissionQueue ( > UINT16 QueueSize; >=20 > Status =3D EFI_SUCCESS; > + Private->CreateIoQueue =3D TRUE; >=20 > for (Index =3D 1; Index < NVME_MAX_QUEUES; Index++) { > ZeroMem (&CommandPacket, > sizeof(EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET)); > @@ -698,6 +702,8 @@ NvmeCreateIoSubmissionQueue ( > } > } >=20 > + Private->CreateIoQueue =3D FALSE; > + > return Status; > } >=20 > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > index c52e960771..78464ff422 100644 > --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c > @@ -587,14 +587,23 @@ NvmExpressPassThru ( > } >=20 > Sq->Prp[0] =3D (UINT64)(UINTN)Packet->TransferBuffer; > - // > - // If the NVMe cmd has data in or out, then mapping the user buffer to= the > PCI controller specific addresses. > - // Note here we don't handle data buffer for CreateIOSubmitionQueue > and CreateIOCompletionQueue cmds because > - // these two cmds are special which requires their data buffer must > support simultaneous access by both the > - // processor and a PCI Bus Master. It's caller's responsbility to ensu= re this. > - // > - if (((Sq->Opc & (BIT0 | BIT1)) !=3D 0) && > - !((Packet->QueueType =3D=3D NVME_ADMIN_QUEUE) && ((Sq->Opc =3D=3D > NVME_ADMIN_CRIOCQ_CMD) || (Sq->Opc =3D=3D > NVME_ADMIN_CRIOSQ_CMD)))) { > + if ((Packet->QueueType =3D=3D NVME_ADMIN_QUEUE) && > + ((Sq->Opc =3D=3D NVME_ADMIN_CRIOCQ_CMD) || (Sq->Opc =3D=3D > NVME_ADMIN_CRIOSQ_CMD))) { > + // > + // Currently, we only use the IO Completion/Submission queues create= d > internally > + // by this driver during controller initialization. Any other IO que= ues > created > + // will not be consumed here. The value is little to accept external= IO > queue > + // creation requests, so here we will return EFI_UNSUPPORTED for > external IO > + // queue creation request. > + // > + if (!Private->CreateIoQueue) { > + DEBUG ((DEBUG_ERROR, "NvmExpressPassThru: Does not support > external IO queues creation request.\n")); > + return EFI_UNSUPPORTED; > + } > + } else if ((Sq->Opc & (BIT0 | BIT1)) !=3D 0) { > + // > + // If the NVMe cmd has data in or out, then mapping the user buffer = to > the PCI controller specific addresses. > + // > if (((Packet->TransferLength !=3D 0) && (Packet->TransferBuffer =3D= =3D NULL)) > || > ((Packet->TransferLength =3D=3D 0) && (Packet->TransferBuffer != =3D NULL))) { > return EFI_INVALID_PARAMETER; > -- > 2.12.0.windows.1