From patchwork Thu Oct 29 09:32:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 1389997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=E7cDZZdE; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CMLBm09WZz9sSC for ; Thu, 29 Oct 2020 20:44:48 +1100 (AEDT) Received: from localhost ([::1]:59838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4U9-0004K9-TC for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:44:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60362) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4KJ-00078q-Jo for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57706) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4KH-0006iR-Sa for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964073; 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=aD6wOmxyFdCPV49Ruw6nu+GcSa7FrFcv+dDSPChtcUc=; b=E7cDZZdEqBtdvmhxy/0xngaGQghmmL6PBsSI0DXuh8gJe+wYlabvtTyTaEt2XSvFROFb43 cdVgIv/sun03VLKnzwSnLJIWoS1+RlWwdlgjlrk3NDNWMuZVkO3R/OK22r37XkcJL7V+BR 93GndoWN+ywTiN4T0EiS8xqjCAInj7c= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-dP4ZnUFeMYSj6RL_EqrjkA-1; Thu, 29 Oct 2020 05:34:31 -0400 X-MC-Unique: dP4ZnUFeMYSj6RL_EqrjkA-1 Received: by mail-ej1-f69.google.com with SMTP id z9so937586ejg.10 for ; Thu, 29 Oct 2020 02:34:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aD6wOmxyFdCPV49Ruw6nu+GcSa7FrFcv+dDSPChtcUc=; b=s6U0XQjGj2T6vDUxy+5rbjXy6C2VzPqTWPSB+OXe0BSrLuZnZJvUSnMIE1ge8YiIl0 VILxRc4U+Zt7pC43hVN6Hr1njIeCN6d0euo8AyhSCnveJ6KcEf3oJ8HXveLtXDBHlXd+ DfseNHAvynLsWVxi1L06/r11nHoRSbmlRszscWcQQ7yZ+KiKJQ+v66L0fEvawpQXCy7+ 1F/o531rx3dzCvnOgnD3fPF6HlqBOsJ6aEfqe92R5GrKLdohrl1B/0zF/frDhHRXe1cO sm0BS24lpzCa908JZEm41mOeYV0Fiwz6PFJKZqysXXgY7ugOXkBVV3iWrMr4EQ56IcEq G/Qg== X-Gm-Message-State: AOAM531CDLlYrrVp2ap3CE9cYr8UUO3+eCqwiwaMC/qem0aQLgT1nJDz ITd6FTj21nQqmz3HW1KYxNFvHPB4g/5oqlLqyyE15eGCp7Mv6LnZ5KO8cWGv2MeNk7bu7cjqO6e oCHzLh+j14RDKteo= X-Received: by 2002:aa7:d690:: with SMTP id d16mr58180edr.329.1603964069879; Thu, 29 Oct 2020 02:34:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3DhRtBm+GvI0yKAKWEkk39Y/cLInIsq1r9fw+4b+rgY9MXGQl6MTc6JoOv5dc7NmbuD9zgQ== X-Received: by 2002:aa7:d690:: with SMTP id d16mr58160edr.329.1603964069720; Thu, 29 Oct 2020 02:34:29 -0700 (PDT) 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 f13sm1144515ejf.42.2020.10.29.02.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 15/25] block/nvme: Simplify ADMIN queue access Date: Thu, 29 Oct 2020 10:32:56 +0100 Message-Id: <20201029093306.1063879-16-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 Received-SPF: pass client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 00:47:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Keith Busch , Eric Auger , Stefan Hajnoczi , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We don't need to dereference from BDRVNVMeState each time. Use a NVMeQueuePair pointer on the admin queue. The nvme_init() becomes easier to review, matching the style of nvme_add_io_queue(). Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 0902aa55428..eed12f4933c 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -700,6 +700,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; + NVMeQueuePair *q; AioContext *aio_context = bdrv_get_aio_context(bs); int ret; uint64_t cap; @@ -781,19 +782,18 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, /* Set up admin queue. */ s->queues = g_new(NVMeQueuePair *, 1); - s->queues[INDEX_ADMIN] = nvme_create_queue_pair(s, aio_context, 0, - NVME_QUEUE_SIZE, - errp); - if (!s->queues[INDEX_ADMIN]) { + q = nvme_create_queue_pair(s, aio_context, 0, NVME_QUEUE_SIZE, errp); + if (!q) { ret = -EINVAL; goto out; } + s->queues[INDEX_ADMIN] = q; s->queue_count = 1; QEMU_BUILD_BUG_ON((NVME_QUEUE_SIZE - 1) & 0xF000); regs->aqa = cpu_to_le32(((NVME_QUEUE_SIZE - 1) << AQA_ACQS_SHIFT) | ((NVME_QUEUE_SIZE - 1) << AQA_ASQS_SHIFT)); - regs->asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova); - regs->acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova); + regs->asq = cpu_to_le64(q->sq.iova); + regs->acq = cpu_to_le64(q->cq.iova); /* After setting up all control registers we can enable device now. */ regs->cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << CC_IOCQES_SHIFT) |