From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898464; cv=none; d=zohomail.com; s=zohoarc; b=ZwAhpczQEubZtZKxHdIrLP18s6bTzf62Suw5k0U/1AZIQ5gtUbgYECvlRkemeRwyuXKQ87uIRzsqFuNWP9jLo5mF38bCT9E72+nhGiKExdai5T46uQkpgyn16YmNzYa48KwiyreAu+MPurwTeXJWZnEX35/x7S+b7+gejMYZU+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898464; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XkqdCy476re75wjyst3nMLbIFP1njQZj90UgXgmJOZc=; b=QJdwWE0YWiXqViJDD9cEFZxT2erEQ2X/qdXTXzFn4HwLVTjNBjUvjJHngsgNXvxBQ3lqe2bpcJVmrXadNqyUuqo8PSckCoZ3aJO/St87gOWtywDIIvf08fFrUlJfxT4Z+PtLxhQJR1lCxvB1ji55AhFzoal7e8SfxfvdQmHYJnc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898464944949.4481039316566; Sat, 4 Jul 2020 14:34:24 -0700 (PDT) Received: from localhost ([::1]:35608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpnj-0007Wm-HV for importer@patchew.org; Sat, 04 Jul 2020 17:34:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpkW-00024c-Ru for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55584 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 1jrpkU-0003sx-BT for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:04 -0400 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-316-wXMdoBshMpWg0juncB4aKg-1; Sat, 04 Jul 2020 17:31:00 -0400 Received: by mail-wm1-f71.google.com with SMTP id t18so40756282wmj.5 for ; Sat, 04 Jul 2020 14:30:59 -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 g195sm17732913wme.38.2020.07.04.14.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:30:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898261; 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=XkqdCy476re75wjyst3nMLbIFP1njQZj90UgXgmJOZc=; b=T4mX5ztxGBAWy4Ve8WNnEWfzjrQ2KbyA/OjoQc3kfnFKSzxDPUB8BEzqkqe3qbcY0E1Vyi p2PPYy2lzBCclaiIvgV/08LEpUW96fpNOiMjwPTEwYkxeLxuKdh1g526+3yO08vkzwj3MX VL6FabfrOcmh5AsOd08E5twYqYAf4GU= X-MC-Unique: wXMdoBshMpWg0juncB4aKg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XkqdCy476re75wjyst3nMLbIFP1njQZj90UgXgmJOZc=; b=tnvIOVGfnrglXswXVRAAC9Q8veY42DRgL503/KbHFIy6MqvTQbh5dNZuO/ZiJm0rqa 67Cn8DqnrTB3p6DPzF3K7Xj16YU8jvqoV8orAqZ5/qcSfUtSbkQpExJyp3JjGjLsCqVM Cf4TSQk5kZqS8HaWU3+FKf2FmFPUMZc3/xAxSydraNQ5L9k2Qt1fpSLCZMg0LVLNSbP0 h4QmgCCCuzUlDaWWYKGj0bZJ6DFPJEJlLDzsJM4QWPHgTDycEIxFs17DeFWh0EnpVJzw sJGKNaD88H3U94nDw9mfz7Bs/WAAXPk7fPGQgaeglz/X3Ye9J70JgAtTKB5A8wAPBw7S fC3Q== X-Gm-Message-State: AOAM530Sqsm8qAR/Muh4kHZWDCTXZ78qvj80Frnzfn1m3KvTuofPSaj6 ho1DhZQMxnQPy3NdJJxol35WRnDFs2oquSzeennLvU4ijAjWJehNbgNWLobn2z8tzmqooTZwR7t BsabmIs8roUp8wyc= X-Received: by 2002:a5d:60d0:: with SMTP id x16mr43284360wrt.5.1593898258784; Sat, 04 Jul 2020 14:30:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfwWt1fjUku4LRRK7AY6ZXQ2wQ8vRyQodplhGmCIRNNFqfGpKJiO0omWy3PTU2j4Iu1mpSlg== X-Received: by 2002:a5d:60d0:: with SMTP id x16mr43284347wrt.5.1593898258605; Sat, 04 Jul 2020 14:30:58 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 01/16] block/nvme: Replace magic value by SCALE_MS definition Date: Sat, 4 Jul 2020 23:30:36 +0200 Message-Id: <20200704213051.19749-2-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.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:28:03 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Use self-explicit SCALE_MS definition instead of magic value. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 374e268915..2f5e3c2adf 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -715,7 +715,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, /* Reset device to get a clean state. */ s->regs->cc =3D cpu_to_le32(le32_to_cpu(s->regs->cc) & 0xFE); /* Wait for CSTS.RDY =3D 0. */ - deadline =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + timeout_ms * 100= 0000ULL; + deadline =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + timeout_ms * SCA= LE_MS; while (le32_to_cpu(s->regs->csts) & 0x1) { if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) > deadline) { error_setg(errp, "Timeout while waiting for device to reset (%" --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898360; cv=none; d=zohomail.com; s=zohoarc; b=Ctg9nanilQ2tz7SNP0AeJdXgh1Or2TdS9+BHjSUcJSNHwkxRpRCVM0hTpZvwQVgb2FECHL8zOWtlWb5n854Z5mrKzkJzeyTKurh8Aut33taZI6yDNHMN4ab5sgq31Z9ZpyTWMPG+mq85U+ZRmDEjHBQ0gtgAO7t0U9x3tEC2HEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898360; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HZH4WbM9lDKriwvJR5iWPBD2dYg3ljxsK8g2n7Z4PXs=; b=XUqQtyvzcoqq7ODPbbAqNZU341HhHOJ7byRhZTqEBf4HXg8sZkVHGDddlM2v2+NYOvpmuOkIerSorN6zYvsIUnW7vTM5SjUL01SIsvmynwE3fj8iuOhuQq9rdbgmH6Faezm9af9jFtD6vB8gut3LIP/rpKK1ltABY1CulimcVw4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898360270365.74709948881696; Sat, 4 Jul 2020 14:32:40 -0700 (PDT) Received: from localhost ([::1]:56328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpm2-00041P-VD for importer@patchew.org; Sat, 04 Jul 2020 17:32:38 -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 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 Received: by mail-wm1-f69.google.com with SMTP id c124so8405260wme.0 for ; Sat, 04 Jul 2020 14:31:04 -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) 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= X-MC-Unique: LAQc1gRkMvqWf5U82UhfZw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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; =20 + if (!trace_event_get_state_backends(TRACE_NVME_SUBMIT_COMMAND_RAW)) { + return; + } for (i =3D 0; i < 8; ++i) { uint8_t *cmdp =3D (uint8_t *)cmd + i * 8; trace_nvme_submit_command_raw(cmdp[0], cmdp[1], cmdp[2], cmdp[3], --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898406; cv=none; d=zohomail.com; s=zohoarc; b=eSd/AFJp8nV/Npa6GaZ+r5KxNuB5dsCes3K3rOKsPmzJ+VzjCFlJ7ZdfMFNor11wGz6Jb9hpZKhMmJqg4CnWOtCtDUsoKfxnmqYrfcVbxi9HkdN3Am9oso1j8yRNoCZnePQIi8gWlPYkBU3Yw4kASMEMirUS5KMzgpkGLNWUueI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898406; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KdE6JsIw8dAhfeVIz93JjPSKDmry/14DEkZ0JE7PkKI=; b=XwAuRPibuLVovprEOpe3mSt5T+NSB4hsE4E/SQaIWxLXc5QKPcGr2sabbr/n3/Uq5WW7WlBGGXNO9PlVjDBttc1SfzwP1HyTxLJFQAffEql0L3j+Tif9UdqUVXa3Z4qKTl5sIGROkvc9++vFII286lL0NPFVt6Y/KmLgMWFPc6s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898406377998.5400544910035; Sat, 4 Jul 2020 14:33:26 -0700 (PDT) Received: from localhost ([::1]:60012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpmm-0005kb-Uu for importer@patchew.org; Sat, 04 Jul 2020 17:33:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpki-0002LY-5k for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:17 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:24948 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 1jrpke-0003yx-Dv for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:15 -0400 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-157-lzGuhFVhNTKBxzivTKyPpg-1; Sat, 04 Jul 2020 17:31:09 -0400 Received: by mail-wm1-f70.google.com with SMTP id g6so34941125wmk.4 for ; Sat, 04 Jul 2020 14:31: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 a3sm16953570wmb.7.2020.07.04.14.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898271; 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=KdE6JsIw8dAhfeVIz93JjPSKDmry/14DEkZ0JE7PkKI=; b=Bj61B2PXYnELutvjATNHou5qAYUymd9F/+Wz0U+iT3Hoo+oGCYIEis9YwjrRC660xZqgwJ Ejb9ShEJXxYJSUnk3JNdxR50Bm8ImXvvfMsAqU8OBGEZDrgmoV81rTtfwHs6KlZ0FD6fQg 27HyJis2aXfueRwDsGX9OXP9xFEWbxE= X-MC-Unique: lzGuhFVhNTKBxzivTKyPpg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KdE6JsIw8dAhfeVIz93JjPSKDmry/14DEkZ0JE7PkKI=; b=R9VeSymSJy59j3/UVafR1NCStCnpC13B+f4YhwoxcfvZG0+RQ6vmkEl0pHufr4iCND Pg8mXzGjh+XpqPsDo8L130XhLQ2wsxpEW4H6jP/SfaRBNHXKETFubd9KmTPbcMnsrltp 6i6T2HhSZKr8C4sINMOuDD5mIgYY7hh4qAlt9pWIYdOQBMZ74EES1BdPl/sVkY+g5VmG 0Xn8B2AoJJDb0bIYZIQ9zuX9hQzng9X+lz9GVJjfwO0RGWAG0JJcxrWh92gMkn60QkoQ O28/l9Oh2YPp+7a+IGQ6qL3/z8h4D1Fks0r/1jeTjbg6wBrO4THbLxZSOmvR/sJ7xwwN ZrBg== X-Gm-Message-State: AOAM531uuDguS2JWBWYMgDo8MYVVV0zo/QVsw9T6FZyO/cmijAFyHLvO VzUg6324LSo4+gO1tNZFQyIiqRynqBwrOuCXaSpKE7xgNtRTHQyxNDM3O6E7OKOARck9WzaAmni 4vtcaJFseyw70qeY= X-Received: by 2002:a5d:69c5:: with SMTP id s5mr42060947wrw.197.1593898268461; Sat, 04 Jul 2020 14:31:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9Y4R53C3Xdv4shoYf5J4ZzSJabEiVfoOQrOIWG5F0SfS5JkNTuZL3roDMpmGjvGfWPxiMHQ== X-Received: by 2002:a5d:69c5:: with SMTP id s5mr42060934wrw.197.1593898268303; Sat, 04 Jul 2020 14:31:08 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 03/16] block/nvme: Let nvme_create_queue_pair() fail gracefully Date: Sat, 4 Jul 2020 23:30:38 +0200 Message-Id: <20200704213051.19749-4-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) As nvme_create_queue_pair() is allowed to fail, replace the alloc() calls by try_alloc() to avoid aborting QEMU. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 8c30a5fee2..e1893b4e79 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -213,14 +213,22 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDri= verState *bs, int i, r; BDRVNVMeState *s =3D bs->opaque; Error *local_err =3D NULL; - NVMeQueuePair *q =3D g_new0(NVMeQueuePair, 1); + NVMeQueuePair *q; uint64_t prp_list_iova; =20 + q =3D g_try_new0(NVMeQueuePair, 1); + if (!q) { + return NULL; + } + q->prp_list_pages =3D qemu_try_blockalign0(bs, + s->page_size * NVME_QUEUE_SIZE); + if (!q->prp_list_pages) { + goto fail; + } qemu_mutex_init(&q->lock); q->s =3D s; q->index =3D idx; qemu_co_queue_init(&q->free_req_queue); - q->prp_list_pages =3D qemu_blockalign0(bs, s->page_size * NVME_NUM_REQ= S); q->completion_bh =3D aio_bh_new(bdrv_get_aio_context(bs), nvme_process_completion_bh, q); r =3D qemu_vfio_dma_map(s->vfio, q->prp_list_pages, --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898524; cv=none; d=zohomail.com; s=zohoarc; b=DI2zO4pzihYeUM9kBcA7M6Q5RXezTM9YXWbuRZ4FfpSJ1U8iQ4jvzorYqqkZ/tRA7SidlM/IxikSWm5PTF0dV3X1GYF0+L9K9wdyvvtCueRgHPiFcuakX0UNA61YWRforqfoYuEk9sASlKjm+XXkuzMcEnnwQSSxectz1nooZN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898524; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ljXJ2uXsj/Qn3r9/6qBf8Xo9qcaKqcWoVzmWGn+EjKs=; b=cLy5BDcavXHUjW0KNqV9zhB2AT6vVf+cUjH7mPhg8nCxlFIKb8K8p5mc8/f7Md0DBwCHOwOS1hGHdl7zoxxHNGcMt0n0rU+l8BZhpGmvCHRNh5K7QGOHNMUozGnq1fMmOich/LFIc6CIxiTye3ml9NwdrePrlVlP4L2Mare5T5U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898524863387.8643859092804; Sat, 4 Jul 2020 14:35:24 -0700 (PDT) Received: from localhost ([::1]:40208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpoh-00018Z-Ns for importer@patchew.org; Sat, 04 Jul 2020 17:35:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpkl-0002Mv-DB for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:19 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:31733 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 1jrpkj-00040C-LX for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:19 -0400 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-101-DHBZx794OdKbu71f4zoXmQ-1; Sat, 04 Jul 2020 17:31:14 -0400 Received: by mail-wr1-f70.google.com with SMTP id j3so17323985wrq.9 for ; Sat, 04 Jul 2020 14:31:14 -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 z16sm17912315wrr.35.2020.07.04.14.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898276; 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=ljXJ2uXsj/Qn3r9/6qBf8Xo9qcaKqcWoVzmWGn+EjKs=; b=E7u9p1gPkU70L3pCCP3q8V2y0h+68BluoksMreCOnuGeeiHvIslsofWLcsrqZoUad9+6qz vrVDe0dxQWngEyQl1/LEGDumLpBR/rMdibjQpCdzkGX3KCtgjGokp5SE90zavpF0o5WewX fe82osi8jIUDxSjz0/Q966WDleClScI= X-MC-Unique: DHBZx794OdKbu71f4zoXmQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ljXJ2uXsj/Qn3r9/6qBf8Xo9qcaKqcWoVzmWGn+EjKs=; b=HAux8fKui2EuQ6KiInFNJW/2ZSs/fwecBv5tFwSnAazZSo70WjRQQDp9gkyV+teKOX qd8V+PeVfXzzkMHPLRxEhWr0v/xY/Vjd/rLpexIVywReob2QVimU9AwyijaiSdmlurpJ dkqpWVHqVF1UEC8ra0kdC5hBmL1K4AyChNTLBHgvJf4cbKmdglvpD2t1D3MiPPRE6gTX E3J0FlUX2VVJ8LRLDfwr5n/R/bpFdn5Ho5evG8UQ6+d5vMk3noF2MShVnGgrHR8MF3Vx LwtdjpLdiSMTdLL2Di70A1yjG9T3JFCZkhy2rWj/93qsrxcDmU8OOD6ga3m3DvLrAuDn hjOw== X-Gm-Message-State: AOAM532lM+WZ6OTabPW1acQz7ykQkNW14O3Y43H7YBpoBO8cqqgk/MZF d3K1ASgeeJ43t0wBAZogXppDO48OLHTjubg0gKBYTI6hoEQ/Eu1/CgXeTBuZFucJfWCPUAqHOg+ WGW2N2k1V9pN6TQk= X-Received: by 2002:a1c:6006:: with SMTP id u6mr41619821wmb.111.1593898273277; Sat, 04 Jul 2020 14:31:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdQfI+2q5Dx06gka11K2Q6hyZPYIaBQvlrH3lA5BUXGeaIrMgfG04dWs9AjMzWkX9DCxa/AA== X-Received: by 2002:a1c:6006:: with SMTP id u6mr41619806wmb.111.1593898273019; Sat, 04 Jul 2020 14:31:13 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 04/16] block/nvme: Define QUEUE_INDEX macros to ease code review Date: Sat, 4 Jul 2020 23:30:39 +0200 Message-Id: <20200704213051.19749-5-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Use definitions instead of '0' or '1' indexes. Also this will be useful when using multi-queues later. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index e1893b4e79..28762d7ee8 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -103,6 +103,9 @@ typedef volatile struct { =20 QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) !=3D 0x1000); =20 +#define QUEUE_INDEX_ADMIN 0 +#define QUEUE_INDEX_IO(n) (1 + n) + struct BDRVNVMeState { AioContext *aio_context; QEMUVFIOState *vfio; @@ -531,7 +534,7 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) } cmd.prp1 =3D cpu_to_le64(iova); =20 - if (nvme_cmd_sync(bs, s->queues[0], &cmd)) { + if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify controller"); goto out; } @@ -555,7 +558,7 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) =20 cmd.cdw10 =3D 0; cmd.nsid =3D cpu_to_le32(namespace); - if (nvme_cmd_sync(bs, s->queues[0], &cmd)) { + if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify namespace"); goto out; } @@ -644,7 +647,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), .cdw11 =3D cpu_to_le32(0x3), }; - if (nvme_cmd_sync(bs, s->queues[0], &cmd)) { + if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create io queue [%d]", n); nvme_free_queue_pair(q); return false; @@ -655,7 +658,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), .cdw11 =3D cpu_to_le32(0x1 | (n << 16)), }; - if (nvme_cmd_sync(bs, s->queues[0], &cmd)) { + if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create io queue [%d]", n); nvme_free_queue_pair(q); return false; @@ -739,16 +742,18 @@ static int nvme_init(BlockDriverState *bs, const char= *device, int namespace, =20 /* Set up admin queue. */ s->queues =3D g_new(NVMeQueuePair *, 1); - s->queues[0] =3D nvme_create_queue_pair(bs, 0, NVME_QUEUE_SIZE, errp); - if (!s->queues[0]) { + s->queues[QUEUE_INDEX_ADMIN] =3D nvme_create_queue_pair(bs, 0, + NVME_QUEUE_SIZE, + errp); + if (!s->queues[QUEUE_INDEX_ADMIN]) { ret =3D -EINVAL; goto out; } s->nr_queues =3D 1; QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000); s->regs->aqa =3D cpu_to_le32((NVME_QUEUE_SIZE << 16) | NVME_QUEUE_SIZE= ); - s->regs->asq =3D cpu_to_le64(s->queues[0]->sq.iova); - s->regs->acq =3D cpu_to_le64(s->queues[0]->cq.iova); + s->regs->asq =3D cpu_to_le64(s->queues[QUEUE_INDEX_ADMIN]->sq.iova); + s->regs->acq =3D cpu_to_le64(s->queues[QUEUE_INDEX_ADMIN]->cq.iova); =20 /* After setting up all control registers we can enable device now. */ s->regs->cc =3D cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << 20) | @@ -839,7 +844,7 @@ static int nvme_enable_disable_write_cache(BlockDriverS= tate *bs, bool enable, .cdw11 =3D cpu_to_le32(enable ? 0x01 : 0x00), }; =20 - ret =3D nvme_cmd_sync(bs, s->queues[0], &cmd); + ret =3D nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd); if (ret) { error_setg(errp, "Failed to configure NVMe write cache"); } @@ -1056,7 +1061,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriv= erState *bs, { int r; BDRVNVMeState *s =3D bs->opaque; - NVMeQueuePair *ioq =3D s->queues[1]; + NVMeQueuePair *ioq =3D s->queues[QUEUE_INDEX_IO(0)]; NVMeRequest *req; =20 uint32_t cdw12 =3D (((bytes >> s->blkshift) - 1) & 0xFFFF) | @@ -1171,7 +1176,7 @@ static coroutine_fn int nvme_co_pwritev(BlockDriverSt= ate *bs, static coroutine_fn int nvme_co_flush(BlockDriverState *bs) { BDRVNVMeState *s =3D bs->opaque; - NVMeQueuePair *ioq =3D s->queues[1]; + NVMeQueuePair *ioq =3D s->queues[QUEUE_INDEX_IO(0)]; NVMeRequest *req; NvmeCmd cmd =3D { .opcode =3D NVME_CMD_FLUSH, @@ -1202,7 +1207,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDr= iverState *bs, BdrvRequestFlags flags) { BDRVNVMeState *s =3D bs->opaque; - NVMeQueuePair *ioq =3D s->queues[1]; + NVMeQueuePair *ioq =3D s->queues[QUEUE_INDEX_IO(0)]; NVMeRequest *req; =20 uint32_t cdw12 =3D ((bytes >> s->blkshift) - 1) & 0xFFFF; @@ -1255,7 +1260,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverS= tate *bs, int bytes) { BDRVNVMeState *s =3D bs->opaque; - NVMeQueuePair *ioq =3D s->queues[1]; + NVMeQueuePair *ioq =3D s->queues[QUEUE_INDEX_IO(0)]; NVMeRequest *req; NvmeDsmRange *buf; QEMUIOVector local_qiov; @@ -1398,7 +1403,7 @@ static void nvme_aio_unplug(BlockDriverState *bs) BDRVNVMeState *s =3D bs->opaque; assert(s->plugged); s->plugged =3D false; - for (i =3D 1; i < s->nr_queues; i++) { + for (i =3D QUEUE_INDEX_IO(0); i < s->nr_queues; i++) { NVMeQueuePair *q =3D s->queues[i]; qemu_mutex_lock(&q->lock); nvme_kick(q); --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898573; cv=none; d=zohomail.com; s=zohoarc; b=mQyOoTyx2up+3oC/QwmsrnIvTIyIYoQ6qh4CKNqf53KKpTSvhd/AqISZ4h5CRQLEramjIeELuNGMaAKE8NmM+Yejk3IxsQLrgVfgxsP6y2N5EYIgPv9UZbojUfSPtwk+/PqPPtLiWn69q672ah+j8pYk4zOFPnENoXuPrflXlDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898573; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GXdIespWFUCgh9geAcuRTrSY8JSFvRPXQ9z+IG0M7kw=; b=NM1ZuTcMKIm2z1M7jn6OmgNHKdLazOm6Achgc+WnHRbe1kZV1OFbwMFF6R7rMdxmSIMfO4CEuH3g77ymHJOWGZ5Ww8x7UwyQIYyYUghKfnk/tarHEVW+HbkpVwbiCB207EN1/BWwpf8eFC1HmVpGfe50Qro1CTDacwtol8R2w9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898573126759.1857617290041; Sat, 4 Jul 2020 14:36:13 -0700 (PDT) Received: from localhost ([::1]:42610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrppS-0002Vz-Mq for importer@patchew.org; Sat, 04 Jul 2020 17:36:10 -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 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 Received: by mail-wm1-f72.google.com with SMTP id v6so38553207wmg.1 for ; Sat, 04 Jul 2020 14:31:19 -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) 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= X-MC-Unique: QFAXcHzQO7ee_TDDiMgtPA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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, Err= or **errp) .cdw11 =3D 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, Err= or **errp) .cdw11 =3D 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; } --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898631; cv=none; d=zohomail.com; s=zohoarc; b=DYcB8EZc1vDwuqMB1ZjMbMiB5Bcf8eIqG3/yAGS3aANC3MaUOhYutHWkHuYpn3MDqlLPabddarpUQzn53iNiahYqjRpxM+3c+BGLt+cOKJVQswVFtAW/ls3W9GNuJKIbP+lC5y8bWpX1uAa2EFlGZGnjE7FdJK4AbYSJXilkDlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898631; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ob08smN6ZI4g8NRDF6m5BXTc3kBCbtPED0vqHga8qI4=; b=Rc5Zco4SdZGXhv5ZTsqzgKcd5K3epQBDNtmQKW1c1EEUbLJXFilWpUhdp4IC5Eo5iymmjTOep3KUsW2R92v3A4CE6Xl7/b9pw0uPitffe/nWkhvFZ86/bBVgPYoHwDNGMzWrfsCXQTW50tpKUoqjMgIYwE9GpoNtEoEO1SE/Frg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898631215588.0019794182347; Sat, 4 Jul 2020 14:37:11 -0700 (PDT) Received: from localhost ([::1]:46620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpqP-0004b6-W2 for importer@patchew.org; Sat, 04 Jul 2020 17:37:10 -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 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 Received: by mail-wr1-f69.google.com with SMTP id i14so36770482wru.17 for ; Sat, 04 Jul 2020 14:31:23 -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) 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= X-MC-Unique: A_dqm35kOYq-NhZsHV3UVg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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, Err= or **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 =3D (NvmeCmd) { .opcode =3D NVME_ADM_CMD_CREATE_SQ, @@ -660,13 +659,15 @@ static bool nvme_add_io_queue(BlockDriverState *bs, E= rror **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 =3D g_renew(NVMeQueuePair *, s->queues, n + 1); s->queues[n] =3D q; s->nr_queues++; return true; +out_error: + nvme_free_queue_pair(q); + return false; } =20 static bool nvme_poll_cb(void *opaque) --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898756; cv=none; d=zohomail.com; s=zohoarc; b=TleWDOMc42d8lnguamC5ueU6DSnr65ufeTZbf+Mb1k2ZQhDnU2YR8YI07LG5NUa4X4Y/t97w+ijo2OvKob7iC1ueUWQLa0YfA7okZtNPwblJmQk5TEXO7aFGeTdbviezGupWML4JcwLuK43zawuNF5WDko4PitfeVFMWFKkybbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898756; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g1c5IpvFtEmHb1Ar7U/yHo4EA4jabVRcmhD5AWDwl8w=; b=AQN8SQTJ845ruEzFT62yMzPsbj0jBK71UbteQywH9a6xI4d7tw8islR6cX7tmY8m9HwXBIZZIqskEzyizyvOdOuAqnMRA1sVzIuxnw7tLvOLkcAq5l9RZZO+cN+Kgm1BZ120Ss6EA4gGjGBJrpI5sIvGlIbq2Wz9RU70FNESuMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898756632598.1689754718317; Sat, 4 Jul 2020 14:39:16 -0700 (PDT) Received: from localhost ([::1]:52984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpsR-0007la-Es for importer@patchew.org; Sat, 04 Jul 2020 17:39:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpkz-0002Y0-6x for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:28048 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 1jrpkx-00042i-3C for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:32 -0400 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-401-Uyt6LeGBOQ2PCetvpsNs5A-1; Sat, 04 Jul 2020 17:31:29 -0400 Received: by mail-wm1-f71.google.com with SMTP id t145so40858479wmt.2 for ; Sat, 04 Jul 2020 14:31:28 -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 r3sm20317005wrg.70.2020.07.04.14.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898290; 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=g1c5IpvFtEmHb1Ar7U/yHo4EA4jabVRcmhD5AWDwl8w=; b=Jy2trg+Xktmb2E5vN38tl7Wi2oRcXCSoXlF9OjNcS8w+bwVqzed2fTGMQwPkbL8XciIDQL p+OlzhpZRphCIFVJeejJY39RSO4Lcz0/5qKQEKOyQe23lY6ORsfWFMNXAAFPnVJYk5cqmD xEDrwmSblBeWo+y8uy6KNvdCsXbjebY= X-MC-Unique: Uyt6LeGBOQ2PCetvpsNs5A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g1c5IpvFtEmHb1Ar7U/yHo4EA4jabVRcmhD5AWDwl8w=; b=VcjzsMjW+Agyv7QEUTO8s8UN6jV96hAtjwekKYpKzaeYbcH5MYbPaPS0xr10BiaKcC iV/HmoYE/94VOuJ5lkjkMZUor/ULyoUjFOnBf3VB2MGG9Zo3zg1Qr/ZdB3d4Y4MXooKu OC1CR7QhmZi0pDQVCllEn0fZvSg9sHHIiq45wW2b9YbVNwVlooVyvatTqEt/kOiPiLyR ZJBfDM5Z8TvJmpR2YkkmZca3x98QJFR5z7LINm7SX6brV1c4hsfQnjkaKvFTKB7ZRCqn dWiNPX0fJj6BhUkV0uF5k3Ajln7UrKlFnlVgwS3acgVZPdRyuL5lcW+kZ2JknHj+UkxS vwKQ== X-Gm-Message-State: AOAM532zL+MACuE/aXAEsIemnhYuNyof8ZhnuFPEJHP43x0Eat2yIrLL 9aWdgs5Bkv9/HZDpjad1BiC9tHD63xuo+vUbhEjf+nRVwnMRATYoxk7ZrjQuO5w1J6wddtpC/HQ RxV4YKVS9r1+02mw= X-Received: by 2002:a5d:4710:: with SMTP id y16mr43646065wrq.189.1593898287671; Sat, 04 Jul 2020 14:31:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5qBnEmPCl99zftVC0GuLy35BSXnn8vwFXd+qK5LBR4ARdr2sC5nZibzJ0bFhKOtP1QooR6g== X-Received: by 2002:a5d:4710:: with SMTP id y16mr43646056wrq.189.1593898287508; Sat, 04 Jul 2020 14:31:27 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 07/16] block/nvme: Rename local variable Date: Sat, 4 Jul 2020 23:30:42 +0200 Message-Id: <20200704213051.19749-8-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We are going to modify the code in the next commit. Renaming the 'resp' variable to 'id' first makes the next commit easier to review. No logical changes. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 7bec52ca35..0e4e5ff107 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -510,8 +510,8 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) BDRVNVMeState *s =3D bs->opaque; NvmeIdCtrl *idctrl; NvmeIdNs *idns; + uint8_t *id; NvmeLBAF *lbaf; - uint8_t *resp; uint16_t oncs; int r; uint64_t iova; @@ -520,14 +520,14 @@ static void nvme_identify(BlockDriverState *bs, int n= amespace, Error **errp) .cdw10 =3D cpu_to_le32(0x1), }; =20 - resp =3D qemu_try_blockalign0(bs, sizeof(NvmeIdCtrl)); - if (!resp) { + id =3D qemu_try_blockalign0(bs, sizeof(NvmeIdCtrl)); + if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - idctrl =3D (NvmeIdCtrl *)resp; - idns =3D (NvmeIdNs *)resp; - r =3D qemu_vfio_dma_map(s->vfio, resp, sizeof(NvmeIdCtrl), true, &iova= ); + idctrl =3D (NvmeIdCtrl *)id; + idns =3D (NvmeIdNs *)id; + r =3D qemu_vfio_dma_map(s->vfio, id, sizeof(NvmeIdCtrl), true, &iova); if (r) { error_setg(errp, "Cannot map buffer for DMA"); goto out; @@ -554,8 +554,7 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) s->supports_write_zeroes =3D !!(oncs & NVME_ONCS_WRITE_ZEROS); s->supports_discard =3D !!(oncs & NVME_ONCS_DSM); =20 - memset(resp, 0, 4096); - + memset(id, 0, 4096); cmd.cdw10 =3D 0; cmd.nsid =3D cpu_to_le32(namespace); if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { @@ -587,8 +586,8 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) =20 s->blkshift =3D lbaf->ds; out: - qemu_vfio_dma_unmap(s->vfio, resp); - qemu_vfree(resp); + qemu_vfio_dma_unmap(s->vfio, id); + qemu_vfree(id); } =20 static bool nvme_poll_queues(BDRVNVMeState *s) --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898511; cv=none; d=zohomail.com; s=zohoarc; b=F+FN0T+VYvzIqb6dO10C+cpvmT+tvKZ1eaedf984dueSmldj3QHUnT3/42J/pIyjja3gfXErAmMxUPNKNMONcu13aUbHey+HSxAsGSZo3S0dYjkru3G4kGVThWw4aPI5Mk4AeAmBW8hsgntmpBud1I0Gb2HiaWe1qgdcOPYpf/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898511; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7qf4SB5pxS18EQoWD8ox8JEyWFcG4DNexsgvb6j1d6o=; b=WMZxojb4BqB3PjnW/TmWckRWJ4mpukQVcU7jziCDDsihJ5/nLIGwScbEXup3DrxhFR9Sk1+ty2zBG94gkkbmvmNSh+tdvbFensQxjvrbBqeHVwjKPezAuO7qHqsokfInZ38Ml0w8KZlQQWsMF81NG2DtKI+LcaxaT24R0GTOcgI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159389851171911.510947877182389; Sat, 4 Jul 2020 14:35:11 -0700 (PDT) Received: from localhost ([::1]:39222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpoU-0000jV-Eb for importer@patchew.org; Sat, 04 Jul 2020 17:35:10 -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 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 Received: by mail-wm1-f69.google.com with SMTP id q20so30916559wme.3 for ; Sat, 04 Jul 2020 14:31:33 -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) 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= X-MC-Unique: MqgWfbKWMz20BYJWrCFkdA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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, NVMeQue= uePair *q, static void nvme_identify(BlockDriverState *bs, int namespace, Error **err= p) { BDRVNVMeState *s =3D 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 n= amespace, Error **errp) .cdw10 =3D cpu_to_le32(0x1), }; =20 - id =3D qemu_try_blockalign0(bs, sizeof(NvmeIdCtrl)); + id =3D qemu_try_blockalign0(bs, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - idctrl =3D (NvmeIdCtrl *)id; - idns =3D (NvmeIdNs *)id; - r =3D qemu_vfio_dma_map(s->vfio, id, sizeof(NvmeIdCtrl), true, &iova); + r =3D 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 n= amespace, Error **errp) goto out; } =20 - 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 =3D le32_to_cpu(idctrl->vwc) & 0x1; - s->max_transfer =3D (idctrl->mdts ? 1 << idctrl->mdts : 0) * s->page_s= ize; + s->write_cache_supported =3D le32_to_cpu(id->ctrl.vwc) & 0x1; + s->max_transfer =3D (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 mo= st * s->page_size / sizeof(uint64_t) entries. */ s->max_transfer =3D MIN_NON_ZERO(s->max_transfer, s->page_size / sizeof(uint64_t) * s->page_size); =20 - oncs =3D le16_to_cpu(idctrl->oncs); + oncs =3D le16_to_cpu(id->ctrl.oncs); s->supports_write_zeroes =3D !!(oncs & NVME_ONCS_WRITE_ZEROS); s->supports_discard =3D !!(oncs & NVME_ONCS_DSM); =20 - memset(id, 0, 4096); + memset(id, 0, sizeof(*id)); cmd.cdw10 =3D 0; cmd.nsid =3D 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 n= amespace, Error **errp) goto out; } =20 - s->nsze =3D le64_to_cpu(idns->nsze); - lbaf =3D &idns->lbaf[NVME_ID_NS_FLBAS_INDEX(idns->flbas)]; + s->nsze =3D le64_to_cpu(id->ns.nsze); + lbaf =3D &id->ns.lbaf[NVME_ID_NS_FLBAS_INDEX(id->ns.flbas)]; =20 - if (NVME_ID_NS_DLFEAT_WRITE_ZEROES(idns->dlfeat) && - NVME_ID_NS_DLFEAT_READ_BEHAVIOR(idns->dlfeat) =3D=3D + if (NVME_ID_NS_DLFEAT_WRITE_ZEROES(id->ns.dlfeat) && + NVME_ID_NS_DLFEAT_READ_BEHAVIOR(id->ns.dlfeat) =3D=3D NVME_ID_NS_DLFEAT_READ_BEHAVIOR_ZEROES) { bs->supported_write_flags |=3D BDRV_REQ_MAY_UNMAP; } --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898609; cv=none; d=zohomail.com; s=zohoarc; b=AxfN1j+7yt6kVu03CBGy8ZFFmN9FiIqV3Yku2wPoAdiVCqSBS+KK99M+Q7KOVc/uMb35mcNL+xPGWagmxgqAD9Y4+tTF2ipgyujGpSQMwW3+IPI6WH9BnxoureblGh6xXNrNgVGyrlhx8Y9e/6+d2PWSBtiyeNjuplJE+KblFrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898609; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+f9l1P8/9tMwFIwJ8vCxS6Cv+1zykZTNOSgQEBgbIRo=; b=GsueIw2e9Qha6RubmK+aP4OIEpJfzViXBbLN8URA6hiWjO2t8rCAhq7cl5/Ry0bCTr6tsQZhvUheFf2eJuSeD7014tGZ8vBvsUXHLWwMY+1r8PS8mdDv4gFIahAptrkySX1RnL9mfWDCWnRIhtkXH2R5R9ft8OSOztHahLmX0m8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898609707499.38488807465797; Sat, 4 Jul 2020 14:36:49 -0700 (PDT) Received: from localhost ([::1]:45682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpq4-0004Cl-Ew for importer@patchew.org; Sat, 04 Jul 2020 17:36:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrpl9-0002xt-Jx for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:43 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:43067 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 1jrpl6-00043s-Ol for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:43 -0400 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-254-ID6pOcd5OVeMB4OwSgz7-g-1; Sat, 04 Jul 2020 17:31:38 -0400 Received: by mail-wm1-f71.google.com with SMTP id g187so40757077wme.0 for ; Sat, 04 Jul 2020 14:31:38 -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 c2sm18468552wrv.47.2020.07.04.14.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898300; 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=+f9l1P8/9tMwFIwJ8vCxS6Cv+1zykZTNOSgQEBgbIRo=; b=XU7d8/1gfYj399el7WyFCRdQtCnuQgECtRpJPlWj+844G4RWbzLLLDiiWeMSN04WFSEupf WpgPI4Wr32TFlZh8PvprOYUtJwSmNToQ3UF5jsqkr9yHEM0G85RHRSLiXLWvWvwEK5ex2p 8PAw8anwp25W2YE4uNpt/VuEF4ZEUKs= X-MC-Unique: ID6pOcd5OVeMB4OwSgz7-g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+f9l1P8/9tMwFIwJ8vCxS6Cv+1zykZTNOSgQEBgbIRo=; b=IKV348ySW7ND15AVwpASZ+OVb7x/xXmRG4gYdcaAUAhX8VpP0raQs2KVZlAaGXvMnh Hvn1zQiVtBTjDXGqs3+0uZUnngBNEEOzYVWHRPaYwi6ds9goar6hw9ZEk/GwkBCdmX6e M4JAurf5Je3acDuw23l4OOnj5GH3HqYIaYM1xaq0BNaC7u87iexKFhR6lWwyJXN7Aghj h0nKBDhU3dZIHdk1k9BvjtPOviU6C7QhHC44PJHW88R5rIl+fJ2RhLy9jnd89JfT8/Yu s2kMlWoJSk5AObjekrZx/peXu7wsHw9GwVSNJNR4GL2zPqY1ohUwvo7VhqCiNg8UIhnm DLhQ== X-Gm-Message-State: AOAM532uibB9nXS87UaCbSpn8E+696UIM+yW+rPXowi8RnmnTX2Va9/j ViI09s7LedSTvz+fgpgfVxrrTa4oJNl4Bt09HLTod0R5Ppp9cEFMGNGVFY7P4NWVWfJCaA4pZ7/ CDRGcIkeY2PLk7iU= X-Received: by 2002:a05:600c:2116:: with SMTP id u22mr41611038wml.82.1593898297266; Sat, 04 Jul 2020 14:31:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx/Xi80qOOyDLEM/YB4VgQOKyWQiUKUeCzP1HBZzWuJA9Z59P8cXmRwbMmD83zlTUDddZahw== X-Received: by 2002:a05:600c:2116:: with SMTP id u22mr41611029wml.82.1593898297051; Sat, 04 Jul 2020 14:31:37 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 09/16] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset Date: Sat, 4 Jul 2020 23:30:44 +0200 Message-Id: <20200704213051.19749-10-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In the next commit we'll get rid of qemu_try_blockalign(). To ease review, first replace qemu_try_blockalign0() by explicit calls to qemu_try_blockalign() and memset(). Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index a611fdd71e..9c118c000d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -174,12 +174,12 @@ static void nvme_init_queue(BlockDriverState *bs, NVM= eQueue *q, =20 bytes =3D ROUND_UP(nentries * entry_bytes, s->page_size); q->head =3D q->tail =3D 0; - q->queue =3D qemu_try_blockalign0(bs, bytes); - + q->queue =3D qemu_try_blockalign(bs, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); return; } + memset(q->queue, 0, bytes); r =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); if (r) { error_setg(errp, "Cannot map queue"); @@ -223,11 +223,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDri= verState *bs, if (!q) { return NULL; } - q->prp_list_pages =3D qemu_try_blockalign0(bs, + q->prp_list_pages =3D qemu_try_blockalign(bs, s->page_size * NVME_QUEUE_SIZE); if (!q->prp_list_pages) { goto fail; } + memset(q->prp_list_pages, 0, s->page_size * NVME_QUEUE_SIZE); qemu_mutex_init(&q->lock); q->s =3D s; q->index =3D idx; @@ -521,7 +522,7 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) .cdw10 =3D cpu_to_le32(0x1), }; =20 - id =3D qemu_try_blockalign0(bs, sizeof(*id)); + id =3D qemu_try_blockalign(bs, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; @@ -531,8 +532,9 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) error_setg(errp, "Cannot map buffer for DMA"); goto out; } - cmd.prp1 =3D cpu_to_le64(iova); =20 + memset(id, 0, sizeof(*id)); + cmd.prp1 =3D cpu_to_le64(iova); if (nvme_cmd_sync(bs, s->queues[QUEUE_INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify controller"); goto out; @@ -1283,11 +1285,11 @@ static int coroutine_fn nvme_co_pdiscard(BlockDrive= rState *bs, =20 assert(s->nr_queues > 1); =20 - buf =3D qemu_try_blockalign0(bs, s->page_size); + buf =3D qemu_try_blockalign(bs, s->page_size); if (!buf) { return -ENOMEM; } - + memset(buf, 0, s->page_size); buf->nlb =3D cpu_to_le32(bytes >> s->blkshift); buf->slba =3D cpu_to_le64(offset >> s->blkshift); buf->cattr =3D 0; --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898694; cv=none; d=zohomail.com; s=zohoarc; b=G+DV1w5bGWFBCrDIPq1bmumEPekks9TULkxk/hqkrGkp2zkla40ZSc2ireENk+utewSf2fQvd8bCrQPpOUzBbafFwKYlXJw49H4oufBqVyXD70vDrNJluv4lkV4jlhuaR/4Se1EMgVCIe3ylH4bvs2w1+kn4dRlMhpy+D8WOCog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898694; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FfmX4SsthOp0qVQWfh38S15QI3pmZ2xeD0V8kh7HNfQ=; b=E4s4LS+0ZMmOIxfvhCJ3cUM46m58q3yuvsoYXDlXU9hkjkblgZ4A0T3kSau9bmRC/eRB2mySPyHOdwmDdpacu63AkP3KI8a+dN8btoyuS2WV6K3gCBg+OZYh9eNqnlFqsOCkr7pbHY4MLSd8NGCcwFOS3a3XEcFDea2NyH10zWo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898694624500.5337957814744; Sat, 4 Jul 2020 14:38:14 -0700 (PDT) Received: from localhost ([::1]:49952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrprR-0006Wj-Bj for importer@patchew.org; Sat, 04 Jul 2020 17:38:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrplF-0003DA-4G for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:49 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:34936 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 1jrplD-00045i-GR for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:31:48 -0400 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-321-rcugwG5yPRu31As_bkkGsw-1; Sat, 04 Jul 2020 17:31:43 -0400 Received: by mail-wr1-f70.google.com with SMTP id c6so17797057wru.7 for ; Sat, 04 Jul 2020 14:31:43 -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 v9sm9897771wri.3.2020.07.04.14.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898306; 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=FfmX4SsthOp0qVQWfh38S15QI3pmZ2xeD0V8kh7HNfQ=; b=iZ0iSRURgj5jhYWbCk92qSK0FMPJ0IXFZ2kKxvWrdMh+csjXdqV2AVF0wXmbbEiUOot60X b026p5JSoOKckcg2iichzNVStAYR75nqnztf6zq6K75CAY5GX1t66rmt2JNOq4W81pnEe4 nePhev/0FYvUJ+wOkfeHtQc77pTNrUM= X-MC-Unique: rcugwG5yPRu31As_bkkGsw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FfmX4SsthOp0qVQWfh38S15QI3pmZ2xeD0V8kh7HNfQ=; b=B6NSoDPPhiNcP8IT3sqYT6VK/wswzKpmdNA0mYo7/gyKONvs9Lv7ESD95Ki71BlP07 p7srlN3W04PRwK3FaAE90GFujwTkS8YYMmb+Hd5GYtIVXN8CWG9ENJgHu09uU3qNdf9O 5VKHtmDP7hax48by957v/n+aBzaqolOjG5vd+ny5DSGLaSIaO1BNDgj7LyHZ3MjlBPoa 3V/Mtdgvs+1W5q9KUnZsa322CVxSxx/76l/scx5O6Fx9eA5B03B5iScf1MUGCKckq/0r VsGCEa/0Aqes7cTTpjqKMefGYIzYVCjtZWiNd7GxePeR8fJv5y1vwE9jHG+Eh8MEAiWV evJg== X-Gm-Message-State: AOAM530qYIqdibBx4FE4HlTDgm58ChQuUnwNf76wOfGadOm/k39GQeM6 if182NxuUpb0886Nb56zrA9Jvgp69b+urynAQEIMjF0f5rdTMDvUJ0Ma5y1aPAYJCvTLG/MYqrE jGtnpGHcqo8GrRSw= X-Received: by 2002:a5d:420e:: with SMTP id n14mr44738237wrq.164.1593898301913; Sat, 04 Jul 2020 14:31:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoZQ4+kKdjV7wZ7Te170gV8axwINWctID0EAxSSncar08/17BXChfDuFnemnKkw698BOnE+w== X-Received: by 2002:a5d:420e:: with SMTP id n14mr44738224wrq.164.1593898301757; Sat, 04 Jul 2020 14:31:41 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 10/16] block/nvme: Replace qemu_try_blockalign(bs) by qemu_try_memalign(pg_sz) Date: Sat, 4 Jul 2020 23:30:45 +0200 Message-Id: <20200704213051.19749-11-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) qemu_try_blockalign() is a generic API that call back to the block driver to return its page alignment. As we call from within the very same driver, we already know to page alignment stored in our state. Remove indirections and use the value from BDRVNVMeState. This change is required to later remove the BlockDriverState argument, to make nvme_init_queue() per hardware, and not per block driver. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 9c118c000d..9566001ba6 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -174,7 +174,7 @@ static void nvme_init_queue(BlockDriverState *bs, NVMeQ= ueue *q, =20 bytes =3D ROUND_UP(nentries * entry_bytes, s->page_size); q->head =3D q->tail =3D 0; - q->queue =3D qemu_try_blockalign(bs, bytes); + q->queue =3D qemu_try_memalign(s->page_size, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); return; @@ -223,7 +223,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDrive= rState *bs, if (!q) { return NULL; } - q->prp_list_pages =3D qemu_try_blockalign(bs, + q->prp_list_pages =3D qemu_try_memalign(s->page_size, s->page_size * NVME_QUEUE_SIZE); if (!q->prp_list_pages) { goto fail; @@ -522,7 +522,7 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) .cdw10 =3D cpu_to_le32(0x1), }; =20 - id =3D qemu_try_blockalign(bs, sizeof(*id)); + id =3D qemu_try_memalign(s->page_size, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; @@ -1141,7 +1141,7 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t= offset, uint64_t bytes, return nvme_co_prw_aligned(bs, offset, bytes, qiov, is_write, flag= s); } trace_nvme_prw_buffered(s, offset, bytes, qiov->niov, is_write); - buf =3D qemu_try_blockalign(bs, bytes); + buf =3D qemu_try_memalign(s->page_size, bytes); =20 if (!buf) { return -ENOMEM; @@ -1285,7 +1285,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverS= tate *bs, =20 assert(s->nr_queues > 1); =20 - buf =3D qemu_try_blockalign(bs, s->page_size); + buf =3D qemu_try_memalign(s->page_size, s->page_size); if (!buf) { return -ENOMEM; } --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898720; cv=none; d=zohomail.com; s=zohoarc; b=HnlxPIQsdJzCQ/FUBdUUh7EPCW+4fvt7sN1aVRQLoKV7D4V3JOj80GTl08Gj5G5Ckhamb+T4ozY9SuXwxZoVD3d8mJelL7zY2QrywbZOLsNbQh1nkRyIt84o+f2hqzKDGrrI68erRWG0/1XBTgol9GOGlioaOF6wb7gO1scuVUs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898720; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KMa3yNwCNdnEQnAOsKRyk2u/lQpm0dom4ME9xGYTEfY=; b=FwbwRzVzlHaaUGpfAxcaIJ7uSqBPGG6Gt7UgBlHF+ZfBS0O5Ac0xTQ/6ZDrQMy15aiymClMg0/m5bQSIxbTW1NPfsoG+X0ObkgkhnYYVFNUvFCF2qYySogQEq2NO+YgyH3HsvZ+BE6TWHbcbVItSBjs21KvOfqHNG2HJO10SWjg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898720756969.0089746055652; Sat, 4 Jul 2020 14:38:40 -0700 (PDT) Received: from localhost ([::1]:52046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrprr-0007Od-JH for importer@patchew.org; Sat, 04 Jul 2020 17:38:39 -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 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 Received: by mail-wr1-f71.google.com with SMTP id y13so36932363wrp.13 for ; Sat, 04 Jul 2020 14:31:47 -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) 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= X-MC-Unique: PXmjHMfnPO6KtDB4AFy2NA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) nvme_init_queue() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState to simplify. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D { }, }; =20 -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 =3D bs->opaque; size_t bytes; int r; =20 @@ -251,14 +250,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDri= verState *bs, req->prp_list_iova =3D prp_list_iova + i * s->page_size; } =20 - 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 =3D &s->regs->doorbells[idx * 2 * s->doorbell_scale]; =20 - 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; --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898850; cv=none; d=zohomail.com; s=zohoarc; b=cxrXCTU0W6kO7A2w3bkd3/TT/uNdZsCETpD3tdqyWH+jkr0U/MIvtaVuanJ2TiwQSSrJBLT/t36ZL1SsViVRLqM/zAaXYQ1VFIAVLYs+Vej/tJssQ11wNiGR20ZvBNAE6/NnpNldkxtS+Fstmb+Doa/t9KcX0YKIaVO1uVwSZVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898850; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fjFAluXrQqAea6BsNgoNTAhItzpMDbo69v4ixXnRHEQ=; b=YxpEJ4Dpy0HRqyA+ApgwvPFBnZZ/vTYc31O+FC6UeD+581cPO0FUTZb+bnIQTw8LBzm3HBUwFFz8RpkMB0fLE0Jqyz6SRrAe2364sFzynVUBgLQAyE8WmgNEO9W3Eu0t3tz4a9WLf8bBMc6XkvJOGuc4fbwX2hBiDc0YXW6ZD/g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898850699292.14042453178024; Sat, 4 Jul 2020 14:40:50 -0700 (PDT) Received: from localhost ([::1]:57044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrptx-0001YP-Fs for importer@patchew.org; Sat, 04 Jul 2020 17:40:49 -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 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 Received: by mail-wm1-f71.google.com with SMTP id q20so30917390wme.3 for ; Sat, 04 Jul 2020 14:31:52 -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) 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= X-MC-Unique: 8pt5tpVTPsWRYZiJbO_FgA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) BDRV_POLL_WHILE() is defined as: #define BDRV_POLL_WHILE(bs, cond) ({ \ BlockDriverState *bs_ =3D (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=C3=A9 --- 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 =3D bdrv_get_aio_context(bs); NVMeRequest *req; int ret =3D -EINPROGRESS; req =3D nvme_get_free_req(q); @@ -501,7 +502,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueu= ePair *q, } nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); =20 - BDRV_POLL_WHILE(bs, ret =3D=3D -EINPROGRESS); + AIO_WAIT_WHILE(aio_context, ret =3D=3D -EINPROGRESS); return ret; } =20 --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898862; cv=none; d=zohomail.com; s=zohoarc; b=F+0f423vH2LlAOHSQ73nIs0l0rEzPY9UbQH9SdOl8I+2rVcVsvkLTdf2CdCwU1l9dRGCNT2zAk3yZAH9Q/Jruf+fMP6AmfKKUHWArS3aeqwdkH7o/ofslIEaqAdRMMlhIKAj4Awlffqon9rTcXIkEIR1sUvtFiFL7CL72xifXAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898862; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rWF/iZSCqkrI9PNeUzMaBp9Bso6oHE9Q+64iOjLLb68=; b=GFKAHtRu5/rHJKMf5Olz9vHuUyjk/1gHFV7bNniAa5+Nq4rBx34vw1397lkIwoBVTOguJuZjytwFouTQLBYfCXKxT+tB3OFJnqS3jNT1WuQUhnuh+sx7kC+g4UJa3ZWLIziFMJdO/qajMYx+N2OOlQ941PSqrJgirhH8h6WufS0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898862567511.73338003506274; Sat, 4 Jul 2020 14:41:02 -0700 (PDT) Received: from localhost ([::1]:57794 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpu9-0001sK-C9 for importer@patchew.org; Sat, 04 Jul 2020 17:41:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrplS-0003iS-DV for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:32:02 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55717 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 1jrplP-00047H-O4 for qemu-devel@nongnu.org; Sat, 04 Jul 2020 17:32:02 -0400 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-278-h-wxi8CNNK-eXyNBa3o70w-1; Sat, 04 Jul 2020 17:31:57 -0400 Received: by mail-wr1-f69.google.com with SMTP id g14so36900868wrp.8 for ; Sat, 04 Jul 2020 14:31:57 -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 f186sm17347039wmf.29.2020.07.04.14.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 14:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593898319; 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=rWF/iZSCqkrI9PNeUzMaBp9Bso6oHE9Q+64iOjLLb68=; b=GEv9ElFH8ZEbJmWWmc2oRDr9TGW9gKhe+Lpsb9+uKgDj221++3HWBtUPnX17vjxQpuUCX5 brBJdd9kDoI+pZdgoM9+HfkfbIGBIy74XBs+r2+w0AqxkUeht+jDLiqXvtz5zY09yi4anL XhRJn5zlWjC9q5lGzZKtU5cIEVKE8mc= X-MC-Unique: h-wxi8CNNK-eXyNBa3o70w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rWF/iZSCqkrI9PNeUzMaBp9Bso6oHE9Q+64iOjLLb68=; b=D8+GWJxoxBl4RTkuMQuJ0iGZXLClf5uhK2atXyGV64FJJS1Z1ASNyD9FsrjIkXz++5 k6ENHl1VyXo2blKC1trZxory7vZy1/U/0d8SPu8AHETKE/JpPnovL5YKKgevd04u6bAa UQbPhlKEF0pUmtg/Fc9xSFGntWSIXKpwABtwWthOc/mD+5Hd32PpA/ZSwbGqoxjY5KAj 1p3em1ZAwbl351aTRb8kAnk+9N9ohJhwuu8d7r1fr6PRhOrLiD1+rwfRRfgHOWVJSM83 UHYlVTCRLImuCZKJlV6W0UfYFETbZNC1d5e7AChk4KD6U/AWa6SmpPQ/Ew8fj5RCGYSM d0aA== X-Gm-Message-State: AOAM530FfncxJclWfITKTE59ZIsYe4WP8HuPp7OVyszWmIxsOfYmL8qp C32t/M9rHrf0rgHAEnOzz61uMkfsFn8zYwkCVCZuGLcM5uzDgpO3x6S1Ek2BSOEQqxfxDzoldsC vRCwDCgSgcxeDjH4= X-Received: by 2002:a5d:6b08:: with SMTP id v8mr43930005wrw.2.1593898316089; Sat, 04 Jul 2020 14:31:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMzQXemqBEpGS2i3o6bqPBlU7wAV8G/iuaqyst6Z+WbkeyxmJtiU0uhjbA1ymr6rdzL/GPAA== X-Received: by 2002:a5d:6b08:: with SMTP id v8mr43929999wrw.2.1593898315931; Sat, 04 Jul 2020 14:31:55 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [PATCH v3 13/16] block/nvme: Simplify nvme_create_queue_pair() arguments Date: Sat, 4 Jul 2020 23:30:48 +0200 Message-Id: <20200704213051.19749-14-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.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:28:03 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) nvme_create_queue_pair() doesn't require BlockDriverState anymore. Replace it by BDRVNVMeState and AioContext to simplify. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index b2fc3c300a..51ac36dc4f 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -208,12 +208,12 @@ static void nvme_free_req_queue_cb(void *opaque) qemu_mutex_unlock(&q->lock); } =20 -static NVMeQueuePair *nvme_create_queue_pair(BlockDriverState *bs, +static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, + AioContext *aio_context, int idx, int size, Error **errp) { int i, r; - BDRVNVMeState *s =3D bs->opaque; Error *local_err =3D NULL; NVMeQueuePair *q; uint64_t prp_list_iova; @@ -232,8 +232,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDrive= rState *bs, q->s =3D s; q->index =3D idx; qemu_co_queue_init(&q->free_req_queue); - q->completion_bh =3D aio_bh_new(bdrv_get_aio_context(bs), - nvme_process_completion_bh, q); + q->completion_bh =3D aio_bh_new(aio_context, nvme_process_completion_b= h, q); r =3D qemu_vfio_dma_map(s->vfio, q->prp_list_pages, s->page_size * NVME_NUM_REQS, false, &prp_list_iova); @@ -637,7 +636,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) NvmeCmd cmd; int queue_size =3D NVME_QUEUE_SIZE; =20 - q =3D nvme_create_queue_pair(bs, n, queue_size, errp); + q =3D nvme_create_queue_pair(s, bdrv_get_aio_context(bs), + n, queue_size, errp); if (!q) { return false; } @@ -683,6 +683,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, Error **errp) { BDRVNVMeState *s =3D bs->opaque; + AioContext *aio_context =3D bdrv_get_aio_context(bs); int ret; uint64_t cap; uint64_t timeout_ms; @@ -743,7 +744,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, =20 /* Set up admin queue. */ s->queues =3D g_new(NVMeQueuePair *, 1); - s->queues[QUEUE_INDEX_ADMIN] =3D nvme_create_queue_pair(bs, 0, + s->queues[QUEUE_INDEX_ADMIN] =3D nvme_create_queue_pair(s, aio_context= , 0, NVME_QUEUE_SIZE, errp); if (!s->queues[QUEUE_INDEX_ADMIN]) { --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898950; cv=none; d=zohomail.com; s=zohoarc; b=jO16DXiXWCOAXJtlJKMP1J5BSoR/m8aX0YlsFfW95jhfB9AwjjSzw8lO83BFre8x9vgBBGmykK0P+7AEzadblsIYXdZwSI2JflSnFB3w0wjCE1r+aUogujDUiDhr2Ll+nQIA3BxtU84Yu7k2V3By93DemocQ54DglY/T0FrIsIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898950; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xumHQmie22PgCKek0cikqjiB9L+Aua1bZGi1TBEXwDY=; b=H2tfteSmM7n/PVOROZq1J/8JobHYlNStH9ogO6ZOwJT7uvYD6og37qYrhikg3VPol53ryIF1/qzeaOnNg19w/Cl4jp2Z6xO5VS8+2meEeQvj6Q+5c5pDlLdFmxsMginHrg/kEASCwbis87mew+RdEcYrFrAFQucyLUgvzJ9zHFs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898950064535.2155492290597; Sat, 4 Jul 2020 14:42:30 -0700 (PDT) Received: from localhost ([::1]:33750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpvY-0003ZO-TZ for importer@patchew.org; Sat, 04 Jul 2020 17:42:28 -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 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 Received: by mail-wr1-f71.google.com with SMTP id i14so36772298wru.17 for ; Sat, 04 Jul 2020 14:32:02 -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) 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= X-MC-Unique: x4s2x__rMJaiduv2p7hwxQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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); } =20 +static bool nvme_poll_queue(NVMeQueuePair *q) +{ + bool progress =3D false; + + const size_t cqe_offset =3D q->cq.head * NVME_CQ_ENTRY_BYTES; + NvmeCqe *cqe =3D (NvmeCqe *)&q->cq.queue[cqe_offset]; + + /* + * Do an early check for completions. q->lock isn't needed because + * nvme_process_completion() only runs in the event loop thread and + * cannot race with itself. + */ + if ((le16_to_cpu(cqe->status) & 0x1) =3D=3D q->cq_phase) { + return false; + } + + qemu_mutex_lock(&q->lock); + while (nvme_process_completion(q)) { + /* Keep polling */ + progress =3D true; + } + qemu_mutex_unlock(&q->lock); + + return progress; +} + static bool nvme_poll_queues(BDRVNVMeState *s) { bool progress =3D false; int i; =20 for (i =3D 0; i < s->nr_queues; i++) { - NVMeQueuePair *q =3D s->queues[i]; - const size_t cqe_offset =3D q->cq.head * NVME_CQ_ENTRY_BYTES; - NvmeCqe *cqe =3D (NvmeCqe *)&q->cq.queue[cqe_offset]; - - /* - * Do an early check for completions. q->lock isn't needed because - * nvme_process_completion() only runs in the event loop thread and - * cannot race with itself. - */ - if ((le16_to_cpu(cqe->status) & 0x1) =3D=3D q->cq_phase) { - continue; - } - - qemu_mutex_lock(&q->lock); - while (nvme_process_completion(q)) { - /* Keep polling */ + if (nvme_poll_queue(s->queues[i])) { progress =3D true; } - qemu_mutex_unlock(&q->lock); } return progress; } --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593899020; cv=none; d=zohomail.com; s=zohoarc; b=SV/Cl3yqixUNJSLkJ0oQKWaZEbJDOfe2l+rX+4pewgbX8AEw4zP7GmeTbMmxEo/JQfdszulHHDP8oCRAQM+BKlDKsj9t/eisMuQHc9Eb/+ZBcai7+5WD3TfA2m1xBUED50JhHiaMNFrmJpXTwGmDVKbGvSXz1oYQaqFJ8gbQ+JU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593899020; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cnx5O7cQ73298hs0R7q+tCG4DHfssKmnNLY31qyZKnA=; b=S/Urj8eB916zi5KtmmI+DiqJ99cNyNA/Tir3qIRdneuzyGRIUYw7S12IzCmbcNt0ZCSQlEoFW476fqJWnIIh0xB4fP/SlsX2CGk3iZmp02rePCf+q7YZyBdq1BL5p1jzUkoXAd6ablGgNDwz3g2tcPqC54/TS3lFjlkEXC1bW84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593899020501963.9671214665226; Sat, 4 Jul 2020 14:43:40 -0700 (PDT) Received: from localhost ([::1]:37710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpwh-0005Ep-Co for importer@patchew.org; Sat, 04 Jul 2020 17:43:39 -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 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 Received: by mail-wm1-f70.google.com with SMTP id g187so40758270wme.0 for ; Sat, 04 Jul 2020 14:32:06 -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) 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= X-MC-Unique: 42Sd_LZBMEiWoowMKcS_xQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 Reviewed-by: Stefan Hajnoczi --- 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); } =20 +static bool nvme_poll_cb(void *opaque) +{ + EventNotifier *e =3D opaque; + BDRVNVMeState *s =3D 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 =3D bs->opaque; @@ -680,15 +689,6 @@ out_error: return false; } =20 -static bool nvme_poll_cb(void *opaque) -{ - EventNotifier *e =3D opaque; - BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, irq_notifier); - - trace_nvme_poll_cb(s); - return nvme_poll_queues(s); -} - static int nvme_init(BlockDriverState *bs, const char *device, int namespa= ce, Error **errp) { --=20 2.21.3 From nobody Sat May 4 10:53:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593898425; cv=none; d=zohomail.com; s=zohoarc; b=QeWWZezyxBlVSMOepKCzoptnpgti6atdtCSsDmz323hmxASwfZexYuf36LwnaT/JKfF2ApQl50eHqLJC5dTfyqT93ejznlgDzi4bw3ipueM3vx9TA8Dm3Qe43SLqbnXfx8+acEgsVm7xxivYV1JgV0/IBefIiNfjzMLdrmUPRn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593898425; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZvMbUnGJQt3yoRlltFf6Mt/5GWmmjKBAstpoETHPIqo=; b=VK2dhuRNbQckLk1idY7VKm04F3+BMu9hyt91E0Dw8osTkslvvUVoDXlB9jmDwi7HDoiLiAQjzh9yIh/UXK+jSSKgs9K57zKFEGFopdBEWOt4Ly0W4vJfOHjpVPEdx77RrznROKmoRlaq0MC+BhDmyuakB0r98bwkir1grr4Y8+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593898425865879.8213476864767; Sat, 4 Jul 2020 14:33:45 -0700 (PDT) Received: from localhost ([::1]:32944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrpn6-0006Ga-IJ for importer@patchew.org; Sat, 04 Jul 2020 17:33:44 -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 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 Received: by mail-wm1-f71.google.com with SMTP id h25so23696569wmb.0 for ; Sat, 04 Jul 2020 14:32:11 -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) 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= X-MC-Unique: ztPYlj5NMGiYjNzwbqv1CQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=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) From: =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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=C3=A9 --- 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 { =20 typedef struct { QemuMutex lock; + AioContext *aio_context; + EventNotifier irq_notifier; =20 /* Read from I/O code path, initialized under BQL */ BDRVNVMeState *s; @@ -107,7 +109,6 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) !=3D 0x= 1000); #define QUEUE_INDEX_IO(n) (1 + n) =20 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; =20 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(BDRVNVMe= State *s, if (!q->prp_list_pages) { goto fail; } + r =3D 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 =3D s; q->index =3D idx; qemu_co_queue_init(&q->free_req_queue); + q->aio_context =3D aio_context; q->completion_bh =3D aio_bh_new(aio_context, nvme_process_completion_b= h, q); r =3D 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 =3D bdrv_get_aio_context(bs); NVMeRequest *req; int ret =3D -EINPROGRESS; req =3D nvme_get_free_req(q); @@ -501,7 +506,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueu= ePair *q, } nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); =20 - AIO_WAIT_WHILE(aio_context, ret =3D=3D -EINPROGRESS); + AIO_WAIT_WHILE(q->aio_context, ret =3D=3D -EINPROGRESS); return ret; } =20 @@ -616,47 +621,35 @@ static bool nvme_poll_queue(NVMeQueuePair *q) return progress; } =20 -static bool nvme_poll_queues(BDRVNVMeState *s) -{ - bool progress =3D false; - int i; - - for (i =3D 0; i < s->nr_queues; i++) { - if (nvme_poll_queue(s->queues[i])) { - progress =3D true; - } - } - return progress; -} - static void nvme_handle_event(EventNotifier *n) { - BDRVNVMeState *s =3D container_of(n, BDRVNVMeState, irq_notifier); + NVMeQueuePair *q =3D container_of(n, NVMeQueuePair, irq_notifier); =20 - trace_nvme_handle_event(s); + trace_nvme_handle_event(q); event_notifier_test_and_clear(n); - nvme_poll_queues(s); + nvme_poll_queue(q); } =20 static bool nvme_poll_cb(void *opaque) { EventNotifier *e =3D opaque; - BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, irq_notifier); + NVMeQueuePair *q =3D container_of(e, NVMeQueuePair, irq_notifier); =20 - trace_nvme_poll_cb(s); - return nvme_poll_queues(s); + trace_nvme_poll_cb(q); + return nvme_poll_queue(q); } =20 -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 =3D bs->opaque; int n =3D s->nr_queues; NVMeQueuePair *q; NvmeCmd cmd; int queue_size =3D NVME_QUEUE_SIZE; + int ret; =20 - q =3D nvme_create_queue_pair(s, bdrv_get_aio_context(bs), - n, queue_size, errp); + q =3D nvme_create_queue_pair(s, aio_context, n, queue_size, errp); if (!q) { return false; } @@ -683,6 +676,17 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Er= ror **errp) s->queues =3D g_renew(NVMeQueuePair *, s->queues, n + 1); s->queues[n] =3D q; s->nr_queues++; + + ret =3D 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 =3D g_strdup(device); s->nsid =3D namespace; - s->aio_context =3D bdrv_get_aio_context(bs); - ret =3D event_notifier_init(&s->irq_notifier, 0); - if (ret) { - error_setg(errp, "Failed to init event notifier"); - return ret; - } =20 s->vfio =3D qemu_vfio_open_pci(device, errp); if (!s->vfio) { @@ -784,12 +782,14 @@ static int nvme_init(BlockDriverState *bs, const char= *device, int namespace, } } =20 - ret =3D qemu_vfio_pci_init_irq(s->vfio, &s->irq_notifier, + ret =3D qemu_vfio_pci_init_irq(s->vfio, + &s->queues[QUEUE_INDEX_ADMIN]->irq_notifi= er, 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); =20 nvme_identify(bs, namespace, &local_err); @@ -800,7 +800,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, } =20 /* Set up command queues. */ - if (!nvme_add_io_queue(bs, errp)) { + if (!nvme_add_io_queue(bs, aio_context, errp)) { ret =3D -EIO; } out: @@ -869,12 +869,14 @@ static void nvme_close(BlockDriverState *bs) BDRVNVMeState *s =3D bs->opaque; =20 for (i =3D 0; i < s->nr_queues; ++i) { - nvme_free_queue_pair(s->queues[i]); + NVMeQueuePair *q =3D 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); =20 @@ -1086,7 +1088,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriv= erState *bs, .cdw12 =3D cpu_to_le32(cdw12), }; NVMeCoData data =3D { - .ctx =3D bdrv_get_aio_context(bs), + .ctx =3D ioq->aio_context, .ret =3D -EINPROGRESS, }; =20 @@ -1195,7 +1197,7 @@ static coroutine_fn int nvme_co_flush(BlockDriverStat= e *bs) .nsid =3D cpu_to_le32(s->nsid), }; NVMeCoData data =3D { - .ctx =3D bdrv_get_aio_context(bs), + .ctx =3D ioq->aio_context, .ret =3D -EINPROGRESS, }; =20 @@ -1236,7 +1238,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDr= iverState *bs, }; =20 NVMeCoData data =3D { - .ctx =3D bdrv_get_aio_context(bs), + .ctx =3D ioq->aio_context, .ret =3D -EINPROGRESS, }; =20 @@ -1286,7 +1288,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverS= tate *bs, }; =20 NVMeCoData data =3D { - .ctx =3D bdrv_get_aio_context(bs), + .ctx =3D ioq->aio_context, .ret =3D -EINPROGRESS, }; =20 @@ -1379,10 +1381,10 @@ static void nvme_detach_aio_context(BlockDriverStat= e *bs) =20 qemu_bh_delete(q->completion_bh); q->completion_bh =3D NULL; - } =20 - 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); + } } =20 static void nvme_attach_aio_context(BlockDriverState *bs, @@ -1390,13 +1392,11 @@ static void nvme_attach_aio_context(BlockDriverStat= e *bs, { BDRVNVMeState *s =3D bs->opaque; =20 - s->aio_context =3D new_context; - aio_set_event_notifier(new_context, &s->irq_notifier, - false, nvme_handle_event, nvme_poll_cb); - for (int i =3D 0; i < s->nr_queues; i++) { NVMeQueuePair *q =3D s->queues[i]; =20 + aio_set_event_notifier(new_context, &q->irq_notifier, + false, nvme_handle_event, nvme_poll_cb); q->completion_bh =3D aio_bh_new(new_context, nvme_process_completion_bh, q); } --=20 2.21.3