Received: from va-1-112.ptr.blmpb.com (va-1-112.ptr.blmpb.com [209.127.230.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87F0138E8AB for ; Wed, 26 Aug 2026 06:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.230.112 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787725040; cv=none; b=Oewyjuu3cL16or+Rgf4ztouLz8cW1Ry4JwvKMJwcvYF2M6+uvBpfFYCimyPSNLFEkbQzgzibB6x0U43T8zQa/U3npuc5N/7Fa2r/4UNk2oQIHtEa6Vnp0GPcV9V4akBWLrRt+kglykzZH+u0NOBtYnntCXguMd0SvmfygPy3PEo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787725040; c=relaxed/simple; bh=ySZjrMXsQhmKrsc/CHrjQNyfRBu+3LNO1/dYvMRqGI8=; h=To:From:Date:Cc:Subject:Mime-Version:References:Message-Id: In-Reply-To:Content-Type; b=nmXHdFWWwcHkXBzKY7mm581mhVJuisv5kRgB4M+1oX0pr5iFrK4mzEFzWSiz6A9M3YsZS4WPa8NWs2xxWdcC7VA1fkpVtt9EkEujZxQTMC6vfynQ6PenHwPrTZptyiE0YIjQZgI2kSzWoKw4H2sxsBec6Gsj9NcKPx5ZkGv7HcA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=loBPhmVZ; arc=none smtp.client-ip=209.127.230.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="loBPhmVZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1787725032; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=0ikuFG/PjRl+tEVGm8h/uhZymzzHiw34XqavQX15+sI=; b=loBPhmVZMPsOrseykj6WTPgk6tMSQQ8eMU4toM1WTgKBPvYLrFz3mbYUHNMuEE4/t3JpHx moQkudRmNlR0DqUixGUhcmEEvveMXoVpFgqKF/vAEWivGq43/AETLZIdaU2cx+7Q9Vyo2c rXC/ESLesc7XNPpgkU/liujtlesMb45TZMjYguIp8T4E5gqcR4fh09NTP/lq4cIKzL1HgR b2EdNjWfRMozknLy2kO1s2YRyXh03ZaJNKcUwCtW8Jm4XjtoetimfysXhsiY+eXn/y3Ab8 KKQ/7stFRHYDXzbZZlWMRcUew7z9vCmwzSbn4g6qiOor388VHwVtG/O+HRpBhg== To: "Keith Busch" , "Jens Axboe" , "Christoph Hellwig" , "Sagi Grimberg" , , , , From: "Fengnan Chang" Date: Wed, 26 Aug 2026 14:15:45 +0800 Cc: , "Fengnan Chang" X-Original-From: Fengnan Chang Subject: [PATCH v2 1/2] nvme-pci: return completion count from nvme_poll_cq Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Lms-Return-Path: Content-Transfer-Encoding: 7bit References: <20260826061546.56006-1-changfengnan@bytedance.com> Message-Id: <20260826061546.56006-2-changfengnan@bytedance.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260826061546.56006-1-changfengnan@bytedance.com> Content-Type: text/plain; charset=UTF-8 Return the number of completions consumed by nvme_poll_cq() instead of a boolean. Existing callers still treat zero vs non-zero as before; nvme_poll() keeps returning 0/1 via a bool local. Extract nvme_irq_complete_batch() from nvme_irq() so the adaptive handler in the next patch can reuse the batch completion path. Signed-off-by: Fengnan Chang --- drivers/nvme/host/pci.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 69932d640b537..620d0430601e3 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -1606,13 +1606,12 @@ static inline void nvme_update_cq_head(struct nvme_queue *nvmeq) } } -static inline bool nvme_poll_cq(struct nvme_queue *nvmeq, - struct io_comp_batch *iob) +static inline unsigned int nvme_poll_cq(struct nvme_queue *nvmeq, + struct io_comp_batch *iob) { - bool found = false; + unsigned int found = 0; while (nvme_cqe_pending(nvmeq)) { - found = true; /* * load-load control dependency between phase and the rest of * the cqe requires a full read memory barrier @@ -1620,6 +1619,7 @@ static inline bool nvme_poll_cq(struct nvme_queue *nvmeq, dma_rmb(); nvme_handle_cqe(nvmeq, iob, nvmeq->cq_head); nvme_update_cq_head(nvmeq); + found++; } if (found) @@ -1627,17 +1627,22 @@ static inline bool nvme_poll_cq(struct nvme_queue *nvmeq, return found; } +static irqreturn_t nvme_irq_complete_batch(struct io_comp_batch *iob, + unsigned int completions) +{ + if (!completions) + return IRQ_NONE; + if (!rq_list_empty(&iob->req_list)) + nvme_pci_complete_batch(iob); + return IRQ_HANDLED; +} + static irqreturn_t nvme_irq(int irq, void *data) { struct nvme_queue *nvmeq = data; DEFINE_IO_COMP_BATCH(iob); - if (nvme_poll_cq(nvmeq, &iob)) { - if (!rq_list_empty(&iob.req_list)) - nvme_pci_complete_batch(&iob); - return IRQ_HANDLED; - } - return IRQ_NONE; + return nvme_irq_complete_batch(&iob, nvme_poll_cq(nvmeq, &iob)); } static irqreturn_t nvme_irq_check(int irq, void *data) -- 2.39.5 (Apple Git-154)