From nobody Sat May 18 12:05:11 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=1597942811; cv=none; d=zohomail.com; s=zohoarc; b=m/gAdmlr9OIQ/i1v+4raDMjh3Sl0AIFHd95QqKgD9ZNWtksbtnYzt8qImcJJ43Ie75oQXdmQKqhegjycMd2uBzARpX1/9EswYHDw/qiN7Xj9t8IqjvWLhgdvUGERQjeTdIetK0ismq2EqqUxBM/WSGdhnv4PAnCEhFNEicM9+ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597942811; 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=rHEDYeSrjvvdM00HU33Jyl9/4zi6c/EmJ9icWxpRyDY=; b=bMxyGMSi3MSEqjzwUxjDXXGwrykiJx06rk6E9KQmSpgDuFJcLJ52IMJsd6N1FoTKoFxUmts6214yUspBf7BbhJOodsVGwSHl+xi6+Z96yqLD4s2NVe5s5kAnK6xT54TvRSE6s7IZTn0CLejRXw2PtaoLLWC1hNTFNWcnncItpN4= 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 1597942811762968.0030379355932; Thu, 20 Aug 2020 10:00:11 -0700 (PDT) Received: from localhost ([::1]:48496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nv6-000489-UW for importer@patchew.org; Thu, 20 Aug 2020 13:00:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuE-0002fT-L6 for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:14 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:55728 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 1k8nuD-0006A4-1u for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:14 -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-191-2wEAvMIbM82AEPYnC3vkGg-1; Thu, 20 Aug 2020 12:59:10 -0400 Received: by mail-wm1-f69.google.com with SMTP id z10so995213wmi.8 for ; Thu, 20 Aug 2020 09:59:10 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id n5sm4967691wrx.22.2020.08.20.09.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942752; 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=rHEDYeSrjvvdM00HU33Jyl9/4zi6c/EmJ9icWxpRyDY=; b=AoRZjnJ0urMnf8AXnnBwIIjjC1GqLgLQqSoyivcyEf4hwNGx6xXKL3J0uJ1CCtOwb3qoMu fQgkjUjC/nFlMYIUIt0ZqNNpboPK7iXI6+9Cja+SJ0FzFQXqlerXpuxgGMbma2xlKcxBGz rDYVDwMSzm/lGnfjUpLHLIqRHLUaKEY= X-MC-Unique: 2wEAvMIbM82AEPYnC3vkGg-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=rHEDYeSrjvvdM00HU33Jyl9/4zi6c/EmJ9icWxpRyDY=; b=oM1cvfZE9bjvJ/RpVo3K0aG0p6w6D7ofIc2YNl0mFKDXO0uf1voAA3IqPMt0TBLX5w b8R1brTxzBMP7H9VZzQEj2ZMn9w4OgMKoHDqQUUJ7Z+3Eds2HdIhtMM7fG/rIEoRyJYn 6G8+C7yYLDdhwVCbFUg5Ty+h5yLq5EG7mUni6i3HgaGDLrZfunf/25RhsDELapOf7ZoH wO575ZpgP+v03ei+HYUCW0w+AHCE4FaTTYFE9ZmSOaSC9CHSl9CzRPHxpwPyZVvSu+jo 1NDS8CKFqcwqo19WI9zPmO/pAj9fFCHkXtPgwXRzbuzXbwWTR/Uwn36ubQX5odyps2jq wgqw== X-Gm-Message-State: AOAM533jS1DgmRoaq9TtgLZcDcq90VRAHMZgtNVP0yDu/RoV6Ec4pPKt KoIENBRihfy1HJplGvIjI1ZkWg/QMI7ed6Eae0Rv859r5FCgGqyceIxAnR3jTEnkPg4He+7C9LV Y8J8DmTQnvJ8d308= X-Received: by 2002:a7b:c38e:: with SMTP id s14mr4311870wmj.124.1597942749095; Thu, 20 Aug 2020 09:59:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ1+7nSnEuUcdp2mGQLt76o7rxF/UHkHpx7JEeHP81SvccPF8tsRDQtgOGenvWRH+SuFP1Cw== X-Received: by 2002:a7b:c38e:: with SMTP id s14mr4311850wmj.124.1597942748903; Thu, 20 Aug 2020 09:59:08 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 01/15] block/nvme: Replace magic value by SCALE_MS definition Date: Thu, 20 Aug 2020 18:58:47 +0200 Message-Id: <20200820165901.1139109-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/20 08:28:03 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 374e2689157..2f5e3c2adfa 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.26.2 From nobody Sat May 18 12:05:11 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=1597942830; cv=none; d=zohomail.com; s=zohoarc; b=VFDQlbAFszFiwEJ8YKy/CdtgyQ49rJAB1tgShTOIWkzQTVLJj0gB5HIShN2b/qmVclrjAQrX/Y2bqztrAYLM/yT7A5STVN4KblesXfJC9q1bRW5ytalZK+egEKWLcJmT77n/7pdmHFPlxAwzBOqIlYaMo+FWkXbecH6qpqCaYAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597942830; 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=969biaX/G7f1D/6G5QoxlHmmKW8KQsbMUTT5iH7LPeo=; b=CPFboASMfG+0pMdF8M+1jUNMuBjgbHUDBVcNuxauYbc72e7fJ6KbmCibHn9HWhckJJ8MXNvze+tRozpMsVU8OSof+QMmzRmzWqkUPx5hUQ/ABSksq/OeM8oCI6egctJxdxyx7AxfYc8HffKU56VNG7oTyYM581jqgL5DUtiP//c= 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 1597942830708947.4967980265027; Thu, 20 Aug 2020 10:00:30 -0700 (PDT) Received: from localhost ([::1]:49562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nvQ-0004a0-2w for importer@patchew.org; Thu, 20 Aug 2020 13:00:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuL-0002rj-9Q for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:21 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:45968) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nuI-0006Bk-CW for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:20 -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-3-aFmcf4dPNzSxntWvncaNCw-1; Thu, 20 Aug 2020 12:59:16 -0400 Received: by mail-wr1-f70.google.com with SMTP id b13so858856wrq.19 for ; Thu, 20 Aug 2020 09:59:16 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id g70sm5873153wmg.24.2020.08.20.09.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942757; 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=969biaX/G7f1D/6G5QoxlHmmKW8KQsbMUTT5iH7LPeo=; b=gICMijik9Gxjerw5fl0/huO5++3bfxnwVN+PjvZbJ+8dkEtNNXvs9F8dK9K2chYucZdOCr G53QPLm7UmQVVthRRLse+BQfbspeS5gP5lZ4E8kmQWg0IOab9LlBLVO1CJtqA94xBWZqM8 BZmey4zfjxu6zgPerLeRP668F57aIlY= X-MC-Unique: aFmcf4dPNzSxntWvncaNCw-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=969biaX/G7f1D/6G5QoxlHmmKW8KQsbMUTT5iH7LPeo=; b=AqiLG3Hy12dJywZ//3v06umtJq+fW/VMvNTjzVssS3PrP5yss16PgNo3rknzSsR5hs H6NSY/Wu7VUADtSRXIHmJkEQKqdVf+JpZjrJWD6ieAzZ9gyiV3kU8D7UgoBbycs/0Gaj K3w81ZqgnJ164f+mwWQs+XgssZ9csPvHrHpSwc+EaSqsHcUg5rt8knIA0rOPuJR0Yfj7 +/zD3T7nuQnXZZvlXjYwTn0jjDffXg7DfM3O5CsYdHC9kHxRr2/dHHpVo2JmFsLEwpwd dvqBR62WlzkNXen5LvDqquhd/U0m7SCiF/1ndyicT1t8abMz1i/YNKx5HvCTnZe89jbb nu7w== X-Gm-Message-State: AOAM530yeMXEWpQrTQEPBwiDfYG0Q+G1itEO4HAkXonzWl9SkxUFw/RR zyFo/5yBSQTpEPgk75VJGtz9mOpY1HO2aVKwgEyTiVbf04Ypi2dPIvS2M8vIZvOwCJ7CvT6r4l7 ZC9gGU5DcAYyf+64= X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr4527093wmh.144.1597942754949; Thu, 20 Aug 2020 09:59:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpAZRQsucfAlWmgf3Z92nfj1GPVqihI5RimRNPIm7nB2a2UeIIZIehaKoQs0Jjx0Ang7SPdw== X-Received: by 2002:a7b:c0c5:: with SMTP id s5mr4527082wmh.144.1597942754736; Thu, 20 Aug 2020 09:59:14 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 02/15] block/nvme: Avoid further processing if trace event not enabled Date: Thu, 20 Aug 2020 18:58:48 +0200 Message-Id: <20200820165901.1139109-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 2f5e3c2adfa..8c30a5fee28 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.26.2 From nobody Sat May 18 12:05:11 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=1597942862; cv=none; d=zohomail.com; s=zohoarc; b=Sosdy58zn2XpLKK0pR+ySIyLjUibgXZpYdog2+f1ODq0GJE52JqKbKvRBEDqq+D2DtcTlSYLXwB5jJeUO3AnAYHj3Q2xRmJcZYwxRZShUmqDG+VKKMRIS73orAIFgh/YOlG2sgA2usxtfh1HnnuHKVk+Cj6lMxdvZy15rJNJaQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597942862; 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=KbIetA1xjsM5ok0/Mv80e7mGjv4Ge5UwAtigSYtZimQ=; b=ToMWzKuYFWmFfRU6ucSNemxfhNqskC1QBAwmxVcQq0n5e1PUhCPLvMQxBX4J+cVovivuwT7+4OxJwo2/CQsxJv6n5vLA9Ox+vacpOYmh8C+hJH4LT9lKniH3hFEk+2Yjkjei4MKCTw+T3fOzYk+eMMTVzztHZZcAdmQ+T9EfJL8= 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 1597942861834209.08860015335324; Thu, 20 Aug 2020 10:01:01 -0700 (PDT) Received: from localhost ([::1]:50590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nvv-00050M-1b for importer@patchew.org; Thu, 20 Aug 2020 13:00:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuP-00031A-U6 for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58769 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 1k8nuO-0006CY-Bx for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59: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-416-Q_UtJ66KNHS6glteT6tsmg-1; Thu, 20 Aug 2020 12:59:21 -0400 Received: by mail-wm1-f72.google.com with SMTP id q15so997906wmj.6 for ; Thu, 20 Aug 2020 09:59:21 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id v12sm5191196wri.47.2020.08.20.09.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942763; 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=KbIetA1xjsM5ok0/Mv80e7mGjv4Ge5UwAtigSYtZimQ=; b=dJrusOAzkyM/PL3nr5u3hWpqyHng2qL98SQiXJ28TTPM2JSc7thiEBqdtCiWnO5o/mr69L QNB4LTWdg8VTLXqHM2QAptPj23jJvGYkrVh0aS47ddxAZMWN1MlFqOnJyTNRaIbcJEdOzo TZmyCFFL824SX/O6PdPF6FEmy0Ll9JM= X-MC-Unique: Q_UtJ66KNHS6glteT6tsmg-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=KbIetA1xjsM5ok0/Mv80e7mGjv4Ge5UwAtigSYtZimQ=; b=lCh7beFyijgMP1MpUFGwBWYvCmyoGp3QmH9U5zGdFRDYLlGR04RvR0o+aZLoLXsgxu icxhJpZhIk9Kx4uB1LEWuTec86firw3fEMciJYkv27+GbiVGktRXZqM70LuRCjUD0YOU 5+Om599yqhXxid4JgKznl74Hn6LHZR3IQGec5dfo0HC1HKQ1IrukhC+BGaqQEF0v39e9 7hcGCLW1HkzwGoZjs59IgVWMf/ivh5FhJRa03CwEEdM5QHFHOjc/VPNuhZPYQarq3ovK MVJBtRxmStbGNC6jem8Kr1xPZp64VhHKFwaV3JShaoGWEpK/oN6U0hEay2ditFlQsnon aHHw== X-Gm-Message-State: AOAM5338X9xKANij5JdS6VTzMxjeuSOaf7mWOPLvwVvzSvxHCAQPtabh P8HIlbIgXFfbxCMXVWKIE5E71wsO7ptnRDBvXW9yT5frDi+o7ltSehug8iEdSzdolErXpUcaYFg oEKoSHLL/duPiUQw= X-Received: by 2002:a1c:e0d7:: with SMTP id x206mr4705432wmg.91.1597942759905; Thu, 20 Aug 2020 09:59:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfhuXkork9oCk1z5RQZ1T4jotPzmNRJLdwynYwdl8g2pK77ZGpr5Q92AuP+5OB99ZYNQix/Q== X-Received: by 2002:a1c:e0d7:: with SMTP id x206mr4705415wmg.91.1597942759770; Thu, 20 Aug 2020 09:59:19 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 03/15] block/nvme: Let nvme_create_queue_pair() fail gracefully Date: Thu, 20 Aug 2020 18:58:49 +0200 Message-Id: <20200820165901.1139109-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/20 03:03:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 8c30a5fee28..e1893b4e792 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.26.2 From nobody Sat May 18 12:05:11 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=1597942981; cv=none; d=zohomail.com; s=zohoarc; b=Ouc3wBv9gzth9EbmgM5Z3iDK0wfShXXbJtW9i+S7kB3lLf9ZL87ooSbJUUmfpV/UApVIX8X8IkcKjYxTJXyKfVa3PhPVXcDa3O6r7VxY9a4vFUvDuWWp0TQ1v7Io26SKDEaNRD8GZfTuWFQMLnLMGk8WDbegoRZa9eHHSb62uXU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597942981; 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=Dgozex87UGEBPqf+gR831D6Ko3iS5NgJedUVEUZWtuc=; b=Qc5NxoOjkwL2nR0J22jWoc8n2hF/NKQ5aN8ZA1PvKe+qk+4d13VD3O1UMC5K5NE6Ufgsx5mvFugWJtDLxl4c2LK5zXtumb3EodtYdl7xkpOMqh6TxTJ4ujjjg4LglcS+8lpLxjwNVGsG7fYo75SGBfgDFNBa0/xsMD536TltVeM= 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 159794298159448.86790541217056; Thu, 20 Aug 2020 10:03:01 -0700 (PDT) Received: from localhost ([::1]:58168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nxr-0008DS-E1 for importer@patchew.org; Thu, 20 Aug 2020 13:02:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuV-0003Hp-LV for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51399) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nuT-0006Ct-Js for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:31 -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-532-JJjDNG-iPOuvQ6oc9m02UQ-1; Thu, 20 Aug 2020 12:59:26 -0400 Received: by mail-wr1-f70.google.com with SMTP id z12so858723wrl.16 for ; Thu, 20 Aug 2020 09:59:26 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id x14sm4919186wmj.37.2020.08.20.09.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942768; 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=Dgozex87UGEBPqf+gR831D6Ko3iS5NgJedUVEUZWtuc=; b=PMSw4xuv2ygqEYP+PUcPeSt95ElqwZElznpohnAmGmP6qwor130JZmdjt8RhZFbkf6wvWf yRlE0vx585RGobk1DZiWMQABQOUufOQY9buSsRdGsMfbMYIPhKNb2WR5jaJA+759GXrdrh vRAphPqypQ63xafEPYXPAplxEXnFzJQ= X-MC-Unique: JJjDNG-iPOuvQ6oc9m02UQ-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=Dgozex87UGEBPqf+gR831D6Ko3iS5NgJedUVEUZWtuc=; b=rKyp0vQX1BzW9vyZM5Urii4SCLIoYVnPwEK/eNh7sVPBcd5t1ebtk5l+UwGzTMMlYG 4r641902IgDBg0gn3qWPZJs+II5gQCmeYQIIYbYnuOC9lpB63R24VOSrR0LmvQ/RolSe pCiBA7vOHJRgJoXmFDCQiC50dw/PKELj16Er9PtjoBdR6r3lJkuujeiEeDxFuaFEQjfa ws72X08lcpZk6SfI/DMgNKlOzAVqWbZlI7iDWIx4T6VxdcNPX3yQUIqOhFHDBrzSIwXs MHvh6bpv3SBN6L2QMGk4+pJtm9ZICoWieAODxX8rewucdGhihDtUIDZEkVCWS44NOJA8 VLgg== X-Gm-Message-State: AOAM533KoYTeLB3E696AK2F7uaKmBcEcPvLC3Z3K3HIPbS/Lwnt0YaQk c5K8/LfVUjderodWu8nFSCdSwAhOGr2W8z8bhi8nTfY7TnCuuIqC5uKLmZ6w1vKaShyZSoSjRTB UxxMtZo9wnSUWtJY= X-Received: by 2002:a05:600c:24cc:: with SMTP id 12mr2908466wmu.117.1597942765140; Thu, 20 Aug 2020 09:59:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaQSYqByxobBWSOTrsdyXm6YNy5kX0Ot1YHSPhgI08QKhZoy7GV/vtL/IGVCmYH1Bn/wZFyA== X-Received: by 2002:a05:600c:24cc:: with SMTP id 12mr2908445wmu.117.1597942764897; Thu, 20 Aug 2020 09:59:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 04/15] block/nvme: Define INDEX macros to ease code review Date: Thu, 20 Aug 2020 18:58:50 +0200 Message-Id: <20200820165901.1139109-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/20 09:00:23 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index e1893b4e792..003809fbd83 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 INDEX_ADMIN 0 +#define 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[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[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[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[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[INDEX_ADMIN] =3D nvme_create_queue_pair(bs, 0, + NVME_QUEUE_SIZE, + errp); + if (!s->queues[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[INDEX_ADMIN]->sq.iova); + s->regs->acq =3D cpu_to_le64(s->queues[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[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[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[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[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[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 INDEX_IO(0); i < s->nr_queues; i++) { NVMeQueuePair *q =3D s->queues[i]; qemu_mutex_lock(&q->lock); nvme_kick(q); --=20 2.26.2 From nobody Sat May 18 12:05:11 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=1597942968; cv=none; d=zohomail.com; s=zohoarc; b=XRib2KtO9TMOzSuyO4Ja1HJvFPGqwxx4IkT68/XWP9WVQME8WpF+IU6A8RnhYxyYiviOJM3YYFOAGQvIzObCAnt9MJGwRgmjkoAi/8g0mfdCdsFJD7WbhtjquhiTbfYaFmkEdfSODBF87YyuaJ9kNPqDewGdTJJ8ZdL7er4fcAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597942968; 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=xMDzywp//OugMrKjSizTC3WTyFIJ7uQWbux4Y7eWkQY=; b=mZ8v4qYgQNVifhUpCz6Pjjv8h7XUZCyhE/DhSRKsC4h0mVmp+LVahqGoNVidlJ9/yQZemlI5oA7Y1wzp9s5FOaFPg707vkT9pu5VIkOw0hw3kZZhf+UTnqUFPCxHVyLtCJ/DsLl+3Xlbi3R8MTd/NluoBnw5S8ac0T/dlHjkJDc= 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 1597942968379685.8261375103199; Thu, 20 Aug 2020 10:02:48 -0700 (PDT) Received: from localhost ([::1]:57060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nxe-0007kW-Lu for importer@patchew.org; Thu, 20 Aug 2020 13:02:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nua-0003VK-AG for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:36 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:21625 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 1k8nuX-0006DH-Np for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:35 -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-200-dY8FWrNnN9eTG7CwsF4nOA-1; Thu, 20 Aug 2020 12:59:31 -0400 Received: by mail-wm1-f70.google.com with SMTP id u14so1941791wml.0 for ; Thu, 20 Aug 2020 09:59:31 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id j4sm5136932wmi.48.2020.08.20.09.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942772; 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=xMDzywp//OugMrKjSizTC3WTyFIJ7uQWbux4Y7eWkQY=; b=HRB/u5DDJLJNVgnnSJRdSYTdJMXUWgSJNBUrzQTW6fEs0u1KMWTnXUX9QkVknACe2+VXHT mw2OeyXQ644cy3zdPfTJxKCvDoWpkCTHfistWBKgCN+YuAXbxUM3Eo0Ha/guV8X8MM6RE1 7Am6TWU0f6QmV42M50cR85+4VUqfpBw= X-MC-Unique: dY8FWrNnN9eTG7CwsF4nOA-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=xMDzywp//OugMrKjSizTC3WTyFIJ7uQWbux4Y7eWkQY=; b=rumhFKVe1rqq7nx50A4Pox7PV/wGtUhs71KSxTTnsdMu2+RQrsicjA7FpfdFmd/Gyj mAT+u2v4cduqrdFJJa48DCX+xf4BKZlt/hL4TdcqK/aCtMfKyx7u8+8/37kOnQWWDxea rkCXIp+tvS+2lCHbu5hMNyzM95JeuXspIpUoWClhJr7SxBne4t4jQ8m3KJwCcgUgKmXU 0X2lXMFvBeOOYygj62cAnyjrEHhyS4/KKaC73GWbveqLXODhlAz+DL+jviSB8jl3qN21 /EBhzLlONGL7gTm5sWYD2PK+hvtvEjPK0eLhrx/SbYoTXPCFYrzhH0SaXfhSxgomuvpC pLyA== X-Gm-Message-State: AOAM531fuqhyZXSOanfbGeHRYPsR8q801Oz0D73JbpKMZ4PcgCMBOUlg maLM9GnreTbl0s3S/7rliIqEFvLn1wTDqG+uJ7rTPy4XwPgkPg5EvdtIg5NWRNV8Y/otXWCvEzV QMSXae69MagjsV+s= X-Received: by 2002:a7b:c401:: with SMTP id k1mr4259211wmi.18.1597942770038; Thu, 20 Aug 2020 09:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIlDAdqewr7poOXewRpVpML2nR7umyFdrOqfMoM0E+zIsKaFM90r1HpKBZxKX7NTWwSS9XKA== X-Received: by 2002:a7b:c401:: with SMTP id k1mr4259203wmi.18.1597942769906; Thu, 20 Aug 2020 09:59:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 05/15] block/nvme: Improve error message when IO queue creation failed Date: Thu, 20 Aug 2020 18:58:51 +0200 Message-Id: <20200820165901.1139109-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/20 03:03:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella --- block/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 003809fbd83..53448b7d230 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[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[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.26.2 From nobody Sat May 18 12:05:11 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=1597943086; cv=none; d=zohomail.com; s=zohoarc; b=JaPJ62UBgCsxALzlNKzsoQme0ORXAO6NrYdBb8qVHtt5pn7rtA+rm51xtTZrkmL50jlEOtcixQdbNAzA59+BkOw86NFMybJBGZw2+gg7WkySzJf+sr/G1w7X5b0VfyPNQUN2XQwzxl1GQjTVEaYKaEEABZNe6I/tzZmLFuK7bGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943086; 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=QyQg0f8W8M9I/uKJA3ih2AcbkHq7TajNoPXSDgqGq4I=; b=KgipCJQsdbTzxuOAyQGck3ARzyfEIES5XyP+fw5e381KqnOYYzYZfDXyxdFD0EqsW4ff9cYZgTHJegZByvKOyNgmHh3qJsF7GeI0YJnGAiJ17P8fmAwgNiq37K8j5B4OoYkiOVIDEPcvT7wl/CEU3dA/a4hMXDSoy0bzFAgaZ4E= 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 1597943086719890.9381012610744; Thu, 20 Aug 2020 10:04:46 -0700 (PDT) Received: from localhost ([::1]:37960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nzZ-00031F-DP for importer@patchew.org; Thu, 20 Aug 2020 13:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nug-0003js-2G for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8nud-0006Dc-88 for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:41 -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-495-vha2TIT5P8eEXpSbskUbqw-1; Thu, 20 Aug 2020 12:59:36 -0400 Received: by mail-wm1-f70.google.com with SMTP id d22so1006094wmd.2 for ; Thu, 20 Aug 2020 09:59:36 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id o125sm5413165wma.27.2020.08.20.09.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942778; 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=QyQg0f8W8M9I/uKJA3ih2AcbkHq7TajNoPXSDgqGq4I=; b=Il/zBo9ZrqRuyvdXYWFkYvSxrh18wI4SyXttKzt6AIUNGc2P/+qCjorU1A4i6qMX3NuetZ joUntxHIPK2HWNopPqyT7xGpl3znsx1Y4DDPS4Tm7DEl2S+nh64CXBqpR2Kbr9i+iTs2dZ tZD5M6CGeQikYaOBpZ67i4zBpN+ejQw= X-MC-Unique: vha2TIT5P8eEXpSbskUbqw-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=QyQg0f8W8M9I/uKJA3ih2AcbkHq7TajNoPXSDgqGq4I=; b=aPbfLyTNge1E8qJ7x0Gj6F2QUWEV6SXGoV7C/0kh7QaU2o0VLIUO+0uuIu1xIECmPH Wxb2NGyifxpRvzwnJQBvnIEknn/bhFK9dLIRBvIpSeMrbxkqm8TUeBn2gxr0uPdbqlmi rNEow7Rsb91kMN2wDj1h15utTE91n386K02JKvadNM0Mfzxh7d1eq74Msvu8IjYoeSGo w6rZR2qbkRhL4XgZTHhZD/S1O4G1cFhP5OI3AizSpgmg77WINlYps8F9hj9KWvoiUcvZ vp/99MzgmtPyYf/iyMYxnRxkzFaeUB+FBy9rhXQITyAo2lhQFFVzx34k3Ktq/pBrqB3y 7Y/Q== X-Gm-Message-State: AOAM532EUlNBvi0YBwP+jyLUogTae5ZCv0jyl4fwN+n0jwWGwsGBjUdM vr2oaB7jcTet4NYzTHzJD2+Fq0h3QEGd6O4eU44lnYVgADI1evvkNBT4m7msBkHTTfYkIM7QLXm diM90lRinGVqDvaw= X-Received: by 2002:adf:fac8:: with SMTP id a8mr4111289wrs.368.1597942775259; Thu, 20 Aug 2020 09:59:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydMsAUhYQbfhGtVA5j/dvyfPGyX+ZXJ2dmEgjyQE5ING4JH30IKSDnuP94sT2fxWnFq3Ngdg== X-Received: by 2002:adf:fac8:: with SMTP id a8mr4111278wrs.368.1597942775110; Thu, 20 Aug 2020 09:59:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 06/15] block/nvme: Use common error path in nvme_add_io_queue() Date: Thu, 20 Aug 2020 18:58:52 +0200 Message-Id: <20200820165901.1139109-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/20 06:28:30 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella --- block/nvme.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 53448b7d230..3101f1ad55d 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[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[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.26.2 From nobody Sat May 18 12:05:11 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=1597943045; cv=none; d=zohomail.com; s=zohoarc; b=Qp7KI1MryjhcbFCUDnifMU4q6ABYQIx7yKTko2vlqBIK9BLQvKniNKfxUWYsuXWCcvP/YYtZcWBkzdq3Ff67AinP4MTD/ONLlAjssdpjUDDKvuintearTqMFD9nFBqqOoLxqDFL6ly4lis7wrDsBxn73ow/iCJpLcPKKpEsaui8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943045; 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=NKc50BIrrP5rch9WHJ6NJlXLamMISYumaOhjTxgnFao=; b=WHDrTihkZ1rFX4aj/gnFzEfEQNf2Ptjf5jprsGb9TVkGTIF05WlndgZ/QtU6DtbtI8fLLOQTLUkVgpL2eOGHnFQjbuq1LilQ6RGH9RPt/1RVOqlTvMHZhq10j9rbf/0GuBTUlx/M5+wXwnZNPGXhonO6QRuI5qWJjO1TmGNpThw= 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 159794304541349.93818620504214; Thu, 20 Aug 2020 10:04:05 -0700 (PDT) Received: from localhost ([::1]:35314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nyu-0001wi-5l for importer@patchew.org; Thu, 20 Aug 2020 13:04:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuj-0003tv-St for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:45 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:20941 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 1k8nui-0006E9-2w for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:45 -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-257-RZyDiQK8NkaeNqIOfiVgKQ-1; Thu, 20 Aug 2020 12:59:41 -0400 Received: by mail-wm1-f71.google.com with SMTP id b73so1010205wmb.0 for ; Thu, 20 Aug 2020 09:59:41 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id w64sm5977018wmb.26.2020.08.20.09.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942783; 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=NKc50BIrrP5rch9WHJ6NJlXLamMISYumaOhjTxgnFao=; b=iHQLRbw6LiAkf4dxUbr2marWfHumGg450DMysK1KDhWIbA43rwQGGMX7sh9aDc39LT4p8n YqPp5RNzuv6tyl+8BONnIWvjJ8NfrW8OgAV3dGkOv1skXPPzQtvW1MOaYgmBWtFebLaKDI TV057vdp1tHe1mCxJspB5AchNVY814k= X-MC-Unique: RZyDiQK8NkaeNqIOfiVgKQ-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=NKc50BIrrP5rch9WHJ6NJlXLamMISYumaOhjTxgnFao=; b=OpUvPLwsF4LU/hxn2RLC5opwUzkOCmbRW5wSFMvhnRej9b537Rb9Jvr8SCwK/f+c0H sKg4h3ehQ3LX3DmSUy1MQK/VxhDJELJkSlm50kMJbK1ObozfyaRwyJytCQOZQYaCgmg2 DI4Y08bc0UUHMOKwwr9pg2f9NKGqoShOVRp5XZthn+hr4qY2vGLXnX8mSpFseikaNdSD ulT/PP+8UsrPMfo3saWAxySYvvFbwtyLfx96o1xz6+vQVZrJazNaAuocS1cUe6wTfFTC fpR9fUpTXhWfhhAn7KbV4jdlCMswUGkb+88IUdki9ih7e6iBlTgsdfsCp9wKR+KeNRNO Nmmg== X-Gm-Message-State: AOAM532CSePRTDe8ZDIfjv3AFgcbQzrq7NTnXNzXhEU6cyAabNrtWEKs ed7Mxl33gSG6RXzIv0a2VoHAAhH+XYqbJnvrR8GcvQmCvIOWDGcaNYLM7aCchGsFsHZH7JwCela W9d6ld8BnCqddrNU= X-Received: by 2002:a7b:c3d2:: with SMTP id t18mr4343876wmj.92.1597942780265; Thu, 20 Aug 2020 09:59:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFonyEwhB0zxrU2YR0L4qmUUhyhI1V4G1yP632cW+r7rqLl5uZMvjeDbImfXO5ymJnV1F2Pg== X-Received: by 2002:a7b:c3d2:: with SMTP id t18mr4343862wmj.92.1597942780103; Thu, 20 Aug 2020 09:59:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 07/15] block/nvme: Rename local variable Date: Thu, 20 Aug 2020 18:58:53 +0200 Message-Id: <20200820165901.1139109-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 3101f1ad55d..99822d9fd36 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[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.26.2 From nobody Sat May 18 12:05:11 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=1597943008; cv=none; d=zohomail.com; s=zohoarc; b=LGw27dzE7DIvkzknX+Qf2doaW2AstaWnzNoBW0Yf5BjqumD/ig6TCKXUgBj2wWAf2tZxgQSKhd+KrfAuxWYmDhJBWNjib8d/Uve6yxXocH+PKJ+3aGW+6VOOHNY3mhpL9HUfXmvMODN8TjeQa6flXBovQtEIWowdvFgHYzCu7ho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943008; 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=CGQmSUZkaMTSA5n136vQxwh8WIRKspK6NFocfmUCdbc=; b=DMXUmOLMORkCcxg+j0Dx3bt38pxOqUBAhl6l3OIKu8sKmwlKuGuC0NGwp/UqWQCyb3uXcJwwhxDMByeCYQs2dHKlF3iI31Trjh1GuGjBTcMSazVer/oIvBqo4bSVgbqMU8b5eUsf66UxOOnDfW3tP5xS56WT++AP/vuQtNnnzGw= 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 1597943008863405.4516630482784; Thu, 20 Aug 2020 10:03:28 -0700 (PDT) Received: from localhost ([::1]:60594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nyI-0000kp-Cc for importer@patchew.org; Thu, 20 Aug 2020 13:03:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuq-0004CL-KQ for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:52 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:27208 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 1k8nuo-0006En-0X for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:52 -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-224-fCZgmUW9PuGd6hvd1rXcNw-1; Thu, 20 Aug 2020 12:59:47 -0400 Received: by mail-wr1-f71.google.com with SMTP id s23so854923wrb.12 for ; Thu, 20 Aug 2020 09:59:47 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id j5sm5539991wma.45.2020.08.20.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942789; 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=CGQmSUZkaMTSA5n136vQxwh8WIRKspK6NFocfmUCdbc=; b=bAK+y92yvy+BPZMes51JY1PManRDBCifPjnE7ytloo+qPH7WoLbVSKrlD4v2mOTkeFZLaQ wKvCUcK4n9dz97smn7OH4QF4bFTtbqfnm+VgvKylI8AUd5AAwL0/46fPD9upTIHwt1TfRQ zcZN0XUwXQxi64aLdd+cdIHl1ZyMils= X-MC-Unique: fCZgmUW9PuGd6hvd1rXcNw-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=CGQmSUZkaMTSA5n136vQxwh8WIRKspK6NFocfmUCdbc=; b=MZ2t9LZPkAOrYFMo9pCOdZLj3XjW1vMyks7s2gva7yOzzs4HQz0mFAkQw0g8afz6Dk oY4Rn0DbLSmXaqyRKDIFaJ5Nf4M+qd5Vqb1eZE4I1w21EY8Fnk0kOOIWhHxfLA2JTns+ 4FdaDTd29C6VzrYsc5wPg1seEiNHdjMjYzF3cVN33VjemtQmixo0UkyHsk1QuIudcKJr +fOwrOoV5NyYCRwlVVMM7UvL/xP4uByf/ijxinAZPmEJBJ9ZtksGxfdSt50Pu8YCmtY5 KLh7PLcOzIf8AGwe3F/PlkLSGpPP8jGxBkGIO0a1cnT2IVItDDis6jQaS9/e1mfCeSRf 5MYQ== X-Gm-Message-State: AOAM5317DXFYNHbv+PvYNOFZKKK89xCVKMLQb+jW90RmJbT686QffsLJ yFgOZ1f20sOw+xwyl3i3XkVk5pclgFQ5gHLD5akahzE8hUiTKk2CiGgAVz0t+Am/SqxT13Pif3L 3Y1sAqnfxqHlg06c= X-Received: by 2002:a5d:544a:: with SMTP id w10mr4154965wrv.317.1597942786207; Thu, 20 Aug 2020 09:59:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhLAJ3NVuCtT/npjOh2UbgEKqPgWCz10FStUVVGH1i2UiOSfLdArNqk/xdVUchZMA+PpBJkw== X-Received: by 2002:a5d:544a:: with SMTP id w10mr4154947wrv.317.1597942785937; Thu, 20 Aug 2020 09:59:45 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 08/15] block/nvme: Use union of NvmeIdCtrl / NvmeIdNs structures Date: Thu, 20 Aug 2020 18:58:54 +0200 Message-Id: <20200820165901.1139109-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/20 03:03:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 99822d9fd36..2bd1935f951 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[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.26.2 From nobody Sat May 18 12:05:11 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=1597943174; cv=none; d=zohomail.com; s=zohoarc; b=d5oLYM+MJ+v1FM9z81CyKfQs+pHkjEtX4EDS2COuzWJ21YqteAnj07MgV7O6p+qSMeyT4i5/d8aMXqnbkRWCfSxytqrz6wco94BXoSZbnlIKWglSTK5L5OAn/y4Fjl9vf5qCVWJIxqMX5QJ1523tnWMxW7JBYKD6iPATkjet7Bk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943174; 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=Z6BpEV2cAZCoO+2PvXqrFXBtVGoZXhqod7yrp9Ptrs4=; b=VELvQo7YimnA3AsZ0tyXtaWkJ0SdwgjFmTgaDvbHw/Q/KrnwokzMxrJu1jaSKqHe7g2y9kFca/yg4W5JOQzKFGPEqFuRmf0AWGgLrVwMneHk1j5j0KjPWr58AAUfGxXJlnBThatD3VAtw5bmXD38cBdIw7e9MtojEg/E64e5kbI= 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 1597943174964300.0410949747462; Thu, 20 Aug 2020 10:06:14 -0700 (PDT) Received: from localhost ([::1]:45734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o0z-0006HR-PM for importer@patchew.org; Thu, 20 Aug 2020 13:06:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nuw-0004U6-PN for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:58 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:32770 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 1k8nut-0006FB-FE for qemu-devel@nongnu.org; Thu, 20 Aug 2020 12:59:58 -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-240-xQVAlfBzNfWV7qaFy6veNw-1; Thu, 20 Aug 2020 12:59:53 -0400 Received: by mail-wr1-f70.google.com with SMTP id k11so859197wrv.1 for ; Thu, 20 Aug 2020 09:59:52 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id w64sm5977910wmb.26.2020.08.20.09.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942794; 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=Z6BpEV2cAZCoO+2PvXqrFXBtVGoZXhqod7yrp9Ptrs4=; b=dFjVBwfdfgkWmMlYNI0hWOUeTaqfFu/4MniuX7XZLR9MiEklR3EWmQbkCYgVBsMogVuT2l 8O9ngZ3WA2ONsqlIDnO1QrLfsud6NACqSv92KE+jRv08cViLZ4qW6WzP2u5zcpEld5LEwA J4i3Tqw/I+r2keLKyi3VgI6LmxlkbMQ= X-MC-Unique: xQVAlfBzNfWV7qaFy6veNw-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=Z6BpEV2cAZCoO+2PvXqrFXBtVGoZXhqod7yrp9Ptrs4=; b=dWoOJHSMYZcF8rYQvRIm9gD1oA33FFIC38QYbS462wlDj9t+X3FhrrsXg5VYN/V4fu +63fwCp5aDBiAreEkvQU3UOLsf9SX4iGU7MxtNT6xms3JvG1MgYjn47yybeNj1PpBPDA EDq/hGSstw/TqD1TD/Ke32tuP/l74bH6u3BprwG9myW7QqcRVD/G5zfQXl7fFH3+Kb// snd1h7vwnwcO/n2kSTUiUXlrnlxqDVfRWUDwOcOw+h2FERA9W0iinyD94/JvC9JBCos9 Q8GsEuvVSe+HWU16jGJ1DUG6E4Fi+7OUpLsJCIeAJ2iE5fhGLQID7E4+eJZIgRARsNjh ip9Q== X-Gm-Message-State: AOAM531IyN5L8FHTu9KFMw/3OxPMOCbfJywCYtw6WWRI/Gqv0sFThycI b41pYYXX3We5NqpMR3DvgSbeSZwpfbioTj8wsz8HOdUj90td/1fxxr4fvt2rv3x9KVhFK8+IVJi T6AbqUvOUePz02cM= X-Received: by 2002:adf:9487:: with SMTP id 7mr3916203wrr.133.1597942791779; Thu, 20 Aug 2020 09:59:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEpqkGZDH9TK1DCoOn36iPjQiqMxIzKxeeLBHvL1hZAk3Fq8CgkXF9pjKjyRd9q9WY/iUZfg== X-Received: by 2002:adf:9487:: with SMTP id 7mr3916185wrr.133.1597942791548; Thu, 20 Aug 2020 09:59:51 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 09/15] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset Date: Thu, 20 Aug 2020 18:58:55 +0200 Message-Id: <20200820165901.1139109-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/20 03:03:34 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 2bd1935f951..ac6bb52043d 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[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.26.2 From nobody Sat May 18 12:05:11 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=1597943100; cv=none; d=zohomail.com; s=zohoarc; b=TmqzoEdZGkxLSVm7Ybjtju19uLy5sKq7F2UBuwaHkXqHBtOoqn0dFbp6aPyouPNs+zUUEDUkQdoMl2KkW+1XLJH+wP6QAsbJg9Qootc33dBTlUSmkclmOtl258tdsyDLYjCVPlHB/wlugebwsNYsxJoQiSkIdmN8bDyQS+zqbzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943100; 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=3JiBIb64BlS2pxwIv33N7yG3by1OM78D/kYXYdLYCac=; b=nl9wjgKizSngvHvnbNh/EKJepRY0Gsgs6/9fNo0X0Itosa6f0cPxbKHRLWMByXLzmJL0MIEW33OARxiMgdO+YXgknQdpLwVj7Y89YAqwGVzoVPoOyXeI8hRHtuDTnya8BNEhHbSH6hhFVLtt/7icfurZP5PzU1O3ham34Fd0h4g= 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 1597943100420709.6407262676003; Thu, 20 Aug 2020 10:05:00 -0700 (PDT) Received: from localhost ([::1]:39292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8nzn-0003Yz-7Y for importer@patchew.org; Thu, 20 Aug 2020 13:04:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nv3-0004j1-CC for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:05 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:51907 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 1k8nv1-0006HG-4P for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:04 -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-103-p66U97jGMGqx2FBt1qoBLA-1; Thu, 20 Aug 2020 12:59:58 -0400 Received: by mail-wm1-f72.google.com with SMTP id p184so1175409wmp.7 for ; Thu, 20 Aug 2020 09:59:58 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id g18sm5594311wru.27.2020.08.20.09.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 09:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942802; 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=3JiBIb64BlS2pxwIv33N7yG3by1OM78D/kYXYdLYCac=; b=gabB4xoTZoqgT1xqNIdDqNu18XE1XfWf2u2velVmRpIKJMv+BRTxpuUYfohNoUtmj/xhjl nt+LiOa79/APA1vJvjnLlu0nxYEkDB6IQImhvL3IdOFfV2yFcaA/JkCgwKw6/aqi5VcO4o fSdYDFaLs6uYMADJTW7o9kyXNsOYBb8= X-MC-Unique: p66U97jGMGqx2FBt1qoBLA-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=3JiBIb64BlS2pxwIv33N7yG3by1OM78D/kYXYdLYCac=; b=OiM4RE5kP3rIAxhMjvkQhpU/7nU0InxpcG1jGY+Nt/NQwpsiFksrHLpUOxztIKPxeU su7iIcsDAAIBPz0GpbZvEUKoPBuOWxxb7xsObJEBBTtf55E8PJVXnikBrygJkBlv4xIK F2g12JHHDGwv/bu6hEF5k3EPFW+21rs/uP44jnS6vPdw6G+C1YJsw8Z+p8YRiNNhj0yT rswzOqLMpqgfVjUHRC/z3b8EC2j3t2PzM9Lbba0tZxQ/a2kC8nqDfeFZoRIHO9l0xzzD jK69ekfQWPcb29750Cqh4AwLgMcHW2np5kzR3OEa6JqV/xBDlIoMsqTEKEhscXC2urEU 3+0Q== X-Gm-Message-State: AOAM530DGbe6i5fY4l4BSr3v5bmTTeaiNKI74FQOHpkkMYnQZXjVueyC XxsVWqrmb8oB/wXckodf3iEOs4ArqbFymk50Pcas2TFpPFi5C0lvpe7lAtTIG5Zd0S7FlRdSaBZ b5tYfv1xm/+J39F0= X-Received: by 2002:a05:6000:c:: with SMTP id h12mr3948208wrx.49.1597942797239; Thu, 20 Aug 2020 09:59:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyir+vLjLTY13DTXVIfwhUyrPcued8OQIEB638O91sIhwHNgIpIS8lB2Ol9hwBa9EEt2hF2Xg== X-Received: by 2002:a05:6000:c:: with SMTP id h12mr3948200wrx.49.1597942797024; Thu, 20 Aug 2020 09:59:57 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 10/15] block/nvme: Replace qemu_try_blockalign(bs) by qemu_try_memalign(pg_sz) Date: Thu, 20 Aug 2020 18:58:56 +0200 Message-Id: <20200820165901.1139109-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-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.003 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/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index ac6bb52043d..f180078e781 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.26.2 From nobody Sat May 18 12:05:11 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=1597943135; cv=none; d=zohomail.com; s=zohoarc; b=ZnJuhofKm7jeKykK2/Yycm/G45/OO3U+VY46HC4cCuhUoTV9hK/f8Rt10OVy23eCMuw0iC9CAxry9BTFA4o91PYFqroQYN3z8UvZ8kuL4pgXfz8Lsu3D0JC4ZL5hSCt6qNwCtVzog1D6lWS1gnRI9seJhtBZHYKiLF7SgzDr+AY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943135; 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=89Wjp5YSaeU8EmV0B/KKiK2s/vD3kpR2gM6yq2fyUAE=; b=j6AOXkfEKmYe4BVe1JffR6bRTlgytQFqZMooyXSoewz0MrCmPHIzOudy8/J6P8W28RkVtzsJNaEz4/otGMhvo68PVOLChhxI5VB1wrQ8ULUYD0VVgGbwApmDa5KFtds+G36EnU5d2VaWmGSr2pjdNQfxgRcO6cHHzahjF2TZPas= 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 1597943135310518.3670039504159; Thu, 20 Aug 2020 10:05:35 -0700 (PDT) Received: from localhost ([::1]:42186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o0L-0004nX-W3 for importer@patchew.org; Thu, 20 Aug 2020 13:05:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nv7-0004sh-JE for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:09 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:36256 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 1k8nv4-0006Iq-5J for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:09 -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-557-5KdO5mE0MR6DKTnkYekTyg-1; Thu, 20 Aug 2020 13:00:03 -0400 Received: by mail-wr1-f71.google.com with SMTP id t12so863101wrp.0 for ; Thu, 20 Aug 2020 10:00:03 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id k4sm5776361wrd.72.2020.08.20.10.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 10:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942805; 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=89Wjp5YSaeU8EmV0B/KKiK2s/vD3kpR2gM6yq2fyUAE=; b=GH0dcBlFVvTQnrHkvliw6VwvFwoC3c7MqaBFvEx6Hx+cXeDrpAzZUY1UzyKYN0+6QXBp+b ZaLcB7APcvbkM5omp4c2V9GhmIHhcbj8ndIGLpFLos3Vui/iMDyNLuxQipPlmUHuL85GUB IT3JwKqSTo3qYUO2KPIvoXIL4Ph4Z6I= X-MC-Unique: 5KdO5mE0MR6DKTnkYekTyg-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=89Wjp5YSaeU8EmV0B/KKiK2s/vD3kpR2gM6yq2fyUAE=; b=ZTVRwQgWdXqAeQDBdmv95aCNZ52j02/sll3y5t7kLGwEsa0Lotg+7X5zn5Sl5+fnCh 6beN/vApGOj0dJIRmJRItpDV+5c9NDoNE2p/5j7k0iJfK9dsW+TyagimhCIEUpMcl+ne 3DibJIrRwZwhfmibV738K3jqBNftfYBSelq/e/sv1afciTQY31m6pY7LsDQap9Xb6LVP vt9UK51GeWO+rpcpYH03fpBu/fIpyMlj4LmNBMZE4Grlt8J0s9FeGtAXoYwXrbbCEcBU DAAISBrMs9Quju6osZGtLdSVkRlpiMVFNLPdkn8z4TNTyQeSp5kpHHqHTM5LtQpl/+nL lTew== X-Gm-Message-State: AOAM530iVdn63Qzygy66U3ehHPVeob/Jy1VhYutecLMt4exT/ldyC0Wo 9B+5Fdwo/yCkZ/uyIEWRvqU4BbNKlk9toAjP0mTCbZ3cUl93VVhQhpyHwG3STBAigNDswsgZMF7 RjBJQhPzBZCy7Bew= X-Received: by 2002:a1c:4e10:: with SMTP id g16mr4082112wmh.146.1597942802268; Thu, 20 Aug 2020 10:00:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+ZuOvD8GbaS8VltipExEIdiLWXcqS8uRCrSOJugg9wZ4Kxifn7KyGDPRqBu/5p5Ah7YHxzg== X-Received: by 2002:a1c:4e10:: with SMTP id g16mr4082097wmh.146.1597942802068; Thu, 20 Aug 2020 10:00:02 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 11/15] block/nvme: Simplify nvme_init_queue() arguments Date: Thu, 20 Aug 2020 18:58:57 +0200 Message-Id: <20200820165901.1139109-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index f180078e781..5b69fc75a60 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.26.2 From nobody Sat May 18 12:05:11 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=1597943259; cv=none; d=zohomail.com; s=zohoarc; b=UZMfkhzL+w08b0D1QQNo/AteG80Rm4Xj06Cu83ZWQaDcvb/WH4nz8F+fVHG0hitgd5D48Ufrkh8pZmUwvnhSObtbGUQHUJRStGmyXb4tfoVUufmO5mK4mt1ZGWdByj7f/+r+0sl7JX+vYhEGz+C3D78X3cYjRcJpbnOF38mQEMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943259; 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=HJf25gsH+6Qwxz9ynms3bXAs8zm6lq5Rrdtx+rf3EyY=; b=Y08FDNGGSjB4MCwxtjMuJx0J4qWJLchkS4LGPPu5tfjh7B72ikjHSqtfVZNwvYZBuy+ennEMFDyZp6n99CJGMRhK50IDwJo1kY46AwK/v08TZ0U0gD+qixXH+JszWS608CCan3JWP0JkBParhlLsUpt6ZM3y9UK9CY1xQszdDg4= 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 1597943258997176.71651634199225; Thu, 20 Aug 2020 10:07:38 -0700 (PDT) Received: from localhost ([::1]:51346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o2L-0000EM-Gy for importer@patchew.org; Thu, 20 Aug 2020 13:07:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36040) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nvB-00050o-Fw for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:13 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:27943 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 1k8nv9-0006Jv-1S for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:13 -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-373-9RUehUs7OdCAlbXHudOKNQ-1; Thu, 20 Aug 2020 13:00:09 -0400 Received: by mail-wm1-f71.google.com with SMTP id h7so998961wmm.7 for ; Thu, 20 Aug 2020 10:00:08 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id l10sm5109782wru.3.2020.08.20.10.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 10:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942810; 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=HJf25gsH+6Qwxz9ynms3bXAs8zm6lq5Rrdtx+rf3EyY=; b=bT9RmzTwIUn8kNmKvbTEop1B+2sn0vAWQXoOBkgiReRqogJmXPO4wr/JcJysL+QOpKOxfp QEirCu7LNMTxitjjzpM8qBJWt5+nGmyOqTc0FjWoEUsfVX/6TtxVZwCoGvbq/+0zy2K8AF hNXnPgSKF5rrmWldBivRzuL6dmh8NKU= X-MC-Unique: 9RUehUs7OdCAlbXHudOKNQ-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=HJf25gsH+6Qwxz9ynms3bXAs8zm6lq5Rrdtx+rf3EyY=; b=Bufo5SSD8Lgthk8pNO8CLyEFR4QPNgLBdZEMlN4PUMegepyzAPDU5LmMgoJVBb2kNk 1zAfPJDL7xtjE1hNxIcCvqD2IQVhtcZUblh8Zp0dkOKIItKlws0ldrGbcFu9TYRKetlH LGRtfTCAtOvRNp5huMlJ2v1VTlrJnLPDVbZXC1nXssjIQkPtNN30BYHDTOAUi1gF2zGX Dejpz4HKIS4PVCbIx9bGMCTHv6hjboypblAm3yVbyDtkkjMAqEU/rcsYT/y6Jb2aP9FD ckxDuK774xpx9gn9Dzi6J5wKAtb0X49W+aXoy4srpMWfxc9Yq5Tmpk3vJcCGD2l0C039 KBxA== X-Gm-Message-State: AOAM530LKRurGKVe5MmuvZ9yRz31qC6MPK5LMbg66ONlSZxgnq1CR7I3 Q0AGaqSzOn8PKkj/HtQQXtKqLhAGimIJAOkYGGGrqxxya6S0ONCed/DCdcAFNsmh+d8VHFgh9ab OdZcbU3/+f0pk9uQ= X-Received: by 2002:adf:fc45:: with SMTP id e5mr4390238wrs.226.1597942807478; Thu, 20 Aug 2020 10:00:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0LX1iEI5sG5+0WY5A4i9+FbisCQGjIP/NsUK+/7fAKoe+5ce7ba4ZbySCKmXmtY+7OwWBSw== X-Received: by 2002:adf:fc45:: with SMTP id e5mr4390210wrs.226.1597942807227; Thu, 20 Aug 2020 10:00:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 12/15] block/nvme: Replace BDRV_POLL_WHILE by AIO_WAIT_WHILE Date: Thu, 20 Aug 2020 18:58:58 +0200 Message-Id: <20200820165901.1139109-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index 5b69fc75a60..456fe61f5ea 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.26.2 From nobody Sat May 18 12:05:11 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=1597943172; cv=none; d=zohomail.com; s=zohoarc; b=ffBYyJMVL4RCm1sFfE51kE6y19aw+vj3KR+utt44lV2S9+SSQFVURzVrRTbyJ6OhM0XdJS4kuTy+1PD0Jp2+BKsKrw3pNd74yHHqnV81wU5zVVurqNYpZa7mVrCIXFVQq84Q0gzXHwmHyriD5dnRXArNMziK0GkjsAIF8IVR8TY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943172; 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=sTB57LR1ao06/Eb932YU4A4+GC8DTLB4LSq0kvq2o30=; b=F/uqEDXG3TUISIvaPaGe6osk9HjNxVmuXAsXW2yed3/7s9wkNSBfCIWVTeDGrAt2hxvF2Sgbtc+kjQwVVDrEzc3TlDm4bUOnTCf42WpYhsDDBVR3eTfB5zQmGekIXb+8ryyYFmFcY9XjP/wZvC2GmnXII5CLZAvgLGT/y9I9OEc= 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 1597943172951364.64998223638133; Thu, 20 Aug 2020 10:06:12 -0700 (PDT) Received: from localhost ([::1]:45546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o0x-0006Cd-Oi for importer@patchew.org; Thu, 20 Aug 2020 13:06:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nvH-0005AN-Sf for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:41243 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 1k8nvF-0006OK-Ei for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:19 -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-456-GuDnBWrqMfKPB_8F1Di4XQ-1; Thu, 20 Aug 2020 13:00:14 -0400 Received: by mail-wm1-f69.google.com with SMTP id g72so1179758wme.4 for ; Thu, 20 Aug 2020 10:00:14 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id p17sm5997005wra.81.2020.08.20.10.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 10:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942816; 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=sTB57LR1ao06/Eb932YU4A4+GC8DTLB4LSq0kvq2o30=; b=MswYx8nGc4DLtzFAPZXwAEu+H7jF/iFL7xwx039uz61ddJeGbRQjJ9JZQqWEFAqcShsdJ0 7aMxeOFn5hc5uDEN9Gv8lwPAWnkouAwTvlBm9qDteyh4etpnJBDo2fABgM/FY+PyQt4XUz 4KsShA37UWq3xDD5ictq6emt/doUtOE= X-MC-Unique: GuDnBWrqMfKPB_8F1Di4XQ-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=sTB57LR1ao06/Eb932YU4A4+GC8DTLB4LSq0kvq2o30=; b=c3nVUbq0yCkuKbjT8cWVb0RrwZsQXJwEYw75CT/u7k/v4MRYDm/BD7W1LBMQb5+beQ 4ZXlvgl5EttabeWBIK6jHMCR913+BMoNG2+A4MmEYAW3V5pkgFVoKr0LnqmvjEfMOin2 +AIQEatxWcF6dxK9zmniXs4bW6DXHIgZwFn1qBQtFhT3uC1RKhFZMi6z0maVLlJ+SNId Wgu43DZys4nafuaOM2TiySxahnkQ20sKGhqFDPRquWgajEwaHrjgcBUNLmPXCF5vxMLi SPphzy+MWDVeQSHbjz1ezB7leyISqLnydxdLlLnIC+Fni0TBy3ohwTWURpvHNP0i/Taw EQ2g== X-Gm-Message-State: AOAM5313EcLlyw+sfVEhHdAzBltWR4y8qYTZKKMqi4jQ1P4XOIsrz/BN V0HaWrWXsyTK6dso6X+5PJRob5VdlXYQz0vkhAJGxm6UJDUk5q/aKaCcOALah2UUpntriPigjZz vrSVXjEtF2EToT8o= X-Received: by 2002:a1c:dc45:: with SMTP id t66mr4106299wmg.17.1597942812648; Thu, 20 Aug 2020 10:00:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/9W0E3gZ6iI4q1ZTY13HVDqoP/XO+g/TshFRlVeYZEcnaxVqP8AbViWapNnosrTm0GZuHPQ== X-Received: by 2002:a1c:dc45:: with SMTP id t66mr4106278wmg.17.1597942812422; Thu, 20 Aug 2020 10:00:12 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 13/15] block/nvme: Simplify nvme_create_queue_pair() arguments Date: Thu, 20 Aug 2020 18:58:59 +0200 Message-Id: <20200820165901.1139109-14-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/20 03:03:32 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 Reviewed-by: Stefano Garzarella --- block/nvme.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 456fe61f5ea..1f67e888c84 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[INDEX_ADMIN] =3D nvme_create_queue_pair(bs, 0, + s->queues[INDEX_ADMIN] =3D nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp); if (!s->queues[INDEX_ADMIN]) { --=20 2.26.2 From nobody Sat May 18 12:05:11 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=1597943209; cv=none; d=zohomail.com; s=zohoarc; b=erj7iMg+TzdR2iP7GGjp0SsqW+JmniefvItw11RSJ8k5hgkH8F47IIxGM9lClNKyJJ6k/J6yfMi3apN1hEII29Y9DABYUPlQgCSAs3Jf4UGVJZ+50IgKs6rDBOzvVDWCL8Bo5dyhFp9MuHgEXKKTzqvWM13c+wtBRx20iNQ80t4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943209; 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=ijWvbXbwV2OfcKpjugDRX3POUSdELxpfYooH/g+NfK0=; b=AxlVW+OctcwaEsclfHAfY6+DcnaittW2wjNntifDnUaVqkQtVFQON8sEMBIKi7mj/l/4nE78Gw7OFfOz74FIVjf77Y7U2L8Gejas1N2+YIvpPwRlscwQPhfIFozQyIbrMw0+VPvqerDY+ia6FEh7YZ6/QXgB6VDvdSz58bpgoB4= 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 1597943209682308.55531686108384; Thu, 20 Aug 2020 10:06:49 -0700 (PDT) Received: from localhost ([::1]:48872 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o1Y-0007b4-DC for importer@patchew.org; Thu, 20 Aug 2020 13:06:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nvN-0005Fz-5n for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:25 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:46285 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 1k8nvL-0006S8-18 for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:24 -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-343-M0eL0UuINCuG97BGSN8IcA-1; Thu, 20 Aug 2020 13:00:20 -0400 Received: by mail-wr1-f71.google.com with SMTP id s23so855307wrb.12 for ; Thu, 20 Aug 2020 10:00:20 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id 32sm5960798wrh.18.2020.08.20.10.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 10:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942822; 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=ijWvbXbwV2OfcKpjugDRX3POUSdELxpfYooH/g+NfK0=; b=L2t580QTdCuN9H8AbPxZeZ88EiC0U7atuKAFDXMSx0ttmnCnRYLgccf3oaey5Yxggs81A2 kudI3JYuaWeqLlsKHiXoseMMNUjuakjUdEQf7V/KFKPELHpoq21M/BDxodAYyoXMbiTDfy 22tOwxO+Mdt9G+R2PsYJ5inNYlHls8A= X-MC-Unique: M0eL0UuINCuG97BGSN8IcA-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=ijWvbXbwV2OfcKpjugDRX3POUSdELxpfYooH/g+NfK0=; b=mcqZDhC19chKhZ0FugwW8swxQopweadUDy1bW69WioC/DsanIRERlJMbJQWyl9+VCh ALV1yjJ9G++CqM4329RWE2vOnv36EognFkHQzcN+IxVT3wMgXXDETjmoUdBbUvakcO2g U+ZrxpHNd2HAxkzRYQfF9vs6MffEkLHIWNT4rRGzFJJiRmV8Lzqy3MNfF3B4pimJcN5V VSyKQTeMHTnKXVGUzaF4EOSDCVmvfGwhGD3XgDIOUXC044HzhCNnLfDKbbRuubGgc4l9 T2VeGFPrjNsY8mXNRatcqHsXW+5yIYCLMgRqD+87HQinmn61M0STauBoXUs41hw/SpKu 3MUg== X-Gm-Message-State: AOAM531y3m8RKEKrOxZQb7bc/VtWMAiowsVaFuSADrQ5+46JVmRzRvEm 0CynRdpiotqayhkrIJjgOpnlQeT8Hc2IA1Nvyjxo/8EYVIxk9nJIu8kyc9QafC7NRh6XWcphrQo OZ7cpJN6Lih/O2+0= X-Received: by 2002:a1c:e0c2:: with SMTP id x185mr4311630wmg.124.1597942819152; Thu, 20 Aug 2020 10:00:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxwV1nFDYWSnyq0i+pIn/lNjE0rC92S0Mdf8EylvWZhroUjF6fcDU6uCiMbVD2+bpQ5WZC1A== X-Received: by 2002:a1c:e0c2:: with SMTP id x185mr4311611wmg.124.1597942818939; Thu, 20 Aug 2020 10:00:18 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 14/15] block/nvme: Extract nvme_poll_queue() Date: Thu, 20 Aug 2020 18:59:00 +0200 Message-Id: <20200820165901.1139109-15-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella --- block/nvme.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 1f67e888c84..a61e86a83eb 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -590,31 +590,41 @@ out: qemu_vfree(id); } =20 +static bool nvme_poll_queue(NVMeQueuePair *q) +{ + bool progress =3D false; + + const size_t cqe_offset =3D q->cq.head * NVME_CQ_ENTRY_BYTES; + NvmeCqe *cqe =3D (NvmeCqe *)&q->cq.queue[cqe_offset]; + + /* + * Do an early check for completions. q->lock isn't needed because + * nvme_process_completion() only runs in the event loop thread and + * cannot race with itself. + */ + if ((le16_to_cpu(cqe->status) & 0x1) =3D=3D q->cq_phase) { + return false; + } + + qemu_mutex_lock(&q->lock); + while (nvme_process_completion(q)) { + /* Keep polling */ + progress =3D true; + } + qemu_mutex_unlock(&q->lock); + + return progress; +} + static bool nvme_poll_queues(BDRVNVMeState *s) { bool progress =3D false; int i; =20 for (i =3D 0; i < s->nr_queues; i++) { - NVMeQueuePair *q =3D s->queues[i]; - const size_t cqe_offset =3D q->cq.head * NVME_CQ_ENTRY_BYTES; - NvmeCqe *cqe =3D (NvmeCqe *)&q->cq.queue[cqe_offset]; - - /* - * Do an early check for completions. q->lock isn't needed because - * nvme_process_completion() only runs in the event loop thread and - * cannot race with itself. - */ - if ((le16_to_cpu(cqe->status) & 0x1) =3D=3D q->cq_phase) { - continue; - } - - qemu_mutex_lock(&q->lock); - while (nvme_process_completion(q)) { - /* Keep polling */ + if (nvme_poll_queue(s->queues[i])) { progress =3D true; } - qemu_mutex_unlock(&q->lock); } return progress; } --=20 2.26.2 From nobody Sat May 18 12:05:11 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=1597943323; cv=none; d=zohomail.com; s=zohoarc; b=TLF75YI/xU3XnStFjA14qHaZZwKZ+nZ3QyybSR3UQMlpGKjW6cTZa8gioFPka0IHV0Y5NGD0kox0w/4hS1KuAlJPNs9SLKoCHgonac4FwdEh3WmyaRN934c0Hhb/G9hIwg5NdMY0668JGZZQbykcSG6qix/CpmCa+ThkrJuS6No= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597943323; 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=v0lvUfHZ5sUY4TlbEB+TMIDYZfmDwZ5AnicnBqS/RQ4=; b=O8RAvr+CuwZim1CNRqF6onINpA4tVFcohThwfR1pUdU0RmBqzX8sLmPqjAmniIfv99gAEeThuret6PQq45Uvq71kvyE6mDw6N9BfCN4YWCM/+H4xpmaUQAVTg4oVcsNVQbGn6GTAj00byWVuql1VoEIcCpuGByo/4G48lWeis9g= 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 1597943323331192.52656548716004; Thu, 20 Aug 2020 10:08:43 -0700 (PDT) Received: from localhost ([::1]:54602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8o3O-0001dE-4C for importer@patchew.org; Thu, 20 Aug 2020 13:08:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8nvW-0005Sv-2A for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:35 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:41088 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 1k8nvS-0006T8-R8 for qemu-devel@nongnu.org; Thu, 20 Aug 2020 13:00:33 -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-481-0OGN-uyyORexCm24Gqkapg-1; Thu, 20 Aug 2020 13:00:25 -0400 Received: by mail-wm1-f72.google.com with SMTP id u144so1005840wmu.3 for ; Thu, 20 Aug 2020 10:00:25 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id n12sm5771622wrq.63.2020.08.20.10.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 10:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597942830; 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=v0lvUfHZ5sUY4TlbEB+TMIDYZfmDwZ5AnicnBqS/RQ4=; b=dtDzWylqnxegiibbsphi1KDY0oSJ5K63wzqNcThpRTE5C8LxXfDsvXoLZZlyedhD46fvZC 6wEbH4ixwUbl6ti2LESchfo8D8wsc5BYG61YEEGxYkFjt0SFzEzYA81r6QWUPwwJSzq5u6 IH/KKNgt1HLzmLChGhtB/VXb8MvaKQc= X-MC-Unique: 0OGN-uyyORexCm24Gqkapg-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=v0lvUfHZ5sUY4TlbEB+TMIDYZfmDwZ5AnicnBqS/RQ4=; b=adOyoO4dzVlLz2Bvim0GRt+VM/kdMDRqzJhyjgh92Piq4pfwkzs2akY58ygcKjhXVO Qwg/ncmgdOh4yj8zDwq7wKzkbVlFi4lUQGXb4PlE9mne38PpqGuvWIYZiEeQr5oxgtGm +uK2u0UjNxgA0YZKHT409uk5fkfdNWAWfS8TabWkQcgK+WQs7zAVy5jrss5dAEItqt9U OI++xgwaLdH4IKxzNwXSpHa8a+Kph2420RCAHOXeSMzkRfLu22mCFC4D35ZCd0WHGTeP ffzkyEFCY43qY5uw1D2beVRnNTDePHO1GWL4Q+u50JeY7Axv420v/FtDRNFofbno7dIX 9OuQ== X-Gm-Message-State: AOAM530lHTmiREPJeH6a3sWtnwoJGria1b0zgBwjoVrHJHjKlVPH5jqg rde4FsaA31R23ohM4tZye1j7xt87sOkn+wjivwfiENybzTZAwFuiaNGlCnQqm3i6Rn42NW45R6G qRvu1vKERAwzlsEY= X-Received: by 2002:a1c:b4c1:: with SMTP id d184mr4578358wmf.26.1597942824428; Thu, 20 Aug 2020 10:00:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAF6ZnVtW7htX6aFBwt/CyNog9meDYTvlWL4La0VHmWkx3XI1/VPe554Tx9WH56RAq9GjDng== X-Received: by 2002:a1c:b4c1:: with SMTP id d184mr4578338wmf.26.1597942824139; Thu, 20 Aug 2020 10:00:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v5 15/15] block/nvme: Use an array of EventNotifier Date: Thu, 20 Aug 2020 18:59:01 +0200 Message-Id: <20200820165901.1139109-16-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200820165901.1139109-1-philmd@redhat.com> References: <20200820165901.1139109-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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/08/19 20:12:44 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.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_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=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 preparation of using multiple IRQ (thus multiple eventfds) make BDRVNVMeState::irq_notifier an array (for now of a single element, the admin queue notifier). Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefano Garzarella --- block/nvme.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index a61e86a83eb..fe8a40b7ede 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -106,6 +106,12 @@ QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) !=3D 0= x1000); #define INDEX_ADMIN 0 #define INDEX_IO(n) (1 + n) =20 +/* This driver shares a single MSIX IRQ for the admin and I/O queues */ +enum { + MSIX_SHARED_IRQ_IDX =3D 0, + MSIX_IRQ_COUNT =3D 1 +}; + struct BDRVNVMeState { AioContext *aio_context; QEMUVFIOState *vfio; @@ -120,7 +126,7 @@ struct BDRVNVMeState { /* How many uint32_t elements does each doorbell entry take. */ size_t doorbell_scale; bool write_cache_supported; - EventNotifier irq_notifier; + EventNotifier irq_notifier[MSIX_IRQ_COUNT]; =20 uint64_t nsze; /* Namespace size reported by identify command */ int nsid; /* The namespace id to read/write data. */ @@ -631,7 +637,8 @@ static bool nvme_poll_queues(BDRVNVMeState *s) =20 static void nvme_handle_event(EventNotifier *n) { - BDRVNVMeState *s =3D container_of(n, BDRVNVMeState, irq_notifier); + BDRVNVMeState *s =3D container_of(n, BDRVNVMeState, + irq_notifier[MSIX_SHARED_IRQ_IDX]); =20 trace_nvme_handle_event(s); event_notifier_test_and_clear(n); @@ -683,7 +690,8 @@ out_error: static bool nvme_poll_cb(void *opaque) { EventNotifier *e =3D opaque; - BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, irq_notifier); + BDRVNVMeState *s =3D container_of(e, BDRVNVMeState, + irq_notifier[MSIX_SHARED_IRQ_IDX]); =20 trace_nvme_poll_cb(s); return nvme_poll_queues(s); @@ -705,7 +713,7 @@ static int nvme_init(BlockDriverState *bs, const char *= device, int namespace, 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); + ret =3D event_notifier_init(&s->irq_notifier[MSIX_SHARED_IRQ_IDX], 0); if (ret) { error_setg(errp, "Failed to init event notifier"); return ret; @@ -784,12 +792,13 @@ 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->irq_notifier, VFIO_PCI_MSIX_IRQ_INDEX, errp); if (ret) { goto out; } - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, + aio_set_event_notifier(bdrv_get_aio_context(bs), + &s->irq_notifier[MSIX_SHARED_IRQ_IDX], false, nvme_handle_event, nvme_poll_cb); =20 nvme_identify(bs, namespace, &local_err); @@ -872,9 +881,10 @@ static void nvme_close(BlockDriverState *bs) nvme_free_queue_pair(s->queues[i]); } g_free(s->queues); - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, + aio_set_event_notifier(bdrv_get_aio_context(bs), + &s->irq_notifier[MSIX_SHARED_IRQ_IDX], false, NULL, NULL); - event_notifier_cleanup(&s->irq_notifier); + event_notifier_cleanup(&s->irq_notifier[MSIX_SHARED_IRQ_IDX]); qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->regs, 0, NVME_BAR_SIZE); qemu_vfio_close(s->vfio); =20 @@ -1381,7 +1391,8 @@ static void nvme_detach_aio_context(BlockDriverState = *bs) q->completion_bh =3D NULL; } =20 - aio_set_event_notifier(bdrv_get_aio_context(bs), &s->irq_notifier, + aio_set_event_notifier(bdrv_get_aio_context(bs), + &s->irq_notifier[MSIX_SHARED_IRQ_IDX], false, NULL, NULL); } =20 @@ -1391,7 +1402,7 @@ static void nvme_attach_aio_context(BlockDriverState = *bs, BDRVNVMeState *s =3D bs->opaque; =20 s->aio_context =3D new_context; - aio_set_event_notifier(new_context, &s->irq_notifier, + aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_I= DX], false, nvme_handle_event, nvme_poll_cb); =20 for (int i =3D 0; i < s->nr_queues; i++) { --=20 2.26.2