From patchwork Sat Jul 4 21:30:37 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: 278545 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=-9.6 required=3.0 tests=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 5C6EBC433DF for ; Sat, 4 Jul 2020 21:32:36 +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 25C0420CC7 for ; Sat, 4 Jul 2020 21:32:36 +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="cmCLO6jA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25C0420CC7 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]:56328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrplz-00041P-Af for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:32:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpkc-0002C1-2u for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:10 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:22065 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrpkZ-0003vt-8z for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898266; 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=HZH4WbM9lDKriwvJR5iWPBD2dYg3ljxsK8g2n7Z4PXs=; b=cmCLO6jAgxk6KRYb757A/FQwZv1ZGn09KfwehwZ7+TUd/B05HXMXbgVia+8uXr0Nhow9iF iNQMSf1j6CE5r0WiUZ+KdP8J4+zvTZ2QxnLK5khQODfIFjGj6nC/FZscpE3KstSl6YTOpj mDUSVrus0AabahKKCnGBp+RWER3SqX0= 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-440-LAQc1gRkMvqWf5U82UhfZw-1; Sat, 04 Jul 2020 17:31:05 -0400 X-MC-Unique: LAQc1gRkMvqWf5U82UhfZw-1 Received: by mail-wm1-f69.google.com with SMTP id c124so8405260wme.0 for ; Sat, 04 Jul 2020 14:31: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=HZH4WbM9lDKriwvJR5iWPBD2dYg3ljxsK8g2n7Z4PXs=; b=JOjlpxQIb7GbWpHTYvnYQ7cQDLI5ieyNiY6MJkA7R2tXcmPG25l6zYdqiFkMVejCxw Fw5vfB81vQSOIi5EmepvJ0bYtOAWSK3ZuA8TX72bT7FSTf7l9AyI5w66Hv8WYR/V9K8O yUnCzkUqr5gAujxU5UMBBNklxkXxZ2WuOATRzxjowrN9eRjH/ewKGzzMzeCvylGQBGjX UtiV1/1h9FXeJ+TXfx093Zlam+IoGBA03PzXlDD4c0LiK4jxCDKD5Gh3RqIVNv+DNcy5 plz4UCQgjAdPxLy7plz2/e3iml2u+Kr9mVkGuuOCv2GZ6s6byteXRmmDEhibp2OqKbig nQVw== X-Gm-Message-State: AOAM531gwVH2U7JWjqGvkjSZ2ewP3fdqMSjgaOvPaC8xc8KrD9t9MQf1 xRDw3lFciIgm8ubgEarhpI2Ly7TqjfwQV8nBxkNGrRgtL6qZ01s5gDJeVXFm1IUKkoQPJK4+zK7 6/2wICCkhys+oXdQ= X-Received: by 2002:a1c:48:: with SMTP id 69mr44147188wma.32.1593898263563; Sat, 04 Jul 2020 14:31:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHvgHTGkWLDjdUq9WKVr7dTdGZagvjrh0bQBolk5vUhPp/bLvBv74WEwQZ1LkINYyrdO4KqA== X-Received: by 2002:a1c:48:: with SMTP id 69mr44147177wma.32.1593898263416; Sat, 04 Jul 2020 14:31:03 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id u15sm19258965wrm.64.2020.07.04.14.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 02/16] block/nvme: Avoid further processing if trace event not enabled Date: Sat, 4 Jul 2020 23:30:37 +0200 Message-Id: <20200704213051.19749-3-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 17:28:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Avoid further processing if TRACE_NVME_SUBMIT_COMMAND_RAW is not enabled. This is an untested intend of performance optimization. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index 2f5e3c2adf..8c30a5fee2 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -441,6 +441,9 @@ static void nvme_trace_command(const NvmeCmd *cmd) { int i; + if (!trace_event_get_state_backends(TRACE_NVME_SUBMIT_COMMAND_RAW)) { + return; + } for (i = 0; i < 8; ++i) { uint8_t *cmdp = (uint8_t *)cmd + i * 8; trace_nvme_submit_command_raw(cmdp[0], cmdp[1], cmdp[2], cmdp[3], From patchwork Sat Jul 4 21:30:40 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: 278542 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=-9.6 required=3.0 tests=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 A875AC433DF for ; Sat, 4 Jul 2020 21:36:08 +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 6FAEA20724 for ; Sat, 4 Jul 2020 21:36: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="aAKvN0GM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6FAEA20724 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]:42610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrppP-0002Vz-Ma for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:36:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40908) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpks-0002Rt-44 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:26 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:31943 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrpkp-00041V-Ct for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898282; 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=GXdIespWFUCgh9geAcuRTrSY8JSFvRPXQ9z+IG0M7kw=; b=aAKvN0GM2dCKd1WyCuPe291FH42EHvNDc1niYrngpY0jShm5xEn8bXXil+9FvkxRuhiwL4 Fh+yNMxVxfLN9UzVwQ05GtyX3YX5LxDBFyE4Dfj3tJl+g9gAqG1sX+Q4w0Pnl+cWjwPs2C WzzxbEdhCzgpZe3MmFD7SlQrQPm93yg= 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-148-QFAXcHzQO7ee_TDDiMgtPA-1; Sat, 04 Jul 2020 17:31:19 -0400 X-MC-Unique: QFAXcHzQO7ee_TDDiMgtPA-1 Received: by mail-wm1-f72.google.com with SMTP id v6so38553207wmg.1 for ; Sat, 04 Jul 2020 14:31: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=GXdIespWFUCgh9geAcuRTrSY8JSFvRPXQ9z+IG0M7kw=; b=eG+l4aPTpBx4EwefHcI3LOiKs8V6rJYBc1glAxLV3nlDekPWBB6Yi1+/8ZzbHYwbqV TC7PqrjY0T3kMjrKSE9Il7O/bud4VsKZTa9GQO68d9i3ZIorB3ckkWkaI+UsgbbQec27 gPw0spd6ODD9tVp+M2o5zG7V+Nno3tY1OHkA0lwdUUwaJeb5/IfaD/BfyxXk0U0ooTd9 2uoFqKXYMgSw4uO5tE0kHNOCcE/frZ6BcMEEDAmRhCp9oOT7rJbak1uiq+a67tlomf1E Pk5VK7lBAVgHEqF3ho+SQXclhQTeSvxdAk69oAxyaKh+DGY6WpHAhRRWnSEys36ZwesY lbIA== X-Gm-Message-State: AOAM530G1g3uYZ1IxVWQHDjqhDYNKBVlQGsITv7VXa3T8B4kc6wU2drG iM5cOTND4ofLM7g5jJRVUTCVSkIfeDnlQHVAcM+gH00XWYz0XgcuN2oncEqpwc8uypao6VH6MeA yp9UwqS1bGPxtHFs= X-Received: by 2002:adf:8067:: with SMTP id 94mr40293986wrk.427.1593898277904; Sat, 04 Jul 2020 14:31:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGnHVNp/PTtr1kaDiCDEDYLt8M9rfZlwbZcIBV+HFX/50zKAm8JENrHozbThl8RynU198Mcw== X-Received: by 2002:adf:8067:: with SMTP id 94mr40293975wrk.427.1593898277774; Sat, 04 Jul 2020 14:31:17 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id w13sm17780609wrr.67.2020.07.04.14.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 05/16] block/nvme: Improve error message when IO queue creation failed Date: Sat, 4 Jul 2020 23:30:40 +0200 Message-Id: <20200704213051.19749-6-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 17:28:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Do not use the same error message for different failures. Display a different error whether it is the CQ or the SQ. 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 28762d7ee8..5898a2eab9 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -648,7 +648,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw11 = cpu_to_le32(0x3), }; if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { - error_setg(errp, "Failed to create io queue [%d]", n); + error_setg(errp, "Failed to create CQ io queue [%d]", n); nvme_free_queue_pair(q); return false; } @@ -659,7 +659,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[QUEUE_INDEX_ADMIN], &cmd)) { - error_setg(errp, "Failed to create io queue [%d]", n); + error_setg(errp, "Failed to create SQ io queue [%d]", n); nvme_free_queue_pair(q); return false; } From patchwork Sat Jul 4 21:30:41 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: 278541 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=-9.6 required=3.0 tests=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 02A3DC433E0 for ; Sat, 4 Jul 2020 21:37: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 BEF7520724 for ; Sat, 4 Jul 2020 21:37: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="ddZa1q92" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEF7520724 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]:46620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpqH-0004b6-Vt for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:37:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpkt-0002Ss-Pv for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:28 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:29984 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrpks-00041u-BO for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898285; 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=ob08smN6ZI4g8NRDF6m5BXTc3kBCbtPED0vqHga8qI4=; b=ddZa1q92yv8xAU+4Q8ywTGL+VNQ6Xohw57FJkPcnt0o78xIPYBOrCS7pUYx8x3Q7FS9/7n qEfCzGzeUM9boBgG/7/3ui9MPSvpltz5ZUMzop3C+nCtNnqEXuUMAFepA1JGGvM908UccW GxuTPIC8N998tVOs2r8idHEiykAH9ak= 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-477-A_dqm35kOYq-NhZsHV3UVg-1; Sat, 04 Jul 2020 17:31:24 -0400 X-MC-Unique: A_dqm35kOYq-NhZsHV3UVg-1 Received: by mail-wr1-f69.google.com with SMTP id i14so36770482wru.17 for ; Sat, 04 Jul 2020 14:31: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=ob08smN6ZI4g8NRDF6m5BXTc3kBCbtPED0vqHga8qI4=; b=ehymDbht1HakxtZqzVUBLji+GxF6JA99MI1XpLumhZEjWd82yDF4zCTgg2B9jeaflb PSw5TRg2vfkOBDVG+TxhpQ1sbyhT/TEpDQa0SMWD2gIc2PKCeqCGqwGAGWqR/o6mRRUJ AD73o4gyW1Z3ZkBdoRec3+hL/v9nT3S9Q+T6O2moRSFArCUv+sGsU4a2aiekXW053LP8 0drCLIyYtMpIvpfHbham1r1aFPkxueWZhhBFKuTiFRwIrgw3SMRfk6HmvIHnNFENgD0U d7wmGMaLLkDYE0lMr2KucBe9gyIUUSyK5bd7DL6FBljbi5aWdA/cPGdRvRHTRV/O+vVD C/gg== X-Gm-Message-State: AOAM531j+Ehq3EXdFTERY4hqdeQskFSjS6K12RSQ+WwKrzFw3BPfK+bw F65zERowsBEfe5UTOGXfamgADWMAH/5ztSI71j4Rs0+5sEEfuOiClwk+rblRPRXDRLldzPyhxvO bsUxB8Bn7E7/+SpQ= X-Received: by 2002:a1c:bb03:: with SMTP id l3mr3489137wmf.24.1593898282742; Sat, 04 Jul 2020 14:31:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl4HZ2txqGViex8mKQYu2TxvYxlPMKyqf1QmlkIm0hWfj/7F37fIVVT9nHKtxTMtk7davrcg== X-Received: by 2002:a1c:bb03:: with SMTP id l3mr3489123wmf.24.1593898282541; Sat, 04 Jul 2020 14:31:22 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 22sm18442029wmb.11.2020.07.04.14.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 06/16] block/nvme: Use common error path in nvme_add_io_queue() Date: Sat, 4 Jul 2020 23:30:41 +0200 Message-Id: <20200704213051.19749-7-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Rearrange nvme_add_io_queue() by using a common error path. This will be proven useful in few commits where we add IRQ notification to the IO queues. 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 5898a2eab9..7bec52ca35 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -649,8 +649,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) }; if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create CQ io queue [%d]", n); - nvme_free_queue_pair(q); - return false; + goto out_error; } cmd = (NvmeCmd) { .opcode = NVME_ADM_CMD_CREATE_SQ, @@ -660,13 +659,15 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) }; if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create SQ io queue [%d]", n); - nvme_free_queue_pair(q); - return false; + goto out_error; } s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1); s->queues[n] = q; s->nr_queues++; return true; +out_error: + nvme_free_queue_pair(q); + return false; } static bool nvme_poll_cb(void *opaque) From patchwork Sat Jul 4 21:30:43 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: 278543 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=-9.6 required=3.0 tests=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 EAE37C433E0 for ; Sat, 4 Jul 2020 21:35:07 +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 B27BF20CC7 for ; Sat, 4 Jul 2020 21:35:07 +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="YGUrMYwL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B27BF20CC7 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]:39222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpoQ-0000jV-Vd for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:35:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpl3-0002kY-SR for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:37 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:28452 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrpl2-00043G-1u for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898295; 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=7qf4SB5pxS18EQoWD8ox8JEyWFcG4DNexsgvb6j1d6o=; b=YGUrMYwLLEqPW70SY7lXcvYrQugF9Lijh+uj8n6zGMdxTKX0A/T3ynUmSoyDFLSPXDIC4x emsgOHi/I2eebfziaA1sqP5+OGUpGKFwxUYKLEj4ljDUlq+WWE/IyZqzXsn3MB0YTRZzFF 0Gkpf7Izhra5JL6huUHVJPRTO3y84zQ= 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-235-MqgWfbKWMz20BYJWrCFkdA-1; Sat, 04 Jul 2020 17:31:33 -0400 X-MC-Unique: MqgWfbKWMz20BYJWrCFkdA-1 Received: by mail-wm1-f69.google.com with SMTP id q20so30916559wme.3 for ; Sat, 04 Jul 2020 14:31:33 -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=7qf4SB5pxS18EQoWD8ox8JEyWFcG4DNexsgvb6j1d6o=; b=s2Dz+8+DUcPECo15Z7jVJqR/J8FCMsXQrpL4zDEps/9kuBDx/qzVjtqaGrvpciW2fn LNJnOA0gs4mJgfvabBI2ueoinqIcLWH142Ty7CvDhdHlpZUaQC6y0ypTGvZRGyA0NjTB QF6xVd8gNeYImIufVGzMIQkxhF6g1ZfdK4WJpmVKVMhRJxUEv27FeTZ6L7uBlaqIFdKK 5Pi3yoQ1BqDUCEPDL/GJTDivu9pSqbg215BNe7/6tTVeG/HpSDK4VgiZYmngVmIgyp+L 9uucq7FqOB6UZhW0D5DeI+Qsr+BkQcGDD7L/OkvF903R+v3TYaDVf2sAu6sBtPGM7OlR 8s7g== X-Gm-Message-State: AOAM5314B+8X0Z8MK8FBQu68m2yBaJC/GgPEuIXoygp1JKXZFunr7niZ MAWvovqCG02lGL79GiQw0OE0W9TlYAvrrJpvDmrisBfI5/GjwsKEdc35yla3ebt7nKOJ5D5CeSX cAN5UndO/1oaM9/c= X-Received: by 2002:a5d:5084:: with SMTP id a4mr43626174wrt.191.1593898292529; Sat, 04 Jul 2020 14:31:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWZ6cqaet+xGZT+rxDEj0LCHULPaKuxp+RUf2wP9dTq3+Unvrxr1hYE96/HwxCw6wdhE6XaA== X-Received: by 2002:a5d:5084:: with SMTP id a4mr43626159wrt.191.1593898292306; Sat, 04 Jul 2020 14:31:32 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id w17sm19531102wra.42.2020.07.04.14.31.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 08/16] block/nvme: Use union of NvmeIdCtrl / NvmeIdNs structures Date: Sat, 4 Jul 2020 23:30:43 +0200 Message-Id: <20200704213051.19749-9-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We allocate an unique chunk of memory then use it for two different structures. By using an union, we make it clear the data is overlapping (and we can remove the casts). Suggested-by: Stefan Hajnoczi Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 0e4e5ff107..a611fdd71e 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -508,9 +508,10 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; - NvmeIdCtrl *idctrl; - NvmeIdNs *idns; - uint8_t *id; + union { + NvmeIdCtrl ctrl; + NvmeIdNs ns; + } *id; NvmeLBAF *lbaf; uint16_t oncs; int r; @@ -520,14 +521,12 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) .cdw10 = cpu_to_le32(0x1), }; - id = qemu_try_blockalign0(bs, sizeof(NvmeIdCtrl)); + id = qemu_try_blockalign0(bs, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - idctrl = (NvmeIdCtrl *)id; - idns = (NvmeIdNs *)id; - r = qemu_vfio_dma_map(s->vfio, id, sizeof(NvmeIdCtrl), true, &iova); + r = qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova); if (r) { error_setg(errp, "Cannot map buffer for DMA"); goto out; @@ -539,22 +538,22 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) goto out; } - if (le32_to_cpu(idctrl->nn) < namespace) { + if (le32_to_cpu(id->ctrl.nn) < namespace) { error_setg(errp, "Invalid namespace"); goto out; } - s->write_cache_supported = le32_to_cpu(idctrl->vwc) & 0x1; - s->max_transfer = (idctrl->mdts ? 1 << idctrl->mdts : 0) * s->page_size; + s->write_cache_supported = le32_to_cpu(id->ctrl.vwc) & 0x1; + s->max_transfer = (id->ctrl.mdts ? 1 << id->ctrl.mdts : 0) * s->page_size; /* For now the page list buffer per command is one page, to hold at most * s->page_size / sizeof(uint64_t) entries. */ s->max_transfer = MIN_NON_ZERO(s->max_transfer, s->page_size / sizeof(uint64_t) * s->page_size); - oncs = le16_to_cpu(idctrl->oncs); + oncs = le16_to_cpu(id->ctrl.oncs); s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROS); s->supports_discard = !!(oncs & NVME_ONCS_DSM); - memset(id, 0, 4096); + memset(id, 0, sizeof(*id)); cmd.cdw10 = 0; cmd.nsid = cpu_to_le32(namespace); if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { @@ -562,11 +561,11 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) goto out; } - s->nsze = le64_to_cpu(idns->nsze); - lbaf = &idns->lbaf[NVME_ID_NS_FLBAS_INDEX(idns->flbas)]; + s->nsze = le64_to_cpu(id->ns.nsze); + lbaf = &id->ns.lbaf[NVME_ID_NS_FLBAS_INDEX(id->ns.flbas)]; - if (NVME_ID_NS_DLFEAT_WRITE_ZEROES(idns->dlfeat) && - NVME_ID_NS_DLFEAT_READ_BEHAVIOR(idns->dlfeat) == + if (NVME_ID_NS_DLFEAT_WRITE_ZEROES(id->ns.dlfeat) && + NVME_ID_NS_DLFEAT_READ_BEHAVIOR(id->ns.dlfeat) == NVME_ID_NS_DLFEAT_READ_BEHAVIOR_ZEROES) { bs->supported_write_flags |= BDRV_REQ_MAY_UNMAP; } From patchwork Sat Jul 4 21:30:46 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: 278540 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=-9.6 required=3.0 tests=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 BDE76C433DF for ; Sat, 4 Jul 2020 21:38:36 +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 8614720724 for ; Sat, 4 Jul 2020 21:38:36 +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="AcyF/swf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8614720724 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]:52046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrprn-0007Od-Qk for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:38:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrplH-0003Iy-Jl for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:51 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:40870 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrplG-00045z-3v for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898309; 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=KMa3yNwCNdnEQnAOsKRyk2u/lQpm0dom4ME9xGYTEfY=; b=AcyF/swf3B8F0rKXxgX+8/ltHAvuXxg+4djbW/azgzBw6Tol6M4FQwJ6lK2Luh8PKSnl4i aGVak0Qmt9tLdeIn3YEOCRrOZ312C+zBY+3IAWaBQzqS0kWZiwqIt0x9U3QJ2+ULWWTuiv eM1P2QBaqsKjchL3b4yUDH0gaHc4Y6A= 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-318-PXmjHMfnPO6KtDB4AFy2NA-1; Sat, 04 Jul 2020 17:31:48 -0400 X-MC-Unique: PXmjHMfnPO6KtDB4AFy2NA-1 Received: by mail-wr1-f71.google.com with SMTP id y13so36932363wrp.13 for ; Sat, 04 Jul 2020 14:31:47 -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=KMa3yNwCNdnEQnAOsKRyk2u/lQpm0dom4ME9xGYTEfY=; b=GeJTK+VflWhzCn13lMKAfaRgCJ3NYwGmLXvuRcPPsFO4zx1XL6rfDvhW11iFG3FxFK K18GXygJI6+2h4HG0zSqUpiovHENuiBk+dTHQUAurdNCOI3FmIzsBFB+JsqjtyQ9GkEa tLYe0GHa+5HGxcjt9L5/ljSPmoDRhoL/7SdHwolYwha+5zAPwKE5zkXtf9vk181OaByj xLIqm6d1r0wGQeCSJl0wZ+6P7qg/6In4A7eFaDx3MRFuGp7xLQYhN4p1WsZ35iiAM+9u enQsZTl7hpX+tM2232PSWq2mIcYQEnRt5vW7mSt/MZEDGAmN1FP+UHZcOawafa7TO5XF DcVQ== X-Gm-Message-State: AOAM533V5wMnaERhpxv9zpE12mzIyOCPVuTbWlCnn5erLyqJhx+wqFxt HQIcI4GpNrXBTEdtq5Yu/QQeH5Mk/YLvVPa6wsAcPbsYQfod2DwJJNA1eU4eoyaOsxtiW17LODR SavSWlKGXSA9nmqE= X-Received: by 2002:a1c:7706:: with SMTP id t6mr1700052wmi.3.1593898306661; Sat, 04 Jul 2020 14:31:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy4n66+oUCV6z6QscLxmjAXBlqtT6LIwTglcpd2ABRnavWmNcU7UAPcpaRzgRlikFbz2CT+g== X-Received: by 2002:a1c:7706:: with SMTP id t6mr1700040wmi.3.1593898306517; Sat, 04 Jul 2020 14:31:46 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id h84sm18654307wme.22.2020.07.04.14.31.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 11/16] block/nvme: Simplify nvme_init_queue() arguments Date: Sat, 4 Jul 2020 23:30:46 +0200 Message-Id: <20200704213051.19749-12-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 17:28:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" nvme_init_queue() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState to simplify. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 9566001ba6..97a63be9d8 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -165,10 +165,9 @@ static QemuOptsList runtime_opts = { }, }; -static void nvme_init_queue(BlockDriverState *bs, NVMeQueue *q, +static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, int nentries, int entry_bytes, Error **errp) { - BDRVNVMeState *s = bs->opaque; size_t bytes; int r; @@ -251,14 +250,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, req->prp_list_iova = prp_list_iova + i * s->page_size; } - nvme_init_queue(bs, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); + nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; } q->sq.doorbell = &s->regs->doorbells[idx * 2 * s->doorbell_scale]; - nvme_init_queue(bs, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); + nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; From patchwork Sat Jul 4 21:30:47 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: 278539 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=-9.6 required=3.0 tests=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 E7884C433DF for ; Sat, 4 Jul 2020 21:40:46 +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 B374021D94 for ; Sat, 4 Jul 2020 21:40:46 +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="JfYwEaet" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B374021D94 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]:57044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrptu-0001YP-0v for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:40:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrplM-0003V4-OO for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:56 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:20562 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrplK-00046K-QI for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898314; 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=fjFAluXrQqAea6BsNgoNTAhItzpMDbo69v4ixXnRHEQ=; b=JfYwEaetH3XIhqFXKCm4CEhz2A/l778Rtye6VaGqubwY4T+IpZSm0337O+P0a7+OR6uVL/ sN9fA9wJXYhno7MPHBmdStdelf/TcBg+wFr66V/PqG7SYgWMAUIhM14VwbIJceVDFNxRap uLadSd9Z0XFtyvaY68GdNpQlHW5IOfc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-347-8pt5tpVTPsWRYZiJbO_FgA-1; Sat, 04 Jul 2020 17:31:52 -0400 X-MC-Unique: 8pt5tpVTPsWRYZiJbO_FgA-1 Received: by mail-wm1-f71.google.com with SMTP id q20so30917390wme.3 for ; Sat, 04 Jul 2020 14:31:52 -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=fjFAluXrQqAea6BsNgoNTAhItzpMDbo69v4ixXnRHEQ=; b=JzwCDA/PREiOg6gHL54aoWEBgY6WkIt4mLWPfDwdpIhC1eT1qNoa+XgQWGEptVgBkn caBtAwW/PhdPK9IEOUteJxrQt2c8bcOlgxhN5gtK071FfKg0yNZnhWn87YVWeiWxTzMV YDdpp61eEaVm7JlS4D3TUdoSFelAXrrA0+Q2rvbu89PGXI6Phg7FcCkWa0j0PVoKcqhz 23ESA3mTfwa+UXY0TMddW32JyRwfHMpnQ3wqoH6oZ5zw/AxiEhbCQC2FQolSXku4eu9V 2bPf7UxTH0mA4Cd6SyKF8u8BMWGvisGedK2wkbZnaFY1+9g/AVYv4smuZdPa26lSkllT Av2Q== X-Gm-Message-State: AOAM533kf4/yjFYvhGM8XyEYNNyGY0Tjod0eQYJ7vLZCBo1Dp82RPITo BImtVVuvM4JAOMtcz2wrJlpX2ZL3YSTCKRtwYPLhXWlZVirASY71ARX7kIy1VWv0C9u90pSrO56 Rx0edVFkbUKWCPoA= X-Received: by 2002:adf:e4d0:: with SMTP id v16mr42249671wrm.193.1593898311362; Sat, 04 Jul 2020 14:31:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvWqZHzCKVvifJ1cJkVaeiIH7gEBjXxL1cg/jMobS3d3kg7cql7XpyTdnxGwx42AD3CRsy7w== X-Received: by 2002:adf:e4d0:: with SMTP id v16mr42249660wrm.193.1593898311167; Sat, 04 Jul 2020 14:31:51 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id p17sm16980699wma.47.2020.07.04.14.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 12/16] block/nvme: Replace BDRV_POLL_WHILE by AIO_WAIT_WHILE Date: Sat, 4 Jul 2020 23:30:47 +0200 Message-Id: <20200704213051.19749-13-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=207.211.31.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 17:30:56 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" BDRV_POLL_WHILE() is defined as: #define BDRV_POLL_WHILE(bs, cond) ({ \ BlockDriverState *bs_ = (bs); \ AIO_WAIT_WHILE(bdrv_get_aio_context(bs_), \ cond); }) As we will remove the BlockDriverState use in the next commit, start by using the exploded version of BDRV_POLL_WHILE(). Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 97a63be9d8..b2fc3c300a 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -493,6 +493,7 @@ static void nvme_cmd_sync_cb(void *opaque, int ret) static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, NvmeCmd *cmd) { + AioContext *aio_context = bdrv_get_aio_context(bs); NVMeRequest *req; int ret = -EINPROGRESS; req = nvme_get_free_req(q); @@ -501,7 +502,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, } nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); - BDRV_POLL_WHILE(bs, ret == -EINPROGRESS); + AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); return ret; } From patchwork Sat Jul 4 21:30:49 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: 278538 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=-9.6 required=3.0 tests=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 8F74FC433E0 for ; Sat, 4 Jul 2020 21:42:26 +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 5611A2184D for ; Sat, 4 Jul 2020 21:42:26 +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="W0HZS9nK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5611A2184D 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]:33750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpvV-0003ZO-M8 for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:42:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrplW-0003n8-QU for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:32:07 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:35010 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrplU-00048k-FL for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:32:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898323; 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=xumHQmie22PgCKek0cikqjiB9L+Aua1bZGi1TBEXwDY=; b=W0HZS9nKw//NDadOhbLbOPsiAi9HCESy/hvwjFKHdQFo02BTZdw/SszDZwIO43VuCemaMG c7nlneCaXIl3jwN46sKpxOHAVwi/+5cWOZfbsNJ/NQG4HawxHUu1yYlbKG+bmQzC9WEJCN SpeEgXlBSiONyt3FVGqq8w9fzOxCq+U= 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-6-x4s2x__rMJaiduv2p7hwxQ-1; Sat, 04 Jul 2020 17:32:02 -0400 X-MC-Unique: x4s2x__rMJaiduv2p7hwxQ-1 Received: by mail-wr1-f71.google.com with SMTP id i14so36772298wru.17 for ; Sat, 04 Jul 2020 14:32:02 -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=xumHQmie22PgCKek0cikqjiB9L+Aua1bZGi1TBEXwDY=; b=bAGh7HnlAFn3lQkiCWfvyoMp9r1kAIqnMyH5KZ52a4bs2daL6UXsmx0QIhNrGaUxIJ cNToiXeltJZ7+pgjFNfcFBf0Fjgla6+fclhu0W/73tAXa0fYBxQZmPVPKaNea+I8Jc8N XhXwOxYL0vjzgUurJBLe/lPuQsGusMMhTAorJ0AkhNxGr0siOh/HHb+6HWx1bMx/N68q Lvpeg/YsMb9H93h5CIxUxo39GhirDkty96Z/af0to7QiR3b0FyirF/GFHpwKc+89xEYz QoT13PF5xvtZdHLzWN441fzXLT0RAz6hlpe4ZJS226uPKJ3OnLIwi77vqYAhnI56Ply7 ANqA== X-Gm-Message-State: AOAM531c71dvJWe6HMm9M5td23gM/R563U30pNz+wYcXrSKzlMgXM1ey 3ozPBre3rqe7mHrPiouW0vkeDcmu6QoUhPCdTKWyCI6zrt+favQauBNsVPRW84F4ePGCOfYfqnC OOlEA51x26HO74kE= X-Received: by 2002:a1c:bb03:: with SMTP id l3mr3490456wmf.24.1593898320850; Sat, 04 Jul 2020 14:32:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIy31XjAsBCygF2UiTow0NHzpb0WF2Sggq9OgMLZpL353dfgIwqImG6oj2PaQfz81zEsHWeg== X-Received: by 2002:a1c:bb03:: with SMTP id l3mr3490446wmf.24.1593898320690; Sat, 04 Jul 2020 14:32:00 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id l190sm17325089wml.12.2020.07.04.14.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:32:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 14/16] block/nvme: Extract nvme_poll_queue() Date: Sat, 4 Jul 2020 23:30:49 +0200 Message-Id: <20200704213051.19749-15-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 17:28:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?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 do per-queue polling, extract the nvme_poll_queue() method which operates on a single queue. Signed-off-by: Philippe Mathieu-Daudé --- Stefan better double check here! --- block/nvme.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 51ac36dc4f..a6ff660ad2 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -590,31 +590,41 @@ out: qemu_vfree(id); } +static bool nvme_poll_queue(NVMeQueuePair *q) +{ + bool progress = false; + + const size_t cqe_offset = q->cq.head * NVME_CQ_ENTRY_BYTES; + NvmeCqe *cqe = (NvmeCqe *)&q->cq.queue[cqe_offset]; + + /* + * Do an early check for completions. q->lock isn't needed because + * nvme_process_completion() only runs in the event loop thread and + * cannot race with itself. + */ + if ((le16_to_cpu(cqe->status) & 0x1) == q->cq_phase) { + return false; + } + + qemu_mutex_lock(&q->lock); + while (nvme_process_completion(q)) { + /* Keep polling */ + progress = true; + } + qemu_mutex_unlock(&q->lock); + + return progress; +} + static bool nvme_poll_queues(BDRVNVMeState *s) { bool progress = false; int i; for (i = 0; i < s->nr_queues; i++) { - NVMeQueuePair *q = s->queues[i]; - const size_t cqe_offset = q->cq.head * NVME_CQ_ENTRY_BYTES; - NvmeCqe *cqe = (NvmeCqe *)&q->cq.queue[cqe_offset]; - - /* - * Do an early check for completions. q->lock isn't needed because - * nvme_process_completion() only runs in the event loop thread and - * cannot race with itself. - */ - if ((le16_to_cpu(cqe->status) & 0x1) == q->cq_phase) { - continue; - } - - qemu_mutex_lock(&q->lock); - while (nvme_process_completion(q)) { - /* Keep polling */ + if (nvme_poll_queue(s->queues[i])) { progress = true; } - qemu_mutex_unlock(&q->lock); } return progress; } From patchwork Sat Jul 4 21:30:50 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: 278537 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=-9.6 required=3.0 tests=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 9EEBBC433E0 for ; Sat, 4 Jul 2020 21:43:33 +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 63B9D2184D for ; Sat, 4 Jul 2020 21:43:33 +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="RYIWe4FJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 63B9D2184D 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]:37710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpwa-0005Ep-N2 for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:43:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrple-0003rg-FK for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:32:15 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:36463 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrpla-0004A5-89 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:32:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898328; 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=cnx5O7cQ73298hs0R7q+tCG4DHfssKmnNLY31qyZKnA=; b=RYIWe4FJnSPyNgb5ySDZQ+dYoYIyOoztlrL2oozXsG2JFhX/KeBEz5sFIpz+4dDqgAAzhn HNoXmFWQtrOfhEeNyM0b59yBpIPKr7PjerYQUDvV8XGilhTm4hHLgl1qn04YclzmrK49+D xh94ggFw7/BRtrqAW70432mqtr8wvGY= 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-213-42Sd_LZBMEiWoowMKcS_xQ-1; Sat, 04 Jul 2020 17:32:06 -0400 X-MC-Unique: 42Sd_LZBMEiWoowMKcS_xQ-1 Received: by mail-wm1-f70.google.com with SMTP id g187so40758270wme.0 for ; Sat, 04 Jul 2020 14:32:06 -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=cnx5O7cQ73298hs0R7q+tCG4DHfssKmnNLY31qyZKnA=; b=SQO2Bd0TEU7rwa5VYKl0y4z0w8e/OlEEGpwBto5bBWev60Tq47aio7H7kj9lFSYzP+ bj9Z/LJj72sj+wQC+K1QD6NEsbom8U3nymsWCKnLj8tirXl5tv3486CPPT2lH5VXYRLr oCooazVANDtP/vfKniv//FBswCWp+qA0cxolYM1O3opILvUvk9tSYMOKYn6tz5GKk2cK MsEh9YMZAhO5pCO0foZceJ/WheJYTiCtbLCCXFEJTXLoFlJ+Bx9u5xvNSMOpsYmT9SVB fMmIUWd2Il1h4/dEL3xbzLf1U5TITfGjoCADVvPWWlmCccDs9Pn3DqhmGsZBvxB9Pc/e bIYg== X-Gm-Message-State: AOAM532bFNapLU1r1hQIjjVTy767Yr+/1ASz607BTUUHRER4NBJha0Pj S2uKNdJUHNmUN3liJuhLtvzMpx6QBnPKmnx8HS6B54zP3BZW8t2+2L7t6FuJqoXYuNMeEM9+Dq9 0/RC4Y+aX+9rymRw= X-Received: by 2002:a7b:c210:: with SMTP id x16mr18515164wmi.178.1593898325525; Sat, 04 Jul 2020 14:32:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDywWeVhKAT9NqaNBQfOcgdd9QVPM1mgFtCiChV4xTMCMRRt5vEK1/7to6mYAErkkGKwqMMQ== X-Received: by 2002:a7b:c210:: with SMTP id x16mr18515153wmi.178.1593898325366; Sat, 04 Jul 2020 14:32:05 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id j4sm13607933wrp.51.2020.07.04.14.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:32:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 15/16] block/nvme: Move nvme_poll_cb() earlier Date: Sat, 4 Jul 2020 23:30:50 +0200 Message-Id: <20200704213051.19749-16-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 08:57:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?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 the next commit. To avoid forward-declaring it, move it before. No logical change. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index a6ff660ad2..42c0d5284f 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -638,6 +638,15 @@ 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); + + trace_nvme_poll_cb(s); + return nvme_poll_queues(s); +} + static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) { BDRVNVMeState *s = bs->opaque; @@ -680,15 +689,6 @@ out_error: return false; } -static bool nvme_poll_cb(void *opaque) -{ - EventNotifier *e = opaque; - BDRVNVMeState *s = container_of(e, BDRVNVMeState, irq_notifier); - - 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 Sat Jul 4 21:30:51 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: 278544 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=-9.6 required=3.0 tests=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 95BECC433E0 for ; Sat, 4 Jul 2020 21:33:41 +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 4DD3F20CC7 for ; Sat, 4 Jul 2020 21:33:41 +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="Q4rYskHD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DD3F20CC7 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]:32944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpn2-0006Ga-IM for qemu-devel@archiver.kernel.org; Sat, 04 Jul 2020 17:33:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpli-0003uR-1w for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:32:18 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:44805 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrplf-0004EL-9Z for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:32:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898334; 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=ZvMbUnGJQt3yoRlltFf6Mt/5GWmmjKBAstpoETHPIqo=; b=Q4rYskHDN9Sbxu7xmNQzQhvEukeTTIoSQkXhHtiNOX9U+BpkOKCdRkDvKyI7Itd4L0FWOe NgpiXPMYu6UZ9qLXzY5TuHsdRQyKg+QT/Ylcs+STU4wlxxynEKZ5d2JnAfgZ8CUF7hBkC9 lhSVx3c/DlkrYVEgh2S5lLc5eGCvrCI= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-ztPYlj5NMGiYjNzwbqv1CQ-1; Sat, 04 Jul 2020 17:32:11 -0400 X-MC-Unique: ztPYlj5NMGiYjNzwbqv1CQ-1 Received: by mail-wm1-f71.google.com with SMTP id h25so23696569wmb.0 for ; Sat, 04 Jul 2020 14:32:11 -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=ZvMbUnGJQt3yoRlltFf6Mt/5GWmmjKBAstpoETHPIqo=; b=QrkTpXVqvBcN3qcyTFFFNXBUCA3h84DYzSL6RmnVpPR0xqS1WP74Pvgr5L7zD/MJyH uP4pgLLlxXgWj72ocbBN9innmleqgoQtxnhLxCSHstH+W//HgROWxQQwq7ENmHdLkVha n85lod7TKphzRJ2joTM4uW3jbS+snrRIy4HtKDEsW0XzeQcalHAqf136R61/k8ZnC81t eA0yNjm25wdCScyAFB7wzuAN5qY9Pea48jTmPkq9lm9ODxJAT9JCjxKY13OLKGJ6Fyue WR/7cf8iL5AwX6FQPzVN32wx2E5BXcigYXH3gPyPX36mRbjseAJ8g8xOAlSSjnNrfOBC s43A== X-Gm-Message-State: AOAM533OtcBMHPTKP5CsDM1q/KlaLR4MQojRt7hOlxrGZG5z4/uB+Iae Al9m8sjy35WPd625jX9QdPcy4FKrMKEsMbg/yqoLVW+quAUlrIpkW+kV3ukhxpEFFwqGxnAQeC3 Z9rzLLRFeAiRb6HQ= X-Received: by 2002:a5d:55cf:: with SMTP id i15mr45943913wrw.204.1593898330320; Sat, 04 Jul 2020 14:32:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmfOos5AcAD4AVipgWUBldTMoGPydw+5QMhjoFwpX9lrNRjRcyIX9DpmkRr9mhboMXQoiXlw== X-Received: by 2002:a5d:55cf:: with SMTP id i15mr45943895wrw.204.1593898329994; Sat, 04 Jul 2020 14:32:09 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id c25sm5781528wml.18.2020.07.04.14.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:32:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 16/16] block/nvme: Use per-queuepair IRQ notifier and AIO context Date: Sat, 4 Jul 2020 23:30:51 +0200 Message-Id: <20200704213051.19749-17-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200704213051.19749-1-philmd@redhat.com> References: <20200704213051.19749-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=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/04 17:28:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Maxim Levitsky , Max Reitz , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To be able to use multiple queues on the same hardware, we need to have each queuepair able to receive IRQ notifications in the correct AIO context. The AIO context and the notification handler have to be proper to each queue, not to the block driver. Move aio_context and irq_notifier from BDRVNVMeState to NVMeQueuePair. Before this patch, only the admin queuepair had an EventNotifier and was checking all queues when notified by IRQ. After this patch, each queuepair (admin or io) is hooked with its own IRQ notifier up to VFIO. AioContexts must be identical across all queuepairs and BlockDriverStates. Although they all have their own AioContext pointer there is no true support for different AioContexts yet. (For example, nvme_cmd_sync() is called with a bs argument but AIO_WAIT_WHILE(q->aio_context, ...) uses the queuepair aio_context so the assumption is that they match.) Signed-off-by: Philippe Mathieu-Daudé --- v3: - Add notifier to IO queuepairs - Reword with Stefan help I'd like to split this into smaller changes, but I'm not sure if it is possible... Maybe move EventNotifier first (keeping aio_context shared), then move AioContext per queuepair? --- block/nvme.c | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 42c0d5284f..fcf8d93fb2 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -60,6 +60,8 @@ typedef struct { typedef struct { QemuMutex lock; + AioContext *aio_context; + EventNotifier irq_notifier; /* Read from I/O code path, initialized under BQL */ BDRVNVMeState *s; @@ -107,7 +109,6 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != 0x1000); #define QUEUE_INDEX_IO(n) (1 + n) struct BDRVNVMeState { - AioContext *aio_context; QEMUVFIOState *vfio; NVMeRegs *regs; /* The submission/completion queue pairs. @@ -120,7 +121,6 @@ struct BDRVNVMeState { /* How many uint32_t elements does each doorbell entry take. */ size_t doorbell_scale; bool write_cache_supported; - EventNotifier irq_notifier; uint64_t nsze; /* Namespace size reported by identify command */ int nsid; /* The namespace id to read/write data. */ @@ -227,11 +227,17 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, if (!q->prp_list_pages) { goto fail; } + r = event_notifier_init(&q->irq_notifier, 0); + if (r) { + error_setg(errp, "Failed to init event notifier"); + goto fail; + } memset(q->prp_list_pages, 0, s->page_size * NVME_QUEUE_SIZE); qemu_mutex_init(&q->lock); q->s = s; q->index = idx; qemu_co_queue_init(&q->free_req_queue); + q->aio_context = aio_context; q->completion_bh = aio_bh_new(aio_context, nvme_process_completion_bh, q); r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, s->page_size * NVME_NUM_REQS, @@ -325,7 +331,7 @@ static void nvme_put_free_req_locked(NVMeQueuePair *q, NVMeRequest *req) static void nvme_wake_free_req_locked(NVMeQueuePair *q) { if (!qemu_co_queue_empty(&q->free_req_queue)) { - replay_bh_schedule_oneshot_event(q->s->aio_context, + replay_bh_schedule_oneshot_event(q->aio_context, nvme_free_req_queue_cb, q); } } @@ -492,7 +498,6 @@ static void nvme_cmd_sync_cb(void *opaque, int ret) static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, NvmeCmd *cmd) { - AioContext *aio_context = bdrv_get_aio_context(bs); NVMeRequest *req; int ret = -EINPROGRESS; req = nvme_get_free_req(q); @@ -501,7 +506,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, } nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); - AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); + AIO_WAIT_WHILE(q->aio_context, ret == -EINPROGRESS); return ret; } @@ -616,47 +621,35 @@ static bool nvme_poll_queue(NVMeQueuePair *q) return progress; } -static bool nvme_poll_queues(BDRVNVMeState *s) -{ - bool progress = false; - int i; - - for (i = 0; i < s->nr_queues; i++) { - if (nvme_poll_queue(s->queues[i])) { - progress = true; - } - } - return progress; -} - static void nvme_handle_event(EventNotifier *n) { - BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier); + NVMeQueuePair *q = container_of(n, NVMeQueuePair, irq_notifier); - trace_nvme_handle_event(s); + trace_nvme_handle_event(q); event_notifier_test_and_clear(n); - nvme_poll_queues(s); + nvme_poll_queue(q); } static bool nvme_poll_cb(void *opaque) { EventNotifier *e = opaque; - BDRVNVMeState *s = container_of(e, BDRVNVMeState, irq_notifier); + NVMeQueuePair *q = container_of(e, NVMeQueuePair, irq_notifier); - trace_nvme_poll_cb(s); - return nvme_poll_queues(s); + trace_nvme_poll_cb(q); + return nvme_poll_queue(q); } -static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) +static bool nvme_add_io_queue(BlockDriverState *bs, + AioContext *aio_context, Error **errp) { BDRVNVMeState *s = bs->opaque; int n = s->nr_queues; NVMeQueuePair *q; NvmeCmd cmd; int queue_size = NVME_QUEUE_SIZE; + int ret; - 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; } @@ -683,6 +676,17 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1); s->queues[n] = q; s->nr_queues++; + + ret = qemu_vfio_pci_init_irq(s->vfio, + &s->queues[n]->irq_notifier, + VFIO_PCI_MSIX_IRQ_INDEX, errp); + if (ret) { + goto out_error; + } + aio_set_event_notifier(aio_context, + &s->queues[n]->irq_notifier, + false, nvme_handle_event, nvme_poll_cb); + return true; out_error: nvme_free_queue_pair(q); @@ -704,12 +708,6 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, qemu_co_queue_init(&s->dma_flush_queue); s->device = g_strdup(device); s->nsid = namespace; - s->aio_context = bdrv_get_aio_context(bs); - ret = event_notifier_init(&s->irq_notifier, 0); - if (ret) { - error_setg(errp, "Failed to init event notifier"); - return ret; - } s->vfio = qemu_vfio_open_pci(device, errp); if (!s->vfio) { @@ -784,12 +782,14 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } } - ret = qemu_vfio_pci_init_irq(s->vfio, &s->irq_notifier, + ret = qemu_vfio_pci_init_irq(s->vfio, + &s->queues[QUEUE_INDEX_ADMIN]->irq_notifier, VFIO_PCI_MSIX_IRQ_INDEX, errp); if (ret) { goto out; } - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, + aio_set_event_notifier(aio_context, + &s->queues[QUEUE_INDEX_ADMIN]->irq_notifier, false, nvme_handle_event, nvme_poll_cb); nvme_identify(bs, namespace, &local_err); @@ -800,7 +800,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: @@ -869,12 +869,14 @@ static void nvme_close(BlockDriverState *bs) BDRVNVMeState *s = bs->opaque; for (i = 0; i < s->nr_queues; ++i) { - nvme_free_queue_pair(s->queues[i]); + NVMeQueuePair *q = s->queues[i]; + + aio_set_event_notifier(q->aio_context, + &q->irq_notifier, false, NULL, NULL); + event_notifier_cleanup(&q->irq_notifier); + nvme_free_queue_pair(q); } g_free(s->queues); - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, - false, NULL, NULL); - event_notifier_cleanup(&s->irq_notifier); qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE); qemu_vfio_close(s->vfio); @@ -1086,7 +1088,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs, .cdw12 = cpu_to_le32(cdw12), }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1195,7 +1197,7 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs) .nsid = cpu_to_le32(s->nsid), }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1236,7 +1238,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1286,7 +1288,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, }; NVMeCoData data = { - .ctx = bdrv_get_aio_context(bs), + .ctx = ioq->aio_context, .ret = -EINPROGRESS, }; @@ -1379,10 +1381,10 @@ static void nvme_detach_aio_context(BlockDriverState *bs) qemu_bh_delete(q->completion_bh); q->completion_bh = NULL; - } - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, - false, NULL, NULL); + aio_set_event_notifier(bdrv_get_aio_context(bs), &q->irq_notifier, + false, NULL, NULL); + } } static void nvme_attach_aio_context(BlockDriverState *bs, @@ -1390,13 +1392,11 @@ static void nvme_attach_aio_context(BlockDriverState *bs, { BDRVNVMeState *s = bs->opaque; - s->aio_context = new_context; - aio_set_event_notifier(new_context, &s->irq_notifier, - false, nvme_handle_event, nvme_poll_cb); - for (int i = 0; i < s->nr_queues; i++) { NVMeQueuePair *q = s->queues[i]; + aio_set_event_notifier(new_context, &q->irq_notifier, + false, nvme_handle_event, nvme_poll_cb); q->completion_bh = aio_bh_new(new_context, nvme_process_completion_bh, q); }