From patchwork Thu Mar 9 13:16:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 9613351 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 884E0604D9 for ; Thu, 9 Mar 2017 13:20:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CFB828518 for ; Thu, 9 Mar 2017 13:20:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71D1328546; Thu, 9 Mar 2017 13:20:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21B6228518 for ; Thu, 9 Mar 2017 13:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754457AbdCINU0 (ORCPT ); Thu, 9 Mar 2017 08:20:26 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:50228 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754648AbdCINUX (ORCPT ); Thu, 9 Mar 2017 08:20:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bmwBgOupOohCThjiNR2ZHv5PFZgFwikJV7tk4FlStMU=; b=thaCyqhZBnbY6nTORYHDyLF1w yf5JeLSAZVMnhvSUPLScjwqqxLlTS0ydwUY5VhR3yDh5ZMa6jLRh1XEvwElbJpbWtzIsFUbcwQcJ1 zV9LJFHeGDCbbvqlpf2/wHU5ReYJm15+PZXxJ27I8tkMIPpcyPrrQhWckiDI09bE3XSEbKEnPLMgM hgY8zbwtu0dt4BxIao6D/14ATBAzVO7kZcvL0MCWzqKWqaLw6AqL6wAxs1Rnu4BYYy/fUDzhxCLAx TaI6qFBKyTabwOsZehrWnGoTFvVNa0BexnXORUeqS7e+yzCly8kvCWRew8s1DethjEtXLRycwUhlH XnyGJeS/w==; Received: from bzq-82-81-101-184.red.bezeqint.net ([82.81.101.184] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1clxwG-0001My-4E; Thu, 09 Mar 2017 13:17:05 +0000 From: Sagi Grimberg To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH rfc 03/10] nvme-pci: open-code polling logic in nvme_poll Date: Thu, 9 Mar 2017 15:16:35 +0200 Message-Id: <1489065402-14757-4-git-send-email-sagi@grimberg.me> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489065402-14757-1-git-send-email-sagi@grimberg.me> References: <1489065402-14757-1-git-send-email-sagi@grimberg.me> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Given that the code is simple enough it seems better then passing a tag by reference for each call site. Signed-off-by: Sagi Grimberg Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- drivers/nvme/host/pci.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 4ed67f194cfd..a7ad514c2451 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -716,7 +716,7 @@ static inline bool nvme_read_cqe(struct nvme_queue *nvmeq, return false; } -static int __nvme_process_cq(struct nvme_queue *nvmeq, int budget, int *tag) +static int __nvme_process_cq(struct nvme_queue *nvmeq, int budget) { struct nvme_completion cqe; int consumed = 0; @@ -725,11 +725,6 @@ static int __nvme_process_cq(struct nvme_queue *nvmeq, int budget, int *tag) nvme_handle_cqe(nvmeq, &cqe); if (++consumed == budget) break; - - if (tag && *tag == cqe.command_id) { - *tag = -1; - break; - } } if (consumed) { @@ -742,7 +737,7 @@ static int __nvme_process_cq(struct nvme_queue *nvmeq, int budget, int *tag) static int nvme_process_cq(struct nvme_queue *nvmeq) { - return __nvme_process_cq(nvmeq, INT_MAX, NULL); + return __nvme_process_cq(nvmeq, INT_MAX); } static irqreturn_t nvme_irq(int irq, void *data) @@ -770,17 +765,28 @@ static irqreturn_t nvme_irq_check(int irq, void *data) static int nvme_poll(struct blk_mq_hw_ctx *hctx, unsigned int tag) { struct nvme_queue *nvmeq = hctx->driver_data; + struct nvme_completion cqe; + int found = 0, consumed = 0; - if (nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase)) { - spin_lock_irq(&nvmeq->q_lock); - __nvme_process_cq(nvmeq, INT_MAX, &tag); - spin_unlock_irq(&nvmeq->q_lock); + if (!nvme_cqe_valid(nvmeq, nvmeq->cq_head, nvmeq->cq_phase)) + return 0; - if (tag == -1) - return 1; + spin_lock_irq(&nvmeq->q_lock); + while (nvme_read_cqe(nvmeq, &cqe)) { + nvme_handle_cqe(nvmeq, &cqe); + consumed++; + + if (tag == cqe.command_id) { + found = 1; + break; + } } - return 0; + if (consumed) + nvme_ring_cq_doorbell(nvmeq); + spin_unlock_irq(&nvmeq->q_lock); + + return found; } static void nvme_pci_submit_async_event(struct nvme_ctrl *ctrl, int aer_idx)