From patchwork Fri Sep 4 12:41:28 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: 306175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E14AC433E2 for ; Fri, 4 Sep 2020 12:43:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A9AC206F2 for ; Fri, 4 Sep 2020 12:43:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G5sApBY7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A9AC206F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEB3T-0007Wz-Cm for qemu-devel@archiver.kernel.org; Fri, 04 Sep 2020 08:42:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEB2K-00069n-8W for qemu-devel@nongnu.org; Fri, 04 Sep 2020 08:41:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22932) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kEB2G-0006YV-TI for qemu-devel@nongnu.org; Fri, 04 Sep 2020 08:41:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599223302; 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=sb4uXiFvtrqRn/GlqalTIrcUPoERtLqLldrd535gyMg=; b=G5sApBY7ycCOYBOzrOsSJsIlYJ2qgUyuMM5i+JU4cUqgvY9Sw3hBD2eL5bqHo018TIP2L4 +EFnhS0nK3pj5xyW2+Llaef+Ltwu3RgiO7aDfHc7NqE6PJ5jpo1V3v031UXYTqXDbyz3A2 PaakpFk0EYL5xZUmXnbvWKpCkePbEiE= 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-7-i6YFI_OcNyO67MYh-Ku1iA-1; Fri, 04 Sep 2020 08:41:39 -0400 X-MC-Unique: i6YFI_OcNyO67MYh-Ku1iA-1 Received: by mail-wm1-f69.google.com with SMTP id g79so3357322wmg.0 for ; Fri, 04 Sep 2020 05:41:39 -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=sb4uXiFvtrqRn/GlqalTIrcUPoERtLqLldrd535gyMg=; b=gKOOtJNjoxNPr/fKSDsg5QiX821707lfG9VK0j6miOmkeYDP+PxJ/zk5DBozUDepLh lAXIRDWFJ6epT8oz7cTVg1QVhvbbCm0rgj+FC0anD3glEehYLC/2X6BXOf5WaVdtdo8X FKiOoH2CDcaeMJdgCr1KnH1SfWYBn1Y7oCgPaIUJUc4ZXGx8tnTZEaXJ221mKPI9iKlM MW/iipeSJ/8iyWRhxbWInNRWuzF6p7aJmwym7FHSDYdbNrluvWy0TQ5Q1lQoAgsQLmwu RLrG7cYuiH8I6HartEcm16GPlcMDzkdFo4lZkFQgm6JqX2unw8gkYg2w5NlfmJlPQUak Ji6g== X-Gm-Message-State: AOAM530gp3ZKjzwzmk1sWwkeCQIQiEjiKSxzpCOtGFpyB0f8HPabd8uC 5m5klTo4EHAchHzWOMM2gnSNA9p4WR+IXrqIWx1Al99SjnetUmXPweDWem7ebEV+g4xkrHpRX6F Cpuv5F3ui+hCPHuw= X-Received: by 2002:a1c:6145:: with SMTP id v66mr7792026wmb.171.1599223298259; Fri, 04 Sep 2020 05:41:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2AWjwRNhrOuxy5aVntw74Dd2eAwFLf58CSi/Y0Z9nEHjuMs6mZ20121sSBuFKRE61s1PTuw== X-Received: by 2002:a1c:6145:: with SMTP id v66mr7792003wmb.171.1599223298008; Fri, 04 Sep 2020 05:41:38 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id 185sm3626889wma.18.2020.09.04.05.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 05:41:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/3] block/nvme: Group controller registers in NVMeRegs structure Date: Fri, 4 Sep 2020 14:41:28 +0200 Message-Id: <20200904124130.583838-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904124130.583838-1-philmd@redhat.com> References: <20200904124130.583838-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 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/09/04 07:42:07 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Keith Busch , Stefan Hajnoczi , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We want to use the NvmeBar structure from "block/nvme.h" in the next commit. As a preliminary step, group all the NVMe controller registers in the 'ctrl' field, keeping the doorbells registers out of it. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 24e6e7f0866..c9c3fc02fed 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -83,21 +83,23 @@ typedef struct { /* Memory mapped registers */ typedef volatile struct { - uint64_t cap; - uint32_t vs; - uint32_t intms; - uint32_t intmc; - uint32_t cc; - uint32_t reserved0; - uint32_t csts; - uint32_t nssr; - uint32_t aqa; - uint64_t asq; - uint64_t acq; - uint32_t cmbloc; - uint32_t cmbsz; - uint8_t reserved1[0xec0]; - uint8_t cmd_set_specfic[0x100]; + struct { + uint64_t cap; + uint32_t vs; + uint32_t intms; + uint32_t intmc; + uint32_t cc; + uint32_t reserved0; + uint32_t csts; + uint32_t nssr; + uint32_t aqa; + uint64_t asq; + uint64_t acq; + uint32_t cmbloc; + uint32_t cmbsz; + uint8_t reserved1[0xec0]; + uint8_t cmd_set_specfic[0x100]; + } ctrl; uint32_t doorbells[]; } NVMeRegs; @@ -734,7 +736,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, /* Perform initialize sequence as described in NVMe spec "7.6.1 * Initialization". */ - cap = le64_to_cpu(s->regs->cap); + cap = le64_to_cpu(s->regs->ctrl.cap); if (!(cap & (1ULL << 37))) { error_setg(errp, "Device doesn't support NVMe command set"); ret = -EINVAL; @@ -747,10 +749,10 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, timeout_ms = MIN(500 * ((cap >> 24) & 0xFF), 30000); /* Reset device to get a clean state. */ - s->regs->cc = cpu_to_le32(le32_to_cpu(s->regs->cc) & 0xFE); + s->regs->ctrl.cc = cpu_to_le32(le32_to_cpu(s->regs->ctrl.cc) & 0xFE); /* Wait for CSTS.RDY = 0. */ deadline = qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + timeout_ms * SCALE_MS; - while (le32_to_cpu(s->regs->csts) & 0x1) { + while (le32_to_cpu(s->regs->ctrl.csts) & 0x1) { if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) > deadline) { error_setg(errp, "Timeout while waiting for device to reset (%" PRId64 " ms)", @@ -771,18 +773,18 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } s->nr_queues = 1; QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000); - s->regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << 16) | NVME_QUEUE_SIZE); - s->regs->asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova); - s->regs->acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova); + s->regs->ctrl.aqa = cpu_to_le32((NVME_QUEUE_SIZE << 16) | NVME_QUEUE_SIZE); + s->regs->ctrl.asq = cpu_to_le64(s->queues[INDEX_ADMIN]->sq.iova); + s->regs->ctrl.acq = cpu_to_le64(s->queues[INDEX_ADMIN]->cq.iova); /* After setting up all control registers we can enable device now. */ - s->regs->cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << 20) | + s->regs->ctrl.cc = cpu_to_le32((ctz32(NVME_CQ_ENTRY_BYTES) << 20) | (ctz32(NVME_SQ_ENTRY_BYTES) << 16) | 0x1); /* Wait for CSTS.RDY = 1. */ now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); deadline = now + timeout_ms * 1000000; - while (!(le32_to_cpu(s->regs->csts) & 0x1)) { + while (!(le32_to_cpu(s->regs->ctrl.csts) & 0x1)) { if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) > deadline) { error_setg(errp, "Timeout while waiting for device to start (%" PRId64 " ms)", From patchwork Fri Sep 4 12:41:29 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: 274509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC467C433E2 for ; Fri, 4 Sep 2020 12:44:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F7D7206F2 for ; Fri, 4 Sep 2020 12:44:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gnyHtz7+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F7D7206F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEB5M-000236-NW for qemu-devel@archiver.kernel.org; Fri, 04 Sep 2020 08:44:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35316) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEB2L-0006Bb-I6 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 08:41:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35066) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kEB2J-0006Z0-Dl for qemu-devel@nongnu.org; Fri, 04 Sep 2020 08:41:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599223306; 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=7VufwieRg1JhzJ8aiEIPGgbaappTVL2Md8brdGSxPk4=; b=gnyHtz7+7M446FMfoS4HHJSFt+t5eIrbZiwCMb0AFc9O4iwPOG8mwemhhRN0yWagxNEDT2 n/b1ay9aR5IEY4HJlKW1KmetDP5GJybXSMQ9BjE9mRQUkRhNVOgFJQLT4IoZMx54Nck/S0 q7yeUAShGs3d+lzfqV+3IewRrNT3wrI= 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-17-rkzPP4T8N8iVGvBW2n_WTQ-1; Fri, 04 Sep 2020 08:41:45 -0400 X-MC-Unique: rkzPP4T8N8iVGvBW2n_WTQ-1 Received: by mail-wm1-f70.google.com with SMTP id s24so1685224wmh.1 for ; Fri, 04 Sep 2020 05:41:45 -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=7VufwieRg1JhzJ8aiEIPGgbaappTVL2Md8brdGSxPk4=; b=QTdXmm3PEIOYEWcZXM2kcy/IGCUro58RZxY0CYV+HDvbBA5+eLwzm0pcnMDye2ru77 mDUfRTI1rIvcApKBCixkQD1U/PGPd6g+bMFQwm7IGC8GGL/iDz9OUxDD7a1TvmS0/BMK kD3SWDWO916Fx0Ltn1iqrhCzH6mR9LbwylVHznggUmNLT3nuMY0yXZYVI+WGr2qUoGZm ET7b2Zg4GwsKDkYwlElEOMmioPUYUdGpy2V67+/EevW2dS4H7STaE/Kb6/iskXtcKONA IWkRFafS4rSjEXoAJPp4E7dOGK3OQ2nabdbiFjOguVgzGec9rEidu+I2yLt9Eu/SZ3zP wdpg== X-Gm-Message-State: AOAM530dzBlEURwHjsoj6mcqtSa7khJQRkMdFg+8tPD2erxbQ4YSPSFB U1yN4oM2txwo53YHbzkZkrDXPQGj2BtdEUHYzv70jO5eGRz9GiePYIjMrsYxAVdi/N6gsloByLL dVKXgCdWe0LsM8Mk= X-Received: by 2002:a1c:4c0d:: with SMTP id z13mr7071083wmf.115.1599223303840; Fri, 04 Sep 2020 05:41:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVi/GUgffyREeodIUQafcx6gCUFbKZYQ9L5hsgCZmvitYkx7UDwU4aWagX61dklCdT5ZXTew== X-Received: by 2002:a1c:4c0d:: with SMTP id z13mr7071066wmf.115.1599223303648; Fri, 04 Sep 2020 05:41:43 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id u66sm11118306wmg.44.2020.09.04.05.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 05:41:43 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/3] block/nvme: Use generic NvmeBar structure Date: Fri, 4 Sep 2020 14:41:29 +0200 Message-Id: <20200904124130.583838-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904124130.583838-1-philmd@redhat.com> References: <20200904124130.583838-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.001 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/09/04 07:42:07 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Keith Busch , Stefan Hajnoczi , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Commit f3c507adcd7 ("NVMe: Initial commit for new storage interface") introduced the NvmeBar structure. Unfortunately in commit bdd6a90a9e5 ("block: Add VFIO based NVMe driver") we duplicated it. Apparently in commit a3d9a352d48 ("block: Move NVMe constants to a separate header") we tried to unify headers but forgot to remove the structure declared in the block/nvme.c source file. Do it now, and remove the structure size check which is redundant with the header check added in commit 74e18435c0e ("hw/block/nvme: Align I/O BAR to 4 KiB"). Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index c9c3fc02fed..a216cc407f6 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -83,28 +83,10 @@ typedef struct { /* Memory mapped registers */ typedef volatile struct { - struct { - uint64_t cap; - uint32_t vs; - uint32_t intms; - uint32_t intmc; - uint32_t cc; - uint32_t reserved0; - uint32_t csts; - uint32_t nssr; - uint32_t aqa; - uint64_t asq; - uint64_t acq; - uint32_t cmbloc; - uint32_t cmbsz; - uint8_t reserved1[0xec0]; - uint8_t cmd_set_specfic[0x100]; - } ctrl; + NvmeBar ctrl; uint32_t doorbells[]; } NVMeRegs; -QEMU_BUILD_BUG_ON(offsetof(NVMeRegs, doorbells) != 0x1000); - #define INDEX_ADMIN 0 #define INDEX_IO(n) (1 + n) From patchwork Fri Sep 4 12:41:30 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: 274510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ABFEC43461 for ; Fri, 4 Sep 2020 12:43:03 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C5BE2206F2 for ; Fri, 4 Sep 2020 12:43:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5BE2206F2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEB3V-0007di-TH for qemu-devel@archiver.kernel.org; Fri, 04 Sep 2020 08:43:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kEB2P-0006Kl-R9 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 08:41:53 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:33458 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 1kEB2O-0006b4-3F for qemu-devel@nongnu.org; Fri, 04 Sep 2020 08:41:53 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-Feofc5LqNgG0TbNn5kBJFQ-1; Fri, 04 Sep 2020 08:41:50 -0400 X-MC-Unique: Feofc5LqNgG0TbNn5kBJFQ-1 Received: by mail-wr1-f72.google.com with SMTP id g6so2291646wrv.3 for ; Fri, 04 Sep 2020 05:41:49 -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=vI7vDBHGjLnbO6/DwFRox42IeAyuzSp/xvHpN9rz7no=; b=FGNkqHGhTwNCmksMN04TGkePxDMeLmGHdg8jloC/10v+Gi5uMlmG2afm4t6vCQqQR4 EjhFAtelPPZsAaREW7AvieYECWS5oeaA+6jp4mhdGDzKn4WCoV64dBs7MrPuXm3UkFMn EmGWDJ/FrKw/ynmqvFQix3vz4v0cWTQYvDhTh+sk/Jf/vg6tNRsLjbcTuHuiuVX/oZ3L +qDNzUHN0qcnGf1XFTJyjy92flCZjvzS6ExGzwnEuQW3T8QSLx+ISK0nwJmpF/M8N7jO z1f6irgzWp48zO87Toqd4njX9CNpeRGe1qWa48xEgyuOq2AYZH/l6cgSfXoRsID1XxxY /m/A== X-Gm-Message-State: AOAM532oV3bj3ApEjoQbXTA/Vy1d9nuJk63InMzi0ek0YCkG6z08bsfc 6r+JbD4hO3WcVTwwaUN57Hf0+I8QA9xJz8J1+KkXRmHZ4zc/XCYzGyNvvGHeQVwKKxN/rdfV1W1 5Ir8YFX1qylDQPmo= X-Received: by 2002:adf:f149:: with SMTP id y9mr7231689wro.93.1599223308696; Fri, 04 Sep 2020 05:41:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwr2Oql+aA4tcJvUwjQLKvdfqF5/OyAsHprOOCST9QcoK61j4ErACC69/gxHO9HQERNTNQB3w== X-Received: by 2002:adf:f149:: with SMTP id y9mr7231675wro.93.1599223308554; Fri, 04 Sep 2020 05:41:48 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id d18sm11184478wrm.10.2020.09.04.05.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 05:41:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/3] block/nvme: Pair doorbell registers Date: Fri, 4 Sep 2020 14:41:30 +0200 Message-Id: <20200904124130.583838-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200904124130.583838-1-philmd@redhat.com> References: <20200904124130.583838-1-philmd@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=205.139.110.61; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 01:57:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=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 , Stefan Hajnoczi , Klaus Jensen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For each queue doorbell registers are paired as: - Submission Queue Tail Doorbell - Completion Queue Head Doorbell Reflect that in the NVMeRegs structure, and adapt nvme_create_queue_pair() accordingly. Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index a216cc407f6..f4f27b6da7d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -84,7 +84,10 @@ typedef struct { /* Memory mapped registers */ typedef volatile struct { NvmeBar ctrl; - uint32_t doorbells[]; + struct { + uint32_t sq_tail; + uint32_t cq_head; + } doorbells[]; } NVMeRegs; #define INDEX_ADMIN 0 @@ -244,14 +247,14 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, error_propagate(errp, local_err); goto fail; } - q->sq.doorbell = &s->regs->doorbells[idx * 2 * s->doorbell_scale]; + q->sq.doorbell = &s->regs->doorbells[idx * s->doorbell_scale].sq_tail; nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, &local_err); if (local_err) { error_propagate(errp, local_err); goto fail; } - q->cq.doorbell = &s->regs->doorbells[(idx * 2 + 1) * s->doorbell_scale]; + q->cq.doorbell = &s->regs->doorbells[idx * s->doorbell_scale].cq_head; return q; fail: