From nobody Mon Feb 9 15:45:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599136157; cv=none; d=zohomail.com; s=zohoarc; b=VGJu1J4+1Sm6kMT6juTDr3nLJRuj9CRu6kDleEQs2KhGAkLBzOikoxf9WthA7eKdyY1JeiVvlSFPEXX8ZpDbEbYV7D62OpX4+7OS9p6J/dgE/2lT+rsym/iSQJvUJ6D8PV5nbgdA6h9XsbSnS5FGGDhSLIFmb3FV42DL7HOkz1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599136157; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=D/1bfeigNPBAr+CZsKwZjr8MJ2jC3u5ha14iMiW2Qnc=; b=j7hRIS5Ao6MK/WuedqMJ7IcLdg6qjn4C+nkmcLyzNkydvAjBhOXsJfS1BvkILG5rIrvCG0m9m+vx+y5axEDSS6a5wUNyXV8hiqdTJnvr43njthXF2fspxLearZCTI5neJmnKapLPGtUmgTZVfJw1+O7L0lXy+Iy3Sb0DKe8z3dk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1599136157882904.2238013107337; Thu, 3 Sep 2020 05:29:17 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-WsbZCKc5Msy1Z9umqcWWFw-1; Thu, 03 Sep 2020 08:29:15 -0400 Received: by mail-wm1-f72.google.com with SMTP id x6so918361wmb.6 for ; Thu, 03 Sep 2020 05:29:15 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id o6sm2969158wrm.76.2020.09.03.05.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 05:29:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599136157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D/1bfeigNPBAr+CZsKwZjr8MJ2jC3u5ha14iMiW2Qnc=; b=DxpGBcXWsrVOtynwsKnJOm+AqE2gmrgslrN//II7gjmbk5kj/yiNbFFxD5mKU101l5EBRx /swcMREj4evgjFAzAfNRDazvoXxnDe1ORyFkuz8tEIlZrH/9h02xI04dJeQXjuj9YHYjXt Z3d52E9DfsKSqsS+DN2oLdNyojrUe2w= X-MC-Unique: WsbZCKc5Msy1Z9umqcWWFw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D/1bfeigNPBAr+CZsKwZjr8MJ2jC3u5ha14iMiW2Qnc=; b=As3Vh/jWYKW6HNr3kSNoltJ7GAKEelH4k+mmzw4s2YQh8BLM7H4bjceuXbggqz56/c T2c2uZ6tNhunoWDitn9DrDsfkGeTNDxVHq5hM4yrOUHofPSaDoqZk8XF6w14Xr3f4wt6 GimT8OfSksmPEjgEE7qW5yymaf/mkUaJVzUBCmHiMYIQPktIhP6fY9A7NpocbAFYFaTD CEyk7tYIRuP/hjJAUjloaha+T4Lx954gTVihX3+XEcLBKDRzp5aA9Ayfy+3DzpuxqP0Y Etom/WkCKT/PUssvIVjK8yXuQtGX1Hv7P5XLpv2yJWXYpPXxbJSNPzkl6rTVOya2qq3l 7GYg== X-Gm-Message-State: AOAM531DeAaDGwg9rPtfwsWGZDlURh0arfuzm3VLvdnXo7cgtKaEryLi BCoxVG8/KhGUJXcsC9jw7MC40umG3YEWNbbj9aTIUkQEXEx/xBWwEcjYqIbXhtmU0RiXeYCIyZt topHwqrGQBnBFgA== X-Received: by 2002:a5d:56cd:: with SMTP id m13mr2161732wrw.261.1599136154266; Thu, 03 Sep 2020 05:29:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTPgSinKaIRHqtaXlf7sopCZGc1ejfatwJo/w0wG4f1Xj7w3z5sSAL1AT7yvfuRQwI3YvN5Q== X-Received: by 2002:a5d:56cd:: with SMTP id m13mr2161703wrw.261.1599136154021; Thu, 03 Sep 2020 05:29:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Fam Zheng , Max Reitz , Keith Busch , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH v7 14/15] block/nvme: Extract nvme_poll_queue() Date: Thu, 3 Sep 2020 14:28:02 +0200 Message-Id: <20200903122803.405265-15-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903122803.405265-1-philmd@redhat.com> References: <20200903122803.405265-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As we want to do per-queue polling, extract the nvme_poll_queue() method which operates on a single queue. Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 914a3c4ab31..e3719d3bd14 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -590,31 +590,41 @@ out: qemu_vfree(id); } =20 +static bool nvme_poll_queue(NVMeQueuePair *q) +{ + bool progress =3D false; + + const size_t cqe_offset =3D q->cq.head * NVME_CQ_ENTRY_BYTES; + NvmeCqe *cqe =3D (NvmeCqe *)&q->cq.queue[cqe_offset]; + + /* + * Do an early check for completions. q->lock isn't needed because + * nvme_process_completion() only runs in the event loop thread and + * cannot race with itself. + */ + if ((le16_to_cpu(cqe->status) & 0x1) =3D=3D q->cq_phase) { + return false; + } + + qemu_mutex_lock(&q->lock); + while (nvme_process_completion(q)) { + /* Keep polling */ + progress =3D true; + } + qemu_mutex_unlock(&q->lock); + + return progress; +} + static bool nvme_poll_queues(BDRVNVMeState *s) { bool progress =3D false; int i; =20 for (i =3D 0; i < s->nr_queues; i++) { - NVMeQueuePair *q =3D s->queues[i]; - const size_t cqe_offset =3D q->cq.head * NVME_CQ_ENTRY_BYTES; - NvmeCqe *cqe =3D (NvmeCqe *)&q->cq.queue[cqe_offset]; - - /* - * Do an early check for completions. q->lock isn't needed because - * nvme_process_completion() only runs in the event loop thread and - * cannot race with itself. - */ - if ((le16_to_cpu(cqe->status) & 0x1) =3D=3D q->cq_phase) { - continue; - } - - qemu_mutex_lock(&q->lock); - while (nvme_process_completion(q)) { - /* Keep polling */ + if (nvme_poll_queue(s->queues[i])) { progress =3D true; } - qemu_mutex_unlock(&q->lock); } return progress; } --=20 2.26.2