From nobody Mon Feb 9 07:56:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603964064; cv=none; d=zohomail.com; s=zohoarc; b=SDHHgeu/cp9ngrUAorvjqbAu2yHtvPEUBO6MN3ARoUfAcjvugy2jTOUkal9mISflnO5iiA7O0h+E9kjqgPsp6TeGMSenkTDlF8Rn1R8EeTZmSsOTIoweAi7cm00E6um38cTq0TqE9B7PZq/L6npvtBkV7lVbRfaJ9gub7m9H0B0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603964064; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=PNbQLcT2YAtJ+9yj7XsSRTYSXNgUiMYhENGCKNffe1M=; b=aufZkFGRtFCiVw+TkvZjI98Tl2jZtqWdQ7osRbH1WKOezDl8Xd5Wbolckc83mJAMUFTPg86pox67UJHAWmdIHagWaPe09GPOfcAz3OcM0YwXyjtpnpjE2zsl+jFf9COgVSDAHBZO3tIJ+Yf7omRbH2dyVwYOxmhqdMa6T574Nx4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603964064435246.1376816599742; Thu, 29 Oct 2020 02:34:24 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-Wr6GYnxvNC-zV79dRbfw3Q-1; Thu, 29 Oct 2020 05:34:20 -0400 Received: by mail-ej1-f70.google.com with SMTP id t1so923473ejb.21 for ; Thu, 29 Oct 2020 02:34:20 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (234.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.234]) by smtp.gmail.com with ESMTPSA id w22sm1143778edu.15.2020.10.29.02.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964063; 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=PNbQLcT2YAtJ+9yj7XsSRTYSXNgUiMYhENGCKNffe1M=; b=Wak2FnW67FLZ466Y3duCJpO+YSsmJuq238NXBMLaIg2Bn9W5LMDFRb1XlSuIqzeBW+90/m zLQdUT1UTquUBJmWDg0hckDHLH85trrzt6NkBpPqlRAs40fN+luBGENxnGSuWL/wNSW7Vr zgMwDBkvMpzGrRV2KcWnF+PtwVKA2bM= X-MC-Unique: Wr6GYnxvNC-zV79dRbfw3Q-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=PNbQLcT2YAtJ+9yj7XsSRTYSXNgUiMYhENGCKNffe1M=; b=tjD2eXDy+lLGKpmaT7m4UkJUeRkqgWCw69zcuMohDCIGyyMe9H20dDvfBAzu4e+5Rd PZ54XCfxwkMU127cRhNxU0bYXYv0ZBiheZ8D0OTXdmfhQpbVgS0UQ3jN9a5oMsiw1hbW CEAxRZGPVh+JM7CeNmBB2ZX0r9j3k/i+iSs8zdUYPVLMQmY9h5C6bZKyIWs/uC30Xe87 OAiDBr4Z4A+Ty7Qzw8992fldVAuqeznbnQydW0n6lfohXRx02Uk+QOx+Nl+pZSsyGN1j KopHRrgioerI0duBlWxkySRHwySLMbFVG/A/jXgqHSdoPFAUY3sOdo2rmO8CUB6qAIZd KESg== X-Gm-Message-State: AOAM5323T2F3cnAhw5u+JRNIZhPorYCMQpynRTBf+BinL5BrEnoYMrl7 zDW6ZrQUx4AS0Q9498jJEtD7qOBcyugfW1jsVJXkw6exFZ2vqODr3LcaFYlDOro9vuOC/uVYwWF Oaq+GO21NjJypYQ== X-Received: by 2002:a17:906:8812:: with SMTP id zh18mr2051844ejb.361.1603964059318; Thu, 29 Oct 2020 02:34:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylYXJSyM7Qt+84sBHsnm4K50hjTWnBMggbpI3PBnzvC4zqNWBBz+oNBhmZhvPC27GOKQDA1A== X-Received: by 2002:a17:906:8812:: with SMTP id zh18mr2051828ejb.361.1603964059155; Thu, 29 Oct 2020 02:34:19 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Stefan Hajnoczi , Kevin Wolf , Klaus Jensen , Eric Auger , Max Reitz , Fam Zheng , Keith Busch , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH-for-5.2 v2 13/25] block/nvme: Use definitions instead of magic values in add_io_queue() Date: Thu, 29 Oct 2020 10:32:54 +0100 Message-Id: <20201029093306.1063879-14-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201029093306.1063879-1-philmd@redhat.com> References: <20201029093306.1063879-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Replace magic values by definitions, and simplifiy since the number of queues will never reach 64K. Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 6eaba4e7039..7285bd2e271 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -652,6 +652,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) NvmeCmd cmd; unsigned queue_size =3D NVME_QUEUE_SIZE; =20 + assert(n <=3D UINT16_MAX); q =3D nvme_create_queue_pair(s, bdrv_get_aio_context(bs), n, queue_size, errp); if (!q) { @@ -660,8 +661,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) cmd =3D (NvmeCmd) { .opcode =3D NVME_ADM_CMD_CREATE_CQ, .dptr.prp1 =3D cpu_to_le64(q->cq.iova), - .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), - .cdw11 =3D cpu_to_le32(0x3), + .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | n), + .cdw11 =3D cpu_to_le32(NVME_CQ_IEN | NVME_CQ_PC), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create CQ io queue [%u]", n); @@ -670,8 +671,8 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Err= or **errp) cmd =3D (NvmeCmd) { .opcode =3D NVME_ADM_CMD_CREATE_SQ, .dptr.prp1 =3D cpu_to_le64(q->sq.iova), - .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), - .cdw11 =3D cpu_to_le32(0x1 | (n << 16)), + .cdw10 =3D cpu_to_le32(((queue_size - 1) << 16) | n), + .cdw11 =3D cpu_to_le32(NVME_SQ_PC | (n << 16)), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to create SQ io queue [%u]", n); --=20 2.26.2