public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>, "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH v1 3/3] MdeModulePkg/NvmExpressDxe: Refine PassThru IO queue creation behavior
Date: Wed, 24 Oct 2018 00:59:02 +0000	[thread overview]
Message-ID: <B80AF82E9BFB8E4FBD8C89DA810C6A093C83DD9D@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <5774f193-fc94-a08c-9093-932363b648f2@Intel.com>

> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Tuesday, October 23, 2018 4:54 PM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Yao, Jiewen; Zeng, Star
> Subject: Re: [PATCH v1 3/3] MdeModulePkg/NvmExpressDxe: Refine PassThru
> IO queue creation behavior
> 
> On 10/18/2018 2:42 PM, Hao Wu wrote:
> > 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: Ruiyu Ni <ruiyu.ni@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>
> > ---
> >   MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 42
> ++++++++++++++++----
> >   1 file changed, 34 insertions(+), 8 deletions(-)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
> b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
> > index c52e960771..0c550bd52c 100644
> > --- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
> > +++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
> > @@ -476,6 +476,7 @@ NvmExpressPassThru (
> >     UINT32                         Data;
> >     NVME_PASS_THRU_ASYNC_REQ       *AsyncRequest;
> >     EFI_TPL                        OldTpl;
> > +  UINT32                         CrIoQid;
> >
> >     //
> >     // check the data fields in Packet parameter.
> > @@ -587,14 +588,39 @@ NvmExpressPassThru (
> >     }
> >
> >     Sq->Prp[0] = (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 ensure this.
> > -  //
> > -  if (((Sq->Opc & (BIT0 | BIT1)) != 0) &&
> > -      !((Packet->QueueType == NVME_ADMIN_QUEUE) && ((Sq->Opc ==
> NVME_ADMIN_CRIOCQ_CMD) || (Sq->Opc == NVME_ADMIN_CRIOSQ_CMD))))
> {
> > +  if ((Packet->QueueType == NVME_ADMIN_QUEUE) &&
> > +      ((Sq->Opc == NVME_ADMIN_CRIOCQ_CMD) || (Sq->Opc ==
> NVME_ADMIN_CRIOSQ_CMD))) {
> > +    //
> > +    // Command Dword 10 should be valid for CreateIOCompletionQueue
> and
> > +    // CreateIOSubmissionQueue commands.
> > +    //
> > +    if (!(Packet->NvmeCmd->Flags & CDW10_VALID)) {
> > +      return EFI_INVALID_PARAMETER;
> > +    }
> > +
> > +    //
> > +    // Bits 15:0 of Command Dword 10 is the Queue Identifier (QID) for
> > +    // CreateIOCompletionQueue and CreateIOSubmissionQueue commands.
> > +    //
> > +    CrIoQid = Packet->NvmeCmd->Cdw10 & 0xFFFF;
> > +
> > +    //
> > +    // Currently, we only use the IO Completion/Submission queues created
> internally
> > +    // by this driver during controller initialization. Any other IO queues
> 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 ((CrIoQid >= NVME_MAX_QUEUES) ||
> > +        ((Sq->Opc == NVME_ADMIN_CRIOCQ_CMD) && (Packet-
> >TransferBuffer != Private->CqBufferPciAddr[CrIoQid])) ||
> > +        ((Sq->Opc == NVME_ADMIN_CRIOSQ_CMD) && (Packet-
> >TransferBuffer != Private->SqBufferPciAddr[CrIoQid]))) {
> > +      DEBUG ((DEBUG_ERROR, "NvmExpressPassThru: Does not support
> external IO queues creation request.\n"));
> > +      return EFI_UNSUPPORTED;
> > +    }
> 
> Does the above check is to make sure only accept IO queues creation
> request from NvmeCreateIoCompletionQueue() and
> NvmeCreateIoSubmissionQueue()?

Yes. Actually, the above codes (including the "Packet->NvmeCmd->Flags") are to
ensure that the IO queues creation request is internal.

> 
> The check is very complex and unnecessary IMO. If we introduce a boolean
> field like CreateQueue in the Private structure and set it to TRUE when
> calling PassThru() from the above two internal functions, the above
> check can be replaced with only one line check:
>    if (Private->CreateQueue)
> 
> It does introduce a "dirty" flag in Private structure, but the above
> complex check can be avoided.
> What's your opinion?

Yes, I think for this way the code is more simple.
I will propose a V2 of the series.

Best Regards,
Hao Wu

> 
> > +  } else if ((Sq->Opc & (BIT0 | BIT1)) != 0) {
> > +    //
> > +    // If the NVMe cmd has data in or out, then mapping the user buffer to
> the PCI controller specific addresses.
> > +    //
> >       if (((Packet->TransferLength != 0) && (Packet->TransferBuffer == NULL))
> ||
> >           ((Packet->TransferLength == 0) && (Packet->TransferBuffer != NULL))) {
> >         return EFI_INVALID_PARAMETER;
> >
> 
> 
> --
> Thanks,
> Ray

      reply	other threads:[~2018-10-24  0:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18  6:41 [PATCH v1 0/3] NvmExpressDxe: Bug fixes within NvmExpressPassThru() Hao Wu
2018-10-18  6:41 ` [PATCH v1 1/3] MdeModulePkg/NvmExpressDxe: Refine data buffer & len check in PassThru Hao Wu
2018-10-23  8:53   ` Ni, Ruiyu
2018-10-18  6:41 ` [PATCH v1 2/3] MdeModulePkg/NvmExpressDxe: Always copy CQ entry to PassThru packet Hao Wu
2018-10-23  8:54   ` Ni, Ruiyu
2018-10-18  6:42 ` [PATCH v1 3/3] MdeModulePkg/NvmExpressDxe: Refine PassThru IO queue creation behavior Hao Wu
2018-10-23  8:53   ` Ni, Ruiyu
2018-10-24  0:59     ` Wu, Hao A [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B80AF82E9BFB8E4FBD8C89DA810C6A093C83DD9D@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox