From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1602691105; cv=none; d=zohomail.com; s=zohoarc; b=fCykKSiGY2+209BLpnLWP7CI9OHe31FgdKe1mJK/M/m1xqNJ56MrcWnWfmuAKLMUL30c116OnYyXe/diq+kHGD0cpnDWAbGWN7JNef5oLjSLVvP96/cl8zQpyHt7L4EYnz2zfNBDlYDgF8cKI7bZezhAIWGGOJttLwA8lSdYNF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691105; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=NKV0WLjtIuXuPWZBe66EqUXPKE/Tlow7+lo7RAkaIjU=; b=MzaxGIsjqE+DONMkThXFdWO/jI0E9yRWOIdXbEsPkWe0xYTAzH9WEtrJVxj7hARmVN0q1Ss9ge+kJPcetoldw1EAcCbduEcte3TNCpUIvNeat3SkcvipgLQh5CbHy4PA6Kh2wL4Vp83rVDJXlOq3As+fFGR/sAzu2ZRy6/MQ3Tk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602691105026378.31604381075465; Wed, 14 Oct 2020 08:58:25 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-240-egBwfysYPBisupkv8g-Ubw-1; Wed, 14 Oct 2020 11:58:22 -0400 Received: by mail-wm1-f70.google.com with SMTP id i9so11300wml.2 for ; Wed, 14 Oct 2020 08:58:21 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id u195sm110593wmu.18.2020.10.14.08.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691103; 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=NKV0WLjtIuXuPWZBe66EqUXPKE/Tlow7+lo7RAkaIjU=; b=Wl8GFo5ER19Zs17xiPyMuT4i5ZEJO5i0XyjX9wOt4QLVWt544h2wPZwjG7JyXcDKiR3IEX fnuC4XXIon1ArLmGjgasH/CkFucu6xZMcxO2515laKPLCS1ztnf1za0E9UEZtTsQuRTfNe mx/yRlcuWjdcp7GBluhkXZYW4H19Cq4= X-MC-Unique: egBwfysYPBisupkv8g-Ubw-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=NKV0WLjtIuXuPWZBe66EqUXPKE/Tlow7+lo7RAkaIjU=; b=VTMuZJjiec/bEaJUtoE7OEiqLmv4+CuaXxGHDEDx8QSJ+eiOW9ZPCChG4Q9F2k5F4p kZpbgtG/VkhXwEG8lrHF5Slur9JJ+v2nWu+XgpI0qvnEHbzmq234PyYfmRkcICwimD4E KDiIO7Q4ouiyUv/xBRMYwtjsHHLxWRYLW4l/DrahS9cwwE5sEqqj3xhrWCod9ExJw2IJ /je5/x2zGzjKxa1BBkihDoXLCBL86kxYiM2WpuoQ54S4zypsiSE5Mh3mC6qUC4pke7kT XSAOcqvbPX+TwrvGn6GnLvSPDa9rM4MwHO9NkZyop+BwOCl99RnIItA4U06GNvuhKUT+ MWXA== X-Gm-Message-State: AOAM531xm/zodaqmdSDi3PJtEmB3UCJSqM4lNsIY1Fu6P6fXfTzbCLf7 NySv6XxUz0rG2Ln5/mn4F/617uO1Ws4h30Y9jfyagG2OXmIU8FDGeZc1BUMRUz2U4shJhXcVv/4 siJ5SSR9k1qhoYA== X-Received: by 2002:a1c:9949:: with SMTP id b70mr119914wme.116.1602691097984; Wed, 14 Oct 2020 08:58:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3oYUQT/8tb+WIc7o1xKH8zo1BJuFESxiUhXIColPAKAlulTqIZ7WoFwBrT5Q3YQ2sW7bX3g== X-Received: by 2002:a1c:9949:: with SMTP id b70mr119902wme.116.1602691097839; Wed, 14 Oct 2020 08:58:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 01/15] block/nvme: Move nvme_poll_cb() earlier Date: Wed, 14 Oct 2020 17:57:56 +0200 Message-Id: <20201014155810.102841-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We are going to use this callback in nvme_add_io_queue() in few commits. To avoid forward-declaring it, move it before. No logical change. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 5f662c55bbe..a534c61b6b6 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -627,6 +627,16 @@ static void nvme_handle_event(EventNotifier *n) nvme_poll_queues(s); } =20 +static bool nvme_poll_cb(void *opaque) +{ + EventNotifier *e =3D opaque; + BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, + irq_notifier[MSIX_SHARED_IRQ_IDX]); + + trace_nvme_poll_cb(s); + return nvme_poll_queues(s); +} + static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) { BDRVNVMeState *s =3D bs->opaque; @@ -669,16 +679,6 @@ out_error: return false; } =20 -static bool nvme_poll_cb(void *opaque) -{ - EventNotifier *e =3D opaque; - BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, - irq_notifier[MSIX_SHARED_IRQ_IDX]); - - trace_nvme_poll_cb(s); - return nvme_poll_queues(s); -} - static int nvme_init(BlockDriverState *bs, const char *device, int namespa= ce, Error **errp) { --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602691108; cv=none; d=zohomail.com; s=zohoarc; b=LttOmDB1bRzsNBqvOlllKG6GJE9091ct9q1p/izVyiYKPLrAsmY4TEOdRbMltlu9F0cI3ohOsqW4fX+Bnml7FbmNuWVVikkZNF6WTywsQgO+sdDbECXPcuu4CKsIunEfzEhmyZgFZ+9vJ8AoPzMBS7LwX7mRFQhSVy4VQ4mx3/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691108; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=JeYSuq0H+8peHPSJMmoLpbQOjUcL6gucQf6bz7s5d5I=; b=VRjLPKq/296w5M2LSmQUI4zzTFLUOr1my95MsbzIzdAa0oMLjsp+31mrADBxp5gBLdAMtqyWAsbDDqqbKPN4mJbwK/ygsHom5HEufvocPFy6Bx2sjLi8qcQQJmeTKMGOYTAMqsLGRS0DnZGEC2NYWI4Wma3gi0SlpeCPs2pARdc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602691108929153.4725174581073; Wed, 14 Oct 2020 08:58:28 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-105-U41USDFUPICJL_OCquIrig-1; Wed, 14 Oct 2020 11:58:24 -0400 Received: by mail-wm1-f69.google.com with SMTP id z7so9351wmi.3 for ; Wed, 14 Oct 2020 08:58:23 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id a199sm135830wmd.8.2020.10.14.08.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691106; 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=JeYSuq0H+8peHPSJMmoLpbQOjUcL6gucQf6bz7s5d5I=; b=LUg4VuHbQtmlnev76ykquHgbTWD+0EYmSGaKpUmj7ZMBb1dxK+tCE6Kc4dg0LDy7njBjFq 7Wl26EEDc0wNDX6qlX45TMj1sY1HIjtKbI4yfCDWk7AZteHRtEFHUlvlG6DKf4xkelTSAs lhl0Q+TIFOQdFYReA/q/uHVeMH0IbMc= X-MC-Unique: U41USDFUPICJL_OCquIrig-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=JeYSuq0H+8peHPSJMmoLpbQOjUcL6gucQf6bz7s5d5I=; b=RvQwluvjW/ZrrOvx7F4LhrZtQ/pMnx2efpRQ1wq8ZZWvToW0qEBOGQJpSsBNc3dMC3 H4loGoI9/jWDxWqx5DBIz5FeiT/wB33jPFUZxCd91E/xGvBX0DoWklfPv8f6xfPIxvfO 7+2XLDYR3L1IXXTXKKHHxA9B++IJfJThTZZy/uTAzaQxjGr+zhTQMy7PIeYuGTAnjznF vrTN7u3AzzlSS+1GgCSI6cnB70GANQgBXjbeEherhPdAn1swjN58juNxPWsOkVV4ob6b ngXjqW6pSJVfMMpVeczIm3m57siAHwdQPdDVZahT0c4/oUjto256ifhvc+E/OTB0fp/n JF8Q== X-Gm-Message-State: AOAM530gVbItkjQIZzuNi6ReftyTdq9GL/vua2fQ6Rypu+w1NoZyUgYs DJSMmGlpy8qd7a5YQ5nJr8EOy7NQQTzoycj8IaEBOF6AUS5OZovuGfuR1rstUScGllBMwzx4cJh Mtbqgo9qV5+XMYg== X-Received: by 2002:a1c:f417:: with SMTP id z23mr87594wma.57.1602691102846; Wed, 14 Oct 2020 08:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzR60g/fSQn3Nj8owevItZNx/z8AFsCZ5ovI0u8RwaA8S/Ehr08qjvVfjbS+y0l+iyfHRazlA== X-Received: by 2002:a1c:f417:: with SMTP id z23mr87577wma.57.1602691102654; Wed, 14 Oct 2020 08:58:22 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 02/15] block/nvme: Trace nvme_poll_queue() per queue Date: Wed, 14 Oct 2020 17:57:57 +0200 Message-Id: <20201014155810.102841-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As we want to enable multiple queues, report the event in each nvme_poll_queue() call, rather than once in the callback calling nvme_poll_queues(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 2 +- block/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index a534c61b6b6..7c253eafa7f 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -585,6 +585,7 @@ static bool nvme_poll_queue(NVMeQueuePair *q) const size_t cqe_offset =3D q->cq.head * NVME_CQ_ENTRY_BYTES; NvmeCqe *cqe =3D (NvmeCqe *)&q->cq.queue[cqe_offset]; =20 + trace_nvme_poll_queue(q->s, q->index); /* * Do an early check for completions. q->lock isn't needed because * nvme_process_completion() only runs in the event loop thread and @@ -633,7 +634,6 @@ static bool nvme_poll_cb(void *opaque) BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, irq_notifier[MSIX_SHARED_IRQ_IDX]); =20 - trace_nvme_poll_cb(s); return nvme_poll_queues(s); } =20 diff --git a/block/trace-events b/block/trace-events index 0e351c3fa3d..fa50af6b6f3 100644 --- a/block/trace-events +++ b/block/trace-events @@ -143,7 +143,7 @@ nvme_complete_command(void *s, int index, int cid) "s %= p queue %d cid %d" nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d" nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, in= t c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x" nvme_handle_event(void *s) "s %p" -nvme_poll_cb(void *s) "s %p" +nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u" nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, i= nt flags, int niov) "s %p is_write %d offset %"PRId64" bytes %"PRId64" flag= s %d niov %d" nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s = %p offset %"PRId64" bytes %"PRId64" flags %d" nvme_qiov_unaligned(const void *qiov, int n, void *base, size_t size, int = align) "qiov %p n %d base %p size 0x%zx align 0x%x" --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602691112; cv=none; d=zohomail.com; s=zohoarc; b=cv7lr8NNAixGQkwTBIT1YReq6rw7xONvKf5Bi2mPG5DDJ1jn8/UfDZIMwcaDjA6diylzEIX6/JmtBVd/WDDQwKbDLcAIhgl7VnxuJJiMozh7OE5N3nR9pvvpAfeZu1z5kLk+AKDu8byl/B5OcykN56N3jhJ2durE7bEc7xCoil8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691112; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=i6X8GnBykdmK/5a5uNwFE6Cz8VpoGtSMgA4K7YGZ7Ns=; b=cpGzKplBsol7dhfTxV6k0g2A0dUec7jmzCxgqrIhyu0XFmWYXT7RubDVkhHw2wIvX1a+yEpzanPJSJHZV0IB8bdN+hLkZQJc10mExalZ4/0ZQ9VY9sZh9V7uFeQbvCkvxWQ9IOqs+a50zYD6gMlDnCUCQpbEOFOqEnpID9AN0wE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602691112598209.24101738362594; Wed, 14 Oct 2020 08:58:32 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-251-aadbrdUwNr-_-ShEpH-yrw-1; Wed, 14 Oct 2020 11:58:29 -0400 Received: by mail-wr1-f72.google.com with SMTP id f11so1536171wro.15 for ; Wed, 14 Oct 2020 08:58:29 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id f14sm94960wme.22.2020.10.14.08.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691111; 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=i6X8GnBykdmK/5a5uNwFE6Cz8VpoGtSMgA4K7YGZ7Ns=; b=ZqfoyhpIX0BiTIEGgGvSeAE0yXirpF7ejnvT+SHJqKvBzOop9CP8SfkT9ZmOdThDOroj/I +P4BpuBdxUkvkfXcCw3CiVf3oKVEQyJBxLnRuU5wQsIPyLHmryYOd5o+FIjYBnTLSfN+0h vIyrJHUzgm9i3M5dmMOuk8EPaC7ieLo= X-MC-Unique: aadbrdUwNr-_-ShEpH-yrw-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=i6X8GnBykdmK/5a5uNwFE6Cz8VpoGtSMgA4K7YGZ7Ns=; b=tgdbGsjFDqmN/TcFB9OsjzR5t/X5VJ4dUEC3lIeWQqplgqlJJB55iWExRU08rGp3dz WCSiuOjDDgUbDcLl/BY52V1Lqd0lZVFKmwt5gGXiCUSLdth1Ke6M4VJ1InjtuXem7VP9 B4BVGrTdTWLmXrrcjqjDSFjR8FGK1T5uWVpdLlCIppp+h9rsgf3X3eXk+PZNqwgHoxGl HkraO6tEUdvsiXXfDQWwJX5aQEAFD5tj15bRleFB+RFaWk7qmsHIY4iplcnflHVyvi7Y w/HxxfLQ2n8FqZv3IFpSeQGpAGVXturmpoO6AP044BMcSGk8PSbOT4QGtK6wf/SdUoWA RgIg== X-Gm-Message-State: AOAM530q90p6worqiKqjGKdvyhHTGuUeI8uPbwTXxk6vu6uco4gBGwf6 g7zfv8g4A8p/ADm7t5Vwy8AYkPpFvkpp8fvhzl2yA6hZIyKZLWbKRF9lwZT0Bn0jf0ttIl1Sg8d 9YHvue4DQ0ynTmA== X-Received: by 2002:adf:e292:: with SMTP id v18mr6286716wri.256.1602691108004; Wed, 14 Oct 2020 08:58:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzBpitalcaSg+IeiqueUqGPcfpwo/IferQGLaPsK2pcjC6erHlT5XVa8mtinwklnxwNcC84w== X-Received: by 2002:adf:e292:: with SMTP id v18mr6286692wri.256.1602691107758; Wed, 14 Oct 2020 08:58:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 03/15] block/nvme: Use unsigned integer for queue counter/size Date: Wed, 14 Oct 2020 17:57:58 +0200 Message-Id: <20201014155810.102841-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We can not have negative queue count/size/index, use unsigned type. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 24 +++++++++++------------- block/trace-events | 10 +++++----- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 7c253eafa7f..d84206b598d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -103,7 +103,7 @@ struct BDRVNVMeState { * [1..]: io queues. */ NVMeQueuePair **queues; - int nr_queues; + unsigned nr_queues; size_t page_size; /* How many uint32_t elements does each doorbell entry take. */ size_t doorbell_scale; @@ -154,7 +154,7 @@ static QemuOptsList runtime_opts =3D { }; =20 static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, - int nentries, int entry_bytes, Error **errp) + unsigned nentries, size_t entry_bytes, Error *= *errp) { size_t bytes; int r; @@ -198,7 +198,7 @@ static void nvme_free_req_queue_cb(void *opaque) =20 static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, AioContext *aio_context, - int idx, int size, + unsigned idx, size_t size, Error **errp) { int i, r; @@ -640,10 +640,10 @@ static bool nvme_poll_cb(void *opaque) static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) { BDRVNVMeState *s =3D bs->opaque; - int n =3D s->nr_queues; + unsigned n =3D s->nr_queues; NVMeQueuePair *q; NvmeCmd cmd; - int queue_size =3D NVME_QUEUE_SIZE; + unsigned queue_size =3D NVME_QUEUE_SIZE; =20 q =3D nvme_create_queue_pair(s, bdrv_get_aio_context(bs), n, queue_size, errp); @@ -657,7 +657,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) .cdw11 =3D cpu_to_le32(0x3), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { - error_setg(errp, "Failed to create CQ io queue [%d]", n); + error_setg(errp, "Failed to create CQ io queue [%u]", n); goto out_error; } cmd =3D (NvmeCmd) { @@ -667,7 +667,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) .cdw11 =3D cpu_to_le32(0x1 | (n << 16)), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { - error_setg(errp, "Failed to create SQ io queue [%d]", n); + error_setg(errp, "Failed to create SQ io queue [%u]", n); goto out_error; } s->queues =3D g_renew(NVMeQueuePair *, s->queues, n + 1); @@ -869,10 +869,9 @@ static int nvme_enable_disable_write_cache(BlockDriver= State *bs, bool enable, =20 static void nvme_close(BlockDriverState *bs) { - int i; BDRVNVMeState *s =3D bs->opaque; =20 - for (i =3D 0; i < s->nr_queues; ++i) { + for (unsigned i =3D 0; i < s->nr_queues; ++i) { nvme_free_queue_pair(s->queues[i]); } g_free(s->queues); @@ -1380,7 +1379,7 @@ static void nvme_detach_aio_context(BlockDriverState = *bs) { BDRVNVMeState *s =3D bs->opaque; =20 - for (int i =3D 0; i < s->nr_queues; i++) { + for (unsigned i =3D 0; i < s->nr_queues; i++) { NVMeQueuePair *q =3D s->queues[i]; =20 qemu_bh_delete(q->completion_bh); @@ -1401,7 +1400,7 @@ static void nvme_attach_aio_context(BlockDriverState = *bs, aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_I= DX], false, nvme_handle_event, nvme_poll_cb); =20 - for (int i =3D 0; i < s->nr_queues; i++) { + for (unsigned i =3D 0; i < s->nr_queues; i++) { NVMeQueuePair *q =3D s->queues[i]; =20 q->completion_bh =3D @@ -1418,11 +1417,10 @@ static void nvme_aio_plug(BlockDriverState *bs) =20 static void nvme_aio_unplug(BlockDriverState *bs) { - int i; BDRVNVMeState *s =3D bs->opaque; assert(s->plugged); s->plugged =3D false; - for (i =3D INDEX_IO(0); i < s->nr_queues; i++) { + for (unsigned i =3D INDEX_IO(0); i < s->nr_queues; i++) { NVMeQueuePair *q =3D s->queues[i]; qemu_mutex_lock(&q->lock); nvme_kick(q); diff --git a/block/trace-events b/block/trace-events index fa50af6b6f3..3bb5a238601 100644 --- a/block/trace-events +++ b/block/trace-events @@ -134,13 +134,13 @@ qed_aio_write_postfill(void *s, void *acb, uint64_t s= tart, size_t len, uint64_t qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t le= n) "s %p acb %p ret %d offset %"PRIu64" len %zu" =20 # nvme.c -nvme_kick(void *s, int queue) "s %p queue %d" +nvme_kick(void *s, unsigned q_index) "s %p q #%u" nvme_dma_flush_queue_wait(void *s) "s %p" nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "= cmd_specific %d sq_head %d sqid %d cid %d status 0x%x" -nvme_process_completion(void *s, int index, int inflight) "s %p queue %d i= nflight %d" -nvme_process_completion_queue_plugged(void *s, int index) "s %p queue %d" -nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d" -nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d" +nvme_process_completion(void *s, unsigned q_index, int inflight) "s %p q #= %u inflight %d" +nvme_process_completion_queue_plugged(void *s, unsigned q_index) "s %p q #= %u" +nvme_complete_command(void *s, unsigned q_index, int cid) "s %p q #%u cid = %d" +nvme_submit_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d" nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, in= t c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x" nvme_handle_event(void *s) "s %p" nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u" --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602691117; cv=none; d=zohomail.com; s=zohoarc; b=I8+H5oUoi3TXRPv82IJoM67k6CFCEHO5/F+TT4EVwXY3AFIZOQzu3vcAJbSn0XUTsXIw1GBp223JVkhO2fD+wu5Fzu9SCH3pDmAMqpN+erzoj6WrxnHnwK/7d5x6llwiPrl/B0DQQ6e3M8X0nVb14PP2bZ/5yyerlnnVyBg8Oek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691117; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=zfEKR3p99JyOaZvgGZWXrkDwRPOMspGtYOhIXhe9jTI=; b=Rtb3V6a/YxJeviU+NqMZgda+H1bxW7q53CvXJEhTgRyw9NrWTByHQCm4PYO78h3CF5vvfTBZUDOufVuLDuDaOymEMdxnK0SNPg4fkgkXtBkx1Tr6ECPedo2hsSWXxsBmPH6q8tvW5/aGA0Lx++jD5LjYcXjhxxcVNQJBuMKGly0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602691117333461.5975377642859; Wed, 14 Oct 2020 08:58:37 -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-167-TToyEQMPOJCsjlscTCnYOg-1; Wed, 14 Oct 2020 11:58:34 -0400 Received: by mail-wm1-f72.google.com with SMTP id f26so39031wml.1 for ; Wed, 14 Oct 2020 08:58:34 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id a3sm54032wmb.46.2020.10.14.08.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691116; 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=zfEKR3p99JyOaZvgGZWXrkDwRPOMspGtYOhIXhe9jTI=; b=bZ15a+h7aFwzAdxTRHUionGjE4E5DBQ0wUHOoLbm8WP090E6UZU6D0lqZC+dgmKlfB/5+z Ukfmryn70Hg9dMjkT+rtmOD2UpcvD22QpXnMMkTxU1nnGChbrFs4kug6Bh5eD5OFg0gcLL L1C3d8Ua5wlRD/PQyVf3MJIogmtf8eM= X-MC-Unique: TToyEQMPOJCsjlscTCnYOg-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=zfEKR3p99JyOaZvgGZWXrkDwRPOMspGtYOhIXhe9jTI=; b=gah8buDgyyMoyIi5QSvQTs0dwgPNvvFwO5tWxPBsy8zkeJtc2elOwSVP9D/H3KPvjn /c9TvTMQvDdUbWSFpYZPlfXaPu95l3vQUWt/lm7DLKwNABm6LOk5fpJAGIWQM5+8pG94 kWMAcsMBdegTD5+wWSAAPqgwbMzPak0T3/UVS3AoXIhWQDg5VH/W2NyN7rKGbYm7mbpx LDktKAWFGA2DBFVK9Ds/LYPPZS5fsaLjpCUXLZDyxl/A5ZeCzmdTYquCq8n/sLOhO6px DsajGUCknRwlvI+8719vmuSCseOE/SOCnTi2PywuE2vsae7Tm7npO9cKty8tBH13PWTG MxLg== X-Gm-Message-State: AOAM532AAp0Wq13yID2WskK/JG/WomQDY/4bpEgO33UDmLUi6uR0gXJu OLLyLuURawLn1b/uDQW1sUeqFTGfVpI+s2zi89p2xpc4oGYUtZ1xB463y2g53figWwHQDyqs8MM iNypf2CQEeDLVsg== X-Received: by 2002:a05:600c:2189:: with SMTP id e9mr67111wme.153.1602691113181; Wed, 14 Oct 2020 08:58:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+wzLSNx1WXbyrQnSXUZ/Fm8q0mCBza+O54nO/s2n807EFJcwLeA/naZ07D8S1HRzw1rzTaA== X-Received: by 2002:a05:600c:2189:: with SMTP id e9mr67095wme.153.1602691113017; Wed, 14 Oct 2020 08:58:33 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 04/15] block/nvme: Improve nvme_free_req_queue_wait() trace information Date: Wed, 14 Oct 2020 17:57:59 +0200 Message-Id: <20201014155810.102841-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) What we want to trace is the block driver state and the queue index. Suggested-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 2 +- block/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index d84206b598d..e9410f2e0eb 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -286,7 +286,7 @@ static NVMeRequest *nvme_get_free_req(NVMeQueuePair *q) =20 while (q->free_req_head =3D=3D -1) { if (qemu_in_coroutine()) { - trace_nvme_free_req_queue_wait(q); + trace_nvme_free_req_queue_wait(q->s, q->index); qemu_co_queue_wait(&q->free_req_queue, &q->lock); } else { qemu_mutex_unlock(&q->lock); diff --git a/block/trace-events b/block/trace-events index 3bb5a238601..410789188cc 100644 --- a/block/trace-events +++ b/block/trace-events @@ -152,7 +152,7 @@ nvme_rw_done(void *s, int is_write, uint64_t offset, ui= nt64_t bytes, int ret) "s nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset %"PRId64" = bytes %"PRId64"" nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p off= set %"PRId64" bytes %"PRId64" ret %d" nvme_dma_map_flush(void *s) "s %p" -nvme_free_req_queue_wait(void *q) "q %p" +nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u" nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) = "s %p cmd %p req %p qiov %p entries %d" nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"= PRIx64 nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d]= %p pages %d" --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1602691122; cv=none; d=zohomail.com; s=zohoarc; b=ascp63pKhrPp3EeVOlquV6UfPsOnrMl1ARgdrhsVlkadVYi65OK0q7pLN2btdH2GTEAsYHVyuGjdqGpGI5szpnYHAzmx/TRj+wbFPLJSxg3MnjF0yDwmpEo6UdByiIAtx+K0sHRIbLnlyCYpZjvJhMYLPCRpo2PXyz0ae/lpmMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691122; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ghmcDakaPsk2ezFRlfrYLZqRji466VE/3yOqwiiBZsA=; b=K8f2MeCNAQaBucq7CblPa31ElsOAdIs3LT583IaARQ1qWCwa6H9O1ItVIw/JRsneCl95M9Axxk13Vi1VliNJylxrsH5ZTryshNVzvfOGFqSyJv2rqmiaXCH13mjWixOcZA9B8UmXs3I4cYw6yc4AaGu3I4fASMjtEgYEuciglcQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602691122113761.7925973298785; Wed, 14 Oct 2020 08:58:42 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-52-0rneiQ2DNnGRVvQGzR_qVw-1; Wed, 14 Oct 2020 11:58:39 -0400 Received: by mail-wr1-f69.google.com with SMTP id j15so1542817wrd.16 for ; Wed, 14 Oct 2020 08:58:39 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 88sm5869224wrl.76.2020.10.14.08.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691121; 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=ghmcDakaPsk2ezFRlfrYLZqRji466VE/3yOqwiiBZsA=; b=gf8wNxsJHKHdCOwmDqbYW7d8Xss2ujUAgYfbKrOWPkMS78WfVK7lsulamsBsw3TjYn8PL+ 74xUUikxT9H/ayF3BTyB9VUK/JCoOPSLa4NZhFw1wjsC/efYoH/T6RE9uUVHi03Vh7qe14 xhXw8anjTscAgJUDxc3HnZm9upFNytw= X-MC-Unique: 0rneiQ2DNnGRVvQGzR_qVw-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=ghmcDakaPsk2ezFRlfrYLZqRji466VE/3yOqwiiBZsA=; b=j7N7TrsjqVND4sJ6Z9IfJ8iCawCo0rflDKjKP3F4gNafU7Nu2WK45odjch738ptWxw WtppumIBQB1DJISfQ3KSoXCJARbPnP6B9IBPyCbu66TYVdLzdCkVrEOaVy2Bu5YhmF35 ZLCKyaHEcNXFohqNNAhYDEQ4ouM8HEwKCtlyHw8BqEMpZvqn50oCI8WKjulJF23KBwPn lyVAtMdkuWtT0f8wu9sO1BqrN0ca926cE5E3dL0aG91NgENpirJyfp1lfW2iZ89lOBKk M7wo9s8AV65DZJyvjgkJ5Iod3DsNUsPWKAzVDAuB6ILpNKS1HDTyWk1FUScoFSjV1OKS L2pg== X-Gm-Message-State: AOAM531VimM7fxGBzXUL689IWOYo3cZgTuiTtjEz0b6nTx5qMfheRtw9 SZsTg2i6QU3iZ+XCg3wT2bV4qD3OYn90ZmRD02c/fjPm03GtusFhohlPqeD4ydYMRVIvczyei9i R+vclJNJ8dIeVkQ== X-Received: by 2002:adf:82f7:: with SMTP id 110mr6213036wrc.261.1602691118067; Wed, 14 Oct 2020 08:58:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsoswR7KcyjOGRJR/+Nr8CZeH4vwy4J2qv5fpShJ2TYeI77QnSRCmu5EvZXnfuQBvWs164Kg== X-Received: by 2002:adf:82f7:: with SMTP id 110mr6213022wrc.261.1602691117854; Wed, 14 Oct 2020 08:58:37 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 05/15] block/nvme: Trace queue pair creation/deletion Date: Wed, 14 Oct 2020 17:58:00 +0200 Message-Id: <20201014155810.102841-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 3 +++ block/trace-events | 2 ++ 2 files changed, 5 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index e9410f2e0eb..95f19e12cd6 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -175,6 +175,7 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue= *q, =20 static void nvme_free_queue_pair(NVMeQueuePair *q) { + trace_nvme_free_queue_pair(q->index, q); if (q->completion_bh) { qemu_bh_delete(q->completion_bh); } @@ -210,6 +211,8 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, if (!q) { return NULL; } + trace_nvme_create_queue_pair(idx, q, size, aio_context, + event_notifier_get_fd(s->irq_notifier)); q->prp_list_pages =3D qemu_try_memalign(s->page_size, s->page_size * NVME_NUM_REQS); if (!q->prp_list_pages) { diff --git a/block/trace-events b/block/trace-events index 410789188cc..6694c23e1c1 100644 --- a/block/trace-events +++ b/block/trace-events @@ -153,6 +153,8 @@ nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %= p offset %"PRId64" bytes nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p off= set %"PRId64" bytes %"PRId64" ret %d" nvme_dma_map_flush(void *s) "s %p" nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u" +nvme_create_queue_pair(unsigned q_index, void *q, unsigned size, void *aio= _context, int fd) "index %u q %p size %u aioctx %p fd %d" +nvme_free_queue_pair(unsigned q_index, void *q) "index %u q %p" nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) = "s %p cmd %p req %p qiov %p entries %d" nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"= PRIx64 nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d]= %p pages %d" --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1602691127; cv=none; d=zohomail.com; s=zohoarc; b=L6lhnPwaMTDafTHk6fGiEZHnKFrUIDuXHD78djIbv2pLgLgEah13PmUtgK5LkBbCw4dhEwKCR9wAU20kaGElHx01Od/JSr26Tvd1bexOxZABfwo0Z9RYMVOWocSlMbVDsTKyYHh9ftKmDybtA9UlWyyL97Rb5hHzkA44V/MI2Mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691127; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=n55Tojzee3U5y86sm0YRlgiaSZuSyN/j5wbWS6M55NQ=; b=d+66V7I5ImItxZPVW2BHPVMAjtkfS4Y82X8GpyDwvWRlXXu8rLQ19DED8OOnfGMhAmEJnvsIeE0LY4eS+1/tDVCY9rSw+AKtXia7NLPoBSw6o2WOJwctjvxZ2kmfQPF1A9XIrAOKooidq+7aD1/ZfYrUl6Vatjv9vekqDyYn7iQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602691127298760.2470384684493; Wed, 14 Oct 2020 08:58:47 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-XpUgnYAZO3S_bXdkxIQLFw-1; Wed, 14 Oct 2020 11:58:44 -0400 Received: by mail-wr1-f72.google.com with SMTP id i6so1534999wrx.11 for ; Wed, 14 Oct 2020 08:58:44 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id y14sm52505wma.48.2020.10.14.08.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691126; 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=n55Tojzee3U5y86sm0YRlgiaSZuSyN/j5wbWS6M55NQ=; b=DUs651IHMsGvdqm/FqvOVf0zwjdTKa0g4pQr5w93PH/WY+4aMY0Lb1UpQT3fw2Yu2XZI+t pd1CJiXWWkCZqP9RwnFpwL3DAH9bGkgkpnCNiLJAu50jkF6oaZTYVLbu5CNVMRFJXYfBGJ aUjoV+LNduvgE7W0I+lZa6+FRJdbkfQ= X-MC-Unique: XpUgnYAZO3S_bXdkxIQLFw-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=n55Tojzee3U5y86sm0YRlgiaSZuSyN/j5wbWS6M55NQ=; b=kcp+1U0E+iX/LNmBaWs5o0kxhP+VjiQV7h3Et0pdFXTB1h4EV0KR9cxwuJsqUMmlE3 E2yM9xxNV2SyMylaiuFLaWq7n+EyoNKy6l0FYKkZZQqNIfeJlQogNQ5xzMDoOeZ614U7 H5ceruG12rPw40b17rtIYnmyn0CmmfuqUEqwPdsD7ucBiMQdL/IemuYMBV2h/4DK2Pvm blTXWjeQtKRSwXcSQ3CGaU1Wl7WAHmFJax96p17X6gMEahTEoB8NtU/MVXJ0TyzcrA7u WDtKlAhpK7rlr54VbmVt9EXoaTUBP62rhIWQvN+xKRrs8xnspVXg4WgkFv72NEEfQLhP NaKw== X-Gm-Message-State: AOAM530l1ewPP4PCMn9hbtWiq21Y2GeKmbkRfyJmjg+nTEat9D9ap0Kv Q2/G5PZLL6BFymBI1ZzuQOsrk5yZxsANTyi8Ek1J0VIzhioWGBrxMddY+H+qNIs6gjOOwWoiFW/ 7J0jZIX+vbYGa2A== X-Received: by 2002:a1c:e48b:: with SMTP id b133mr142439wmh.0.1602691123050; Wed, 14 Oct 2020 08:58:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU5/fKCXdU6560Jh9AUqT/0+Qts4e54qcj5ajEnL+jQMGHTPBVChIr9SLcJF5frgRKodrzrQ== X-Received: by 2002:a1c:e48b:: with SMTP id b133mr142431wmh.0.1602691122885; Wed, 14 Oct 2020 08:58:42 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 06/15] block/nvme: Make nvme_identify() return boolean indicating error Date: Wed, 14 Oct 2020 17:58:01 +0200 Message-Id: <20201014155810.102841-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Just for consistency, following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), return a boolean value indicating an error is set or not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 95f19e12cd6..95f8f8b360b 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -496,9 +496,11 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQue= uePair *q, return ret; } =20 -static void nvme_identify(BlockDriverState *bs, int namespace, Error **err= p) +/* Returns true on success, false on failure. */ +static bool nvme_identify(BlockDriverState *bs, int namespace, Error **err= p) { BDRVNVMeState *s =3D bs->opaque; + bool ret =3D false; union { NvmeIdCtrl ctrl; NvmeIdNs ns; @@ -575,10 +577,13 @@ static void nvme_identify(BlockDriverState *bs, int n= amespace, Error **errp) goto out; } =20 + ret =3D true; s->blkshift =3D lbaf->ds; out: qemu_vfio_dma_unmap(s->vfio, id); qemu_vfree(id); + + return ret; } =20 static bool nvme_poll_queue(NVMeQueuePair *q) --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1602691132; cv=none; d=zohomail.com; s=zohoarc; b=g1ivBeC0JD2AQM5qH2Y8/lzpJg4DwTp/6Qfe1x43qcJBiBt6Awakuy4Gny/o7HpTMsUkUNeQnuMDCtrYWtOdCIfSZV8+W76RUq+RDva/yzm4uwDFN85hrCcFFeRNJLW5BMES7/gsdb8QZVfq2jsszFpBpm2zx+gFgKU2/5Qaugk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691132; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=wiI/Pw6gOhc7zyCY4AJaHk9ZttCyA1OQsSTkGRUxoTI=; b=lT43p1tfwNqJaAttPt7G+q3oaWMw85NpiiSd+XXYH1eAQjsdhf4OvZzu+q9o/gFvE5s1ZpSobb8HhFeJhyGhgMF7XnQxaocrSHY6DR0lYNXSpqzHuD34Tdb5KAdwUL656d4khzsgTaAOenZctRX4AYUz4c1IjY4C+d6cS4vxJCg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602691132905682.740606592618; Wed, 14 Oct 2020 08:58:52 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-430-XD9PIe4xNs-RPFdtoa7kaQ-1; Wed, 14 Oct 2020 11:58:49 -0400 Received: by mail-wm1-f69.google.com with SMTP id c204so4021wmd.5 for ; Wed, 14 Oct 2020 08:58:49 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id t13sm106904wmj.15.2020.10.14.08.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691131; 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=wiI/Pw6gOhc7zyCY4AJaHk9ZttCyA1OQsSTkGRUxoTI=; b=W+rgKFK/kuP58bc8bKZAC5tl5/PzJyjJKjPC3izPRcmO3WKeYTkTDzl8+GtAMN29Yi92Od qnZZtb3/c3Z5Ayh1szvdXWRri/wDtfPGKBoLy17kFxsdnXrpyBHQr7XFpM78q2uRjUl2uF 7GJBE6C7vJm2Gzr9GXM8CJTJvFPKBdI= X-MC-Unique: XD9PIe4xNs-RPFdtoa7kaQ-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=wiI/Pw6gOhc7zyCY4AJaHk9ZttCyA1OQsSTkGRUxoTI=; b=b+R8A13YfpWXQZyvOkZ4rc7O4BGU6Iyk/GnaaWLZ6ADWvR634mAbti6Rg9zN2tUvWo jTcNc3jIUcxmD+G6PNQa+D7gO55iebpA/Akym0fvAObP7hsb8f5rL1s7WcJDMLUb+f1Y T0ROVGLlfcEUhUR7NmpZLY5rp9UMhfj4isedWMCZu60QZPe3v1j7naD6TiWShhdwfeVm HfHhFENNtmrnyJVFI6z9yIjwhmUrW2BjRPVVV5SRoY2xEOVCt3cdoH1Wi2GRNvU6k2lw 19qWIVcB5urv9fT0MMwaXOV2EUeFxKaGKMv4BL0fgveQpnN23TlnsuW3vsJvuGxdaZdc DW6g== X-Gm-Message-State: AOAM530YKYP+iIaFzntuqoSKEMKPVGZ8WsUm97kgat4HKmk+D9ep5ior OaCFApjDCFwsR9Ut3jFscwFlFSunN8/XnZy6RGLAz9QwmsIhj7bQL72n+5bj80IpWvsW7tObvD9 Z0JGTSF/DxdPJcg== X-Received: by 2002:a1c:3d46:: with SMTP id k67mr119208wma.150.1602691128193; Wed, 14 Oct 2020 08:58:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQHMAjXnvIMBcP4t8kkQfexIbI+9mLXQjTrrp/OzMu5S13aiIHObL/zS7XqNWjaLMm6rL4pQ== X-Received: by 2002:a1c:3d46:: with SMTP id k67mr119186wma.150.1602691127970; Wed, 14 Oct 2020 08:58:47 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 07/15] block/nvme: Make nvme_init_queue() return boolean indicating error Date: Wed, 14 Oct 2020 17:58:02 +0200 Message-Id: <20201014155810.102841-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Just for consistency, following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), return a boolean value indicating an error is set or not. This simplifies a bit nvme_create_queue_pair(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 95f8f8b360b..523814a1243 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -153,7 +153,8 @@ static QemuOptsList runtime_opts =3D { }, }; =20 -static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, +/* Returns true on success, false on failure. */ +static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, unsigned nentries, size_t entry_bytes, Error *= *errp) { size_t bytes; @@ -164,13 +165,14 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQue= ue *q, q->queue =3D qemu_try_memalign(s->page_size, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); - return; + return false; } memset(q->queue, 0, bytes); r =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, err= p); if (r) { error_prepend(errp, "Cannot map queue: "); } + return r =3D=3D 0; } =20 static void nvme_free_queue_pair(NVMeQueuePair *q) @@ -203,7 +205,6 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, Error **errp) { int i, r; - Error *local_err =3D NULL; NVMeQueuePair *q; uint64_t prp_list_iova; =20 @@ -240,16 +241,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMe= State *s, req->prp_list_iova =3D prp_list_iova + i * s->page_size; } =20 - nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp)) { goto fail; } q->sq.doorbell =3D &s->doorbells[idx * s->doorbell_scale].sq_tail; =20 - nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp)) { goto fail; } q->cq.doorbell =3D &s->doorbells[idx * s->doorbell_scale].cq_head; --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1602691137; cv=none; d=zohomail.com; s=zohoarc; b=fsfOUG6Yg6IMF6ZO/hLdu2Ojp2sOILZPGMtD8I0ludILppd2prH6HuprQ9lX0fl0rVkvTnpgvq/Zp0gFLTgBBRxq7KAKjdBV7TbTI25YnowfEJBhCgODgBTWzHM9ItViQSLoDg9AGL0apzCZQXvZOTSUpdFxQ2t0yzAY2Fy4dbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691137; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ajyUIBZhYcYMjtG3GzX+aV0rxCP2KwW8xZEaitynopk=; b=SDyogZ8afdqihOZW8SZJ9qNnldi+p3hqf1ScYlzMx00OIfTnFjHv0eWpLfjX0km0GiyREcS03q+nx/kQ6/H4vxRrR0a07gqL2tXF0kOb9p9WY3dJzIlkyv9yZ7lDk8KfxqzEell5fjxu1cj4JXpEL4ZxTNr2mXh9r+6Fdwo9qSY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602691137130726.1378264983389; Wed, 14 Oct 2020 08:58:57 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-ztbDOsESNoaDphO2X3TMhA-1; Wed, 14 Oct 2020 11:58:54 -0400 Received: by mail-wm1-f71.google.com with SMTP id v14so948wmj.6 for ; Wed, 14 Oct 2020 08:58:54 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id m12sm6058664wrs.92.2020.10.14.08.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691136; 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=ajyUIBZhYcYMjtG3GzX+aV0rxCP2KwW8xZEaitynopk=; b=D21m9eqr2clKbHeyP9L0o3kuxmFzRr3GQ58BxdYsd9nwH3fn4GMRCXvt1RFaX7msix3Jdj H7mkskNjGnDVZRQWZVJDnW6z1Eq1TFrqaIl8Ydj2Ex6POiU7VaBlFvS9S3v9x0TfDl9L5E W/1hJm8ybFZLJ3oZl3N1Z8iBR6WnYfk= X-MC-Unique: ztbDOsESNoaDphO2X3TMhA-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=ajyUIBZhYcYMjtG3GzX+aV0rxCP2KwW8xZEaitynopk=; b=uD/wQb3+iEaL7O4YUnDq9mC1klxuM4fbmAHie817LO2981jIT10odC7irhELNN6pK6 VIWG+IwfKvTiGOsIP22JmQb8+//gtnQvSSe3BAW92rtT66bfgqE6qg4arpmG+BrF/6Wr J2z0WDYeo1lQU2yKF6OxfblM5Sh2OZ+IVrGLgyPVdC1YfWQDNMaAQc1hdgBTM4c2cts9 LQCORDjLVpOzlbzyF+BQMUc2DddTtnzxvJa3aVhsuv4stBry/gApFsHrn3VQmCdWNwRD FSQfj4K90nT8kc+lqC+AWmznLftmqdEmZJguxD/8JDrUuMi+Yfl2tcckDlYR2lav0f7q 82PQ== X-Gm-Message-State: AOAM531qdvwEVv+1tVnmyTDCdVe3diS0/hrQwus5YYiSOEm2ITHZ0lNu WMq4sr+WhbFAWybfAJxNB6oCIjrHwEUSjhKYqUygHOkNX3W5yvYNFIvDYThi3HKjIp+xdzlXaYk b90+XXEJy1PvPIA== X-Received: by 2002:a1c:2d8f:: with SMTP id t137mr137411wmt.26.1602691133190; Wed, 14 Oct 2020 08:58:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXyQI3UJlkRk7SVnqrRiqNE3ZWWlwAPgp9jjgzAaj6Euzj4X8XBL3WnLoAJfzDmC/zX+njug== X-Received: by 2002:a1c:2d8f:: with SMTP id t137mr137385wmt.26.1602691132884; Wed, 14 Oct 2020 08:58:52 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 08/15] block/nvme: Pass AioContext argument to nvme_add_io_queue() Date: Wed, 14 Oct 2020 17:58:03 +0200 Message-Id: <20201014155810.102841-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We want to get ride of the BlockDriverState pointer at some point, so pass aio_context along. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 523814a1243..b841c5950c5 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -642,7 +642,9 @@ static bool nvme_poll_cb(void *opaque) return nvme_poll_queues(s); } =20 -static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) +/* Returns true on success, false on failure. */ +static bool nvme_add_io_queue(BlockDriverState *bs, + AioContext *aio_context, Error **errp) { BDRVNVMeState *s =3D bs->opaque; unsigned n =3D s->nr_queues; @@ -650,8 +652,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) NvmeCmd cmd; unsigned queue_size =3D NVME_QUEUE_SIZE; =20 - q =3D nvme_create_queue_pair(s, bdrv_get_aio_context(bs), - n, queue_size, errp); + q =3D nvme_create_queue_pair(s, aio_context, n, queue_size, errp); if (!q) { return false; } @@ -805,7 +806,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, } =20 /* Set up command queues. */ - if (!nvme_add_io_queue(bs, errp)) { + if (!nvme_add_io_queue(bs, aio_context, errp)) { ret =3D -EIO; } out: --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602691141; cv=none; d=zohomail.com; s=zohoarc; b=ROiG7OrHa5zz41r+9U9K1qnGah9LjfDajTfkOOqtdeFY7e1iI62FQ0OFrZZvxa455M9jbDIvD7tfQzD04t8+qL6In6J2RTsF33xj56jiKHLkHlU1fIdSccmXZJy38EusGLbeg3Eu68hSQ88i0HNXVIPlZMA6mcq6pJikgBKu/fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691141; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=IaWnoSHk3gYww0GtxO3QwPtbarT6V9nMm5FHP0y80Lw=; b=WyKg3QyEJkojCF1rmkjQ0LGHy4k3i2I3AG6BKULrHWK4++1GTKu26k3Abw5rv4tzqQKHUT4F+xBjYOWfJPGhgiyzwm+Wf/biNpru1rLxlS1w16ZbpQxxjruclquoTcso+UxPyBk7bSw3PKE9FUtVkHUoGfCp+KXIZSk5EohQ4m0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602691141742733.6883589828243; Wed, 14 Oct 2020 08:59:01 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-561-9RvsnfvuMvOOF0FtdpGyIA-1; Wed, 14 Oct 2020 11:58:59 -0400 Received: by mail-wr1-f69.google.com with SMTP id r8so1549955wrp.5 for ; Wed, 14 Oct 2020 08:58:58 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id y14sm53247wma.48.2020.10.14.08.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691140; 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=IaWnoSHk3gYww0GtxO3QwPtbarT6V9nMm5FHP0y80Lw=; b=cxfSmlB3aNMj7H7nM1LT8H5n6gtMyDeVgmNXzNVjQvAkAMhUc25IxJ6VbDFxygNsdAvH2I QqNvsWeyY6XTQWwPkzG9XojEXNTgjTBgte//NWfDpcSyF+3uFNegMWE6ZpTxaYAtmg5Bcb oVrwWzTyxs/mILSFx/jUzzkXbG/CTnU= X-MC-Unique: 9RvsnfvuMvOOF0FtdpGyIA-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=IaWnoSHk3gYww0GtxO3QwPtbarT6V9nMm5FHP0y80Lw=; b=gGx5K4KeLx3JMke6/HFqaw+mZGdps0/Z4/uTqFLhydGMUXcG2dajy7rYwFl49FW8sO nJP7Uz2WhXtddhxbPHAjvSWTXm4nTU1SvpGJHaGUu6EP5M5BOPZbBTPQoua50wtkoP7o VYcXHGWQNox6GAXjf3uSchKh6nzFHFcu9g5IkliGOQm81yDVKXyyZ9WtcLmE7omuSTci fIwSw1LOGqV2LVUmsdmm5qPXbCz2/sECM4oU2/hl0ojJAbRTDNzJDwG0O9R2W4DbGpFg gp8FPPLGs1vAtjjODxz8VmVz7tUAg9Pl26+DKc1U06T2FqcpZUW4kZbaW0cuXhcFgaeT H8wg== X-Gm-Message-State: AOAM533PzwEvNWwvK4x1Zvt9bt9VlB5++Bh+otITjbK3BOkTZD1ZcaBq jVYX9KqdkLe5BdxwqXK6t5U/g5M+sD1Jf0X2BGyCWPBdr7NcQoG/D0RkFq8CtY6ByOVAqt5/vdq HxktEKjcJCgy+wA== X-Received: by 2002:a05:600c:247:: with SMTP id 7mr101663wmj.7.1602691138017; Wed, 14 Oct 2020 08:58:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUb/GZ2L+BC8kA6ML62LH0sRSc955uVJLtoZrNm8wY5pELMs3TXDh/+XNcVTuuaLPHlxspUw== X-Received: by 2002:a05:600c:247:: with SMTP id 7mr101648wmj.7.1602691137864; Wed, 14 Oct 2020 08:58:57 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 09/15] block/nvme: Introduce Completion Queue definitions Date: Wed, 14 Oct 2020 17:58:04 +0200 Message-Id: <20201014155810.102841-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Rename Submission Queue flags with 'Sq' and introduce Completion Queue flag definitions. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/block/nvme.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/block/nvme.h b/include/block/nvme.h index 65e68a82c89..079f884a2d3 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -491,6 +491,11 @@ typedef struct QEMU_PACKED NvmeCreateCq { #define NVME_CQ_FLAGS_PC(cq_flags) (cq_flags & 0x1) #define NVME_CQ_FLAGS_IEN(cq_flags) ((cq_flags >> 1) & 0x1) =20 +enum NvmeFlagsCq { + NVME_CQ_PC =3D 1, + NVME_CQ_IEN =3D 2, +}; + typedef struct QEMU_PACKED NvmeCreateSq { uint8_t opcode; uint8_t flags; @@ -508,12 +513,12 @@ typedef struct QEMU_PACKED NvmeCreateSq { #define NVME_SQ_FLAGS_PC(sq_flags) (sq_flags & 0x1) #define NVME_SQ_FLAGS_QPRIO(sq_flags) ((sq_flags >> 1) & 0x3) =20 -enum NvmeQueueFlags { - NVME_Q_PC =3D 1, - NVME_Q_PRIO_URGENT =3D 0, - NVME_Q_PRIO_HIGH =3D 1, - NVME_Q_PRIO_NORMAL =3D 2, - NVME_Q_PRIO_LOW =3D 3, +enum NvmeFlagsSq { + NVME_SQ_PC =3D 1, + NVME_SQ_PRIO_URGENT =3D 0, + NVME_SQ_PRIO_HIGH =3D 1, + NVME_SQ_PRIO_NORMAL =3D 2, + NVME_SQ_PRIO_LOW =3D 3, }; =20 typedef struct QEMU_PACKED NvmeIdentify { --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602691149; cv=none; d=zohomail.com; s=zohoarc; b=mPhQrLF/GG25hTkxWRFIjbV4x5bBxR/lU+5ck4+MTxEhKA3pqzzSn5qTtSIe7eKQ9djl3EdgKPuAAwuJJuxw7LseICFECGVm0w3+ZpmYL4pTFepEKdD7uwTEw9QCtU2paZPiX4EZd1yFpVmJDuC2Exc0JT3J0dB9AJFbeOSqZuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691149; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=8P+APGAGVBASJKD+E4d9JUwx3Znjoc4buR2IIfeAxOA=; b=lLIFAK+pyHE0pGLj/Zsy6VNuS8VA156iP8iEFCgKPHk+3EbGPw6rYLPPwYXhV9JpOknKUUSnzMKmgpEhMp8przerviTAAFD9BHuPNJKzRPTFvv92ELiIeRKLa4c6GcyHZKZmmPdi+SwRIC1+wZe7epV+eKI+kps3SQHXrZKh24c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602691149384253.3606796257327; Wed, 14 Oct 2020 08:59:09 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-Ph95F8QYOhqwPxfMWFL6vw-1; Wed, 14 Oct 2020 11:59:04 -0400 Received: by mail-wr1-f70.google.com with SMTP id m20so1539059wrb.21 for ; Wed, 14 Oct 2020 08:59:03 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id y14sm53518wma.48.2020.10.14.08.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:59:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691148; 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=8P+APGAGVBASJKD+E4d9JUwx3Znjoc4buR2IIfeAxOA=; b=eLqgzm0UsU7j7XbS48Sny4w7eax7WHZM93hJybGNNYSKpu21Rr1tOes5T+sSHN7ehdXxEt uHSuq+Ms+WZU+cd5wxJc+AyfOypqiOaKfFfgwh4xOtruZxk7sL1ErpujGKwM7iAGAkXxaQ G+zOKXVqHzTkJ6q5a/x0eAdY+2eD44s= X-MC-Unique: Ph95F8QYOhqwPxfMWFL6vw-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=8P+APGAGVBASJKD+E4d9JUwx3Znjoc4buR2IIfeAxOA=; b=quqlJP37iWIoL3D08BfuaXMa/EY9ZibvJ7npnpbIhP4VpH04rG/3l8xY0G1pkrpoEn UvpNyilQbDyaqGQdVWCzTWZNy0wZNbxXlNjuEabYsjYR9VMhzy5bbimJOSA/jg3rXqnC po8uz6jDxfwM3+wP6EAuNpJ//YhR1K6szBBVjPX/r+H/1QOOmUi/01D1iPCtyPyrfdtU imZ1SHBGxw7ktK5DdH+RUprFE0mCVvAmbTP1Nm1tdl3n+sOYjVLrJcnnYcxVEvjFLwTl uyOX6AGYE6CHaZQ7jdtIfh/rarrQ+zkmENEJAl7XvRzwmyzhzSqZZWqcx4PQLyFPCwA6 EyzA== X-Gm-Message-State: AOAM530RAT/WhnssAIFh3GHF44Z07fo+Kag6PMoU5vGFl5zgTGnt8wRf MhqgkxoNfgVuNbJtQ066XkVAtkdakhwrgtFQRKZhDKoQdd1eRH7vQ4WSc0H79KUqNwr7MqrDoFB 18AIn/r+QUVA+ug== X-Received: by 2002:a1c:9e0e:: with SMTP id h14mr141588wme.18.1602691142984; Wed, 14 Oct 2020 08:59:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyf/HbfO5K0bSOwQFaE37QJp53txyIDwWfEl6EYjydcLED8ojLbkCqAneZc0RnmFflXM8nm4A== X-Received: by 2002:a1c:9e0e:: with SMTP id h14mr141573wme.18.1602691142784; Wed, 14 Oct 2020 08:59:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 10/15] block/nvme: Use definitions instead of magic values in add_io_queue() Date: Wed, 14 Oct 2020 17:58:05 +0200 Message-Id: <20201014155810.102841-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Replace magic values by definitions, and simplifiy since the number of queues will never reach 64K. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index b841c5950c5..11fba2d754d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -652,6 +652,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, NvmeCmd cmd; unsigned queue_size =3D NVME_QUEUE_SIZE; =20 + assert(n <=3D UINT16_MAX); q =3D nvme_create_queue_pair(s, aio_context, n, queue_size, errp); if (!q) { return false; @@ -659,8 +660,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, cmd =3D (NvmeCmd) { .opcode =3D NVME_ADM_CMD_CREATE_CQ, .dptr.prp1 =3D cpu_to_le64(q->cq.iova), - .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), - .cdw11 =3D cpu_to_le32(0x3), + .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | n), + .cdw11 =3D cpu_to_le32(NVME_CQ_IEN | NVME_CQ_PC), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create CQ io queue [%u]", n); @@ -669,8 +670,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, cmd =3D (NvmeCmd) { .opcode =3D NVME_ADM_CMD_CREATE_SQ, .dptr.prp1 =3D cpu_to_le64(q->sq.iova), - .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), - .cdw11 =3D cpu_to_le32(0x1 | (n << 16)), + .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | n), + .cdw11 =3D cpu_to_le32(NVME_SQ_PC | (n << 16)), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create SQ io queue [%u]", n); --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602691152; cv=none; d=zohomail.com; s=zohoarc; b=BGUG8XGbzkdpc9bPJXaUZs9dZV80o9ysxa2zN7vSKYgeyZspAc9ff51SbLrSnWZ2T2VNIzmfdquIZVVT+zjgdIKvu9JDIbN9ZCpAh72RTeVpgMwEqXdPAjxxzAZouL77dCMeitF4lZp+CydhX5Bti/LYwh6dpcHLyKqyaVZoXAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691152; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=HjmUmabdPFrqIWe27bV/PHgVzD7yxSTl/8t6QReuLlI=; b=S0NkBVVKmEpKw1NghHLxDysH4bga2Xd0/7C/7LXtmYt3UH6/kLrH6h3oe5ygQVr9qkYYbzCL1bj50b4R8Fp9Ufs8Ewl77KGnAdEnsSZfHbfwPZMSqSEjaUoL3FMjrZ2h48KCyzvFnPb68WidrKhj6GgjnKla9HUOvzvaGTSm2x8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602691152174362.1556310943978; Wed, 14 Oct 2020 08:59:12 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-135-qK-0UsXINByTPMBqpXlWgA-1; Wed, 14 Oct 2020 11:59:09 -0400 Received: by mail-wm1-f70.google.com with SMTP id y83so31339wmc.8 for ; Wed, 14 Oct 2020 08:59:08 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id z11sm5527165wrh.70.2020.10.14.08.59.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:59:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691151; 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=HjmUmabdPFrqIWe27bV/PHgVzD7yxSTl/8t6QReuLlI=; b=QNdIfTr4fDgH4Apc9dXvVtJ62J+fHHhEu5HBKOElTZeVJBIvGxwibS7ZHAf2RfLTU/XBrY gfLpf5UrctJhPBFCYvLWF5L6CWuYGIjam9tiJrpBaxKyXx+jDA0QdyYismaLuL8BKJUesD ja6KvqlcI1bwV1r3UwEzmN1zHCYfmqc= X-MC-Unique: qK-0UsXINByTPMBqpXlWgA-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=HjmUmabdPFrqIWe27bV/PHgVzD7yxSTl/8t6QReuLlI=; b=Eo2B2lhz+/3TDYmNIt97PkEtGqjLe2YiCXDbaQqwW2ADuHIDZBE6SCHP10KZ7Y37X8 IdmFYzJF3f13Nm2xv3MxQmjfiTSNFFDEuEP6Dw+2Uulk5WFqf5htDGyRnyKLGM/zZU7i hAL+9PCExVLD9vXTBd7h0dy4gJX1AxWSFLRqX7yz65E9u7dOVkTKJjOtXyywttGWd5Av L2REOxq8yWahHq66JoZ08dLQilOPbHtLl4oswqWPXyZrpHk/v6QW+GI88ynwEP3A8zPQ UKLylxlKJf6IGKSy0TX5/FF2co3ZQ1w+iUilItjT394qruHQKCfTHjvla9pRFcjG9lWz epQw== X-Gm-Message-State: AOAM532Ny82DZhXFz5VfiU2SVuBeVsQawV4+1+EAJhZHxk7VHjYOWhd/ Ua1vRcIqhieSA6BMd5fYKnGdywAj43GIlZXK4a/4nJsduNaJn/vMFWR7b9vGv57hXcfiV0Jvr6G wqkokZBLXbU0hgg== X-Received: by 2002:a1c:9e0e:: with SMTP id h14mr141904wme.18.1602691147906; Wed, 14 Oct 2020 08:59:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTCbHG7OyDh9+X4wwi0BcuIZEZiLxT8dDgXYokzetAJfBJy4+u1HRLfPIgjPrJGskXMtGz/A== X-Received: by 2002:a1c:9e0e:: with SMTP id h14mr141895wme.18.1602691147688; Wed, 14 Oct 2020 08:59:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 11/15] block/nvme: Trace controller capabilities Date: Wed, 14 Oct 2020 17:58:06 +0200 Message-Id: <20201014155810.102841-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Controllers have different capabilities and report them in the CAP register. We are particularly interested by the page size limits. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 10 ++++++++++ block/trace-events | 1 + 2 files changed, 11 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index 11fba2d754d..fad727416ee 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -725,6 +725,16 @@ static int nvme_init(BlockDriverState *bs, const char = *device, int namespace, * Initialization". */ =20 cap =3D le64_to_cpu(regs->cap); + trace_nvme_controller_capability("Maximum Queue Entries Supported", + NVME_CAP_MQES(cap)); + trace_nvme_controller_capability("Contiguous Queues Required", + NVME_CAP_CQR(cap)); + trace_nvme_controller_capability("Subsystem Reset Supported", + NVME_CAP_NSSRS(cap)); + trace_nvme_controller_capability("Memory Page Size Minimum", + NVME_CAP_MPSMIN(cap)); + trace_nvme_controller_capability("Memory Page Size Maximum", + NVME_CAP_MPSMAX(cap)); if (!NVME_CAP_CSS(cap)) { error_setg(errp, "Device doesn't support NVMe command set"); ret =3D -EINVAL; diff --git a/block/trace-events b/block/trace-events index 6694c23e1c1..8a24d7a8650 100644 --- a/block/trace-events +++ b/block/trace-events @@ -134,6 +134,7 @@ qed_aio_write_postfill(void *s, void *acb, uint64_t sta= rt, size_t len, uint64_t qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t le= n) "s %p acb %p ret %d offset %"PRIu64" len %zu" =20 # nvme.c +nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64 nvme_kick(void *s, unsigned q_index) "s %p q #%u" nvme_dma_flush_queue_wait(void *s) "s %p" nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "= cmd_specific %d sq_head %d sqid %d cid %d status 0x%x" --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602691156; cv=none; d=zohomail.com; s=zohoarc; b=BWUtm8/WEleGD61WKWS67rqzGcYImX/r5Ayl0i/F7ThBoHPmq/JUQ09hwBqJG0+Mfa/htJEOLu4hbkT94MbCJEouyyuWCdjclLzSAxQHNZD3jIlx1DiDM1UTQTDHAMjNORvh1cdDq1DWymaNP3YHKS2kbJqGBE4d2sTZPR19cNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691156; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=QyCXoVZFq8inv3p7sgwPGouRR8crt3jaKhnpEZxJyes=; b=VKiFXW4p1gs29jVFmhV+U+8HykyYt39cAB58FV2QqstLCthed0CT/dz6E9p0HKbhHgarqbFK6hpAdHcX7bWlsFysOD5x/i2aC1IcDrsa96JBpGpThw7dhvAyKEeDBPPMzy/bzlj5n06sHflmKGTpcIfogfzjJiPlgCh+0l0vywI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160269115661264.0338301908622; Wed, 14 Oct 2020 08:59:16 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-491-3oLUb-XkP8-asZ0Q0I09og-1; Wed, 14 Oct 2020 11:59:13 -0400 Received: by mail-wr1-f69.google.com with SMTP id b11so1559179wrm.3 for ; Wed, 14 Oct 2020 08:59:13 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id g139sm158863wme.2.2020.10.14.08.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:59:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691155; 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=QyCXoVZFq8inv3p7sgwPGouRR8crt3jaKhnpEZxJyes=; b=YhMzEXOMcnTON3CWth/lsU8MDORmHceNklEIGFmmRV17mM4oBqKEBySmKFy6o8xh4oYIKr sWH7T67NjciDu5RalrKguyuxzPVlHEvCOjhhD7l4tbeMV2yerZMQVFgwSIkefW1BuJyIR7 R/vsUtvTyIK4uvaaeDHnKa3HCciY8Zc= X-MC-Unique: 3oLUb-XkP8-asZ0Q0I09og-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=QyCXoVZFq8inv3p7sgwPGouRR8crt3jaKhnpEZxJyes=; b=tYxVy8flmfydj0pDAcILDMNJxIlqvXS44b81MpZAKopGWTnup05FtANiFR9KEw5+XK iOM/SOEU5KWisE2Tx3MKmHLxFmhUhf3wZkwNhLZsEcMtCXAIKsR8gYdT7KUtf6ARf0q3 Ico4BsNcpN0r9wWazmksKLBB8z84AeUGi4J/jejzdi3B3Y0XZmAT1gnN5evIXWpyoeT7 LdzzHuHtkjvm5TecENgjj+Ig3Cifyequ3NQwPW+us1g9O7iq+kSbrqy8lkZRADknjqPn Ek5LNcmagQ2eR1zNmtPJnKWhugUUGSH0LDcgSHY2sjTIoyPlSg2EEV9T7owOeg5evbb8 ug2w== X-Gm-Message-State: AOAM530DYKANW0dRDqo25MV2yqNMskgGp6ZlpigNrrB9Ae0X+J4geKoI b2VwCrheSz2JD32ITMB4mFrhKSn67sM4Qf0+bzMv8wLFjkXpnRoOiXlZVckD3/zvYVPVyDQyR/3 bqge5Fn4tTe8WnQ== X-Received: by 2002:a5d:558e:: with SMTP id i14mr6742854wrv.40.1602691152731; Wed, 14 Oct 2020 08:59:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvgeZSzRI+G99Y25lH/EWje7a/1IUyrssbWQ/uBHCdOCDXF42aJI52Cwfl/+kF6VcXix3tAA== X-Received: by 2002:a5d:558e:: with SMTP id i14mr6742838wrv.40.1602691152595; Wed, 14 Oct 2020 08:59:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 12/15] block/nvme: Simplify device reset Date: Wed, 14 Oct 2020 17:58:07 +0200 Message-Id: <20201014155810.102841-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Avoid multiple endianess conversion by using device endianess. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index fad727416ee..299fc82f40f 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -747,7 +747,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, timeout_ms =3D MIN(500 * NVME_CAP_TO(cap), 30000); =20 /* Reset device to get a clean state. */ - regs->cc =3D cpu_to_le32(le32_to_cpu(regs->cc) & 0xFE); + regs->cc &=3D const_le32(0xFE); /* Wait for CSTS.RDY =3D 0. */ deadline =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + timeout_ms * SCA= LE_MS; while (NVME_CSTS_RDY(le32_to_cpu(regs->csts))) { --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1602691161; cv=none; d=zohomail.com; s=zohoarc; b=HWNblJncrFaR9btFukQai43g4prdYsy9MmH19JCDsVzQUsJ5cOTVpaMEUkDcg+RfW1QgOvvggjQhDPYS2Fk30f96oEge8LGjnqJkeBYAv9fbMzCh0X1cyJdzhSbyvTq7oRm+vRoEyTfnroWqtA0YkbDdigvA7ApVuCmDz/GtOFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691161; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=YLxkAx2Y6NEXeaia5IYrWdVkNlawKHl6NTNLCcRm+HM=; b=W/vXUQB9lisIQX/BL5AhSOzp9Dfkic/6csF7RZKBhv/39fqamvToWCEEV4FNdUaewcFB/8VVDBE/ROxmTKvOlRtJGXjdf6gzBad3YtsvgY1lbtgrww6e9E5nNpMAIlo5XFyuXUrc12M0m6WhA4Ea882EE9vsXP9HMOdfT1JPwj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602691161699153.63372910020894; Wed, 14 Oct 2020 08:59:21 -0700 (PDT) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-Er_c0MtMOLmAzy4f2PnHSQ-1; Wed, 14 Oct 2020 11:59:19 -0400 Received: by mail-wm1-f71.google.com with SMTP id z7so33301wme.8 for ; Wed, 14 Oct 2020 08:59:18 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id b63sm140620wme.9.2020.10.14.08.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691160; 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=YLxkAx2Y6NEXeaia5IYrWdVkNlawKHl6NTNLCcRm+HM=; b=eCw39aui4rW+qALP06qu0jbZAMem/pdXIdaHK2Ln2Lx2YAyRAAwo8upSJprbNHp0kfyCFH v+I9qUJrcuSg2JO2za/8EbaM4ttrWZmQiDfG35kSZbQDddvCnmRQWR3o0+j9TUGIVzPkpt QVfZLytEXF/i+iiLzPuuvBXi4EtkKOE= X-MC-Unique: Er_c0MtMOLmAzy4f2PnHSQ-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=YLxkAx2Y6NEXeaia5IYrWdVkNlawKHl6NTNLCcRm+HM=; b=B0SqXhc1ZVo5OUPX70OKMuhn6VLSEwKXAr7hsosxFRlbU6bLJKNb103ojkOkxfZexa m4At1QHv2wSxsa9giSee3YUvR45Eu13pXIFQQk+xEqS4VkMBTaJ5v4QUVARJvpG8KBG7 UPtJ8pEFs7KpzjlutDrp/H7NpBzkMdlzPX2XeW9lQloswcac3WE7ZcgNwiI+6N9Fw3on fUhYdFVP+yya/56QVvsizFrc6Ul9AmLsNtLHrawMpEvZPMAyjBlwLVSPGPo4pRpegRMx 1KtOUdAG9dvLSYtGzEcaNUSzTiUpuMLmK93xyzDAYasC6d8mKYlDgrlX7lUaOJopIhxG jHqA== X-Gm-Message-State: AOAM5325d3LnRZUMDDewigyleXSqNh/TiLVE8Ygq+o+/+K/7VPieNU0r 6JSeEfaxLzg6cy+LCg0S89wvQq/X2Jb9jyhZd53AsteFlbhuOd037FO5KW1Dp940B08Nral6WF7 SgVB1zmLuuU95jA== X-Received: by 2002:adf:fc51:: with SMTP id e17mr6110752wrs.45.1602691157631; Wed, 14 Oct 2020 08:59:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAAwx+uTHoB0/5UNZAAiU8ffhFaePPO/3N56ZhAQ7f9v+cQmbMDDmAHAii2DzE/YyqdXlApA== X-Received: by 2002:adf:fc51:: with SMTP id e17mr6110732wrs.45.1602691157409; Wed, 14 Oct 2020 08:59:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 13/15] block/nvme: Simplify ADMIN queue access Date: Wed, 14 Oct 2020 17:58:08 +0200 Message-Id: <20201014155810.102841-14-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We don't need to dereference from BDRVNVMeState each time. Use a NVMeQueuePair pointer to the admin queue and use it. The nvme_init() becomes easier to review, matching the style of nvme_add_io_queue(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 299fc82f40f..ea5180d8a27 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -690,6 +690,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, Error **errp) { BDRVNVMeState *s =3D bs->opaque; + NVMeQueuePair *q; AioContext *aio_context =3D bdrv_get_aio_context(bs); int ret; uint64_t cap; @@ -769,19 +770,20 @@ static int nvme_init(BlockDriverState *bs, const char= *device, int namespace, =20 /* Set up admin queue. */ s->queues =3D g_new(NVMeQueuePair *, 1); - s->queues[INDEX_ADMIN] =3D nvme_create_queue_pair(s, aio_context, 0, + q =3D nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp); - if (!s->queues[INDEX_ADMIN]) { + if (!q) { ret =3D -EINVAL; goto out; } + s->queues[INDEX_ADMIN] =3D q; s->nr_queues =3D 1; QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000); regs->aqa =3D cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) | (NVME_QUEUE_SIZE << AQA_ASQS_SHIFT)); - regs->asq =3D cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova); - regs->acq =3D cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova); + regs->asq =3D cpu_to_le64(q->sq.iova); + regs->acq =3D cpu_to_le64(q->cq.iova); =20 /* After setting up all control registers we can enable device now. */ regs->cc =3D cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << CC_IOCQES_SHIF= T) | --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1602691171; cv=none; d=zohomail.com; s=zohoarc; b=mlaYxUCrj87wLFMx3iDJvyWrfJYk1gqC7sGyVS4Bv2wyZIDOW2keG5NOmcNAtLVzOkIVnBk8NJRYrO24fwFDF+Sc+ReqY7QlN9XF2G7SV2kc2paK9h4WLeMY9164pMueC0RN3B+DOLKeNe6HIE+jQpRK35XTTSzoZIsG8M/8hbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691171; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=r+CY1sHnrvso4O/aGPEZOoKUho8+gm/1sZCae1y4g1c=; b=Y//6+qyK4TzCQwzjqpmhVvIYA40yQHYlVDCele4Lyy3L5ujA9AkV4PHNw64evFmCvc6DvNtbqD7Nv2kB9saeh57u3tuDQQDLcjpvLtEoQENQGTcmWHuA7VCoeNQw4a0aemfhB6YODBku7cDY5oXIMqcpvASyvL7tOT0BBAswB+o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602691171571613.8147844198091; Wed, 14 Oct 2020 08:59:31 -0700 (PDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-156-ecM-IYEtNmyqsNka_SXyWQ-1; Wed, 14 Oct 2020 11:59:23 -0400 Received: by mail-wr1-f69.google.com with SMTP id b11so1559436wrm.3 for ; Wed, 14 Oct 2020 08:59:23 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id s2sm63940wmf.45.2020.10.14.08.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691168; 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=r+CY1sHnrvso4O/aGPEZOoKUho8+gm/1sZCae1y4g1c=; b=Wuv3HiCVQ8lzhGoYgWMU/8cLHKWBvty8tCMEpAQ7JRafLoT1ArxorpcdMB/eSL2bhX0bRX 3BiGvBRS05TYwTpyobjmoZDKKyb2x6N3VbCSkUV7mN3uBcyPMJmRQlnw/GS/89Ztgaburr bhsCa88fU5MHumKpMoKGdjBuQvzk+JY= X-MC-Unique: ecM-IYEtNmyqsNka_SXyWQ-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=r+CY1sHnrvso4O/aGPEZOoKUho8+gm/1sZCae1y4g1c=; b=nGxNh72O/j2wldzGsMO1ej7bjDUEqi1L3xk8vGoPTj7xR4Sdhza/wui57G4NaCg70U brnu/QxjsDGcJSqwFqqNP7ZMvMGwlPor9MljrECUeFv8KciPKAqbRLONZ4EiHgRlcYM/ RIcvLyn/rgPQ0jGiCpmrHPHONDXAbUJy1QV34rrlHg3virTwUPdIteOT2Og75V3bJYAp 81LkpVOisuCBgfcLfEJZQ2qMCqY7hEbCNqKwah551A+iHz+L0xwVJiLRWpYFO4aJ9x1b +yx0LV9mxdUMfD/3PmQQdRpN6Y0JHJkkJFIeIpPSAlbWeUruUs+wi7c0vEAM1XZD440f d2kA== X-Gm-Message-State: AOAM530b1359/8WJXPDR5lPMNBmDWZ4TKna4XHLlCGrvZPLiPxRF5n0o glBFj3k1dZ8pzrGDGKKA4ZqWKPdrk9Uf9s1KbZLTmVp7L+ItGUxeQ//6/STBNWrBXvnRFsYhKsU AKkZQz5GT5qYJDw== X-Received: by 2002:a05:600c:2144:: with SMTP id v4mr110677wml.172.1602691162633; Wed, 14 Oct 2020 08:59:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxb8NE/Don2naHAFdAZNdX9CrlkYcoDtTq/mU0sA5Zw2NiSxEvBkUgqL9rDk2GjVE/oltEDAA== X-Received: by 2002:a05:600c:2144:: with SMTP id v4mr110667wml.172.1602691162464; Wed, 14 Oct 2020 08:59:22 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 14/15] block/nvme: Report warning with warn_report() Date: Wed, 14 Oct 2020 17:58:09 +0200 Message-Id: <20201014155810.102841-15-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Instead of displaying warning on stderr, use warn_report() which also displays it on the monitor. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index ea5180d8a27..4d2b7fdf4f4 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -390,8 +390,8 @@ static bool nvme_process_completion(NVMeQueuePair *q) } cid =3D le16_to_cpu(c->cid); if (cid =3D=3D 0 || cid > NVME_QUEUE_SIZE) { - fprintf(stderr, "Unexpected CID in completion queue: %" PRIu32= "\n", - cid); + warn_report("NVMe: Unexpected CID in completion queue: %"PRIu3= 2", " + "queue size: %u", cid, NVME_QUEUE_SIZE); continue; } trace_nvme_complete_command(s, q->index, cid); --=20 2.26.2 From nobody Sun Feb 8 11:33:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602691172; cv=none; d=zohomail.com; s=zohoarc; b=FTM0P4hoifpJwymuBD44p9yq+n0th3UyBwlBVIugGculH1rLYlpW85BbeFwDVUOig6fM/aIYbVpuV9xouph84Xp4l4JhluN2NV7nYW9VhZSHjsXnInBLCU2KchSLnLb431fYmAdAziPqCSFmH8eHbrZ1FPgInQkNcbItTr/RH7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602691172; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=KZ4OlirG8Onm3Jtad3QpAqRCwzSXUh6XNOAp0g51qc0=; b=RNeSWE/XOCDW9wh03MV49k4KMAx4inQyako+nUdLXUItZdSGMzDndGY50rZ2MglOnLg0XO9ZuJcfiLq/nqQPZpptFG+VNBlPNMHV/zLAccec7UftEvvf5AMRTDEJR2A1nfg1TTu85Uq2j9StROZWWFGD/fftZFFwZUYK38LMQlk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602691172602704.6617101154094; Wed, 14 Oct 2020 08:59:32 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-Di8TAw9tPMmb5t19Qz2Kvg-1; Wed, 14 Oct 2020 11:59:29 -0400 Received: by mail-wr1-f72.google.com with SMTP id n14so1553744wrp.1 for ; Wed, 14 Oct 2020 08:59:29 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (106.red-83-59-162.dynamicip.rima-tde.net. [83.59.162.106]) by smtp.gmail.com with ESMTPSA id 88sm5873022wrl.76.2020.10.14.08.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 08:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691171; 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=KZ4OlirG8Onm3Jtad3QpAqRCwzSXUh6XNOAp0g51qc0=; b=IYJ+HQYjLo0vuWiZEhMO5RACIb9NjYBbLYZeE/9dlO0vb6iKTjEKTxEGgPyI/LJvusY8uG OiNAnsMnEzHFCTPzHjlZxuwfDafxzPXOmvd2Sw3Q1YX3y518+0YFIyB4kBJQ5nB7RaWV8I qdSB/AHhzdwTKLKSueoVLfdKgr+jNO8= X-MC-Unique: Di8TAw9tPMmb5t19Qz2Kvg-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=KZ4OlirG8Onm3Jtad3QpAqRCwzSXUh6XNOAp0g51qc0=; b=Eltomp7FjA+AMrugIfHuj5Stj3cgsBE7+FiDOWUSinDoRSK6dkoCs1c8XoLl/FnJYG 0F1ZTg9aS0TCEnkSushfpYi7SGvpcvyikHlkupmqgxcVfwGRj6QJFF9wAwNjgGlxf6uq wLs4j1RsCNUCMKgnYPwdAee7WZZEIQ22Ont9afYJI8Mbf2iEbuDAZu41rEALZosbSryA Vgx4kWdNAW/Iid+PBxqGE5UP5xMrXzRVCdL3vr4k/beZZhWv2TTsPRXvoFEJjarG84Il MhAATJlAa0wNYDGArB5z5F3xhwj8ghH3ja814UcW7wHJPyIJJ1m9hBsxSuYXg/w8NbZm MKCA== X-Gm-Message-State: AOAM533Ds/Aj9ddNRhChi64Smki3ehveod88zTt6/0PPb69bcdSSYDSr 8aQdOWA5GGBp2IB2AMRlO8orrVRxBt3dkGAFbWUWzG+OPSdjBsz0EYSSVK5SUw4GbuzoyVthEqx XkhSrqGYBiWuUdg== X-Received: by 2002:adf:9f4c:: with SMTP id f12mr6361138wrg.108.1602691168536; Wed, 14 Oct 2020 08:59:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybi0k9qApaltJAIu/BtwQS/Z0EvcXNsTFDkcNMzR1Vy3U0q1Sh3SKLC4zJMrL/O8U3mbbmXA== X-Received: by 2002:adf:9f4c:: with SMTP id f12mr6361115wrg.108.1602691168296; Wed, 14 Oct 2020 08:59:28 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Fam Zheng , Stefan Hajnoczi , Kevin Wolf , Max Reitz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 15/15] block/nvme: Set request_alignment at initialization Date: Wed, 14 Oct 2020 17:58:10 +0200 Message-Id: <20201014155810.102841-16-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201014155810.102841-1-philmd@redhat.com> References: <20201014155810.102841-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 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) When introducing this driver in commit bdd6a90a9e5 ("block: Add VFIO based NVMe driver") we correctly set the request_alignment in nvme_refresh_limits() but forgot to set it at initialization. Do it now. Reported-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/nvme.c b/block/nvme.c index 4d2b7fdf4f4..04608b49f56 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -745,6 +745,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, s->page_size =3D MAX(4096, 1 << NVME_CAP_MPSMIN(cap)); s->doorbell_scale =3D (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment =3D s->page_size; + bs->bl.request_alignment =3D s->page_size; timeout_ms =3D MIN(500 * NVME_CAP_TO(cap), 30000); =20 /* Reset device to get a clean state. */ --=20 2.26.2