From patchwork Thu Oct 29 09:32:42 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: 1389984 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=WV601rmX; 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 4CML172gHzz9sS8 for ; Thu, 29 Oct 2020 20:36:27 +1100 (AEDT) Received: from localhost ([::1]:58190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4M5-0000bD-AN for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:36:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4J7-0005aq-OP for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56407) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4J5-0006LM-Vv for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603963999; 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=HzihUm8NymkiDBlfQBSISyvHHXOYy17rVLFGNCZADrc=; b=WV601rmXcFARmZ4Tv+YoVQF5ucEskXGpxkZ2JwaovKrsyT/Y1QtlzuptmuUuOXUztclTPB hhfmIMzMaEN7HVa4cE63AoV6hfGlmEUjGY8bPIwGQAOs5buop9qJDJ0wwJ4oxupz1rTKWz HK7RoVRIdNdRN3ErTu1SHbdFP6Y1ldc= 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-573-Uq1WoRqAPwuitVOQQi9a1Q-1; Thu, 29 Oct 2020 05:33:16 -0400 X-MC-Unique: Uq1WoRqAPwuitVOQQi9a1Q-1 Received: by mail-ej1-f69.google.com with SMTP id p6so948358ejj.5 for ; Thu, 29 Oct 2020 02:33:16 -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=HzihUm8NymkiDBlfQBSISyvHHXOYy17rVLFGNCZADrc=; b=KJa38mHEh057HAIupphERaENH4oqhpU5vpsus56hXsS65h7WmB7Cr8zfAz1dzBcDsT S8wIHtI2eLgUHfTx6tWdE6N9Z9b6OjsH7uCG3Toay4CmK9VfTXJlh7tXqUHr4aTXwk4e 0LdQ67iug+S5SW5Z7xR4E+yoWsyFnLfA/8kI/cexehBniqSRdOPCpYryHWSqHRT93bPI I++nqzPz0KGUj4LJQgg+BmCC+M9LRSkpnu/EFPracb47busJJvzHgm73LVCOgoDV6/yS 9AP5OBP6SBwTqfxUeu83jiUe41Rzo/qk2c+kKb4Hq5JwnMESXscww6M/bCqjlw1V1wNx 4aPA== X-Gm-Message-State: AOAM532K4rXlJEu7Y3hxdBGCCoFHvIXV2MwfLLQmwD5YaWiLZhKWX/FY sOvVFa/Ixhy/dPRsMpuBOaJYRXjgk1pPh6EUmW6aYLfgV9KMhxJBhShxMw1SfMkZ01vNGPqvyBI bP2sbgFHBiUevZQE= X-Received: by 2002:aa7:c358:: with SMTP id j24mr3017548edr.265.1603963995215; Thu, 29 Oct 2020 02:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwXX6GI99gsy25MlesbEa8ZEq08SVfPqsuh/Pi4oyFh5uEmuxTK2+US3kHFJhWYla4MKGuKg== X-Received: by 2002:aa7:c358:: with SMTP id j24mr3017533edr.265.1603963995059; Thu, 29 Oct 2020 02:33:15 -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 y1sm1158610edj.76.2020.10.29.02.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:14 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 01/25] MAINTAINERS: Cover 'block/nvme.h' file Date: Thu, 29 Oct 2020 10:32:42 +0100 Message-Id: <20201029093306.1063879-2-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, Klaus Jensen , 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" The "block/nvme.h" header is shared by both the NVMe block driver and the NVMe emulated device. Add the 'F:' entry on both sections, so all maintainers/reviewers are notified when it is changed. Reviewed-by: Klaus Jensen Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7e442b52472..1289bccc972 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1876,6 +1876,7 @@ M: Klaus Jensen L: qemu-block@nongnu.org S: Supported F: hw/block/nvme* +F: include/block/nvme.h F: tests/qtest/nvme-test.c T: git git://git.infradead.org/qemu-nvme.git nvme-next @@ -2959,6 +2960,7 @@ R: Fam Zheng L: qemu-block@nongnu.org S: Supported F: block/nvme* +F: include/block/nvme.h T: git https://github.com/stefanha/qemu.git block Bootdevice From patchwork Thu Oct 29 09:32:43 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: 1389988 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=N2uK52qp; 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 4CML3b2vGWz9sSG for ; Thu, 29 Oct 2020 20:38:35 +1100 (AEDT) Received: from localhost ([::1]:38384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4O9-0003ym-Cg for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:38:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4JE-0005h8-Fd for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58371) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4JC-0006NG-Nx for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964003; 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=/iwpBUyVm11cIWEap1iOuTMpnwVQgkzK5ulnL1uzeS8=; b=N2uK52qpJDGHHvNNfQAfmv1Ke0N3IG9Ecu98CwZamatgsw2w/O4nDP8t0yfVjIZU0X5IAV S/6GKDmzk31hlOAp2DmHZ8bQAqkuVKTsXGAZO6wG4aGhykh31pS0sCTE63dUUM0vaqHorF dk+bwj7642k251QUiN97X0FrS7GcDEY= 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-210-WoUxsB_XOdWsVBRwcc_F0Q-1; Thu, 29 Oct 2020 05:33:21 -0400 X-MC-Unique: WoUxsB_XOdWsVBRwcc_F0Q-1 Received: by mail-ej1-f69.google.com with SMTP id lf18so934093ejb.13 for ; Thu, 29 Oct 2020 02:33:21 -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=/iwpBUyVm11cIWEap1iOuTMpnwVQgkzK5ulnL1uzeS8=; b=ijHdp/+9y/jf4IqTUI9Kmwi5JK9kA+1VtXSg2/q9drQLZ0gg2y2rqCoMf897s5BI+O 7yNcgKjb1XKQvG3vicCOLbuAiKntJkZKsFZJqm+z5LYsiCsj7noocU4Fap2lhPVoPU0x Q2m3QGwdC1qJiEEXBhti4ziNYLAfCH6BOmkhyWt5yOIjrYxgbDRzNYM0l2giWXwLdyNo IGn/mJewqYtKAMxcH2b94pwpKVUlShE1GwnkoFbWOKttcKKuRp0hIQWwG0HO2L6UjO/s FtCnwHJV99ivDA1LObqUWLDPiJEgy+Guh9eTxKjdJ9zaBt8WITwrdilSmq8pHKwhLVWx DJZg== X-Gm-Message-State: AOAM532zRBLuJ6Zf2lnIgwBOJXwUtnqUxisFZr7UjbMoGPl39JCZyVRc xydtguIz4x0FHydjNKJCZvARwtNANkRmemKHLevwMvRKiP8SE+7vR/ZFzQsTqlDlJ1ZJJWzXYZr 8oyGULCQCYBHIQXg= X-Received: by 2002:aa7:c68b:: with SMTP id n11mr2903233edq.340.1603964000425; Thu, 29 Oct 2020 02:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd9Y8hKZV4slTVUtEz8KDCwuGq5dGIoeff9nHapDqnvlJpaa0B5kAJ5yY0eat74Q20PwHb9A== X-Received: by 2002:aa7:c68b:: with SMTP id n11mr2903216edq.340.1603964000288; Thu, 29 Oct 2020 02:33:20 -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 e14sm1170048ejc.15.2020.10.29.02.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 02/25] block/nvme: Use hex format to display offset in trace events Date: Thu, 29 Oct 2020 10:32:43 +0100 Message-Id: <20201029093306.1063879-3-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=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/10/29 01:47:28 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=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" Use the same format used for the hw/vfio/ trace events. Suggested-by: Eric Auger Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/trace-events | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/trace-events b/block/trace-events index 0e351c3fa3d..0955c85c783 100644 --- a/block/trace-events +++ b/block/trace-events @@ -144,13 +144,13 @@ nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d" nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x" nvme_handle_event(void *s) "s %p" nvme_poll_cb(void *s) "s %p" -nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, int flags, int niov) "s %p is_write %d offset %"PRId64" bytes %"PRId64" flags %d niov %d" -nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset %"PRId64" bytes %"PRId64" flags %d" +nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, int flags, int niov) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" flags %d niov %d" +nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset 0x%"PRIx64" bytes %"PRId64" flags %d" nvme_qiov_unaligned(const void *qiov, int n, void *base, size_t size, int align) "qiov %p n %d base %p size 0x%zx align 0x%x" -nvme_prw_buffered(void *s, uint64_t offset, uint64_t bytes, int niov, int is_write) "s %p offset %"PRId64" bytes %"PRId64" niov %d is_write %d" -nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s %p is_write %d offset %"PRId64" bytes %"PRId64" ret %d" -nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset %"PRId64" bytes %"PRId64"" -nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset %"PRId64" bytes %"PRId64" ret %d" +nvme_prw_buffered(void *s, uint64_t offset, uint64_t bytes, int niov, int is_write) "s %p offset 0x%"PRIx64" bytes %"PRId64" niov %d is_write %d" +nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" ret %d" +nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" bytes %"PRId64"" +nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d" nvme_dma_map_flush(void *s) "s %p" nvme_free_req_queue_wait(void *q) "q %p" nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d" From patchwork Thu Oct 29 09:32:44 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: 1389992 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=iJ2dyWzF; 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 4CML5n1pmXz9sRR for ; Thu, 29 Oct 2020 20:40:29 +1100 (AEDT) Received: from localhost ([::1]:46854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Pz-0007OH-53 for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:40:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4JH-0005md-AX for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:56655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4JF-0006OW-M4 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964008; 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=hraDvgDvE6lqUS9SKN8n1vi9r/o4Ua52Hm0UVRZeM1o=; b=iJ2dyWzFTjVEQgiS1FiRm1E2T30op/zRGDz17DjilV6r1Klbq7kQA8bPSNuXMekd782m9q zw9yKNlBhpikrvQZln17inMC+Iu3ccv2CxxDWPtJiylMaQWR4LcKdOy82cobvbLihLNwR5 u8yfkeNvr1AyI716IVlwVeY9HtVKEDU= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-jt87ynU6NIGYq4XtoAIVKA-1; Thu, 29 Oct 2020 05:33:27 -0400 X-MC-Unique: jt87ynU6NIGYq4XtoAIVKA-1 Received: by mail-ed1-f71.google.com with SMTP id bs10so918093edb.22 for ; Thu, 29 Oct 2020 02:33:26 -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=hraDvgDvE6lqUS9SKN8n1vi9r/o4Ua52Hm0UVRZeM1o=; b=pqSteSoK4CTauHyRNEW4fDDDBeIZwKip89lnY68JsbaSFQTOCYdQ3Y8m5N1oPl6w5S U/W7xZ6m3DwKTD6XxywRztteakNjXhObotcwQL/ysRJR39RdBJx6akQIHW2RziB6+JFM AqpfbXGQd9OhOaZOCH/oEwATd0ZXMK1S3fJGsJ8M1OFtps1S5R7VE7V1noi6Qii70Dm2 Wgsisd9xgBYQw5q+FhEfxC2nHwrA8RqjbZRZKdyo1nRIU/uFaKGOQePgaQOsjYUdXuqz r8Oyt6ivb7ruIg/dTr7PF3DDyroCKHFOMNyBbVAgF7jMkI87FnkZcKaCpIoiVZhVZjwb 9DBQ== X-Gm-Message-State: AOAM532PxKheueceYFm8BKcV+XfaOrj6wRRZVbjEyTTPfjLUebMrcivV PsuaaRPqkYc9OkTyr28Z7lBnSXvdZto62+AEZSF/hLk6aWO5pk6jUXIqnczVrUu9ffg9vLgEuYb 7n6xc9BEEO95YpGo= X-Received: by 2002:a17:906:68cd:: with SMTP id y13mr2995402ejr.230.1603964005694; Thu, 29 Oct 2020 02:33:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxL1Mrs2QuCn8mg3yOsAVD6nuPyNXSDBC6f2UKIVtsts6WHymgLL6DoCvIlNkMGzbLsgAAvtA== X-Received: by 2002:a17:906:68cd:: with SMTP id y13mr2995386ejr.230.1603964005494; Thu, 29 Oct 2020 02:33:25 -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 os11sm1126198ejb.104.2020.10.29.02.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:24 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 03/25] block/nvme: Report warning with warn_report() Date: Thu, 29 Oct 2020 10:32:44 +0100 Message-Id: <20201029093306.1063879-4-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=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/10/29 01:47:28 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=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" Instead of displaying warning on stderr, use warn_report() which also displays it on the monitor. Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 739a0a700cb..6f1d7f9b2a1 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -399,8 +399,8 @@ static bool nvme_process_completion(NVMeQueuePair *q) } cid = le16_to_cpu(c->cid); if (cid == 0 || cid > NVME_QUEUE_SIZE) { - fprintf(stderr, "Unexpected CID in completion queue: %" PRIu32 "\n", - cid); + warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", " + "queue size: %u", cid, NVME_QUEUE_SIZE); continue; } trace_nvme_complete_command(s, q->index, cid); From patchwork Thu Oct 29 09:32:45 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: 1389981 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=NckW2u9g; 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 4CMKzM4fLRz9sS8 for ; Thu, 29 Oct 2020 20:34:55 +1100 (AEDT) Received: from localhost ([::1]:51774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Kb-0006DE-G8 for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:34:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4JM-0005xx-Se for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4JL-0006Qa-06 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964014; 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=8OTYCQauWLqy/pYJjIYbS2aJ8PCndAOeGCZKOtfKeEs=; b=NckW2u9gF93EyL1uU1v/mM2XCbeOBCCggA51Vlz+GIVKcoR3SQ77DdL4q1CxVST+49kLgp lC+4DKmZJqjIolc6g7J6+TGX0YkMdLjgJHkRRAvIndAfYabfJkhRFsXnkLVKlo1nkJvv80 XvxDTYCXIgeVe+4umNLyyx3kIfH1oIk= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-igD4E1AAMhGklUedCKoYUg-1; Thu, 29 Oct 2020 05:33:32 -0400 X-MC-Unique: igD4E1AAMhGklUedCKoYUg-1 Received: by mail-ed1-f69.google.com with SMTP id dn20so938659edb.14 for ; Thu, 29 Oct 2020 02:33:32 -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=8OTYCQauWLqy/pYJjIYbS2aJ8PCndAOeGCZKOtfKeEs=; b=ghmcfdCNzclzCyb3afkNZ/tvPjnor9ed24zIlF1RNWoqS+ozXFFq40o7/G+lqNGky3 31nUulsdSBSeRywLMk70RVjVAqozu/audnchYrzObEmH5OC3A5VdsOvarFEnaLkm1l1q eCkcKKeL3S3aWugt0VJ7xSrz9v4/g/LGER68bIyfXgC3BkPfD0KPGbyE5oe1SgJuqzBu M5HQuOw182v/XeGi6z5Dc4CdUrBLsn2L92Do2W2bxoYBRHwZ0rQTNALwQoNHGw5tNt16 PZprSkbJHzsbqyWIP5YJ7GO/jdOmRZ3mQ9GTky+I0l9jMtYeyijN5w9NH5d41Xm4v/7n +5mQ== X-Gm-Message-State: AOAM531+QdjK5lMXar94u87SVGnM4H1Xw2L35zQdJAiuiciRZwS80AAB olpZfBZpxEuGQYWpdw3tIWhc5jqmgmH5zruuyya7g8AZhSxOIEkx4xrmvQIe9yybll0MFhMgA5j /6bVTjRAAHy0vQu0= X-Received: by 2002:a05:6402:3056:: with SMTP id bu22mr2970999edb.252.1603964011016; Thu, 29 Oct 2020 02:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNGB271VNY8YtLI//fo52gK1aTdhRzFjRvhd88T54f99mHfTTD3TOoj5UU1sgoncKt2f7mlQ== X-Received: by 2002:a05:6402:3056:: with SMTP id bu22mr2970984edb.252.1603964010863; Thu, 29 Oct 2020 02:33:30 -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 z18sm378105ejf.41.2020.10.29.02.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 04/25] block/nvme: Trace controller capabilities Date: Thu, 29 Oct 2020 10:32:45 +0100 Message-Id: <20201029093306.1063879-5-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" Controllers have different capabilities and report them in the CAP register. We are particularly interested by the page size limits. Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Auger Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 13 +++++++++++++ block/trace-events | 2 ++ 2 files changed, 15 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index 6f1d7f9b2a1..361b5772b7a 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -727,6 +727,19 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, * Initialization". */ cap = le64_to_cpu(regs->cap); + trace_nvme_controller_capability_raw(cap); + trace_nvme_controller_capability("Maximum Queue Entries Supported", + 1 + NVME_CAP_MQES(cap)); + trace_nvme_controller_capability("Contiguous Queues Required", + NVME_CAP_CQR(cap)); + trace_nvme_controller_capability("Doorbell Stride", + 2 << (2 + NVME_CAP_DSTRD(cap))); + trace_nvme_controller_capability("Subsystem Reset Supported", + NVME_CAP_NSSRS(cap)); + trace_nvme_controller_capability("Memory Page Size Minimum", + 1 << (12 + NVME_CAP_MPSMIN(cap))); + trace_nvme_controller_capability("Memory Page Size Maximum", + 1 << (12 + NVME_CAP_MPSMAX(cap))); if (!NVME_CAP_CSS(cap)) { error_setg(errp, "Device doesn't support NVMe command set"); ret = -EINVAL; diff --git a/block/trace-events b/block/trace-events index 0955c85c783..b90b07b15fa 100644 --- a/block/trace-events +++ b/block/trace-events @@ -134,6 +134,8 @@ qed_aio_write_postfill(void *s, void *acb, uint64_t start, size_t len, uint64_t qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s %p acb %p ret %d offset %"PRIu64" len %zu" # nvme.c +nvme_controller_capability_raw(uint64_t value) "0x%08"PRIx64 +nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64 nvme_kick(void *s, int queue) "s %p queue %d" nvme_dma_flush_queue_wait(void *s) "s %p" nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "cmd_specific %d sq_head %d sqid %d cid %d status 0x%x" From patchwork Thu Oct 29 09:32:46 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: 1389982 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=bPa57C0/; 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 4CMKzb35KFz9sS8 for ; Thu, 29 Oct 2020 20:35:07 +1100 (AEDT) Received: from localhost ([::1]:52124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Kn-0006MK-Eh for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:35:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60084) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4JW-00062D-PR for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4JT-0006SF-O7 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964021; 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=cs1C0obG4nToPrEZSg1uNXVjaS/D+BwTncjleFbCDLw=; b=bPa57C0/jDxvyyRIZnFb5WmL3M48Ize6sVvdGl3irDLek8o8FpE2iawWbsLE4q9RGq1zMk gkrfv+NR9QbP2w3G1Y5JJbAnTc3CdKOhPaRK8r9abtbIr+unMROforwz+4xfW4tyBxEEL1 m6OsEwi4idvBp5n0fFHx7g0TKzv1XKI= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-cAg8LfxcNA-oUxqRT57UPw-1; Thu, 29 Oct 2020 05:33:38 -0400 X-MC-Unique: cAg8LfxcNA-oUxqRT57UPw-1 Received: by mail-ed1-f72.google.com with SMTP id ay19so917778edb.23 for ; Thu, 29 Oct 2020 02:33:37 -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=cs1C0obG4nToPrEZSg1uNXVjaS/D+BwTncjleFbCDLw=; b=Wu4lUL6Mn+/lvvWTC5mOLs+fFwH6aMcTtB37OxxDaXVOXWm8UlFdgcz1NgJmo5R6TS hwwoicJibHDx+KNDLcsI/z7RnUHkI4T1t/IZyzjwmnDBpoyOFjbH9SAbPPTHCNpgFyeF VtEc3DXn8cVcNkcChGUwuzqoG0WmhaJHriCAXqrqGTzU32QB+WINp0Gq4s/YCcPMZDbh Lm8p3IaKy3HCYAXeCzt3XCq1M9iktpFMq70l/tEWG27f6S2muDQ/GjfoKgHH+Jw+eDOR hmDVg35318tmTZfA0m4wGFLtmD1+9KMJh3Ik+V1Jxz2Nwxs3D5QboNhd21+IUq3+xk+J netA== X-Gm-Message-State: AOAM533mhCZKgp0gzBcX+Szi1wSJJRp4RASHHVM++k0lN016VvfTT+t/ qcDYanG0fgAh2hF4+OW15piTlBIwRlKQBxffLq0eJTaDpwzLp/Qb6Ar6OJubQTtUuQVyu8hc2mC wbC4m5U1hoOwju3E= X-Received: by 2002:a17:906:1989:: with SMTP id g9mr1528541ejd.62.1603964016494; Thu, 29 Oct 2020 02:33:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBI0FYASgwJnrVETq5oEFCOqMrX+j4zrUx/mZmzqhHhAAQ31wYwUzNeRp/NjdnFvFxuh3Xjg== X-Received: by 2002:a17:906:1989:: with SMTP id g9mr1528523ejd.62.1603964016282; Thu, 29 Oct 2020 02:33:36 -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 d24sm1163692edq.34.2020.10.29.02.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 05/25] block/nvme: Trace nvme_poll_queue() per queue Date: Thu, 29 Oct 2020 10:32:46 +0100 Message-Id: <20201029093306.1063879-6-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=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 , 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" As we want to enable multiple queues, report the event in each nvme_poll_queue() call, rather than once in the callback calling nvme_poll_queues(). Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 2 +- block/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 361b5772b7a..8d74401ae7a 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -594,6 +594,7 @@ static bool nvme_poll_queue(NVMeQueuePair *q) const size_t cqe_offset = q->cq.head * NVME_CQ_ENTRY_BYTES; NvmeCqe *cqe = (NvmeCqe *)&q->cq.queue[cqe_offset]; + trace_nvme_poll_queue(q->s, q->index); /* * Do an early check for completions. q->lock isn't needed because * nvme_process_completion() only runs in the event loop thread and @@ -684,7 +685,6 @@ static bool nvme_poll_cb(void *opaque) BDRVNVMeState *s = container_of(e, BDRVNVMeState, irq_notifier[MSIX_SHARED_IRQ_IDX]); - trace_nvme_poll_cb(s); return nvme_poll_queues(s); } diff --git a/block/trace-events b/block/trace-events index b90b07b15fa..86292f3312b 100644 --- a/block/trace-events +++ b/block/trace-events @@ -145,7 +145,7 @@ nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d" nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d" nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x" nvme_handle_event(void *s) "s %p" -nvme_poll_cb(void *s) "s %p" +nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u" nvme_prw_aligned(void *s, int is_write, uint64_t offset, uint64_t bytes, int flags, int niov) "s %p is_write %d offset 0x%"PRIx64" bytes %"PRId64" flags %d niov %d" nvme_write_zeroes(void *s, uint64_t offset, uint64_t bytes, int flags) "s %p offset 0x%"PRIx64" bytes %"PRId64" flags %d" nvme_qiov_unaligned(const void *qiov, int n, void *base, size_t size, int align) "qiov %p n %d base %p size 0x%zx align 0x%x" From patchwork Thu Oct 29 09:32:47 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: 1389985 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=HMJwztie; 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 4CML201QwGz9sS8 for ; Thu, 29 Oct 2020 20:37:12 +1100 (AEDT) Received: from localhost ([::1]:60584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Mm-0001Y3-PP for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:37:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jb-00064y-7f for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44272) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4JX-0006TU-3R for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:33:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964025; 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=/V2bopfrgs5z9fXdSqKgAQr3mfETDBQSgYOoqY9Jixw=; b=HMJwztie6yqZ2oBGfIcEZbwyQyVq8RjijRhiet9pLHhLnDb/5fxdFTP8NhBFTB7ZNXcfWO LmnZxUBcnX2CFfo9Dhq01xXIupKB401DrB/yadVX24aqgLk45WTVkDeQm2EIW60Jwyn4sY +LW+ExVOi65vm1VofLpBGf8Kgecuw5g= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-592-FFeTHNa6O5iy0Uo7IGg2Fg-1; Thu, 29 Oct 2020 05:33:43 -0400 X-MC-Unique: FFeTHNa6O5iy0Uo7IGg2Fg-1 Received: by mail-ed1-f69.google.com with SMTP id dm20so954443edb.2 for ; Thu, 29 Oct 2020 02:33:43 -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=/V2bopfrgs5z9fXdSqKgAQr3mfETDBQSgYOoqY9Jixw=; b=jsXm6Tbi93rM9h3c4aHnidD7QxAHUBxkYgNOJnoDAY/gpYeXeLKrv2eu4bp31SN+VC F8WXOi5BtvsHmvVyoVmpja5Td8y1c82v0she5kbL9jjl8haWJxnQhlfBLhWgEIMLfMly wDalCg1DVV/hNnoA4nJG6TpV4F1mnm5CsRtyUBtsdGMUwz1HwGhRmMZt7fPEdkLflLVW PEXWv9icCovaFZb1KSU7RODhPO2VNZv60RzsuzQpKn9opYK1c9qZ1LETz8YeYs01lwYU OHqUpdC+s6V+HVzjP3WeojlHTIW/Ik2GHyL3jk4WrppoeClu5SQ+GyVsoHJxMhzk3YRD GtwQ== X-Gm-Message-State: AOAM5320zPRKIj5jZZG3dlnWZEcgSenAYvm+u6cwOfX7i8sl9sLG1crj 4e6D7npV+uGqwDMwcdU4DF/VGQTtWQ3sXIttHPTEDqMC0tdoKFENo5PRZZcPwEM9ifyYt41egID 0xup/HcdrgLQLlmc= X-Received: by 2002:aa7:c792:: with SMTP id n18mr2975749eds.209.1603964021784; Thu, 29 Oct 2020 02:33:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYpESBUBbOB5lW/BGGS4fuMQ3uYbb/gclHdzF0P/kIYuQNRO6rAfDaJcaq0s9OfNJKAYveQQ== X-Received: by 2002:aa7:c792:: with SMTP id n18mr2975728eds.209.1603964021606; Thu, 29 Oct 2020 02:33:41 -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 x2sm1176316edr.65.2020.10.29.02.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 06/25] block/nvme: Improve nvme_free_req_queue_wait() trace information Date: Thu, 29 Oct 2020 10:32:47 +0100 Message-Id: <20201029093306.1063879-7-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=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/10/29 01:47:28 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 , 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" What we want to trace is the block driver state and the queue index. Suggested-by: Stefan Hajnoczi Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 2 +- block/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 8d74401ae7a..29d2541b911 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -292,7 +292,7 @@ static NVMeRequest *nvme_get_free_req(NVMeQueuePair *q) while (q->free_req_head == -1) { if (qemu_in_coroutine()) { - trace_nvme_free_req_queue_wait(q); + trace_nvme_free_req_queue_wait(q->s, q->index); qemu_co_queue_wait(&q->free_req_queue, &q->lock); } else { qemu_mutex_unlock(&q->lock); diff --git a/block/trace-events b/block/trace-events index 86292f3312b..cc5e2b55cb5 100644 --- a/block/trace-events +++ b/block/trace-events @@ -154,7 +154,7 @@ nvme_rw_done(void *s, int is_write, uint64_t offset, uint64_t bytes, int ret) "s nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" bytes %"PRId64"" nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d" nvme_dma_map_flush(void *s) "s %p" -nvme_free_req_queue_wait(void *q) "q %p" +nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u" nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d" nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64 nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pages %d" From patchwork Thu Oct 29 09:32:48 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: 1389986 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=fK6t4ldT; 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 4CML284ChZz9sS8 for ; Thu, 29 Oct 2020 20:37:20 +1100 (AEDT) Received: from localhost ([::1]:60898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Mw-0001fd-HV for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:37:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jl-00066R-FA for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jh-0006Ws-79 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964030; 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=EBb5GrRIOVLLA2GDg9frMwfzobl3y/7Xq37zU2+GEk8=; b=fK6t4ldTLnsIUojM9BdKo85YWSRKbkkEqtS1Ub/OXA9wXkaF+RpRphGgXAwqbB+1Zpxwb/ m2mhiIOV+3dAHrRkFy4x2Gj5cgg9IqcLOO/ygbjMaeynF9e3cLnlzMIxktut8pKRtHwoVE 09pxQBzTDb6tqXC6IkvGMD/wrnEPyAc= 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-346-hzDqeQQHNP-jJ6YQpfE_yA-1; Thu, 29 Oct 2020 05:33:48 -0400 X-MC-Unique: hzDqeQQHNP-jJ6YQpfE_yA-1 Received: by mail-ej1-f70.google.com with SMTP id b17so929466ejb.20 for ; Thu, 29 Oct 2020 02:33:48 -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=EBb5GrRIOVLLA2GDg9frMwfzobl3y/7Xq37zU2+GEk8=; b=kc1Kxhg73K9avrf1wLP0/4ZqDUk4d5/Je/kqPk9OGwZrIYeTm4MRz5q9G/EYs2yJ3f ioOfglg3NCxl9JeNcAbAMtm2xJR/WjdOR0y6L19jxmGAjLfAHzPyGAiBWvaJqqLfDFgD QigX+FKzcG6PYb3KNzQWj8FoBexIshzWcZF5GNycihYuwcYGWD9Pbl31oEOH74uP+x4D AdzfB+BJgq/fkhssH6NOQkueqnBYQsUvr3vKlhkTC29HOJzCdnOZms7potrXiGJX6AAq 0c0dQXoyKDaMwgV56g8tSimRFTWjCDouN/+VqJFySfUAj28OeJdHKdjHsd9NGzKewncK gXeg== X-Gm-Message-State: AOAM530nYZsaarjAilI9JC4dZuzqLMrVaHbbS0iqI5RQTwDSvE6KGcmb jDrbjIDxzK2QFBFUQm1uMldalkBvALp85qFhcC580S3XkKd/FIBamxzFHPFfgswlBrmxiLtPmpP HOIbJX2u13s6asl4= X-Received: by 2002:a17:906:7210:: with SMTP id m16mr3319986ejk.490.1603964026928; Thu, 29 Oct 2020 02:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwimITMNtQ8O1OpBtiouA1FKrkJa7uHuXVtHe9G82z1AC8mSDLoBSF94Qk2MLwKAL7koIYlpw== X-Received: by 2002:a17:906:7210:: with SMTP id m16mr3319980ejk.490.1603964026799; Thu, 29 Oct 2020 02:33:46 -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 j20sm1184367edt.4.2020.10.29.02.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 07/25] block/nvme: Trace queue pair creation/deletion Date: Thu, 29 Oct 2020 10:32:48 +0100 Message-Id: <20201029093306.1063879-8-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=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/10/29 01:47:28 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=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" Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 3 +++ block/trace-events | 2 ++ 2 files changed, 5 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index 29d2541b911..e95d59d3126 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -181,6 +181,7 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, static void nvme_free_queue_pair(NVMeQueuePair *q) { + trace_nvme_free_queue_pair(q->index, q); if (q->completion_bh) { qemu_bh_delete(q->completion_bh); } @@ -216,6 +217,8 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, if (!q) { return NULL; } + trace_nvme_create_queue_pair(idx, q, size, aio_context, + event_notifier_get_fd(s->irq_notifier)); q->prp_list_pages = qemu_try_memalign(s->page_size, s->page_size * NVME_NUM_REQS); if (!q->prp_list_pages) { diff --git a/block/trace-events b/block/trace-events index cc5e2b55cb5..f6a0f99df1a 100644 --- a/block/trace-events +++ b/block/trace-events @@ -155,6 +155,8 @@ nvme_dsm(void *s, uint64_t offset, uint64_t bytes) "s %p offset 0x%"PRIx64" byte nvme_dsm_done(void *s, uint64_t offset, uint64_t bytes, int ret) "s %p offset 0x%"PRIx64" bytes %"PRId64" ret %d" nvme_dma_map_flush(void *s) "s %p" nvme_free_req_queue_wait(void *s, unsigned q_index) "s %p q #%u" +nvme_create_queue_pair(unsigned q_index, void *q, unsigned size, void *aio_context, int fd) "index %u q %p size %u aioctx %p fd %d" +nvme_free_queue_pair(unsigned q_index, void *q) "index %u q %p" nvme_cmd_map_qiov(void *s, void *cmd, void *req, void *qiov, int entries) "s %p cmd %p req %p qiov %p entries %d" nvme_cmd_map_qiov_pages(void *s, int i, uint64_t page) "s %p page[%d] 0x%"PRIx64 nvme_cmd_map_qiov_iov(void *s, int i, void *page, int pages) "s %p iov[%d] %p pages %d" From patchwork Thu Oct 29 09:32:49 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: 1389990 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=YyMjI9HX; 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 4CML4W5lnrz9sSn for ; Thu, 29 Oct 2020 20:39:21 +1100 (AEDT) Received: from localhost ([::1]:41102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Os-000550-0B for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:39:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jr-00067a-9N for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jk-0006YC-4d for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964037; 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=LNTJ5igNyyXKkWieXTvLU2UcanJIdRIlRwN2Ir3xgfg=; b=YyMjI9HXPXjEuiTT7LEsQczaQ/swk272L0mmyZbRxpWjp/sjkOMv+YkfQxQj9IO7mj0d/P 1vNVgnoNJR4KTv5qwMORwjhyONTot7lxOIXpj8XqibxNpdiA5OM2s8Jm569/zr2RHkB5G1 Vi6Lgcbv9XK7HMaDpci4z17KzG1rQUo= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-mIqPevmvMjq0Mx106GNdng-1; Thu, 29 Oct 2020 05:33:53 -0400 X-MC-Unique: mIqPevmvMjq0Mx106GNdng-1 Received: by mail-ed1-f71.google.com with SMTP id a15so937370eda.15 for ; Thu, 29 Oct 2020 02:33:53 -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=LNTJ5igNyyXKkWieXTvLU2UcanJIdRIlRwN2Ir3xgfg=; b=kuwRbrtlH5tIpHfuGpRXfC+5KWHD01xgIjNQ4pc8ToZf3oeu5CPpK/owjD2XjmSxcS NrwA+cpScbwStpAK2nvvYV9IYbDNhoKiQHhmoKw8oTqhb3m4mOkPs2mqcT0FjrzxUrDu F0u/J4/uuTX2eMkQg72fy8V4U1hKIjScF3phxqN0Dj3NmGkBBRFFLHs6WJlMFfJoQmi7 fdKwUCgGvuB9OzNsfCoYqo3kJ2YbYzZGsP4BXEsb06H8H0sFW7ZI888yIwBWdce6EjJ6 PxJgtclyYgsNcva7e091lYZhVzMLKTOegM/0pZNjoth5T5Bk8vSu1lVYudIdkQxHckg5 laqA== X-Gm-Message-State: AOAM533FiMY+R+MmIDBsCMAmNTrMvNmDeLS2NTvjc+dn20ECdPTYpNvL HYhgmSou9N5jXUcplbep4iDQIxbEgzKdz2VKD6xnTF/eS1yW3WuCZGca5BYPjjdwB02bWCrTWlP luuYicbLF8WnGYuw= X-Received: by 2002:a17:906:f148:: with SMTP id gw8mr518344ejb.192.1603964032301; Thu, 29 Oct 2020 02:33:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztTl+bsWy4FrmaMCFpQbfLGLKKcnQIg2bTntM3tBGkLjyLF1s0qLKsE7iZ9jsaLp8s9OC3/A== X-Received: by 2002:a17:906:f148:: with SMTP id gw8mr518331ejb.192.1603964032094; Thu, 29 Oct 2020 02:33:52 -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 b24sm398626edt.68.2020.10.29.02.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 08/25] block/nvme: Move definitions before structure declarations Date: Thu, 29 Oct 2020 10:32:49 +0100 Message-Id: <20201029093306.1063879-9-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=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/10/29 01:47:28 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 , 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" To be able to use some definitions in structure declarations, move them earlier. No logical change. Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index e95d59d3126..b0629f5de80 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -41,6 +41,16 @@ typedef struct BDRVNVMeState BDRVNVMeState; +/* Same index is used for queues and IRQs */ +#define INDEX_ADMIN 0 +#define INDEX_IO(n) (1 + n) + +/* This driver shares a single MSIX IRQ for the admin and I/O queues */ +enum { + MSIX_SHARED_IRQ_IDX = 0, + MSIX_IRQ_COUNT = 1 +}; + typedef struct { int32_t head, tail; uint8_t *queue; @@ -81,15 +91,6 @@ typedef struct { QEMUBH *completion_bh; } NVMeQueuePair; -#define INDEX_ADMIN 0 -#define INDEX_IO(n) (1 + n) - -/* This driver shares a single MSIX IRQ for the admin and I/O queues */ -enum { - MSIX_SHARED_IRQ_IDX = 0, - MSIX_IRQ_COUNT = 1 -}; - struct BDRVNVMeState { AioContext *aio_context; QEMUVFIOState *vfio; From patchwork Thu Oct 29 09:32:50 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: 1389983 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=ALVWqlDE; 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 4CMKzn4yFnz9sS8 for ; Thu, 29 Oct 2020 20:35:17 +1100 (AEDT) Received: from localhost ([::1]:52280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Kx-0006RB-Kj for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:35:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jt-00068m-3a for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42970) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jm-0006ZJ-K1 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964041; 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=JbCLCh2QwnhtqrPps05dA+PCf5WKH0hmY19HFhGchDk=; b=ALVWqlDEecnkXRv2kKaNmm3XJbqWB7WjkxPSSsR/gHjCa02ZSTM5YV00UyM5LRNzmimino 5oCGsKHme8Vrcm3zow9hQOiIyBaKDfB/p3t+Z0bHuLCTYcBv7XAyL916AD7Lk9EhlrrsNI YtSGFhQ489mIvKnLSuoXQ6Z6XbGrpFs= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-FuNlutInMPmPjWlcveTCiQ-1; Thu, 29 Oct 2020 05:33:59 -0400 X-MC-Unique: FuNlutInMPmPjWlcveTCiQ-1 Received: by mail-ej1-f72.google.com with SMTP id d12so927599ejr.19 for ; Thu, 29 Oct 2020 02:33:59 -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=JbCLCh2QwnhtqrPps05dA+PCf5WKH0hmY19HFhGchDk=; b=pt7WmMjTCXrhU2K6EhTUHX/g4TFOulwEhrUTWmCeuuICyXlXbzEZzx6gdQPAis6Yz0 3u06asIDfaW6nuq/AhsMYiGkqQ01eMRAak8a+DxjQh9xGeInjZiY+0foxREV2PpH74qC Bmhfxz2vkkwXtWhdls7fcAmYbSm8N3ssPY9GoCaWOHWmFZFd+GPXH8FnYDiMqE9Luvc4 5EPte8VQAX/NyxAmwE4tTAjEBV+AnMLBwB9omP/Ie3hKAYVhD+xozDxdI6siWGQsoQ0S asUil5o+8H9ArUEUITndrTlJOTZzFRzfTixB5QK/6ZVIpPJrXOCrPu9fDRjpADm3z7Hb 36VA== X-Gm-Message-State: AOAM530Vx2y7TJwdb/0h8uKmyis6M9QjS5RU+wC+d91rsw+E27b0WvrL Qj0kTH0R+rFA+FAEnBRmrjFIRs02VgHqWJkMioGqS3Jpnvsonksh/8k5JLGPgwubbiNv32R3ioJ 3iENNsh0bjMJ6IqQ= X-Received: by 2002:aa7:d495:: with SMTP id b21mr2864654edr.231.1603964037659; Thu, 29 Oct 2020 02:33:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8RI/W8+eeUHv6rqdvFaXOPRMeMIt5JGcuoO5gG28fNCEiftgVjHEV70j9TsCew5xH5p1tkQ== X-Received: by 2002:aa7:d495:: with SMTP id b21mr2864629edr.231.1603964037415; Thu, 29 Oct 2020 02:33:57 -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 m20sm1180120edq.16.2020.10.29.02.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:33:56 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 09/25] block/nvme: Use unsigned integer for queue counter/size Date: Thu, 29 Oct 2020 10:32:50 +0100 Message-Id: <20201029093306.1063879-10-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=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/10/29 01:47:28 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=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 can not have negative queue count/size/index, use unsigned type. Rename 'nr_queues' as 'queue_count' to match the spec naming. Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 38 ++++++++++++++++++-------------------- block/trace-events | 10 +++++----- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index b0629f5de80..c450499111e 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -104,7 +104,7 @@ struct BDRVNVMeState { * [1..]: io queues. */ NVMeQueuePair **queues; - int nr_queues; + unsigned queue_count; size_t page_size; /* How many uint32_t elements does each doorbell entry take. */ size_t doorbell_scale; @@ -161,7 +161,7 @@ static QemuOptsList runtime_opts = { }; static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, - int nentries, int entry_bytes, Error **errp) + unsigned nentries, size_t entry_bytes, Error **errp) { size_t bytes; int r; @@ -206,7 +206,7 @@ static void nvme_free_req_queue_cb(void *opaque) static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, AioContext *aio_context, - int idx, int size, + unsigned idx, size_t size, Error **errp) { int i, r; @@ -623,7 +623,7 @@ static bool nvme_poll_queues(BDRVNVMeState *s) bool progress = false; int i; - for (i = 0; i < s->nr_queues; i++) { + for (i = 0; i < s->queue_count; i++) { if (nvme_poll_queue(s->queues[i])) { progress = true; } @@ -644,10 +644,10 @@ static void nvme_handle_event(EventNotifier *n) static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) { BDRVNVMeState *s = bs->opaque; - int n = s->nr_queues; + unsigned n = s->queue_count; NVMeQueuePair *q; NvmeCmd cmd; - int queue_size = NVME_QUEUE_SIZE; + unsigned queue_size = NVME_QUEUE_SIZE; q = nvme_create_queue_pair(s, bdrv_get_aio_context(bs), n, queue_size, errp); @@ -661,7 +661,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw11 = cpu_to_le32(0x3), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { - error_setg(errp, "Failed to create CQ io queue [%d]", n); + error_setg(errp, "Failed to create CQ io queue [%u]", n); goto out_error; } cmd = (NvmeCmd) { @@ -671,12 +671,12 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw11 = cpu_to_le32(0x1 | (n << 16)), }; if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { - error_setg(errp, "Failed to create SQ io queue [%d]", n); + error_setg(errp, "Failed to create SQ io queue [%u]", n); goto out_error; } s->queues = g_renew(NVMeQueuePair *, s->queues, n + 1); s->queues[n] = q; - s->nr_queues++; + s->queue_count++; return true; out_error: nvme_free_queue_pair(q); @@ -785,7 +785,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, ret = -EINVAL; goto out; } - s->nr_queues = 1; + s->queue_count = 1; QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000); regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) | (NVME_QUEUE_SIZE << AQA_ASQS_SHIFT)); @@ -895,10 +895,9 @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable, static void nvme_close(BlockDriverState *bs) { - int i; BDRVNVMeState *s = bs->opaque; - for (i = 0; i < s->nr_queues; ++i) { + for (unsigned i = 0; i < s->queue_count; ++i) { nvme_free_queue_pair(s->queues[i]); } g_free(s->queues); @@ -1123,7 +1122,7 @@ static coroutine_fn int nvme_co_prw_aligned(BlockDriverState *bs, }; trace_nvme_prw_aligned(s, is_write, offset, bytes, flags, qiov->niov); - assert(s->nr_queues > 1); + assert(s->queue_count > 1); req = nvme_get_free_req(ioq); assert(req); @@ -1233,7 +1232,7 @@ static coroutine_fn int nvme_co_flush(BlockDriverState *bs) .ret = -EINPROGRESS, }; - assert(s->nr_queues > 1); + assert(s->queue_count > 1); req = nvme_get_free_req(ioq); assert(req); nvme_submit_command(ioq, req, &cmd, nvme_rw_cb, &data); @@ -1285,7 +1284,7 @@ static coroutine_fn int nvme_co_pwrite_zeroes(BlockDriverState *bs, cmd.cdw12 = cpu_to_le32(cdw12); trace_nvme_write_zeroes(s, offset, bytes, flags); - assert(s->nr_queues > 1); + assert(s->queue_count > 1); req = nvme_get_free_req(ioq); assert(req); @@ -1328,7 +1327,7 @@ static int coroutine_fn nvme_co_pdiscard(BlockDriverState *bs, return -ENOTSUP; } - assert(s->nr_queues > 1); + assert(s->queue_count > 1); buf = qemu_try_memalign(s->page_size, s->page_size); if (!buf) { @@ -1408,7 +1407,7 @@ static void nvme_detach_aio_context(BlockDriverState *bs) { BDRVNVMeState *s = bs->opaque; - for (int i = 0; i < s->nr_queues; i++) { + for (unsigned i = 0; i < s->queue_count; i++) { NVMeQueuePair *q = s->queues[i]; qemu_bh_delete(q->completion_bh); @@ -1429,7 +1428,7 @@ static void nvme_attach_aio_context(BlockDriverState *bs, aio_set_event_notifier(new_context, &s->irq_notifier[MSIX_SHARED_IRQ_IDX], false, nvme_handle_event, nvme_poll_cb); - for (int i = 0; i < s->nr_queues; i++) { + for (unsigned i = 0; i < s->queue_count; i++) { NVMeQueuePair *q = s->queues[i]; q->completion_bh = @@ -1446,11 +1445,10 @@ static void nvme_aio_plug(BlockDriverState *bs) static void nvme_aio_unplug(BlockDriverState *bs) { - int i; BDRVNVMeState *s = bs->opaque; assert(s->plugged); s->plugged = false; - for (i = INDEX_IO(0); i < s->nr_queues; i++) { + for (unsigned i = INDEX_IO(0); i < s->queue_count; i++) { NVMeQueuePair *q = s->queues[i]; qemu_mutex_lock(&q->lock); nvme_kick(q); diff --git a/block/trace-events b/block/trace-events index f6a0f99df1a..8368f4acb0b 100644 --- a/block/trace-events +++ b/block/trace-events @@ -136,13 +136,13 @@ qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t len) "s # nvme.c nvme_controller_capability_raw(uint64_t value) "0x%08"PRIx64 nvme_controller_capability(const char *desc, uint64_t value) "%s: %"PRIu64 -nvme_kick(void *s, int queue) "s %p queue %d" +nvme_kick(void *s, unsigned q_index) "s %p q #%u" nvme_dma_flush_queue_wait(void *s) "s %p" nvme_error(int cmd_specific, int sq_head, int sqid, int cid, int status) "cmd_specific %d sq_head %d sqid %d cid %d status 0x%x" -nvme_process_completion(void *s, int index, int inflight) "s %p queue %d inflight %d" -nvme_process_completion_queue_plugged(void *s, int index) "s %p queue %d" -nvme_complete_command(void *s, int index, int cid) "s %p queue %d cid %d" -nvme_submit_command(void *s, int index, int cid) "s %p queue %d cid %d" +nvme_process_completion(void *s, unsigned q_index, int inflight) "s %p q #%u inflight %d" +nvme_process_completion_queue_plugged(void *s, unsigned q_index) "s %p q #%u" +nvme_complete_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d" +nvme_submit_command(void *s, unsigned q_index, int cid) "s %p q #%u cid %d" nvme_submit_command_raw(int c0, int c1, int c2, int c3, int c4, int c5, int c6, int c7) "%02x %02x %02x %02x %02x %02x %02x %02x" nvme_handle_event(void *s) "s %p" nvme_poll_queue(void *s, unsigned q_index) "s %p q #%u" From patchwork Thu Oct 29 09:32:51 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: 1389989 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=T0LxP+Hu; 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 4CML4Q5YCJz9sRR for ; Thu, 29 Oct 2020 20:39:17 +1100 (AEDT) Received: from localhost ([::1]:40806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Op-0004xt-BL for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:39:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jv-0006EJ-4Y for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Js-0006aq-UH for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964048; 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=C+MwM4zuNe+rNYGXGpfeK41VSib34xtRzDIP8WoYZOs=; b=T0LxP+Hub2oDOqnuMNCLj/y3U5tGd+VHmOwPLw3pA/isG8JMMX397FfqWqrFL/95xzDidZ tKNM1wyw3GUU0DrCe411YclmD28dOu61w+1qEreBIwe62PKQgw4etzHrtrCY+9BJHmGQCB M4E4IxRprO7W/jtWclu5qDi8iB7v/V8= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-xNwsfrrqMvuWu6tV1aBMqQ-1; Thu, 29 Oct 2020 05:34:04 -0400 X-MC-Unique: xNwsfrrqMvuWu6tV1aBMqQ-1 Received: by mail-ed1-f72.google.com with SMTP id bs10so918652edb.22 for ; Thu, 29 Oct 2020 02:34:04 -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=C+MwM4zuNe+rNYGXGpfeK41VSib34xtRzDIP8WoYZOs=; b=asj9IZhNNtcE/stwMAS5VGdD646H6n42Q2a+EOSLoWlSZ9jh4r+5D5zjuIQVROJoio rU/oM0xcW1APqRRHrT4O6BaURUa0D30GocTtxcK/X/MfZQRwtRNWEoz9jzoU5RKG3aEc rVgA1OJcqLmBjMs3K21YOMKpy6aL/zBrDteEw0kZXlKrPTYUeLXI+efCOwOSsL580pLm YHvA+EZMZG3G8EeFYUNlJICb/mgzsD2Bxx6wU8Dq0NddVmbSsc+pcxTZKSFYdg8FfbX5 0QDKQDasF/YDXff4B/xsvo0C0E+DdvWIyPyJHlGMzMYZ9YYfMLBq7tZlqWOXxOaa84LD lKYw== X-Gm-Message-State: AOAM532zhLS04BpS0x66A24J3hr9bl9whsybuEh3h173O9sicuPlHAAq hvqcX/I2++sOtMI08zHOKg8CbM6+mX7jcAKVJChoZHIGwy6xmWQlJLCA2HolQwZPUQagXXiX0H7 6ZG96/EkMGG8ytNg= X-Received: by 2002:a50:8125:: with SMTP id 34mr3152140edc.39.1603964043060; Thu, 29 Oct 2020 02:34:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF4kkM/D9J7bCjTQpyvr3ZD4e+DAev94YnVBvQHSdQCIOAaI9hOoQR1Cw/w4IUExJsIfzPKQ== X-Received: by 2002:a50:8125:: with SMTP id 34mr3152120edc.39.1603964042834; Thu, 29 Oct 2020 02:34:02 -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 k26sm1166658edf.85.2020.10.29.02.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:02 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 10/25] block/nvme: Make nvme_identify() return boolean indicating error Date: Thu, 29 Oct 2020 10:32:51 +0100 Message-Id: <20201029093306.1063879-11-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=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 , 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" Just for consistency, following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), return a boolean value indicating an error is set or not. Directly pass errp as the local_err is not requested in our case. Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index c450499111e..98335012457 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -506,9 +506,11 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, return ret; } -static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) +/* Returns true on success, false on failure. */ +static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) { BDRVNVMeState *s = bs->opaque; + bool ret = false; union { NvmeIdCtrl ctrl; NvmeIdNs ns; @@ -585,10 +587,13 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) goto out; } + ret = true; s->blkshift = lbaf->ds; out: qemu_vfio_dma_unmap(s->vfio, id); qemu_vfree(id); + + return ret; } static bool nvme_poll_queue(NVMeQueuePair *q) @@ -701,7 +706,6 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, uint64_t cap; uint64_t timeout_ms; uint64_t deadline, now; - Error *local_err = NULL; volatile NvmeBar *regs = NULL; qemu_co_mutex_init(&s->dma_map_lock); @@ -818,9 +822,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, &s->irq_notifier[MSIX_SHARED_IRQ_IDX], false, nvme_handle_event, nvme_poll_cb); - nvme_identify(bs, namespace, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!nvme_identify(bs, namespace, errp)) { ret = -EIO; goto out; } From patchwork Thu Oct 29 09:32:52 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: 1389993 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=Cg5uRFWq; 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 4CML6g5c9sz9sRR for ; Thu, 29 Oct 2020 20:41:15 +1100 (AEDT) Received: from localhost ([::1]:49174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Qj-0008JH-Nm for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:41:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jz-0006RA-Mg for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33720) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Jw-0006cM-Jb for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964051; 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=kaU4zZuJB4tESn4H6GCPctUQ4pXRnoC4EnBxMdQNjsg=; b=Cg5uRFWqOQAwrfYSnxEX26TGHaNuCV0osUcgeFtPPjcJ2o/lXkhqF/hQnABjcnXgb43eEM mrHhJn3zO14ojJ3KilXOIc/scm5TzCVcIkrPpcZZCP6hILg8FlQmGxclyzIbAI2Vq5RBHr R+VfHpcuh11K2XX42hZ0Boo/VKpy82c= 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-69-HVuzqqCJPQWDKQxTkQSi4g-1; Thu, 29 Oct 2020 05:34:10 -0400 X-MC-Unique: HVuzqqCJPQWDKQxTkQSi4g-1 Received: by mail-ej1-f69.google.com with SMTP id x12so919020eju.22 for ; Thu, 29 Oct 2020 02:34:09 -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=kaU4zZuJB4tESn4H6GCPctUQ4pXRnoC4EnBxMdQNjsg=; b=KhZeraOpZQx2+NfDhdc7QZ0yKPDsx8L2IgrudWMTVOeZnNyXXIEomOpWsO4cdZ9SCD MSoud+I0PHV1BukIMTf7+vElT0Iwk51Ts7vH1cktiOt5UF1NUjBdSrg4NKOTclk5Fb73 JRx5pOFvUMAt4aTdPVCEU8YJb+G0TzXHafKS8fJy1T91f8HnrfoCP9qp3fGE/InMDcKo +0RHXop6CC0v8zugEwYOirv+b7pbZKclthxk4Fll+Bv4pHeKZzC5R9fQHqYbmzqjqk9K 8nl95PWQdCwqu0Sj4nuPosKGIHWwSloOjGMKUI39ZEG0Mp3tzETm51a7CEA1aEl+3GDp 3lkg== X-Gm-Message-State: AOAM533CiEH59YV+EX8SABWu4edbSW5X7oYV6pNnf6G4RExcdARYWVk+ FVxMyYCnf9k2dM7OJlf68nO7D/CTY2iu3Hxb/ltbgVpF6A/mhWu0qlySUG1vwo5bRYLBAo7pqih teCM0k8AkgsEZFY4= X-Received: by 2002:a05:6402:141:: with SMTP id s1mr2884124edu.87.1603964048409; Thu, 29 Oct 2020 02:34:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjcgH2rmz4jkf1kCqXySw/RvA8JU3syM6Ue6HVP6EL2HofhsUzs21j0aQXfQ0C/Q3T4kMnhQ== X-Received: by 2002:a05:6402:141:: with SMTP id s1mr2884116edu.87.1603964048257; Thu, 29 Oct 2020 02:34:08 -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 v2sm1134551ejh.57.2020.10.29.02.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:07 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 11/25] block/nvme: Make nvme_init_queue() return boolean indicating error Date: Thu, 29 Oct 2020 10:32:52 +0100 Message-Id: <20201029093306.1063879-12-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=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 , 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" Just for consistency, following the example documented since commit e3fe3988d7 ("error: Document Error API usage rules"), return a boolean value indicating an error is set or not. Directly pass errp as the local_err is not requested in our case. This simplifies a bit nvme_create_queue_pair(). Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 98335012457..6eaba4e7039 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -160,7 +160,8 @@ static QemuOptsList runtime_opts = { }, }; -static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, +/* Returns true on success, false on failure. */ +static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, unsigned nentries, size_t entry_bytes, Error **errp) { size_t bytes; @@ -171,13 +172,15 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, q->queue = qemu_try_memalign(s->page_size, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); - return; + return false; } memset(q->queue, 0, bytes); r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); if (r) { error_setg(errp, "Cannot map queue"); + return false; } + return true; } static void nvme_free_queue_pair(NVMeQueuePair *q) @@ -210,7 +213,6 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, Error **errp) { int i, r; - Error *local_err = NULL; NVMeQueuePair *q; uint64_t prp_list_iova; @@ -247,16 +249,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, req->prp_list_iova = prp_list_iova + i * s->page_size; } - nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, &local_err); - if (local_err) { - error_propagate(errp, local_err); + if (!nvme_init_queue(s, &q->sq, size, NVME_SQ_ENTRY_BYTES, errp)) { goto fail; } q->sq.doorbell = &s->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); + if (!nvme_init_queue(s, &q->cq, size, NVME_CQ_ENTRY_BYTES, errp)) { goto fail; } q->cq.doorbell = &s->doorbells[idx * s->doorbell_scale].cq_head; From patchwork Thu Oct 29 09:32:53 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: 1389994 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=QvZbEF6A; 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 4CML6k2zqnz9sRR for ; Thu, 29 Oct 2020 20:41:18 +1100 (AEDT) Received: from localhost ([::1]:49564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Qm-0008Sa-9Z for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:41:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4K6-0006ZF-MW for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4K2-0006eG-2N for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964057; 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=rby//ZoQW9S03FtYoV9vfiisbCFRimYXfnLqhWXSPDA=; b=QvZbEF6AivVKlTdq0lWq2MyLyR9lZmYTivWIABVIw+O0sllezRjj0uVg9BedgNAfsxAMVq 8yE1WH+0N2iKO4u3j5v5deH1luIwdFxl92EHauYZMxxhC68PZb+vx3Uw3UFpDehgC7joQC X1YSBktOF3StWAMjKLBEWwUZUj/IYjY= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-390-2v8EEPDBO5OsEcIVlkowgw-1; Thu, 29 Oct 2020 05:34:15 -0400 X-MC-Unique: 2v8EEPDBO5OsEcIVlkowgw-1 Received: by mail-ej1-f71.google.com with SMTP id x12so919111eju.22 for ; Thu, 29 Oct 2020 02:34:15 -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=rby//ZoQW9S03FtYoV9vfiisbCFRimYXfnLqhWXSPDA=; b=Jq7f9rYwhBObgPNJ2MVfXh/X88nXvdCGdg3tLs7XQUIChW3rAaFKn0iE0uzUnatdAJ MT2y2HZ3+4EQ63BUljb3Ko34sw1LBuIdNPXkim7fRePr8Z88AnSD0zXjc1khtd8xoEJm d+a2yIYpcvs0pxkMx/0fDcmAsGNRIEiYXAeRmOpO2ZMJ4i+yqE9QSz2IKq2jsIWO2uyJ XrAZX5meKfYkjpXSwcVLTNEoBvvEd+OceawdV0HyKYTm4HJSP4G6oaELaBs+DOKODca0 258rBgflUNxMmmARuIMVTueBPDAWx4fbCRJmozASky6z38HhgVmcu2iEbdZjk7fyt5Kj POfA== X-Gm-Message-State: AOAM5300EQNA+6lY3JlPI+5BJMW+RJoaVBN8Xk8aqwEszKhft1Ot1uL/ Ky3iIJVU+HpjIPVrlTI5stR6TBogcMtcwRGkC0W1ietfXSgDaZMOZI+0nNRjfx/mcpziklpL/la mh0xlu1Filyg5ApI= X-Received: by 2002:aa7:db07:: with SMTP id t7mr3066317eds.161.1603964053891; Thu, 29 Oct 2020 02:34:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJ0kdNF1Qc1dmy/i0wEBvojqnfi6haarp1JXLZ5a3wlyMNBoVkGSKDdNY5Kfbi2K2Yo5WUEw== X-Received: by 2002:aa7:db07:: with SMTP id t7mr3066301eds.161.1603964053749; Thu, 29 Oct 2020 02:34:13 -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 j3sm1186945edh.25.2020.10.29.02.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 12/25] block/nvme: Introduce Completion Queue definitions Date: Thu, 29 Oct 2020 10:32:53 +0100 Message-Id: <20201029093306.1063879-13-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=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/10/29 01:47:28 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 , 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" Rename Submission Queue flags with 'Sq' to differentiate submission queue flags from command queue flags, and introduce Completion Queue flag definitions. Reviewed-by: Eric Auger Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- include/block/nvme.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/block/nvme.h b/include/block/nvme.h index 65e68a82c89..c7ab9449125 100644 --- a/include/block/nvme.h +++ b/include/block/nvme.h @@ -491,6 +491,11 @@ typedef struct QEMU_PACKED NvmeCreateCq { #define NVME_CQ_FLAGS_PC(cq_flags) (cq_flags & 0x1) #define NVME_CQ_FLAGS_IEN(cq_flags) ((cq_flags >> 1) & 0x1) +enum NvmeFlagsCq { + NVME_CQ_PC = 1, + NVME_CQ_IEN = 2, +}; + typedef struct QEMU_PACKED NvmeCreateSq { uint8_t opcode; uint8_t flags; @@ -508,12 +513,13 @@ typedef struct QEMU_PACKED NvmeCreateSq { #define NVME_SQ_FLAGS_PC(sq_flags) (sq_flags & 0x1) #define NVME_SQ_FLAGS_QPRIO(sq_flags) ((sq_flags >> 1) & 0x3) -enum NvmeQueueFlags { - NVME_Q_PC = 1, - NVME_Q_PRIO_URGENT = 0, - NVME_Q_PRIO_HIGH = 1, - NVME_Q_PRIO_NORMAL = 2, - NVME_Q_PRIO_LOW = 3, +enum NvmeFlagsSq { + NVME_SQ_PC = 1, + + NVME_SQ_PRIO_URGENT = 0, + NVME_SQ_PRIO_HIGH = 1, + NVME_SQ_PRIO_NORMAL = 2, + NVME_SQ_PRIO_LOW = 3, }; typedef struct QEMU_PACKED NvmeIdentify { From patchwork Thu Oct 29 09:32:54 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: 1389987 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=TBaEF3W2; 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 4CML2R0QMCz9sS8 for ; Thu, 29 Oct 2020 20:37:35 +1100 (AEDT) Received: from localhost ([::1]:34280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4NB-0002Ks-0N for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:37:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4KA-0006kS-UW for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52869) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4K9-0006fV-9N for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964064; 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=TBaEF3W24N8HnYzXwazKR6IK5HLc1jXe92UhCZwF3S4Ef+8jlx2hBqON5J8n6KTpH0FAU5 Y4NwNWXs22DIQdRz9lDYR6Ufpsy5FurQOqgZ/P+OoVAy85lB13p06QMr4WRcoWZvlDV48B Fl0twnMEFWp2Lq3RzTMPLdG0redTrKM= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-NR3hA535Mey0QFCaRTQa3w-1; Thu, 29 Oct 2020 05:34:20 -0400 X-MC-Unique: NR3hA535Mey0QFCaRTQa3w-1 Received: by mail-ej1-f72.google.com with SMTP id d12so927924ejr.19 for ; Thu, 29 Oct 2020 02:34:20 -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=PNbQLcT2YAtJ+9yj7XsSRTYSXNgUiMYhENGCKNffe1M=; b=pkSOWZ5aQNrTCVO7dp+u7MkQvPIXUy+JX8QXjJcLNK+ywhV9xK23TsDxDRoiyMkYlJ 17+xe2FUYt/TNa3Lcvr418FNgermdbRRoaZxxoEWUZ15CgCGs6PNMhFF1e+UknaXANQS 4DdN8vgeivAcp6P4j86UMMFHzWrH496vlIWn73VQKM+rkbui+c4+Qaud0fjg8MKZOySJ XcqO9p1BAFZj6jQiTUHvb3Er4fFtY2OGIx457Sx+yC40b7HYW8nr9w1KIMwuLDQLUUzk MnKwc+2304Z0VDAW8XLTsPnPq7hdHxQ+j/9eqOOESRb8GXpCkDpfWq9unzwAFsxbD6jb ShYQ== X-Gm-Message-State: AOAM533mC9OCxCces1ZZoBCFGl0Fs4pyY4knSTndRyHGuzU+g0Xp/TaK hr3RL6aLEXCo/2HGk/Kt8tLquu+lueVL06w4+LdvaR4Xx75GIdLXZElaZByPR4E0q5oZ0763ZAz YCW1ENhYIVYK48l8= X-Received: by 2002:a17:906:8812:: with SMTP id zh18mr2051843ejb.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) 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) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org 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 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/10/29 01:47:28 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 , 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" 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é --- 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, Error **errp) NvmeCmd cmd; unsigned queue_size = NVME_QUEUE_SIZE; + assert(n <= UINT16_MAX); q = 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, Error **errp) cmd = (NvmeCmd) { .opcode = NVME_ADM_CMD_CREATE_CQ, .dptr.prp1 = cpu_to_le64(q->cq.iova), - .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), - .cdw11 = cpu_to_le32(0x3), + .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n), + .cdw11 = 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, Error **errp) cmd = (NvmeCmd) { .opcode = NVME_ADM_CMD_CREATE_SQ, .dptr.prp1 = cpu_to_le64(q->sq.iova), - .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | (n & 0xFFFF)), - .cdw11 = cpu_to_le32(0x1 | (n << 16)), + .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n), + .cdw11 = 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); From patchwork Thu Oct 29 09:32:55 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: 1389991 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=bAjkEx3O; 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 4CML4k6c68z9sRR for ; Thu, 29 Oct 2020 20:39:34 +1100 (AEDT) Received: from localhost ([::1]:42724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4P6-0005jG-SS for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:39:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4KE-0006su-4O for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23952) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4KC-0006gZ-FK for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964067; 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=d/cFTVW+ke5uZg7BAFOkxbRZHK6mRcrvyD+HcJ4ykuI=; b=bAjkEx3Ovo46Vaqj2UOAn9sPzbUxOAPaXSXpeZiASxh9kiReUFmNjAulmZIph/hA03MdWh GMc1aPizHdHG/WAQ/9n0MR896DbZzvMEVZ0fB8y+AjfieO7MgcTtvGrNZOtPb4iF/MBrn4 Lfk3PuYNVlbCOegMCK2pxukpvaBKtH4= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-287-Om8eoJLGNUeHokQT4d_cYQ-1; Thu, 29 Oct 2020 05:34:26 -0400 X-MC-Unique: Om8eoJLGNUeHokQT4d_cYQ-1 Received: by mail-ej1-f71.google.com with SMTP id z25so952898ejd.2 for ; Thu, 29 Oct 2020 02:34:25 -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=d/cFTVW+ke5uZg7BAFOkxbRZHK6mRcrvyD+HcJ4ykuI=; b=VTcIlXYsrKiBptC9sTvf/VmGNlENvzY5XLKaA4OPaM/s7D5aydp61aRjqFuiy68fjD TjmtuxTrZBZMl7uiKnl8V4HbOONYHEWpl4xAFU3CrO1Gq8GOO7py7sscL0Yhqk7uvYqe mzKz29t4xkBfq2PTeN7yps8KBzhZmx1X5o4C6Ksip65Szj2hsb33PXQXnFe+NqS2mRCG zvWKNHkTo3uwp0boJATJ4ycNz/qnfkQF+6unBnK6Gnrn9Gfp7gOjmquemAy3AEZ4cgHD Zbt1JhIJy+uYA/cuyENkipql1c8mGeUjDB4LOxG7qltzUm7OVJlKCIcM+D4BLfI2uqXE WTtw== X-Gm-Message-State: AOAM531s9uH6rYkYB2q9/nGAfLJbdLjZq52Ey+vFvq27jICkMBqhCKWK G/ArXudWYkgTf/UU/75PDHePocoLL7lioC+oIdgrjJ8Q0p2cW/1ZCgzmNXoOraBh/aqjgDgUFLe OXUyTHLgH9Qy4zRQ= X-Received: by 2002:a17:907:72cd:: with SMTP id du13mr2973288ejc.398.1603964064633; Thu, 29 Oct 2020 02:34:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVSu+lYk6jMn2irOn3PJRKjNzw+BrS0+xizRLdjzcZjOzFzUQEKieP9hh/pnhDXNiADjs22g== X-Received: by 2002:a17:907:72cd:: with SMTP id du13mr2973272ejc.398.1603964064456; Thu, 29 Oct 2020 02:34:24 -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 p9sm1137861ejo.75.2020.10.29.02.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 14/25] block/nvme: Correctly initialize Admin Queue Attributes Date: Thu, 29 Oct 2020 10:32:55 +0100 Message-Id: <20201029093306.1063879-15-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" From the specification chapter 3.1.8 "AQA - Admin Queue Attributes" the Admin Submission Queue Size field is a 0’s based value: Admin Submission Queue Size (ASQS): Defines the size of the Admin Submission Queue in entries. Enabling a controller while this field is cleared to 00h produces undefined results. The minimum size of the Admin Submission Queue is two entries. The maximum size of the Admin Submission Queue is 4096 entries. This is a 0’s based value. This bug has never been hit because the device initialization uses a single command synchronously :) Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 7285bd2e271..0902aa55428 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -789,9 +789,9 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, goto out; } s->queue_count = 1; - QEMU_BUILD_BUG_ON(NVME_QUEUE_SIZE & 0xF000); - regs->aqa = cpu_to_le32((NVME_QUEUE_SIZE << AQA_ACQS_SHIFT) | - (NVME_QUEUE_SIZE << AQA_ASQS_SHIFT)); + 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); 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) | From patchwork Thu Oct 29 09:32:57 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: 1389995 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=ct8Rm56t; 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 4CML8T214Nz9sRR for ; Thu, 29 Oct 2020 20:42:49 +1100 (AEDT) Received: from localhost ([::1]:52544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4SF-0001Jz-74 for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:42:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4KQ-0007BQ-AT for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4KN-0006jn-PX for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964078; 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=uk13P8LCKUO2+gTBuoYZIar/VXLSwVbHDVchagy2v9g=; b=ct8Rm56tFcblCqlRbllqXZfHRi6oUkygOL4a7bJOBn5ndtsk3M4O4NXE62T6BXw48WvGc4 JbaaGJSLQ1Yk8ogJiu08IBqgQTGGtXP+b6EaEchx6b1iQNFPVvfPAkJ/yWHbUYv7PyxEqa AY1aZ+eoATzkS0SdplnhF2Wcx73hMfg= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-6-qfCPOU8QOPO7szw8IzWH8g-1; Thu, 29 Oct 2020 05:34:37 -0400 X-MC-Unique: qfCPOU8QOPO7szw8IzWH8g-1 Received: by mail-ed1-f70.google.com with SMTP id n16so929637edw.19 for ; Thu, 29 Oct 2020 02:34:36 -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=uk13P8LCKUO2+gTBuoYZIar/VXLSwVbHDVchagy2v9g=; b=UxPRK5x0ddp6Hp2mnv/2By36BaRCdfBAd1wQ/sQcqnXLi2BFNEEDzVED55a+HviWh8 B+OuItA4iay/9ADJImim3c4hOEvbXhQHPPFKnK8123/dT3LZWL0p2WMNc894eVkkmaU8 MFrlC8SWSsme/34zvZVuZCg5rDEU9Z8NezNpeQreM5++O7bjgazlgPu3xlMFl1tinIwk hspSwR4zZNRPCp5MjXTORMIn3G5MV/F+fPaKxQsbWKGIL4oNqPq0yPdqKBzjDi5YvwcW V9P11uzqaa/EbLu283SsnCwxq0xUdJkS4Xs5ZnuNldMIkcbqZpDZR64CZsoVlNL84be9 0wTw== X-Gm-Message-State: AOAM5308CCJaE9dbpFbgAfcytp2bX92+L6vG+XimB8orSfkJ92eAAUsr ZQORG/gdTedrnaYFdcpvae7PORsnXKfwD/G3fiR8ZtOh+TXdViDeRCi2zjO0/xHpVEkehK0Cap0 lqvor9qrC5rqwTaE= X-Received: by 2002:a17:906:3092:: with SMTP id 18mr3151795ejv.43.1603964075356; Thu, 29 Oct 2020 02:34:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbjM2Fpj5bt3pLxqZcx9djWaztai0dnd9QsR+pjSkJnrj3nhT6Umio4zz7kcYBYWoYzyDdsw== X-Received: by 2002:a17:906:3092:: with SMTP id 18mr3151781ejv.43.1603964075144; Thu, 29 Oct 2020 02:34:35 -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 oz18sm1151838ejb.55.2020.10.29.02.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 16/25] block/nvme: Simplify nvme_cmd_sync() Date: Thu, 29 Oct 2020 10:32:57 +0100 Message-Id: <20201029093306.1063879-17-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=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/10/29 01:47:28 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 , 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" As all commands use the ADMIN queue, it is pointless to pass it as argument each time. Remove the argument, and rename the function as nvme_admin_cmd_sync() to make this new behavior clearer. Reviewed-by: Eric Auger Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index eed12f4933c..cd875555caf 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -481,16 +481,17 @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req, qemu_mutex_unlock(&q->lock); } -static void nvme_cmd_sync_cb(void *opaque, int ret) +static void nvme_admin_cmd_sync_cb(void *opaque, int ret) { int *pret = opaque; *pret = ret; aio_wait_kick(); } -static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, - NvmeCmd *cmd) +static int nvme_admin_cmd_sync(BlockDriverState *bs, NvmeCmd *cmd) { + BDRVNVMeState *s = bs->opaque; + NVMeQueuePair *q = s->queues[INDEX_ADMIN]; AioContext *aio_context = bdrv_get_aio_context(bs); NVMeRequest *req; int ret = -EINPROGRESS; @@ -498,7 +499,7 @@ static int nvme_cmd_sync(BlockDriverState *bs, NVMeQueuePair *q, if (!req) { return -EBUSY; } - nvme_submit_command(q, req, cmd, nvme_cmd_sync_cb, &ret); + nvme_submit_command(q, req, cmd, nvme_admin_cmd_sync_cb, &ret); AIO_WAIT_WHILE(aio_context, ret == -EINPROGRESS); return ret; @@ -535,7 +536,7 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) memset(id, 0, sizeof(*id)); cmd.dptr.prp1 = cpu_to_le64(iova); - if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { + if (nvme_admin_cmd_sync(bs, &cmd)) { error_setg(errp, "Failed to identify controller"); goto out; } @@ -558,7 +559,7 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) memset(id, 0, sizeof(*id)); cmd.cdw10 = 0; cmd.nsid = cpu_to_le32(namespace); - if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { + if (nvme_admin_cmd_sync(bs, &cmd)) { error_setg(errp, "Failed to identify namespace"); goto out; } @@ -664,7 +665,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n), .cdw11 = cpu_to_le32(NVME_CQ_IEN | NVME_CQ_PC), }; - if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { + if (nvme_admin_cmd_sync(bs, &cmd)) { error_setg(errp, "Failed to create CQ io queue [%u]", n); goto out_error; } @@ -674,7 +675,7 @@ static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp) .cdw10 = cpu_to_le32(((queue_size - 1) << 16) | n), .cdw11 = cpu_to_le32(NVME_SQ_PC | (n << 16)), }; - if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { + if (nvme_admin_cmd_sync(bs, &cmd)) { error_setg(errp, "Failed to create SQ io queue [%u]", n); goto out_error; } @@ -887,7 +888,7 @@ static int nvme_enable_disable_write_cache(BlockDriverState *bs, bool enable, .cdw11 = cpu_to_le32(enable ? 0x01 : 0x00), }; - ret = nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd); + ret = nvme_admin_cmd_sync(bs, &cmd); if (ret) { error_setg(errp, "Failed to configure NVMe write cache"); } From patchwork Thu Oct 29 09:32:58 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: 1389996 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=NNBYfHeU; 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 4CMLBN515Sz9sRR for ; Thu, 29 Oct 2020 20:44:26 +1100 (AEDT) Received: from localhost ([::1]:57982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Tm-0003aW-QL for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:44:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4KU-0007Dx-4W for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50320) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4KS-0006ln-8B for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964083; 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=JSY478yiFOxfyipIIVIRTU0bevcPEjwiKUZ7hzso9Eo=; b=NNBYfHeUJYyE5Yh5bUFB4D44RqCEXlNAkRKNTxRy4UJuRAHspxQ6PJhDBIZ3tC5pvKM0kS twmm2LBkYoUaFdV4TOs8pjUVZ2Bw2dQ0Pxh3mNt/Qx0oEV27tgUoF6IPrATezwDGMGaooi 9IUo10TzTeNryOLSj8MpUqa7mzAjzsg= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-dM_A1GD2O_6eGSKsysjmYw-1; Thu, 29 Oct 2020 05:34:42 -0400 X-MC-Unique: dM_A1GD2O_6eGSKsysjmYw-1 Received: by mail-ed1-f71.google.com with SMTP id y99so633563ede.3 for ; Thu, 29 Oct 2020 02:34:41 -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=JSY478yiFOxfyipIIVIRTU0bevcPEjwiKUZ7hzso9Eo=; b=rbTTJAmRIWKVrCaPSr3jWVfB9NEs8oTtIUMO82ShLWrmg/5UlX4ezksNPUcuKnwxsf n/S1ZomgSdFy9qGvHK8ELGNEpRqnqR0jc9dXsYSTZvmzXP9aN8L/J0vNWCNK9d0fWmC9 hlZCuwMK80z4jppi275QgA+gVIdASwHnrnC5DpZaHvUAeOMCFVOSXfqH2+5ZTqCQh+g0 ciLsaODTzjHwuX0VvMcjRHgzfk92g/P+rCkpApn0Yzyt6ymoz6hESmwjucu+PObzE2K+ 16RuwiJZ7BvyO5KyDqQZ+YqQxNSmjOPbKD6qSORXMkM/kEJy3lBTNtZXXXiFUqAmCl/4 2p0A== X-Gm-Message-State: AOAM531MmUGz2FYIuDKiI7su8maPy0m8GoMka4nBMnSLFxryvGu35TnN RvJ379MqjckjPim40pD55EIgbpWNpYljPOFghC9g+SdPWZxHaET4UO7Jlq6tHmTUvjfOQfbJMFw zFcXz0jBU2dcJBYg= X-Received: by 2002:a05:6402:392:: with SMTP id o18mr3052701edv.283.1603964080701; Thu, 29 Oct 2020 02:34:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeYmxKt1Lq9v3GLSodnup8MdE9OlKJ3EwKtZI4k15vDKyB6ksdiQ9fU22CdMTavYoOecYPXg== X-Received: by 2002:a05:6402:392:: with SMTP id o18mr3052691edv.283.1603964080561; Thu, 29 Oct 2020 02:34:40 -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 m19sm1145059eda.72.2020.10.29.02.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 17/25] block/nvme: Set request_alignment at initialization Date: Thu, 29 Oct 2020 10:32:58 +0100 Message-Id: <20201029093306.1063879-18-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" Commit bdd6a90a9e5 ("block: Add VFIO based NVMe driver") sets the request_alignment in nvme_refresh_limits(). For consistency, also set it during initialization. Reported-by: Stefan Hajnoczi Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/nvme.c b/block/nvme.c index cd875555caf..bb75448a09f 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -758,6 +758,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, s->page_size = MAX(4096, 1 << NVME_CAP_MPSMIN(cap)); s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment = s->page_size; + bs->bl.request_alignment = s->page_size; timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000); /* Reset device to get a clean state. */ From patchwork Thu Oct 29 09:32:59 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: 1390003 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=XYHuVfNT; 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 4CMLFk5vryz9sRR for ; Thu, 29 Oct 2020 20:47:22 +1100 (AEDT) Received: from localhost ([::1]:39976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4We-0007mH-MW for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:47:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kb-0007I6-QF for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4KZ-0006oA-PH for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964089; 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=cY+deayBxNQZ5fZVujrukclTBWuP/LZ1eYsnj5g50jE=; b=XYHuVfNT/CgbwUL85wStzzbjChTIPeKTWdORHCdpzzDnbvAzxI8SGc5An52Tr6Liov/iyt Egr6T1uIOwYpKPjF+RN4uTCyToUOtqpt+YcwU+9HpydmAsoOubAqoL8lQtTq/6aiQaKg1E WrpTB4mMB9EKQEN/ClndU/1s2PRWShQ= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-AX4KvXYpPhWLICyoLadJgQ-1; Thu, 29 Oct 2020 05:34:47 -0400 X-MC-Unique: AX4KvXYpPhWLICyoLadJgQ-1 Received: by mail-ej1-f72.google.com with SMTP id p18so939449ejl.14 for ; Thu, 29 Oct 2020 02:34:47 -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=cY+deayBxNQZ5fZVujrukclTBWuP/LZ1eYsnj5g50jE=; b=mQchrGwNQohoUGFykHTjADfvmwiNP3yc9edUJxrbDcPaVG5gw13dCTWeAMb9xUODTL Q8jnyTMgPq4Ay5RxPPxpa0JKtygQN/NrT+o5NFcbTAFW9b235NH8jTnHzOnnvesxx+H7 LkqZ9JkKYgktDv/0SbKrVwYaB9ziM5lNM/kT/zFjJXqzjQuYD/KOclr/RtoxyIIqbhb0 w8/ENaZ604HTlovOTNbh8ZYOYAWtl5zzH25ae5rMIB3XYLBM7pDF/AQ5+N/oYomQg/X0 V96kQ6co0A/JnCYiQOB1C0wkWEPiEDNll3whq8aCkWN4i7IM53thlTzucubO87P0Sxcq qO/Q== X-Gm-Message-State: AOAM531qgHinbu2idOZM43g4n/+UghBBHmCZVwFgIl0zSB4Rvx/yHSxu NoOLkcBvMZMKozH30T8JQ8CdWemIXVJoAnyZLuowsPK+G+l99FkV4fdS+uK20QfUHITTf0ePn5i u+IFRopcQY/ZtegA= X-Received: by 2002:a17:906:b216:: with SMTP id p22mr3200837ejz.228.1603964086029; Thu, 29 Oct 2020 02:34:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPLTTLbOHI19ZgEFF+IVkmv117xie8yC+hrbe79Wkp3q3/8uNxXAwNzCsAZpTAzqdAUa2Bow== X-Received: by 2002:a17:906:b216:: with SMTP id p22mr3200816ejz.228.1603964085862; Thu, 29 Oct 2020 02:34:45 -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 h4sm1160619edj.1.2020.10.29.02.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:45 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 18/25] block/nvme: Correct minimum device page size Date: Thu, 29 Oct 2020 10:32:59 +0100 Message-Id: <20201029093306.1063879-19-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" While trying to simplify the code using a macro, we forgot the 12-bit shift... Correct that. Fixes: fad1eb68862 ("block/nvme: Use register definitions from 'block/nvme.h'") Reported-by: Eric Auger Reviewed-by: Stefan Hajnoczi Reviewed-by: Eric Auger Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index bb75448a09f..bd3860ac4ef 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -755,7 +755,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, goto out; } - s->page_size = MAX(4096, 1 << NVME_CAP_MPSMIN(cap)); + s->page_size = 1u << (12 + NVME_CAP_MPSMIN(cap)); s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment = s->page_size; bs->bl.request_alignment = s->page_size; From patchwork Thu Oct 29 09:33:00 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: 1390002 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=i/Lh4ilK; 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 4CMLFj22bqz9sRR for ; Thu, 29 Oct 2020 20:47:21 +1100 (AEDT) Received: from localhost ([::1]:39842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Wd-0007ij-6q for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:47:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kh-0007QV-4B for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31288) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kf-0006qP-KP for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:34:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964096; 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=rWiNSG2LUOKYVBwx8cuVrYTSHgZcY9BMn/MdeeoAo/g=; b=i/Lh4ilKDhkxr2YwsTetdA1kDxEKD5XbjqogzJIwP8e4TsnuCE6cfkr0vEjsdZBdT6EkyM ZYB4WGUbZgx3ShIHdeDMYD8VZuFL8+IJ9LYga27WtGSQtTsgYJEzMVZppHPC7cgpiqn0+1 VERTqrm0DcIRcdQxquFWNiuf7q4Rhsw= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-pT430mQMMYaLnspxPHLMyQ-1; Thu, 29 Oct 2020 05:34:52 -0400 X-MC-Unique: pT430mQMMYaLnspxPHLMyQ-1 Received: by mail-ed1-f71.google.com with SMTP id ay19so918977edb.23 for ; Thu, 29 Oct 2020 02:34:52 -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=rWiNSG2LUOKYVBwx8cuVrYTSHgZcY9BMn/MdeeoAo/g=; b=ZyE3DU2Lr8o3sNLbC0APpxduBGPVpwCLbfHUTh/DYlU+t9OcSVChBhiizVMO8iq69x oElx3HJu9+zjp1NMqIYofrMZyz73QpHuBGtNZfWTo3si6hWPuWlf3eJIlFn59eZl9OEB MJGC8ZI5ibnWNljRCg2l2OKPHuiiN/M+/ukd1Q6aHlEppxA4V55uZj7j+doAXgFRw6sO Niag1H5sG5MNoRCDXIkR3B0XNqJULiwS8jS6Tu/fiZky/lx4ZIoRA/i7gnh9+e9e4bzB DV286qNNGmnfC3qESRt/OO2Uy/10dUzvcGr4dkNr9WODonkHJBi+VN7sAgwWLrQdiwiO 5mSA== X-Gm-Message-State: AOAM533Pblprnoc1sP2izuLgijpQMMBSpqKdKJvxi0wmnVQYxjKmDK9A 41ZqgMPvK0PPe+tDdmXb334+3fLpmgl6rieAj+pjfcbV3WgHGDR05yxOeRCLuVhVpVhpH0dsSct C3OtRPFgN54XDm1s= X-Received: by 2002:a17:906:268c:: with SMTP id t12mr2980897ejc.377.1603964091267; Thu, 29 Oct 2020 02:34:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2fplAeCmn4KjQvLFwcFetSv60We+HjuDBR+g03i54KhnKmwag5CQRx/3lJomd4K8fucH/4w== X-Received: by 2002:a17:906:268c:: with SMTP id t12mr2980881ejc.377.1603964091126; Thu, 29 Oct 2020 02:34:51 -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 qp17sm1125194ejb.111.2020.10.29.02.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 19/25] block/nvme: Change size and alignment of IDENTIFY response buffer Date: Thu, 29 Oct 2020 10:33:00 +0100 Message-Id: <20201029093306.1063879-20-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=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/10/29 01:47:28 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 , 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" From: Eric Auger In preparation of 64kB host page support, let's change the size and alignment of the IDENTIFY command response buffer so that the VFIO DMA MAP succeeds. We align on the host page size. Signed-off-by: Eric Auger Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index bd3860ac4ef..7628623c05a 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -522,19 +522,20 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) .opcode = NVME_ADM_CMD_IDENTIFY, .cdw10 = cpu_to_le32(0x1), }; + size_t id_size = QEMU_ALIGN_UP(sizeof(*id), qemu_real_host_page_size); - id = qemu_try_memalign(s->page_size, sizeof(*id)); + id = qemu_try_memalign(qemu_real_host_page_size, id_size); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - r = qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova); + r = qemu_vfio_dma_map(s->vfio, id, id_size, true, &iova); if (r) { error_setg(errp, "Cannot map buffer for DMA"); goto out; } - memset(id, 0, sizeof(*id)); + memset(id, 0, id_size); cmd.dptr.prp1 = cpu_to_le64(iova); if (nvme_admin_cmd_sync(bs, &cmd)) { error_setg(errp, "Failed to identify controller"); @@ -556,7 +557,7 @@ static bool nvme_identify(BlockDriverState *bs, int namespace, Error **errp) s->supports_write_zeroes = !!(oncs & NVME_ONCS_WRITE_ZEROES); s->supports_discard = !!(oncs & NVME_ONCS_DSM); - memset(id, 0, sizeof(*id)); + memset(id, 0, id_size); cmd.cdw10 = 0; cmd.nsid = cpu_to_le32(namespace); if (nvme_admin_cmd_sync(bs, &cmd)) { From patchwork Thu Oct 29 09:33:01 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: 1390006 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=J0kDhgnn; 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 4CMLHs0KKtz9sRR for ; Thu, 29 Oct 2020 20:49:13 +1100 (AEDT) Received: from localhost ([::1]:48376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4YQ-0002lG-Vz for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:49:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kr-0007Ts-EI for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kn-0006sW-4R for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964101; 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=JwHFa3n4K0MRNvY+MTlxR5FZfku0vELlzpKB46QufT0=; b=J0kDhgnnPRuricAZf6foSuYBsNxfM+yo65xybsKMuntrAbanoURIHVGitS7tb4FDMrZIS3 cywsqfewokinSEzLImoR4IK7tIMJKHafkwL+4sO30kKDjGQ7wqUZMnQSHyfX06eZR3rqD7 guf2JCBeFyBxmjVQec47LjM5HU1y2lA= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-71-lffEFtLRMfGxpkRHUCmckA-1; Thu, 29 Oct 2020 05:34:58 -0400 X-MC-Unique: lffEFtLRMfGxpkRHUCmckA-1 Received: by mail-ed1-f70.google.com with SMTP id h6so931805edt.12 for ; Thu, 29 Oct 2020 02:34:57 -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=JwHFa3n4K0MRNvY+MTlxR5FZfku0vELlzpKB46QufT0=; b=dV4QgIVc+sJOLSIgtoY1p9I1QyIw8AfkaKcsZkavpnY+1381UEKcIc3HS0qHUyt5Nc Lo7n8i7dmVVtMrsZiUoFKxGvnimGtA7T92/4hW3F6jaHVtMogEQFtfH57b1rhBQOHVNB CPOlZEOi3zpxv+O9pRUHp5Asac4h5FgVUSsXPjLFsy8Vt9ITw7oxR0wXA1xKNASNLfC/ crPoWTqb9I+WhWpK4H88yvW13AJNIk3Ti3/RexhIBr0+HmhJYSpeX1+WouXKcMKR74Fh nsh8PMeaQRzOIFIJDqs7n1vxM7JkYr3jDhAYw5Kw18l8FdaIO4o+TTgkVbi9QYTiZt1T GKQQ== X-Gm-Message-State: AOAM5338pCKRKa+85NGK6nVkA8uUQA+s5uFxnwHnY40+RnBH/CI+mX0l xl5uS7RlYUE/vfY+J+0BkgeqTL/1M88dNCykN0jB+8cHpcIkmUuJqQmF7qzFsMER/1bZVOYIQkp 4ABa6Xf3Y6gw0EkI= X-Received: by 2002:a05:6402:141:: with SMTP id s1mr2886713edu.87.1603964096570; Thu, 29 Oct 2020 02:34:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7QAuuOGe2dK1cCwBgfqi+eBk4CBwAgMYE63Wgmr/SVWtbmU6rBBDo3gwwXt1muWGhPX8cjA== X-Received: by 2002:a05:6402:141:: with SMTP id s1mr2886692edu.87.1603964096391; Thu, 29 Oct 2020 02:34:56 -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 m16sm1185758edj.37.2020.10.29.02.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:34:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 20/25] block/nvme: Change size and alignment of queue Date: Thu, 29 Oct 2020 10:33:01 +0100 Message-Id: <20201029093306.1063879-21-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" From: Eric Auger In preparation of 64kB host page support, let's change the size and alignment of the queue so that the VFIO DMA MAP succeeds. We align on the host page size. Signed-off-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 7628623c05a..4a8589d2d29 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -167,9 +167,9 @@ static bool nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, size_t bytes; int r; - bytes = ROUND_UP(nentries * entry_bytes, s->page_size); + bytes = ROUND_UP(nentries * entry_bytes, qemu_real_host_page_size); q->head = q->tail = 0; - q->queue = qemu_try_memalign(s->page_size, bytes); + q->queue = qemu_try_memalign(qemu_real_host_page_size, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); return false; From patchwork Thu Oct 29 09:33:02 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: 1390007 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=N/QtvrlE; 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 4CMLMR3tRTz9sRR for ; Thu, 29 Oct 2020 20:52:19 +1100 (AEDT) Received: from localhost ([::1]:54600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4bR-0005Qu-IN for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:52:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Ku-0007Vi-3F for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38130) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kp-0006sm-6p for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964105; 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=ubWiemzbTn6vqYXI00YAYHXkMl8cmZxlbdS4QE+huSY=; b=N/QtvrlERwoLZ5nrtTQzX3FUfs6LlYu8bGVLfKEUFNB+X4ROKcl1kBCzbo4PgKW42dw0mt 0LOz0QoonNrMDGEP0hezE0aV74/hrQGD7b0zDLCh2YCnVQdJ1sP2Yb21wgL2Lsbq/ceJ5B SUROrybT1558h4HvsS+qwMStijBv4a0= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-193-cEItcgB9MRWL25b4t9mjNA-1; Thu, 29 Oct 2020 05:35:03 -0400 X-MC-Unique: cEItcgB9MRWL25b4t9mjNA-1 Received: by mail-ej1-f72.google.com with SMTP id p18so939670ejl.14 for ; Thu, 29 Oct 2020 02:35:03 -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=ubWiemzbTn6vqYXI00YAYHXkMl8cmZxlbdS4QE+huSY=; b=NAphbz4z0F1o4XCV/wF9BESVOZwLPbd329v4MepTrLZ3nV8NSVuOWy4mgwCcH5aFmj nvouQ/nuVhWxXHXUdTxh70mZlhGa5hlMyaqlC5wmrM4INB1JwL6HR56ehfee+YDYvmKE Gvs1bQ7iJO07nM5T2zU5jlzXBHR1KrxfLwUl4KoU6MbVepOdC8z8l5DZAhvqLgVdp+Ts EnU6FW/EiuYcAiuh7xSrikeQ9iIB/TEJtPgkokKNaZpnIjDlEXMOO1Fhl+UM98MkpIMO LgMxigcni+P0yWBbzWA/UaxuP4CArZbqH66WOEMhy/KynrLwoWfksvdQrbCNz01CPO7I 5MJw== X-Gm-Message-State: AOAM532HJddz/UWSrQlLFkt0uaqtEZlF83hPmGPYj8sGWQAgdv+vpRPO KhzrP1zyn//5z5rDQ2M+fH6zoy67fxqorvd7uLSDh9dOabYuUbpSmrE2JxoKz/ObmZmGmvjUURD XXP0tmdGCLNZUoks= X-Received: by 2002:a50:e705:: with SMTP id a5mr3025233edn.29.1603964101963; Thu, 29 Oct 2020 02:35:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj7AU9r302XYl0o0JrbIYdM6n4Tgtrrcvc5eHp/Ce/n3dgfajSbx0/WUJb1zx5rdqTrrQNUw== X-Received: by 2002:a50:e705:: with SMTP id a5mr3025225edn.29.1603964101828; Thu, 29 Oct 2020 02:35:01 -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 f13sm1145307ejf.42.2020.10.29.02.35.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:35:01 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 21/25] block/nvme: Change size and alignment of prp_list_pages Date: Thu, 29 Oct 2020 10:33:02 +0100 Message-Id: <20201029093306.1063879-22-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=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 , 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" From: Eric Auger In preparation of 64kB host page support, let's change the size and alignment of the prp_list_pages so that the VFIO DMA MAP succeeds with 64kB host page size. We align on the host page size. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 4a8589d2d29..e807dd56dfe 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -215,6 +215,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, int i, r; NVMeQueuePair *q; uint64_t prp_list_iova; + size_t bytes; q = g_try_new0(NVMeQueuePair, 1); if (!q) { @@ -222,19 +223,19 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, } trace_nvme_create_queue_pair(idx, q, size, aio_context, event_notifier_get_fd(s->irq_notifier)); - q->prp_list_pages = qemu_try_memalign(s->page_size, - s->page_size * NVME_NUM_REQS); + bytes = QEMU_ALIGN_UP(s->page_size * NVME_NUM_REQS, + qemu_real_host_page_size); + q->prp_list_pages = qemu_try_memalign(qemu_real_host_page_size, bytes); if (!q->prp_list_pages) { goto fail; } - memset(q->prp_list_pages, 0, s->page_size * NVME_NUM_REQS); + memset(q->prp_list_pages, 0, bytes); qemu_mutex_init(&q->lock); q->s = s; q->index = idx; qemu_co_queue_init(&q->free_req_queue); q->completion_bh = aio_bh_new(aio_context, nvme_process_completion_bh, q); - r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, - s->page_size * NVME_NUM_REQS, + r = qemu_vfio_dma_map(s->vfio, q->prp_list_pages, bytes, false, &prp_list_iova); if (r) { goto fail; From patchwork Thu Oct 29 09:33:03 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: 1389998 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=YZB+lcUH; 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 4CMLBy5jKkz9sRR for ; Thu, 29 Oct 2020 20:44:58 +1100 (AEDT) Received: from localhost ([::1]:32826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4UK-0004nn-OS for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:44:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kw-0007XO-Tk for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kt-0006v9-AW for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964110; 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=8ebpGRl8V/SQHWtFmQyZ24PuNhlns0+asaugWNkot24=; b=YZB+lcUH/UulU+lYN7O22YvOniWGaSgxlJ6ydxU49Nvxa7joArMHd3M56bSHY2hWVhsiBK oMFWfqzW8N1j+jFASntG0zZJJkvr90277PDUNgdZO+PQFSs1FGeH1I1Ozl8yvHwBP8MEpc ZsJO47V9JUrIf8UBak2pKxsfCpG1rzc= 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-264-FSQNrRK4NRq85nPtBPBi4A-1; Thu, 29 Oct 2020 05:35:08 -0400 X-MC-Unique: FSQNrRK4NRq85nPtBPBi4A-1 Received: by mail-ej1-f70.google.com with SMTP id o27so929514eji.12 for ; Thu, 29 Oct 2020 02:35:08 -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=8ebpGRl8V/SQHWtFmQyZ24PuNhlns0+asaugWNkot24=; b=ifRLNHcyaryjsYGtgZ8WVkn2KbeQOLxAtMODKYudMULzH+OSW/CpCbMVPj418UAPUj yioWcjcLQW3fyFPE08fhdMlKRRqanvuEAUxe82kFsyrMrZyunJYxpOwbZH5bZQUSt8OJ udn2ZoZkld9neLlf48h3XMqJpqg+5SXa55JHFaPrPKxoFFLyoEsJEL0c+VUCvX8AO6Zo y8eutgjcsQq9z8AFkxG/NUbFKl6WBFdadfhp9G/Ylp3ALm436sZVJvPjeEIGer1zeL8E VXyvPlGgarYPQ7MiSTHJNiOKNplSlgzRGTZvy8hJtuyjjVKoJkfihR5ZGttcLj2ZXEg0 LiMQ== X-Gm-Message-State: AOAM533ZSaKCf2gTl+m/p90vuk5cSnGcqW3PWZtpjqd/9p8CG9YJLOPq ObvRDOcSlIMl6whotDzeHI8g+U0mLZHPvmHiCL7+1gdPdSV1gcSGwx080HiQy+qPUeRBdswWndx uOiAQ8/ayEQCHTHE= X-Received: by 2002:a05:6402:1004:: with SMTP id c4mr3001094edu.149.1603964107186; Thu, 29 Oct 2020 02:35:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydv1/hzCveV0yJGEQIelPM8p1TF/vx6Lv0Ya7VjwzOzBrXzGv+iGdES7KEf2jLrzvvLRSAlA== X-Received: by 2002:a05:6402:1004:: with SMTP id c4mr3001077edu.149.1603964107030; Thu, 29 Oct 2020 02:35:07 -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 ds7sm1162895ejc.83.2020.10.29.02.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:35:06 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 22/25] block/nvme: Align iov's va and size on host page size Date: Thu, 29 Oct 2020 10:33:03 +0100 Message-Id: <20201029093306.1063879-23-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=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/10/29 01:47:28 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=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" From: Eric Auger Make sure iov's va and size are properly aligned on the host page size. Signed-off-by: Eric Auger Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index e807dd56dfe..f1e2fd34cdf 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1015,11 +1015,12 @@ static coroutine_fn int nvme_cmd_map_qiov(BlockDriverState *bs, NvmeCmd *cmd, for (i = 0; i < qiov->niov; ++i) { bool retry = true; uint64_t iova; + size_t len = QEMU_ALIGN_UP(qiov->iov[i].iov_len, + qemu_real_host_page_size); try_map: r = qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, - qiov->iov[i].iov_len, - true, &iova); + len, true, &iova); if (r == -ENOMEM && retry) { retry = false; trace_nvme_dma_flush_queue_wait(s); @@ -1163,8 +1164,9 @@ static inline bool nvme_qiov_aligned(BlockDriverState *bs, BDRVNVMeState *s = bs->opaque; for (i = 0; i < qiov->niov; ++i) { - if (!QEMU_PTR_IS_ALIGNED(qiov->iov[i].iov_base, s->page_size) || - !QEMU_IS_ALIGNED(qiov->iov[i].iov_len, s->page_size)) { + if (!QEMU_PTR_IS_ALIGNED(qiov->iov[i].iov_base, + qemu_real_host_page_size) || + !QEMU_IS_ALIGNED(qiov->iov[i].iov_len, qemu_real_host_page_size)) { trace_nvme_qiov_unaligned(qiov, i, qiov->iov[i].iov_base, qiov->iov[i].iov_len, s->page_size); return false; @@ -1180,7 +1182,7 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, int r; uint8_t *buf = NULL; QEMUIOVector local_qiov; - + size_t len = QEMU_ALIGN_UP(bytes, qemu_real_host_page_size); assert(QEMU_IS_ALIGNED(offset, s->page_size)); assert(QEMU_IS_ALIGNED(bytes, s->page_size)); assert(bytes <= s->max_transfer); @@ -1190,7 +1192,7 @@ static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t bytes, } s->stats.unaligned_accesses++; trace_nvme_prw_buffered(s, offset, bytes, qiov->niov, is_write); - buf = qemu_try_memalign(s->page_size, bytes); + buf = qemu_try_memalign(qemu_real_host_page_size, len); if (!buf) { return -ENOMEM; From patchwork Thu Oct 29 09:33:04 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: 1389999 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=QipEwxeY; 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 4CMLC51vWXz9sRR for ; Thu, 29 Oct 2020 20:45:05 +1100 (AEDT) Received: from localhost ([::1]:33472 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4UR-000555-40 for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:45:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4L2-0007dU-RZ for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58161) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4Kz-0006wT-E5 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964115; 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=98878GiMo+xjdVFdoB+TjeRF3YgJ60igYiOFDXm/QLU=; b=QipEwxeYlro8IYd1NNxm09+qmyA8CjRWsriPXTV1Y9hYMPMBF7hDT+TFAWJAG8hQMICzc0 m19EvaWCCLYmp47wQ9dDPcaa55jgNBm3wMJZmcJpmFIK/ZyczI415jBVkTHM30BD9LCTIl CLJuJwGl/ld3qGifa2gw/jfDz5hyvZI= 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-522-TzowVO2YPrGepcrv8EN9bQ-1; Thu, 29 Oct 2020 05:35:14 -0400 X-MC-Unique: TzowVO2YPrGepcrv8EN9bQ-1 Received: by mail-ej1-f69.google.com with SMTP id x22so926736ejs.17 for ; Thu, 29 Oct 2020 02:35:14 -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=98878GiMo+xjdVFdoB+TjeRF3YgJ60igYiOFDXm/QLU=; b=P0B6Yi9w7B8YdJghx9lDAFBk5aDHYQp1wKpKI8MZvGpySrZ3cZ+NdBoW3fslyL/7mR hk5hV7ch/xEnSJo9wmfIO4OcDBCQJ5aJQHfapX8aD66/TVUN8N9CL6fbb3+jv82eYc03 mlfqJXyGkf8AM12V6KAKzUOMD3Cx6M22189gBqMG0ohlI0koEwGq/iRF18FhA8VjnVmW aHRQFKSEVwdOC6Hn2d+btpKHMAMMi1pfAzvfZu/NVrkS4rLOZkV9BjQW/mBn7dEuoJBQ 4VPFFmive1zt4TKA6fy/rDjBo4UEcoayc0KmKtPdawxdKFXAYyCKsoLahtoARqiGOwXG 2ZpA== X-Gm-Message-State: AOAM530Dwqme+w3wXw5irmQZEwu9HCfV+nGCt/fInsURFzg5enN/hejA IxLY1x6Lsqv+L7czYthiJtaD1vDoKxHv+w4mY5SW9hgLa9zrRjmMIJCv6NqUwc/M0daRAoasSTY WZBgNe2a/8ugujUo= X-Received: by 2002:a17:906:400f:: with SMTP id v15mr3072904ejj.378.1603964112373; Thu, 29 Oct 2020 02:35:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFJ+q1BWMaXOzvorAV1c/Ju86MCTBCYBhdj5L58nZSQnc5XWJk9FPRccn1+tIjdzqhZmBbug== X-Received: by 2002:a17:906:400f:: with SMTP id v15mr3072892ejj.378.1603964112216; Thu, 29 Oct 2020 02:35:12 -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 m25sm1158234edp.36.2020.10.29.02.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:35:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 23/25] block/nvme: Fix use of write-only doorbells page on Aarch64 arch Date: Thu, 29 Oct 2020 10:33:04 +0100 Message-Id: <20201029093306.1063879-24-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=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/10/29 01:47:28 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=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" qemu_vfio_pci_map_bar() calls mmap(), and mmap(2) states: 'offset' must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE). In commit f68453237b9 we started to use an offset of 4K which broke this contract on Aarch64 arch. Fix by mapping at offset 0, and and accessing doorbells at offset=4K. Fixes: f68453237b9 ("block/nvme: Map doorbells pages write-only") Reported-by: Eric Auger Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi Tested-by: Eric Auger Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index f1e2fd34cdf..c8ef69cbb28 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -94,6 +94,7 @@ typedef struct { struct BDRVNVMeState { AioContext *aio_context; QEMUVFIOState *vfio; + void *bar0_wo_map; /* Memory mapped registers */ volatile struct { uint32_t sq_tail; @@ -777,8 +778,10 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } } - s->doorbells = qemu_vfio_pci_map_bar(s->vfio, 0, sizeof(NvmeBar), - NVME_DOORBELL_SIZE, PROT_WRITE, errp); + s->bar0_wo_map = qemu_vfio_pci_map_bar(s->vfio, 0, 0, + sizeof(NvmeBar) + NVME_DOORBELL_SIZE, + PROT_WRITE, errp); + s->doorbells = (void *)((uintptr_t)s->bar0_wo_map + sizeof(NvmeBar)); if (!s->doorbells) { ret = -EINVAL; goto out; @@ -910,8 +913,8 @@ static void nvme_close(BlockDriverState *bs) &s->irq_notifier[MSIX_SHARED_IRQ_IDX], false, NULL, NULL); event_notifier_cleanup(&s->irq_notifier[MSIX_SHARED_IRQ_IDX]); - qemu_vfio_pci_unmap_bar(s->vfio, 0, (void *)s->doorbells, - sizeof(NvmeBar), NVME_DOORBELL_SIZE); + qemu_vfio_pci_unmap_bar(s->vfio, 0, s->bar0_wo_map, + 0, sizeof(NvmeBar) + NVME_DOORBELL_SIZE); qemu_vfio_close(s->vfio); g_free(s->device); From patchwork Thu Oct 29 09:33:05 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: 1390004 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=Mru2aeYG; 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 4CMLFz6Ltjz9sRR for ; Thu, 29 Oct 2020 20:47:35 +1100 (AEDT) Received: from localhost ([::1]:41276 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Wr-0008Jw-P3 for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:47:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4L7-0007rb-M5 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41620) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4L5-0006yI-UI for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964123; 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=E7ARdMdjChejWzNOv4rbThOcf14/Pp3Q0pevnTZmOLU=; b=Mru2aeYGSi9Qd/mKVg8D5e5kubhsN/fE8+QSwqzPhlmj7wHsUDqr6kqcwIS7ycBmP/3/GX wrznmKgrtNQJZCE4hxi2yHHbIFtVr+VdYdvOy8sSDCIkm5NijjsxCfV3AhqMjI5OEpyYPK PNmnfxHRcCYK0QMBnrICB/plLOx6EWs= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-LY4l8oY5Onmxac_bSHVb_A-1; Thu, 29 Oct 2020 05:35:19 -0400 X-MC-Unique: LY4l8oY5Onmxac_bSHVb_A-1 Received: by mail-ed1-f71.google.com with SMTP id 28so940956edv.9 for ; Thu, 29 Oct 2020 02:35:19 -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=E7ARdMdjChejWzNOv4rbThOcf14/Pp3Q0pevnTZmOLU=; b=b20dnmyD1+4qM7ZlIoGfUrTd/a7lI6xwx+AfLyNKL7jDzxB7yTd4u9wTd2E62fwvsP dt0uTHRw7p3uxl9crf+esEpJf8o20sMC+eV32wWfarhsWxC4BmzSL1SmY0eVfVSELoXD ADt3YeMkM3tYxjqhTG+0l8QH7NdAv/Ny42kNV7WqRBgfJU6wJGEaV+518LH/U5tCFtbx NuyLfHlMJpOOukxIEYJ4x0Hl2rUqxAoZu8b5he9FzXrYyN3sWAt+WwL2df0yqXsAQBYd G5Iin/TYvqf6zwvPpmxYu9uYYL79miA2YRHNPZlBQLcDnoQKlaxzJPsGTqJHDzyFmzKk IqjA== X-Gm-Message-State: AOAM530+nJdZvL8IDRWVEu2viJADgJ/OS7XpeeonQCeSlAXSl/6xzvRh 2xBrXYXXuPTIq9MV668NwDiXWcwex8ZnpXV5fX2p9N4WY/rY4bXk6nyl8E3hybi3uOVXovIBOA6 oSututea+It7gHJk= X-Received: by 2002:aa7:d843:: with SMTP id f3mr3132448eds.354.1603964117845; Thu, 29 Oct 2020 02:35:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAay3pmJYlLgbH6MPTB2Q0PEhx1HhlZ8YZ0CFL2D+WbqyLxHWDudhWsgUz+4hKpE6k5jM12w== X-Received: by 2002:aa7:d843:: with SMTP id f3mr3132424eds.354.1603964117514; Thu, 29 Oct 2020 02:35:17 -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 ao17sm1179118ejc.18.2020.10.29.02.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:35:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-5.2 v2 24/25] block/nvme: Fix nvme_submit_command() on big-endian host Date: Thu, 29 Oct 2020 10:33:05 +0100 Message-Id: <20201029093306.1063879-25-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=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/10/29 01:47:28 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 , 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" The Completion Queue Command Identifier is a 16-bit value, so nvme_submit_command() is unlikely to work on big-endian hosts, as the relevant bits are truncated. Fix by using the correct byte-swap function. Fixes: bdd6a90a9e5 ("block: Add VFIO based NVMe driver") Reported-by: Keith Busch Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index c8ef69cbb28..a06a188d530 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -469,7 +469,7 @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req, assert(!req->cb); req->cb = cb; req->opaque = opaque; - cmd->cid = cpu_to_le32(req->cid); + cmd->cid = cpu_to_le16(req->cid); trace_nvme_submit_command(q->s, q->index, req->cid); nvme_trace_command(cmd); From patchwork Thu Oct 29 09:33:06 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: 1390005 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=BJNepoLM; 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 4CMLG55BmNz9sRR for ; Thu, 29 Oct 2020 20:47:41 +1100 (AEDT) Received: from localhost ([::1]:41972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kY4Wx-00009I-It for incoming@patchwork.ozlabs.org; Thu, 29 Oct 2020 05:47:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kY4LA-0007z7-LV for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:36941) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kY4L8-0006zK-S8 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 05:35:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603964126; 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=6CxG9NMayv7lNoH0p7bnq04QWgTt0XfGriSybRVHEeM=; b=BJNepoLMw+gvZQgS1jOoYInFYD2+n5tW90+RHkd5AEfGQb460j8OWwd1cx8LEppz04Skw2 A7UbeZsMw0PZiVXYWKQGtEfBUvwatzVQgVs37NqxjCcSMC/Lbxld9ckhYiUDqyMbVP+LjT Rv/ls88VdhXW7uGUZJDgdoBX/glltA8= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-oIpCnK5QM5aNNpAUET7iHg-1; Thu, 29 Oct 2020 05:35:24 -0400 X-MC-Unique: oIpCnK5QM5aNNpAUET7iHg-1 Received: by mail-ed1-f72.google.com with SMTP id o2so956557edw.1 for ; Thu, 29 Oct 2020 02:35:24 -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=6CxG9NMayv7lNoH0p7bnq04QWgTt0XfGriSybRVHEeM=; b=omHZR1KMc4fO26jm/hDi+OhuudA5ZuR1XKtoLtmal13YUGZG23XdztAWC6quJrYSx7 wx3iIKFQB/dGTtXtIcIpLvdFrIHAYKxYF47DGn8+T4RX5vy0A6KEBQokcUI7DzlyBFWe 22sbEqIe9o72iu87C3dIEwwWYYEAeXnE2X4VpWHNn/H0SY04VSqP9wX7p9fwYWlEAVaA x9ytj566FADBSXtVAMuySc8btn0UESN5w6WDFo92UaMURjRCsULsltsgAlwh3hpSEZoH wkEKkNAHs3GMuSO3o4CyzVqW+kKj83B1eyX9JYC/GooB46ExwqF0lHp6Z808M50EjlzK 9R3A== X-Gm-Message-State: AOAM533qeq6e638KMUPlAbgnvomuXfeJLpitgpYa00ivZqwlmIep+2K0 8Gc77OH1jpV8kk4uyv1YNG8RixB11vI5b+U9+Oh1NsEkIpdb1S4iEHYxB+8fjqkokrUmxYChI+n T3YwVaRzDIog2LgM= X-Received: by 2002:a17:906:ad8:: with SMTP id z24mr3088364ejf.222.1603964123089; Thu, 29 Oct 2020 02:35:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwC+IWVYnxsFiNYMeoq8eRoPda2VfeSkfVEOq2EjdCKwWfduPOmGFFbe830j93S6av6NEoJ0A== X-Received: by 2002:a17:906:ad8:: with SMTP id z24mr3088349ejf.222.1603964122892; Thu, 29 Oct 2020 02:35:22 -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 z26sm1132422ejr.95.2020.10.29.02.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Oct 2020 02:35:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH-for-6.0 v2 25/25] block/nvme: Simplify Completion Queue Command Identifier field use Date: Thu, 29 Oct 2020 10:33:06 +0100 Message-Id: <20201029093306.1063879-26-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" The "Completion Queue Entry: DW 2" describes it as: This identifier is assigned by host software when the command is submitted to the Submission As the is just an opaque cookie, it is pointless to byte-swap it. Suggested-by: Keith Busch Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index a06a188d530..e7723c42a6d 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -344,7 +344,7 @@ static inline int nvme_translate_error(const NvmeCqe *c) trace_nvme_error(le32_to_cpu(c->result), le16_to_cpu(c->sq_head), le16_to_cpu(c->sq_id), - le16_to_cpu(c->cid), + c->cid, le16_to_cpu(status)); } switch (status) { @@ -401,7 +401,7 @@ static bool nvme_process_completion(NVMeQueuePair *q) if (!q->cq.head) { q->cq_phase = !q->cq_phase; } - cid = le16_to_cpu(c->cid); + cid = c->cid; if (cid == 0 || cid > NVME_QUEUE_SIZE) { warn_report("NVMe: Unexpected CID in completion queue: %"PRIu32", " "queue size: %u", cid, NVME_QUEUE_SIZE); @@ -469,7 +469,7 @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeRequest *req, assert(!req->cb); req->cb = cb; req->opaque = opaque; - cmd->cid = cpu_to_le16(req->cid); + cmd->cid = req->cid; trace_nvme_submit_command(q->s, q->index, req->cid); nvme_trace_command(cmd);