From patchwork Wed Oct 14 15:57:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271266 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BAF75C433E7 for ; Wed, 14 Oct 2020 16:02:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 06ECF20B1F for ; Wed, 14 Oct 2020 16:02:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bcgH6HKI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06ECF20B1F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjEJ-0006EN-PM for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:02:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjAa-0004HV-1s for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjAT-0000rf-Tn for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691101; 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=bcgH6HKIZ0Ll3ty3TV3DVGjlH/d4c+WWI30W7YYRXqyeLjY7gMJGeDTo3+GvGMLoWqI2QQ FuYPvLRkqF3tN5mHsA0ZG6FwsGlAwOxLTAnocCXwrs+5lUCqh6lRoIbXzTEM6WEYOPphiO 2c7KzsHKOX8wd/9Er0zlF41h+rzMtP4= 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-585-XI73lhc7P5K6r3mdJe3eMg-1; Wed, 14 Oct 2020 11:58:19 -0400 X-MC-Unique: XI73lhc7P5K6r3mdJe3eMg-1 Received: by mail-wm1-f70.google.com with SMTP id m14so16466wmi.0 for ; Wed, 14 Oct 2020 08:58:19 -0700 (PDT) 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=RtDLp3p6UcUkgzv+1wE6gHYs5nn3gsOwsTIZMr9DAomlZzJFZYlzIMGKLyQfwHiy8l iQQRwHb/tAv9xFY8ktk+Ls3NF8el8NwvRgODKJb3beX9eLSK85PaTL37UwZ0JkVhs0Uy tFDHvENAznP4DBGgMcCCbMeuoslJRNzexNIoC3Ei+TZWWWHLOOnZKsekqkn3PahRngq/ I8tAwQIsLnnlKDpXtonrWxzGjQzjrgOfgTA3uOfB8OZU/KqJOuaJX/KEfg3so8nUYFtV +25V1P6A8BPijRMOM6C8Vw6v+8FidU/WU6T/fPV5xkYyqCzDNTm6Nb66b8c10mLIV+Wb /bhg== X-Gm-Message-State: AOAM532eZXhnUTqovAFcrUOi9ErPrAbcTELPo+iJfc3OvTshp06aS8qV N+JZRYaZXkcFmXsU9QbolXvd6AyeLC8vIzVE5px9iac5NDX1EO0BNxPpG0/YiHWNP+FtG/xy5I4 JTtLovJ2D9rSmg8s= X-Received: by 2002:a1c:9949:: with SMTP id b70mr119916wme.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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); } +static bool nvme_poll_cb(void *opaque) +{ + EventNotifier *e = opaque; + BDRVNVMeState *s = 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 = bs->opaque; @@ -669,16 +679,6 @@ out_error: return false; } -static bool nvme_poll_cb(void *opaque) -{ - EventNotifier *e = opaque; - BDRVNVMeState *s = 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 namespace, Error **errp) { From patchwork Wed Oct 14 15:57:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302862 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87A70C433DF for ; Wed, 14 Oct 2020 16:05:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC73620B1F for ; Wed, 14 Oct 2020 16:05:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="P93v6MK5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC73620B1F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjGv-0000yD-NP for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:05:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjAh-0004Jo-7g for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40628) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjAZ-0000sH-Hq for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691107; 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=P93v6MK5hu0KGffiAFWEj6m7G57uegjc4iWWJVYg7nQeCERis4XHbFodDJs4UVshh8wDF9 7mw1UkOj/1Tj8QFjWfnf0r7ivvpdvKGjUG9vQATi98YH6mlmcw0vUDpK4ena0UQCp0OmEw BqlD1E7wUjH8hZfjkGr5s1rSH9IoWpU= 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-61-CAoYrL1zObuKU1SL7lCAqQ-1; Wed, 14 Oct 2020 11:58:24 -0400 X-MC-Unique: CAoYrL1zObuKU1SL7lCAqQ-1 Received: by mail-wr1-f69.google.com with SMTP id 47so1539516wrc.19 for ; Wed, 14 Oct 2020 08:58:24 -0700 (PDT) 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=GHsOIzjkhO/dnTBHngNydojnIKM5Tyn5+/xyQTS73AslzRMFdfELEw1AiMTgWMGFyH lkjK+3E+p1olmIs7JLiLmyzGOuuNYVetkTY+zSVupeBQCSW7xNOaBg3s9pxrud94FVgl LHCO+C9I0RYcksEC8jLpbnkmn3jYSoCMHmFHEHR9/Et8VPkwB0FV4Cfks4WgISBrr37K 8o8CRqesejIbynvWcEbqULgG0mseTHZz4EFZxLA05OLg1N3d/w5DpzRQnipW4Xt4RMPA CA/sLkrYj1xtz8x/XkQyCaPnf1ACAFi98VJTAXt7lQtyOdGz9mr48E893P1rGRyDHX+I Bw3Q== X-Gm-Message-State: AOAM531pyPNuuTu1d3H1bBuaQYEU+V/y3VgVYMecLs1cE5MMAw0RlHhR 2T2pVdpuM3c6AcZ1Ts1mSdXaMXPjZa+/joJ0rzlymUo3SF5SqI5V8BlWEFgZkAT6geIrGBsXIWt tbZw5q9FUUWtVMjY= X-Received: by 2002:a1c:f417:: with SMTP id z23mr87591wma.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 = q->cq.head * NVME_CQ_ENTRY_BYTES; NvmeCqe *cqe = (NvmeCqe *)&q->cq.queue[cqe_offset]; + 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 = container_of(e, BDRVNVMeState, irq_notifier[MSIX_SHARED_IRQ_IDX]); - trace_nvme_poll_cb(s); return nvme_poll_queues(s); } 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, int 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, int flags, int niov) "s %p is_write %d offset %"PRId64" bytes %"PRId64" flags %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" From patchwork Wed Oct 14 15:57:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271262 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 144FFC43467 for ; Wed, 14 Oct 2020 16:11:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A121221EB for ; Wed, 14 Oct 2020 16:10:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZqfoyhpI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A121221EB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjMf-0000Cj-VN for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:10:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjAl-0004M4-5Y for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40001) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjAg-0000sn-TY for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:36 -0400 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= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-188-AFBBDsVuNKGCvqdn4CYl1w-1; Wed, 14 Oct 2020 11:58:29 -0400 X-MC-Unique: AFBBDsVuNKGCvqdn4CYl1w-1 Received: by mail-wr1-f71.google.com with SMTP id b11so1557974wrm.3 for ; Wed, 14 Oct 2020 08:58:29 -0700 (PDT) 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=DAaYKwpquohGLx1du79yvSrsV8rHpnmUnlwQYcUzG0A/37Gq5FRiS9MSvTtgzldT/D 2VVd4yMiqA+G6cW3h3KY6v/RcuuQ9042oxtQd0Hy+RL8xPR5mGM1wRVa37Uljc0RIGEa oQTTUamxws6qjn0l3eQXqP3yZvjDJ5MK+v4FVrrrAL5QL9eIgPOzHpK3VGk83Sn3ah2M KQ3uw+U8GDgqp2pg+X2rOymLL1/79cA9f+oCDkQ+ShiAzibIDhChemOMPJ9SamVg1sfm xDc7m9t0scNUgjhqNJtPiCdISZC/jFDlXdOKVAG3ry3e1W8or8LBxNPbLQLmpGqI6aez tCTw== X-Gm-Message-State: AOAM531W5ZdZOS6tzTdUtaaGbUwgCLTMQo/5M4H8WMp8VCObdqKs7l/Y vk86kLXodUpDMF9C1arwpAZvXBaRJXe2DKYb48BD5chFZzfUX4AqW1I2NeTPVfzNDr3//1FC56l t0I2hc8VhshVm278= X-Received: by 2002:adf:e292:: with SMTP id v18mr6286713wri.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 03:37:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We can not have negative queue count/size/index, use unsigned type. Signed-off-by: Philippe Mathieu-Daudé --- 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 = { }; 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) 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 = bs->opaque; - int n = s->nr_queues; + unsigned n = s->nr_queues; NVMeQueuePair *q; NvmeCmd cmd; - int queue_size = NVME_QUEUE_SIZE; + unsigned queue_size = NVME_QUEUE_SIZE; q = 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, Error **errp) .cdw11 = 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 = (NvmeCmd) { @@ -667,7 +667,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw11 = 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 = g_renew(NVMeQueuePair *, s->queues, n + 1); @@ -869,10 +869,9 @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable, static void nvme_close(BlockDriverState *bs) { - int i; BDRVNVMeState *s = bs->opaque; - for (i = 0; i < s->nr_queues; ++i) { + for (unsigned i = 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 = bs->opaque; - for (int i = 0; i < s->nr_queues; i++) { + for (unsigned i = 0; i < s->nr_queues; i++) { NVMeQueuePair *q = s->queues[i]; 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_IDX], false, nvme_handle_event, nvme_poll_cb); - for (int i = 0; i < s->nr_queues; i++) { + for (unsigned i = 0; i < s->nr_queues; i++) { NVMeQueuePair *q = s->queues[i]; q->completion_bh = @@ -1418,11 +1417,10 @@ static void nvme_aio_plug(BlockDriverState *bs) static void nvme_aio_unplug(BlockDriverState *bs) { - int i; BDRVNVMeState *s = bs->opaque; assert(s->plugged); s->plugged = false; - for (i = INDEX_IO(0); i < s->nr_queues; i++) { + for (unsigned i = INDEX_IO(0); i < s->nr_queues; i++) { NVMeQueuePair *q = 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 start, size_t len, uint64_t qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu" # 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 inflight %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, int 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" From patchwork Wed Oct 14 15:57:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FED3C433DF for ; Wed, 14 Oct 2020 16:04:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A645214D8 for ; Wed, 14 Oct 2020 16:04:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bZ15a+h7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A645214D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjGr-0000pn-8J for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:04:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjAr-0004Oz-TE for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjAk-0000uP-Tv for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:45 -0400 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= 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-62-YereZKAiPf6NgzvlQRIDGA-1; Wed, 14 Oct 2020 11:58:34 -0400 X-MC-Unique: YereZKAiPf6NgzvlQRIDGA-1 Received: by mail-wm1-f69.google.com with SMTP id f26so39035wml.1 for ; Wed, 14 Oct 2020 08:58:34 -0700 (PDT) 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=e3IS1C/2LUCPWtw3cB7kp0Yx6QSamsWMoIdXA/ptfcn+uK9dO8VcXYLqeIGtTw8CCv grfwEtt+7vGRNt9CLXZaD1RKy2w3NVqAV3zUTyAXTt36HRW9fiamYQxNV1XJf7GS6rIX hkCm2U6ViYUhroBBHzUpWoyLR6FyWqLzY0F3SXDExdkSgXpHkAkmdsebBm+r0aLaHFXQ W8gMoyQn/HHqnn0Ym5PLbwhH3mMy5ECEk4Z6RGFLSqxEceMqBtpG1OPUpONfgAhD2iQT rNX4kbfkKjkzin0Dv9ZxyQucP3UFjaq3vwgGpoqbvIHVtQlJoXazmQq6E8cv4tg/B9ei PPnw== X-Gm-Message-State: AOAM5328NGBBNMNSULNt/iS8bOftg9thrkx6myu970+9U/w+igYnN7Qs kWMVKn3X/WMknrf8nDqKZNOkWrrfOpJgWdaUAxshpcvd4l95p0hBDOWNh3ujJzT8HU+DWoKS068 GbTaWyT+4uxEjucI= X-Received: by 2002:a05:600c:2189:: with SMTP id e9mr67115wme.153.1602691113182; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 03:37:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" What we want to trace is the block driver state and the queue index. Suggested-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- 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) while (q->free_req_head == -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, uint64_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 offset %"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" From patchwork Wed Oct 14 15:58:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271264 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33EF5C433DF for ; Wed, 14 Oct 2020 16:07:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95046206F4 for ; Wed, 14 Oct 2020 16:07:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gf8wNxsJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 95046206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjJb-0004cW-9l for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:07:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjAs-0004QY-GS for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42812) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjAq-0000v5-Sd for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:46 -0400 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= 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-63-6MWdQrssNSSms-fwWaVeyQ-1; Wed, 14 Oct 2020 11:58:39 -0400 X-MC-Unique: 6MWdQrssNSSms-fwWaVeyQ-1 Received: by mail-wr1-f69.google.com with SMTP id t3so1559528wrq.2 for ; Wed, 14 Oct 2020 08:58:39 -0700 (PDT) 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=YzDork2Fu+50p6QBBVaYVMrgR/kSgj4+HgGjAf7kppgFUiidYSruDccOJsr+2kBivA 86Y2ZOzuMlxuIpGWh5L9/bxhUuMxk0GC4L7iMsSGb6dhEz5VA5u99BCARSrQfEW5PU5h /wId1MUe9tXexx4V3bNX+PUDiTA8ZE955V4ilrx1Bb7bGqE5P2Y11XMQY6tUTuWLvtDe 6vj9NnA3Qgmmx2y8mGigT+QB/zCXWIHbG5OvVpZp69OCUvxJzXZv/LuDAMyaFiRhA1ZB XWq4wS9tZ2FuFw7HetiYWsgfzJjALpeq8LEyk8LYuVD5mUQo5wbUl4tnrzBAMHj91nFv eN0w== X-Gm-Message-State: AOAM530GU16b6VlEbN2dHqb7t9JOBbYgfceoiClRNexlp6OhI7pBOAiV cvL2Z7o0ilcrwrBXZTwcX+9CS32t1L4V83fvLwCo+UWNdMQIz9hv9p3bxRPDvA5j26zqEp9d9Zy PeuyGhmeTGrQMzOw= X-Received: by 2002:adf:82f7:: with SMTP id 110mr6213039wrc.261.1602691118068; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Philippe Mathieu-Daudé --- 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, 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(BDRVNVMeState *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 = 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 offset %"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" From patchwork Wed Oct 14 15:58:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302863 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42E57C433DF for ; Wed, 14 Oct 2020 16:03:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4EA0C20B1F for ; Wed, 14 Oct 2020 16:03:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XI7Ptz92" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4EA0C20B1F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjEz-0006md-3M for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:03:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjAw-0004XL-Gn for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41872) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjAv-0000vz-0q for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:58:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691128; 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=XI7Ptz92jzM0lDHv23O4OqUzgc6oSuL1SvXGr4bKFjK0co5O7LwxYBkKN3O61DYdoax3+c I/fmYUweMRti2Aj1jQol0DsbpCYqAg1MU5T8ZpxU5xzphm1+h8jh6FWYsQ6CJYh06Hhjfu UJQzsi4O+5vJJyLFqvQK52hT6+gvHkM= 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-439-5Th9mXdiNfGvoTSxmHIn8Q-1; Wed, 14 Oct 2020 11:58:44 -0400 X-MC-Unique: 5Th9mXdiNfGvoTSxmHIn8Q-1 Received: by mail-wr1-f70.google.com with SMTP id t11so677279wrv.10 for ; Wed, 14 Oct 2020 08:58:44 -0700 (PDT) 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=eu3CH2UVUsOndwQTATtwTombglFk8ky6sdmrilg714QsLCoii0KQ24Lm+w51W+bhXh 7f8S7piU737JxvmNdoHzGE6FC1Xr5C7vAuhOfADS6YxyXVtk/MihTdaDAA4QZokAdDNd GPdh9iR3ucShHR6APv0xrJ4y2cSw4YMyu1v4AkcFdx/F4livajabY0dI86iId/7M8n2T H+dXw0Y99aBD/1Q7xk/19AE6UFVtqTYv5PnjSIQnsDQ0/TzihUX95l/KOE+DLohJz9tB ZE35JAx2CefGIrrWJUG3mnDFOb1nEyKBjJKCvilZXeX0E/dp0c25Yrf7SRmlr0Ms90L9 PuRw== X-Gm-Message-State: AOAM533pIPWRySiMIzVCn43FaY/kfEaMzhfDDO1YGLPkl6i/ApdipKbm pe81ZNkfUDZUn41fkhPXFjwjJpyYgcFix4G9GdyWZpA8UjM92mRpVFXM5x+F/ey+3EivY9OY762 3Ci1mMwYb2qScHeI= X-Received: by 2002:a1c:e48b:: with SMTP id b133mr142443wmh.0.1602691123051; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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, NVMeQueuePair *q, return ret; } -static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) +/* Returns true on success, false on failure. */ +static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; + bool ret = false; union { NvmeIdCtrl ctrl; NvmeIdNs ns; @@ -575,10 +577,13 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) goto out; } + ret = true; s->blkshift = lbaf->ds; out: qemu_vfio_dma_unmap(s->vfio, id); qemu_vfree(id); + + return ret; } static bool nvme_poll_queue(NVMeQueuePair *q) From patchwork Wed Oct 14 15:58:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 933A9C433E7 for ; Wed, 14 Oct 2020 16:07:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E80BC206F4 for ; Wed, 14 Oct 2020 16:07:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MVN9FfgR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E80BC206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjJc-0004hX-N6 for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:07:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBA-0004ap-PT for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29145) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjB8-0000wW-JH for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691133; 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=MVN9FfgR7iYX+tM/8JyT15NHJWBA4lPJq9xHIJunqAnsSPbaPSAUE1FYGPDTTwolfuFSGN BzcvFSng1C/LH86uDn1hjJ1Qs31CdYWDS15rl8lsUMq3PlTaRI2mBhSCAfOjFtnXZPXLDQ 7MFsjLLlKKnLCB1E8FDufVbEC0PyD0M= 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-427-5yvTvqL6NMmA7dqdiIg_6w-1; Wed, 14 Oct 2020 11:58:49 -0400 X-MC-Unique: 5yvTvqL6NMmA7dqdiIg_6w-1 Received: by mail-wm1-f70.google.com with SMTP id y83so30929wmc.8 for ; Wed, 14 Oct 2020 08:58:49 -0700 (PDT) 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=H496sr9LaTKemsDPDVQ8hEd8U/vrUWrcKegPrVaa1rslc8jfSS7hummPrpZ1K7in6J hm7f170MW15S3MFSbWntT2j04dvofA+13q7kUenRqPrDLOKSYTnBoXa41OyhfpjZwCHr RAvbmXePGwPqmaUr4Znb+/k7LqxCKbJIpkb0qbmAwDdrJa3hWqztsR4Edw6dVQeMjOJ3 zvQ8X6lif6CpgEdxAjR1whDZYVxCIZFoJwLCbAN/bzm1p++4ZQXsVczYZO0V9IX+LciF ox2yoXep1zYTQZnfh8YfE9KQ59f+Ru2SuZMHcFhF53j0Cb0KeCIggncdzA5nv9LPsId6 MhVA== X-Gm-Message-State: AOAM530s8ACL1A2D8Pw1LcxYtc9C0TLWQBqfhd/3R2TAV4bgEPAGs5CZ IvRy/hsBi4/fiRlj8H4uFN+bkk4Wm8dGAIzFqG/jkSHuc2zhUiU3z+r5x/AU5gesYB1jnmzKgsK AlNQ1HumZ2k741LI= X-Received: by 2002:a1c:3d46:: with SMTP id k67mr119209wma.150.1602691128194; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 = { }, }; -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, NVMeQueue *q, q->queue = 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 = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, errp); if (r) { error_prepend(errp, "Cannot map queue: "); } + return r == 0; } static void nvme_free_queue_pair(NVMeQueuePair *q) @@ -203,7 +205,6 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, Error **errp) { int i, r; - Error *local_err = NULL; NVMeQueuePair *q; uint64_t prp_list_iova; @@ -240,16 +241,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, req->prp_list_iova = prp_list_iova + i * s->page_size; } - 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 = &s->doorbells[idx * s->doorbell_scale].sq_tail; - 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 = &s->doorbells[idx * s->doorbell_scale].cq_head; From patchwork Wed Oct 14 15:58:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69418C433E7 for ; Wed, 14 Oct 2020 16:12:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD320206F4 for ; Wed, 14 Oct 2020 16:12:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="D21m9eqr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD320206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjOZ-0004U4-Qr for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:12:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBL-0004gl-Tc for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjBA-0000wg-Hy for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:14 -0400 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= 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-583-OCcVr3u4MW2-8V4jXM7wdw-1; Wed, 14 Oct 2020 11:58:54 -0400 X-MC-Unique: OCcVr3u4MW2-8V4jXM7wdw-1 Received: by mail-wm1-f69.google.com with SMTP id u207so6979wmu.4 for ; Wed, 14 Oct 2020 08:58:54 -0700 (PDT) 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=bNnui+MlhiJKGDBhPyIiOWd+6Jr8Q4Q0MbPmMxPbH3NXtuY2fuSJbdiHR94gfw9bdP hFEIJXy6kRCr7yVVsEjtT5z13+7v4bnMf551Uoqk2YZKOK0JawCl8Pxl7s/MV2fVBroO bc9HGJgJRW/IQDzWf3rt7yxxQP2SisRaDI0nvDEFL4Ik2nP3yVSwB6I7Gh9IVf9eqGT+ PQW6gOa6FBcZnyVKEuoto4tWrWcQH5h0IBP8k1nn78g5rBPCMkc6yTHHR+Nga0WMP6SW j/1EQWr9WKTsBGJv956MiXrciSAErlKD5GQpje2fDLydDTbXGeNBpn9GuQICMzc1bAgr ZKBQ== X-Gm-Message-State: AOAM531mpqdVGcpzt42ynQNdw8l1z/Pyxa+Mq8MQKdWIF25QfFbnf1SZ jayOllHka4/0ojgOdFaW9TGMObtViDyA7duWe823TPPAAmLzZI+TjcZKy9JfC/g/TvPgTB0H0vA 1SHJjF9ofLRSC1LM= X-Received: by 2002:a1c:2d8f:: with SMTP id t137mr137410wmt.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We want to get ride of the BlockDriverState pointer at some point, so pass aio_context along. Signed-off-by: Philippe Mathieu-Daudé --- 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); } -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 = bs->opaque; unsigned n = s->nr_queues; @@ -650,8 +652,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) NvmeCmd cmd; unsigned queue_size = NVME_QUEUE_SIZE; - q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs), - n, queue_size, errp); + q = 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, } /* Set up command queues. */ - if (!nvme_add_io_queue(bs, errp)) { + if (!nvme_add_io_queue(bs, aio_context, errp)) { ret = -EIO; } out: From patchwork Wed Oct 14 15:58:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72724C43467 for ; Wed, 14 Oct 2020 16:06:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE94E22247 for ; Wed, 14 Oct 2020 16:06:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YWdzx0ul" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE94E22247 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjHw-0001d1-Fv for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:06:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBK-0004dV-95 for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjBA-0000x1-Gf for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691141; 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=YWdzx0ulpOzbtdmuh1rSfcF08o0gCdL4Y2RyJGUpn2omqNl8kqJtR0g7GmH6Uc8yRmduXO ag0VRh8yZiYdqMv9jaDPbeC2a6kKWWL2nPx7+Q0TBx6bxRYvW+4dBh3RaYQm8FEMVBGo/r tMAXEo2ZmUM+LCwzVqDL6MsrCNwmILM= 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-161-z81Y_vLOOUyK8mNOwX04kQ-1; Wed, 14 Oct 2020 11:58:59 -0400 X-MC-Unique: z81Y_vLOOUyK8mNOwX04kQ-1 Received: by mail-wr1-f72.google.com with SMTP id 33so1541704wrk.12 for ; Wed, 14 Oct 2020 08:58:59 -0700 (PDT) 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=OqMO8/UwQpd0Cc8PaBDSR6YzbMc/gm61c5TXccLwLPyghOehnb9z55dPRIN4O1SRDG UqmNosWXPXyMDC732jfYPSReWw+TBBvtpzxeQIDPmLVmPSWnjAS/zNpDcWtaO6/3uS11 GWp+ruM962w/0DBhz6vLAMIahvQXF1fpXGYuQ0o6iHcQTy2+Cdkm6uCw5Prm+opOkxhH OjgRyIWSHhZ0Lv8HXb8L9ZpvtlofuQS7lLcsvjV6CWXTZ9cYGgOACRS1ulDevlgfiwiT eLI1eIs5IoQ+7jaqKiijZXGcMbc31Q+fA0osoqQ7sQpcwEHrrql39fuDBiFjrNhpzfyc 5B8Q== X-Gm-Message-State: AOAM5322STNibxELKoLvrqVT7i52mgip/Ey/8bq0pnN7ut0B4SQSWj/Q ZT0PT43GRqiUpbX6nYYYc++6zWD2efh/dJIuzn1cZyoSfgQwyHSpn8NMr04xiKbWQRu0xmIqfiJ ZRgitV5YKb2RHrOs= X-Received: by 2002:a05:600c:247:: with SMTP id 7mr101662wmj.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Rename Submission Queue flags with 'Sq' and introduce Completion Queue flag definitions. Signed-off-by: Philippe Mathieu-Daudé --- 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) +enum NvmeFlagsCq { + NVME_CQ_PC = 1, + NVME_CQ_IEN = 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) -enum NvmeQueueFlags { - NVME_Q_PC = 1, - NVME_Q_PRIO_URGENT = 0, - NVME_Q_PRIO_HIGH = 1, - NVME_Q_PRIO_NORMAL = 2, - NVME_Q_PRIO_LOW = 3, +enum NvmeFlagsSq { + NVME_SQ_PC = 1, + NVME_SQ_PRIO_URGENT = 0, + NVME_SQ_PRIO_HIGH = 1, + NVME_SQ_PRIO_NORMAL = 2, + NVME_SQ_PRIO_LOW = 3, }; typedef struct QEMU_PACKED NvmeIdentify { From patchwork Wed Oct 14 15:58:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 499B9C433DF for ; Wed, 14 Oct 2020 16:11:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B718206F4 for ; Wed, 14 Oct 2020 16:11:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YMgJvRJo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B718206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjMp-0000Ks-5n for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:11:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBK-0004eF-Ge for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjBF-0000xh-9M for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691146; 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=YMgJvRJoFve12amM0SajTEMua3SDqtIf2ClDA1OZjxqf1BqdLeZY4Z5IhLdaspu6wNr9vV m07gl+5S+YrrLrI3OVCXtptjbAjt90+AONIWw955I8qz4wxl7M6SWJEYLg0tfQJbO56W7w CoDpOoCHq0AzTkrYW5oj+3UgJeqaSs8= 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-264-xJKFrdOOPEajwS7tgsZOnA-1; Wed, 14 Oct 2020 11:59:04 -0400 X-MC-Unique: xJKFrdOOPEajwS7tgsZOnA-1 Received: by mail-wr1-f69.google.com with SMTP id f11so1537033wro.15 for ; Wed, 14 Oct 2020 08:59:04 -0700 (PDT) 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=edq/IgCI6r/MyAdVB4ooWttRWiE3UOXViqDeKlAP82rt4qLBPBEO59SUdu0aA9bzDw J4ZHqwcUW0DvnjzJaJXq7R0O+yA271h4xjEwDus6+gHKL9dy6YsoZDQ6kr/J3NsBW1sA ANnq61Y8ISQ8kldjZQ0cRkCtZPPKBKSHaz5hKI5mdLjcsXkZbD1Y5W+W4Qqf+F0rqyx4 A8aBDGvtD2wqHyGRkAyM0I760jTOGBizMq1loRRw51/lgadFv8m8Ty4YZmIvyDbldH4R 2HFUWBVlX2TiPka1chn0A51FugU8hwjrqdxsRsOnkZ+Z2CStIzfX8AbYN/Ksk/58c6bb hqeA== X-Gm-Message-State: AOAM531kzD5BnoMGvTVWblUaWfxSksMqsPZLEJiLZ8zQuyA6FPIEPSk6 zQw/sjDBJxRQnFJ+d7DbHBMEfhvlXuWPMbCi7jiH98IlsIi6pJR/aQpyn8+0WJ0KYutuCsWzJBH xIzrsj2lldNKNJgg= X-Received: by 2002:a1c:9e0e:: with SMTP id h14mr141584wme.18.1602691142983; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 03:37:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Replace magic values by definitions, and simplifiy since the number of queues will never reach 64K. Signed-off-by: Philippe Mathieu-Daudé --- 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 = NVME_QUEUE_SIZE; + assert(n <= UINT16_MAX); q = 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 = (NvmeCmd) { .opcode = NVME_ADM_CMD_CREATE_CQ, .dptr.prp1 = cpu_to_le64(q->cq.iova), - .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), - .cdw11 = cpu_to_le32(0x3), + .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n), + .cdw11 = 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 = (NvmeCmd) { .opcode = NVME_ADM_CMD_CREATE_SQ, .dptr.prp1 = cpu_to_le64(q->sq.iova), - .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), - .cdw11 = cpu_to_le32(0x1 | (n << 16)), + .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n), + .cdw11 = 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); From patchwork Wed Oct 14 15:58:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AE82C433DF for ; Wed, 14 Oct 2020 16:08:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F944206F4 for ; Wed, 14 Oct 2020 16:08:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aKmDgwca" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F944206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjK9-0005WB-78 for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:08:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBM-0004hU-9L for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjBK-0000yL-Hr for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691153; 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=aKmDgwca57V7ATeoD19DpJg+f4WGCDpKTTfDsgtJH1ixB//jevVXqn7U8Jc9yehjAoZLcT C6/vuRB+ON6paws6zbgu/UAVIdk/TFAtBX+g699XiJk+IRJoRvTtk5lye5uCDeVJeh2U3Y qR82b6hSyJScBunXMr2vYMl/GvWf+5g= 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-337-SqK6CnflMVWaQxZNDmat4Q-1; Wed, 14 Oct 2020 11:59:12 -0400 X-MC-Unique: SqK6CnflMVWaQxZNDmat4Q-1 Received: by mail-wm1-f70.google.com with SMTP id g71so13134wmg.2 for ; Wed, 14 Oct 2020 08:59:12 -0700 (PDT) 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=tkHfS/3Zs3YHkDIEw1tn82NFNv6OlCDF8gzAo4155PqhY4CXvBu0cwzzzF1ETY2S2X KVUDVkl+AW6mdnDauF0oq0OyXhsmyZAl1YoI/+vU7QNOI5BYCa9yi1/w7eKJfNxlkVZM AiwWmwwQqlFAAgnNcozJvIDJZlAZ1JbbhMTrochM7tYSsD3e6dUTPyD2xLFy6aa79o3o QAzLafgoANmYyJ25092ZX57XMKB5dkPrdaqv8BEOA65elnVowysxj1mRmbG7w4Ujuopb HmqOicCeOCy8hh08RwCKfsp+QP98uhBB+lTmyxkcUc9kg0KBN9mRQiizIyiHNExW5CeL dH5g== X-Gm-Message-State: AOAM533MnQK2xMU7ocUT6JERrP/QucvDkbVQhrB+3A6hXc5bsmAUwgBY 5bzzG+9+ybWKlpWR2AHL7heTRtV7h3iQiaue3VZj24rNyKIML+t55eQxN7rDqxSIS7pEVxc0cvk cl6TZ2RJQ9N7DvXA= X-Received: by 2002:a1c:9e0e:: with SMTP id h14mr141912wme.18.1602691147910; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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". */ cap = 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 = -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 start, size_t len, uint64_t qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu" # 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" From patchwork Wed Oct 14 15:58:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11676C433DF for ; Wed, 14 Oct 2020 16:16:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B1FC214D8 for ; Wed, 14 Oct 2020 16:16:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YhMzEXOM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B1FC214D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjRl-0000JC-Ce for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:16:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBO-0004jp-0L for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjBM-0000z4-Dt for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:17 -0400 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= 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-525-Tw4F_z6dM0S3SYh0EMaTmA-1; Wed, 14 Oct 2020 11:59:14 -0400 X-MC-Unique: Tw4F_z6dM0S3SYh0EMaTmA-1 Received: by mail-wm1-f72.google.com with SMTP id r19so29865wmh.9 for ; Wed, 14 Oct 2020 08:59:13 -0700 (PDT) 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=DoT4JGcEQN9EAD923MbujwTmWvbFRu2I2O5UjWRBDjbRWkkYCT+EhNu0TGbIDR/kBB RjNN8FIimtDAAPBy8q43uIloa+PnU0rPxCC0WQP1NYsmcY+MvLpi63gMoS9W7ZQd5qH6 oOK7hrZSxWDqZCUK6J/WqDkmeyvk4VRjPCkJQSkfU7LkGMUos+Kn4P8yOzbZ0+8DCbih qy9+cdRmQ9Cx8B/NTOHsvb4btwC4AnwyCy9Z1Yp5cV6oWpc434CO/yfyNrjdTSkESRhh LfQ38+ZVSEqxQ4cJif98beMtc3tB2nRe4pO2LyNqcJEwozl0/egN66P9Iw7Itvhq0N80 Y00A== X-Gm-Message-State: AOAM532qDHbBjgk9FVJI2w8S/zyf3mno1GoLkmVPoIZxG/Z+P8H9WUMb jeF/3uo5k9j00DhNQ286BEecv+n1o9RZrU0BseqDQaZME6Zyk4TWiZwwMYly+UDGDjKBGTxILaP /Sz3jxDZqO1E654A= X-Received: by 2002:a5d:558e:: with SMTP id i14mr6742853wrv.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Avoid multiple endianess conversion by using device endianess. Signed-off-by: Philippe Mathieu-Daudé --- 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 = MIN(500 * NVME_CAP_TO(cap), 30000); /* Reset device to get a clean state. */ - regs->cc = cpu_to_le32(le32_to_cpu(regs->cc) & 0xFE); + regs->cc &= const_le32(0xFE); /* Wait for CSTS.RDY = 0. */ deadline = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + timeout_ms * SCALE_MS; while (NVME_CSTS_RDY(le32_to_cpu(regs->csts))) { From patchwork Wed Oct 14 15:58:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30F58C433DF for ; Wed, 14 Oct 2020 16:12:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5EBB820B1F for ; Wed, 14 Oct 2020 16:12:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EgtO1jWP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EBB820B1F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjOb-0004Yl-7b for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:12:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBi-0004oh-9E for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjBZ-00010K-Bf for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:37 -0400 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=YLxkAx2Y6NEXeaia5IYrWdVkNlawKHl6NTNLCcRm+HM=; b=EgtO1jWPAtRgMXw5vmguPte6QxYPRYGzkCQyKBGR/Rcpwav1nxTIoi+w+f7Lu9obRi1Wxa Nq/YJTAhsJ96mn6/k2mBrt2pHEmGef8spL4oO1JNn1VxcBGPkZa2Apv3OPvs38o1RxJEDT E/EBfQXGy5rh03NVmaEUtdZuUlWFN7s= 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-293-nMaUIel9PaKaVK_fUEfICQ-1; Wed, 14 Oct 2020 11:59:24 -0400 X-MC-Unique: nMaUIel9PaKaVK_fUEfICQ-1 Received: by mail-wr1-f69.google.com with SMTP id t3so1560675wrq.2 for ; Wed, 14 Oct 2020 08:59:23 -0700 (PDT) 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=DlxBlwzE+0IelqLjOV33k7mlcI3ANGJXaRl1+7j4kMrEmMN4t5eJ1EPWlq2VmlUtZZ NVvufp7fmxWELK/awgkMlJSYjL4iR7D06eKkuSygaQqU1TW2zp3XjaJMS0lnpLLPa6GH cCa49iDi+VQgJ1XsPETzy70Vkbb550QFYu9jXJ/1bN8E6tVSmY+qGkJHrzJz0zVGFGfn YBDAnzPaGse+scoxAYbfYlwnts15Ls5rXp408jTf+KdYPQJvDQFCbUFgdiblPvtVV9aB u65YdpOCNu4//wKwd42ztcOrJl4BLOKZgsVOqMIePGxjKzxQStpa8E3+kUMDHvVSMjWf jFKg== X-Gm-Message-State: AOAM532pWeIMM6t02CUaWTs3Zm94TOUnpNxloDiwTP8Dh0vhKRQ9oumu ZskxR0tFt7jkbGuN+ZuMY9LPFXSLnE9FdJB0Ecd7SzD8HlaTuLXDlERo1PokMlmRPcT7jvjbSME EDHp6j2nyLh5hNGo= X-Received: by 2002:adf:fc51:: with SMTP id e17mr6110750wrs.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 = bs->opaque; + NVMeQueuePair *q; AioContext *aio_context = 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, /* Set up admin queue. */ s->queues = g_new(NVMeQueuePair *, 1); - s->queues[INDEX_ADMIN] = nvme_create_queue_pair(s, aio_context, 0, + q = nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp); - if (!s->queues[INDEX_ADMIN]) { + if (!q) { ret = -EINVAL; goto out; } + s->queues[INDEX_ADMIN] = q; s->nr_queues = 1; QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000); regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) | (NVME_QUEUE_SIZE << AQA_ASQS_SHIFT)); - regs->asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova); - regs->acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova); + regs->asq = cpu_to_le64(q->sq.iova); + regs->acq = cpu_to_le64(q->cq.iova); /* After setting up all control registers we can enable device now. */ regs->cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << CC_IOCQES_SHIFT) | From patchwork Wed Oct 14 15:58:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 302856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E0F1C433E7 for ; Wed, 14 Oct 2020 16:17:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A221214D8 for ; Wed, 14 Oct 2020 16:17:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Wuv3HiCV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A221214D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjSz-00019S-Ho for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:17:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBk-0004u9-LU for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51388) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjBZ-00010J-BZ for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:40 -0400 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= 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-293-HJ52pVRiOWiu9vPGiQHzaw-1; Wed, 14 Oct 2020 11:59:24 -0400 X-MC-Unique: HJ52pVRiOWiu9vPGiQHzaw-1 Received: by mail-wr1-f69.google.com with SMTP id f11so1537594wro.15 for ; Wed, 14 Oct 2020 08:59:23 -0700 (PDT) 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=Rr/ZB9rmzIjbKAFhqvEdUrkthJaMTRnySBqQoSzYmU0e2yTvKn8S/UaejAzoSBG0Ht MqtFu5pKoguoh6ZMapk08+/fLoCCK5F9UAKx1B/yDDk2xkKb4UOrjDYBbKpgONlC4nHm 2inPNLKrV+IoRIsCIy+9iqY6/oC2UdOnfqu6IRTSDi7KJsCPJQlGyg2aLWjSzCN7ktbV 26Fhqz8KGY+yMr1ixrV/DI/SfYx1esYrDrHm72EX2QASkxS7Q5/JAoNHG0ESROsOtphf ThJTSL/FP4VuadXsg7zMTAexA18TbhG4pOTSLOKexzpFjqcvnPw9eKmNRe4fo3hn7l2n KfLA== X-Gm-Message-State: AOAM5328n7BQNs3f6y6/UbQup9dUb6P/cuDVhlhREKOrs1ZcTMuwYCQX /2yjFtt0snDMG3jKxfmd35sKWtb1IzIgG40UQMBcyn0HLrTHCbB5XcaHUOsrxqdrDBB5yBu1vdB 7vPq7Xdx0aOSVJi0= X-Received: by 2002:a05:600c:2144:: with SMTP id v4mr110680wml.172.1602691162634; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 01:12:43 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instead of displaying warning on stderr, use warn_report() which also displays it on the monitor. Signed-off-by: Philippe Mathieu-Daudé --- 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 = le16_to_cpu(c->cid); if (cid == 0 || cid > NVME_QUEUE_SIZE) { - fprintf(stderr, "Unexpected CID in completion queue: %" PRIu32 "\n", - cid); + warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", " + "queue size: %u", cid, NVME_QUEUE_SIZE); continue; } trace_nvme_complete_command(s, q->index, cid); From patchwork Wed Oct 14 15:58:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 271260 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E18C433E7 for ; Wed, 14 Oct 2020 16:13:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A2AB206F4 for ; Wed, 14 Oct 2020 16:13:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H5iY2+vM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A2AB206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kSjP8-0004op-B7 for qemu-devel@archiver.kernel.org; Wed, 14 Oct 2020 12:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kSjBj-0004rQ-JK for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kSjBe-00010m-1m for qemu-devel@nongnu.org; Wed, 14 Oct 2020 11:59:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602691172; 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=H5iY2+vMz8MdTP9DgrQlFbZkOYhQMCyfUaetbIZoX5Ys46u5lXBggPP1MFUUriyehXPzt6 NLg3x0HJHNYGZu/MJ0DU8k1jqU0uYpa6LWhFjPdTSx8/9FZvhA3iyeRdkiZCsZRGaBoFmZ gXAJCAp5Nexl/qdbs0IHX6OsovrV1WM= 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-154-Np-ec252MMu3jGWljjzqjw-1; Wed, 14 Oct 2020 11:59:31 -0400 X-MC-Unique: Np-ec252MMu3jGWljjzqjw-1 Received: by mail-wm1-f69.google.com with SMTP id c204so5047wmd.5 for ; Wed, 14 Oct 2020 08:59:29 -0700 (PDT) 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=tX902X0pplUbv7flIuNAx8p6Aff87biXWdHe5uD12saHHFuI3+jKzcUyMLHif1iGbw BC/80Z2wtqlxUne/vHv8/qEASS4rdNCh8wcg/Zgjhap4c32uiMkxduY+PRtAHIBMi409 WVb/2PtDS7q/3NUuwMWc1d7CC7K3Aloci085Hw5PY6MZo3/oXAXfkx5q5To/yYNISgKO xIzGcwmjOFnhIKbK467EeroeonHjpVvc2Lb656Zw2O5Ude+N6oRvn1/QO0T5T3gmJ4Ia mUpMxxjqveZ0XfQ0aFwn/BH7lm22aWc9uhFBK3N4HWKgn7vq+Avo0c3HYNHW7ftMX/r4 /7lg== X-Gm-Message-State: AOAM531hSPxx6mu3wmOhg26UpegD9vncEpT+Cl9AixMfwslbL4QgsVP4 S1zjRDVk/sRKBIBsfjc79koYDpen56HhFvLLi4YKh0Dmsj9iwxo05Ai0amNPssd9YqAnnfDPJDe vJjE+5GuIpGeBVkw= X-Received: by 2002:adf:9f4c:: with SMTP id f12mr6361134wrg.108.1602691168524; 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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 Received-SPF: pass client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/14 03:37:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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é --- 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 = MAX(4096, 1 << NVME_CAP_MPSMIN(cap)); s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment = s->page_size; + bs->bl.request_alignment = s->page_size; timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000); /* Reset device to get a clean state. */