From patchwork Mon Oct 26 10:54: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: 270446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03D1AC4363A for ; Mon, 26 Oct 2020 10:57:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7651922404 for ; Mon, 26 Oct 2020 10:57:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K+IxzdyW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7651922404 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Bc-0000Ul-E3 for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 06:57:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX09o-0006w2-FX for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX09l-0007yG-GX for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709716; 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=RehUHE9smya/dLsky2IXktduYA/iO28rTmGbzKYGc9c=; b=K+IxzdyWMw62NoT6I61Xv4eBSglX2uei9ehh7dm9AUeYwaBM3nSTOi1yaDSDWbuPeGlZCT LjzNAKJQN0XSrmF5ZvwbD6N4nZC0MOeKYKdtGYsk1FkUmNu6Ybl6AVkDOz6XsSzcGeTEOP 3j9n1dxBe6C+s9zpTcKSruoOeKS/nDI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-T55Gtx7ZOqu6zuvGArDsbA-1; Mon, 26 Oct 2020 06:55:13 -0400 X-MC-Unique: T55Gtx7ZOqu6zuvGArDsbA-1 Received: by mail-wm1-f72.google.com with SMTP id r19so6172227wmh.9 for ; Mon, 26 Oct 2020 03:55:12 -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=RehUHE9smya/dLsky2IXktduYA/iO28rTmGbzKYGc9c=; b=gdWwct0/VQxpjx5o/Bn73Fgm/Da0CXrXbdt2XsMM1an/m4KnD3gEjCKFQYfS+nULpr DX7lhD9hBI7gvuWwU+0Th3JEL7IO+5haJz4AuimlHjjqsweQLRwNkxDk0T70DrQ2JLx4 tGl0RE0b5X4wUo+GPO7DYneXu1cFIpQMvSit5Sv+u/m34FR9/kTarre33awh4oGMz4SN A4dXgGLLk8KLXkaZzRs51a0WiMpdKYO2oTVUcQI3rSNg8Kc6yIncN6c1CJKIWSde2BvT CIoVsDanN47X3BYZUo+RKGyt7RIlEqzKJNLOFzc6HVfS4BOwSkORsEAuwsVNjLJXNzFD BVqw== X-Gm-Message-State: AOAM530+88P+MtnrldjqOCKcwnqtSWKxwjfTfPvzHO9QK2z8KucT57rn pQAINftsGxcZTgYvroeks0D1Nx+c3LgarVF7x6tNBGFxXVu/sLzrbyJwqrLDk1IL0h8+z2aiubm oEjJDdhJIDnzQIxc= X-Received: by 2002:a1c:3d0b:: with SMTP id k11mr16527956wma.155.1603709711813; Mon, 26 Oct 2020 03:55:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkJnI+75GNifqeIxOa5vyOW++22eYcXgv7c+VGmme8smKEu4b4HgE7XX5HtMH91aJ5X4PWyQ== X-Received: by 2002:a1c:3d0b:: with SMTP id k11mr16527937wma.155.1603709711669; Mon, 26 Oct 2020 03:55:11 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id o184sm19666112wmo.37.2020.10.26.03.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 01/19] block/nvme: Correct minimum device page size Date: Mon, 26 Oct 2020 11:54:46 +0100 Message-Id: <20201026105504.4023620-2-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.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 Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger --- block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index b48f6f25881..029694975b9 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -724,7 +724,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 = MAX(4096, 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; timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000); From patchwork Mon Oct 26 10:54: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: 302058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9916FC55178 for ; Mon, 26 Oct 2020 10:57:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 12D3D22404 for ; Mon, 26 Oct 2020 10:57:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BWqLZx/k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12D3D22404 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Bd-0000Wd-1u for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 06:57:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX09s-00071U-0D for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX09q-00082u-CP for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709721; 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=ffM492hetK8u/GqoMVkU0TJmIWrPk8dUIU3q04M7GGw=; b=BWqLZx/kD/uePf3MyoWF27bzYpol/ZHk0XwSNSowYTxL/WHuRp4DVFu+NAVjIh66WIbJ7P dNfvOiTiTJHv0HhKxuxXP+2/8+B/zHXODXFZQkK8dZf6fz5ppoBSrIRVDptc9Dh/cZPGrv vIpHf7Mt1hphd4Z61t68eyym3x03sx4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-203-8QQ0V6piOtCxFfPiAVEU7w-1; Mon, 26 Oct 2020 06:55:18 -0400 X-MC-Unique: 8QQ0V6piOtCxFfPiAVEU7w-1 Received: by mail-wr1-f72.google.com with SMTP id i6so8168275wrx.11 for ; Mon, 26 Oct 2020 03:55:17 -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=ffM492hetK8u/GqoMVkU0TJmIWrPk8dUIU3q04M7GGw=; b=rwo9vI8raL6+48yoZhY65EAHrdLYpZhjuh0TGjAKq6SWqZkVvcW9RtX214rc3ReWs3 OEZO4Z/udaG5Go8ytNP0If09Msl6CQQHUv8XnujhQYXBQvlyjd4yJDhPK6mmmn3LDTZQ j7NMDSmNdRnfu/ESIu7KLv+b9IWfFoTCpndKntpab0iIzMuXEUPXCr+yWEUfPLuBffSP 2Cu42oyqyFzodWGX+dNwshsriES+X8kA3Ot+GGVeIDTC96RaPrz08hBrCF02DpC1UfOT iO7iwIwwTaERmWmeEboNM6Kgui1AbyAZUu8By+yoid4K3sgbZjqBulLPQSMJr1xVxMxl xXRw== X-Gm-Message-State: AOAM532sWLZv0AnRBs8oVl1F56AKBhYzGPzFMwOe+47UEyuyvVk8tOgg +QFz6RPyIn19Tmcs9JsNuzEOuCSXPpPfr75DjpD0h+3ts1KRrFzaQWQZb6GJQveCFP/+NdHzC2b trnXMtqBPCIZAnaM= X-Received: by 2002:a1c:e1c2:: with SMTP id y185mr14956762wmg.81.1603709716730; Mon, 26 Oct 2020 03:55:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhIuyInzKn2sgFIiJf08tBwESRjMqdMxn5AcKY1mo1jNirvpBOWrhLuNjMMCTmdogxlmeARg== X-Received: by 2002:a1c:e1c2:: with SMTP id y185mr14956750wmg.81.1603709716535; Mon, 26 Oct 2020 03:55:16 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id e15sm21209863wro.13.2020.10.26.03.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:16 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 02/19] block/nvme: Set request_alignment at initialization Date: Mon, 26 Oct 2020 11:54:47 +0100 Message-Id: <20201026105504.4023620-3-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When introducing this driver in commit bdd6a90a9e5 ("block: Add VFIO based NVMe driver") we correctly set the request_alignment in nvme_refresh_limits() but forgot to set it at initialization. Do it now. Reported-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/nvme.c b/block/nvme.c index 029694975b9..aa290996679 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -727,6 +727,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, s->page_size = MAX(4096, 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; timeout_ms = MIN(500 * NVME_CAP_TO(cap), 30000); /* Reset device to get a clean state. */ From patchwork Mon Oct 26 10:54: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: 270444 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 668F0C55178 for ; Mon, 26 Oct 2020 10:59:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D6F7F22282 for ; Mon, 26 Oct 2020 10:59:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GPPAHYie" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6F7F22282 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:50328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0E4-000446-Qf for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 06:59:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX09w-00074X-5u for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX09t-00088l-TD for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709724; 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=TR2vPgke7yC3Tw04v9RRPAjEqIwyrI6NV8B8irqGPbU=; b=GPPAHYieH7zqqIJ9lSLHgCSSZy1HfDS2iaD+RfSY1Uvmf1SJK7JqV/xDWvAvWsIl6ZoeIM hc5AHJ/CmBwc7+bnC0KW+jnqWECSANX706kRmQDGbtEpwc9W5yRhPQhKlVpE/Z6A4m+1Vw +mBuq4bfKQXPIy2VjfR5BHWSTq3dOus= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-100-7HYDXEHBOwyLA0zH5t9ycQ-1; Mon, 26 Oct 2020 06:55:23 -0400 X-MC-Unique: 7HYDXEHBOwyLA0zH5t9ycQ-1 Received: by mail-wr1-f72.google.com with SMTP id k14so8191876wrd.6 for ; Mon, 26 Oct 2020 03:55:22 -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=TR2vPgke7yC3Tw04v9RRPAjEqIwyrI6NV8B8irqGPbU=; b=s/K6Zre0kCbfMyo9tuWPmySUfEkv0587X+uFtBOYw/hSZofWqMlA4sgfr6ZDyQaDvF kaES6z5T2fgPJuthTtt9+1D4bEdaC3GLH6Ie8ANgW9xgY8sYBeFI6yzlDkmBHwb1/Y2b ozkFUWJfOjtWs2QO4NVE8KcCG3/12j34YU3sz5AbV0veC0ZUMt4QRmjAWdnAI94DChiJ jQIVEWworFXlzi6b9E+M5loUxweuTCCwXekKTcMEuESAXZUxZZarpuuDSJplXL+7FQi3 dLdlxl7/pBCPxvGDBqjr2XDtxKWGYDmBiZ3/YqHNnh7HZtMD0GGh9+vRHPpYMIwk/r6T YE9g== X-Gm-Message-State: AOAM5331eFODYsWuNsnLRk3+Bx//iMVHWciGGHn+dlZSt641C7xF32Kd ORPYemhyZuJp5Qvmrq+e7ZKr1kvgI6GUf9I/SLVhtNnhGz4Jjf3oaQGnEl86Du81mho6fJzrymj DcVb2dPhi4E8cXP4= X-Received: by 2002:adf:fac3:: with SMTP id a3mr16453402wrs.240.1603709721621; Mon, 26 Oct 2020 03:55:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfKtDEGK6X/lpxCTfTGZoxf5rtNsDcwucctNYJkaT3xbI2aPqz9CPIhL4qSEngN9llLEwczA== X-Received: by 2002:adf:fac3:: with SMTP id a3mr16453371wrs.240.1603709721380; Mon, 26 Oct 2020 03:55:21 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id x6sm22609887wmb.17.2020.10.26.03.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 03/19] block/nvme: Introduce device/iommu 'page_size_min' variables Date: Mon, 26 Oct 2020 11:54:48 +0100 Message-Id: <20201026105504.4023620-4-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Introduce device/iommu 'page_size_min' variables to make the code clearer. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/nvme.c b/block/nvme.c index aa290996679..5abd7257cac 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -690,6 +690,8 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, uint64_t deadline, now; Error *local_err = NULL; volatile NvmeBar *regs = NULL; + size_t device_page_size_min; + size_t iommu_page_size_min = 4096; qemu_co_mutex_init(&s->dma_map_lock); qemu_co_queue_init(&s->dma_flush_queue); @@ -724,7 +726,8 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, goto out; } - s->page_size = MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap))); + device_page_size_min = 1u << (12 + NVME_CAP_MPSMIN(cap)); + s->page_size = MAX(iommu_page_size_min, device_page_size_min); 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 Mon Oct 26 10:54: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: 270445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54E09C2D0A3 for ; Mon, 26 Oct 2020 10:57:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ABF5922404 for ; Mon, 26 Oct 2020 10:57:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="W3msZQBx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABF5922404 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Bj-0000lz-DX for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 06:57:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0A2-0007Bd-Pu for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46482) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0A0-0008EA-9i for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709731; 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=W5p4tPu2TXjCzyH8ugJtEh2K4jonp6V4FsAYE5GR61Q=; b=W3msZQBxSYG9rhkQbnp3zJCd6RAT3Esl3SC6ukG2rI2Wob1TRCUHicEdIIVnMx8gqXgNi2 TdzUzymPQPLXN5O/HKCeHsZXZAuRj4dF12u/rdR2VibPJJs28AfStBNsi7qFmqrmMq6LDk fk+34X+lxjgOGFPWW3TKfXFPelGoPME= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-41-N_8FUwJZNM-47a-ztDHoLg-1; Mon, 26 Oct 2020 06:55:27 -0400 X-MC-Unique: N_8FUwJZNM-47a-ztDHoLg-1 Received: by mail-wm1-f71.google.com with SMTP id f191so5548142wmf.9 for ; Mon, 26 Oct 2020 03:55:27 -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=W5p4tPu2TXjCzyH8ugJtEh2K4jonp6V4FsAYE5GR61Q=; b=VVRWkHifOOfmRmfiRcEqk5gT9rGcSqS6Nresob/0V8rnV3be5H1pPx5DDjVbRHUNH6 4eYxFGMz+SeRTi612FSsVJTZRqNeQi2YMk9qtPFEnf7M4myNuOpvCKz8ECiYqxsik16+ VBpm3bPQ9D9ikyGFxGKp79XcDL3V1PNE310JqzcLar6CBhzOn65kSWwAfDB7Wn/Xs9VI 0j0vRd3fUsoLgN0+wVx79hqQMjPe189kpOExxK/rf+dpACzJaRB7kx0GAx5iVFpt1cRQ CYz1nDIpP5Tn9z9VZ6FRjjSXF31FD2szL8L8+z4eSQB3hdpKGm07Q3IoTT9kZhHW89B9 JPRQ== X-Gm-Message-State: AOAM531joSr18yUomkFj7xRckz3S7TMnWsjXFEci8c4OhQjECC88FBnk mcXygTrZa9+gd1ZYhKm6GqdRt0p3NG074r5xHL0ewPC67N7CY/aYBC7lcEQ8119JlueQPpL2jqb aG2HKNsxtfLgC6WA= X-Received: by 2002:a5d:4c4f:: with SMTP id n15mr16563047wrt.137.1603709726445; Mon, 26 Oct 2020 03:55:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVe+9JTZp3qp5jWBddiD8ybrIJ6tz51eInzL2wyLjC2LjAT3R04O9eDZwCyFG6bb89m+Rmmg== X-Received: by 2002:a5d:4c4f:: with SMTP id n15mr16563021wrt.137.1603709726215; Mon, 26 Oct 2020 03:55:26 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id s2sm22714740wmf.45.2020.10.26.03.55.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 04/19] block/nvme: Trace controller capabilities Date: Mon, 26 Oct 2020 11:54:49 +0100 Message-Id: <20201026105504.4023620-5-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.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. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi --- block/nvme.c | 10 ++++++++++ block/trace-events | 1 + 2 files changed, 11 insertions(+) diff --git a/block/nvme.c b/block/nvme.c index 5abd7257cac..3b6d3972ec2 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -720,6 +720,16 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, * Initialization". */ cap = le64_to_cpu(regs->cap); + trace_nvme_controller_capability("Maximum Queue Entries Supported", + NVME_CAP_MQES(cap)); + trace_nvme_controller_capability("Contiguous Queues Required", + NVME_CAP_CQR(cap)); + trace_nvme_controller_capability("Subsystem Reset Supported", + NVME_CAP_NSSRS(cap)); + trace_nvme_controller_capability("Memory Page Size Minimum", + NVME_CAP_MPSMIN(cap)); + trace_nvme_controller_capability("Memory Page Size Maximum", + 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 0e351c3fa3d..3f141dc6801 100644 --- a/block/trace-events +++ b/block/trace-events @@ -134,6 +134,7 @@ 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(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 Mon Oct 26 10:54: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: 270443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 497ABC4363A for ; Mon, 26 Oct 2020 11:00:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C81A6222EA for ; Mon, 26 Oct 2020 11:00:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ePl2R3Kq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C81A6222EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0F0-0005Mw-QP for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:00:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0A6-0007IH-04 for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:38275) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0A3-0008FL-7h for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709734; 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=v40hj3qY78whRoPdfOU/jnlm9Vu0+VmOWNSL1HaIBaY=; b=ePl2R3KqIeerkAl03ElWG+flDa7PG2vR7mg82IH0nxOyyJGFEWJtfsDnz4JsVH3JYDtvll hnASa1rbaodVbmIKzNmfSlHqXGswWCQ+vW7MUXQQ0CcB/dlB6ylo+Nfb6O6XTaV0FlNsm4 XompFkGHDlZH+GEDIyTvaTEi0UikUjo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-496-1inJM73QO7-XfztiREmXUQ-1; Mon, 26 Oct 2020 06:55:32 -0400 X-MC-Unique: 1inJM73QO7-XfztiREmXUQ-1 Received: by mail-wr1-f71.google.com with SMTP id 33so8153739wrf.22 for ; Mon, 26 Oct 2020 03:55: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=v40hj3qY78whRoPdfOU/jnlm9Vu0+VmOWNSL1HaIBaY=; b=UTevnFfWcMV7U6bRBrqDjLVX0GJ0KmkHzHhw3rj22cXNfv+juoqY7+6KpH60dlMC7c oHHg4KFLyAjq6mzwidDujQ06uEI9Cbwg6StvoVUmdEosXvBxemgJPAgpi/1pbVRFHFPp 2cqHhHRBDdjVBtsIP1l4ybyYKp4VZuZsT0V0UjBITbCjAh54V9AZ9d8c4e6g7eu1F9By xiwiGmK5ygljC9JCoDFxh7FE70EtcnmeDKgRJoS7JBEVSjn43ULFpYSY3TYUtqofW88G m6o9hjZcBNIM1HFeW8yIKLFSTauMJFPsWaM+mRSIpUgo1RrLSVRpPNJNXc4DQTUXlRE5 k3eA== X-Gm-Message-State: AOAM532NpIB4RbCHGXLpEDjp/1Mbaeoy2nj0gQvnK6gxewtiWR/Zb9je tMg5OdFpZTGhGjeEW+1lvmN1IjIdjhPqCrtryVpPsyae346+UFoF/nKw292lfZv7iYtPZFCQ/L4 3Ig4CfgC1ltU0ZYc= X-Received: by 2002:adf:b787:: with SMTP id s7mr18080753wre.390.1603709731141; Mon, 26 Oct 2020 03:55:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxArnquS83MoKMOGB9wkQvP/rs0d4NxPjydeloJhB2Mh9ZkwP/gL2SCIvEIBjtZbOso4aloNw== X-Received: by 2002:adf:b787:: with SMTP id s7mr18080737wre.390.1603709730967; Mon, 26 Oct 2020 03:55:30 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id v19sm18878384wmj.31.2020.10.26.03.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/19] util/vfio-helpers: Improve reporting unsupported IOMMU type Date: Mon, 26 Oct 2020 11:54:50 +0100 Message-Id: <20201026105504.4023620-6-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Change the confuse "VFIO IOMMU check failed" error message by the explicit "VFIO IOMMU Type1 is not supported" once. Example on POWER: $ qemu-system-ppc64 -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw qemu-system-ppc64: -drive if=none,id=nvme0,file=nvme://0001:01:00.0/1,format=raw: VFIO IOMMU Type1 is not supported Suggested-by: Alex Williamson Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index c469beb0616..14a549510fe 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -300,7 +300,7 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, } if (!ioctl(s->container, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) { - error_setg_errno(errp, errno, "VFIO IOMMU check failed"); + error_setg_errno(errp, errno, "VFIO IOMMU Type1 is not supported"); ret = -EINVAL; goto fail_container; } From patchwork Mon Oct 26 10:54: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: 302056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DBE3C61DD8 for ; Mon, 26 Oct 2020 11:00:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5FB32225C for ; Mon, 26 Oct 2020 11:00:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WYDTJ2aK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5FB32225C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:51770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0ES-0004eK-QF for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:00:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0AD-0007N6-Fy for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0A9-0008Hb-8P for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709740; 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=Xorc1cOMXgP1kep2uzooHQ3r71AwjF7u/vtY5+daI0U=; b=WYDTJ2aKBHact6t3hMDDeE6umBy5KUyYSw1rzH3B+DS8bTUF+rO1dORQnyLKHgdCpqwKIL z+6TRpuQyG4PcjgssXabh0iNWQbQ53GvgZk2b+P7ylO1dsfHdrmZU6psZxcmxOVPi18EEa Te5CZnqnkAu7goVuFQNL1CAm/GWlaDo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168-t2PGVpDrPby1jwqTKi78_g-1; Mon, 26 Oct 2020 06:55:39 -0400 X-MC-Unique: t2PGVpDrPby1jwqTKi78_g-1 Received: by mail-wm1-f71.google.com with SMTP id b23so295010wmj.6 for ; Mon, 26 Oct 2020 03:55: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=Xorc1cOMXgP1kep2uzooHQ3r71AwjF7u/vtY5+daI0U=; b=SumMM0Y34YAdlO4jgKi3xy/vzRybVnN/Nat+eV2oKvu1awktGjF5IjQKHDBKCYPE3c wTZL3IpILPi6FiS7Tr7GWQ9LhBlXI8h7bCFLU7SghExv76BrE5+ciyheZzzWEqd6o9EC XGsWZ9C9nY2G/2tYLc/rCjN4VggIABwL3T0L2JCE1IukfpRUZ+enmr0PjXWPKHRYe8g9 0yVIj54qUf7tM39b7aNjKRl1uIdYGVbsxenUnJricV++EUkX3n8rFVq1vQFnCjnS8Dht q9xccwlSNa5cw9G7D/Mf1Txwb371rEF0Q6UwNIioe0oWyEXT2ulvkwvz/qXtVthdgBWf xy2w== X-Gm-Message-State: AOAM5300upQSxK7/BAGW+q5lIibE1Nfy2ZAhU1cgXyh5kwkOHRae3bj+ xO8Op7szzYH87Za6utRMCTgs+0eCd5CMl1SJaFBVngXmXjHG8FGyV1M1QqMRzitqk2EhxZYTTCS gKdlGl/LT51TLiiI= X-Received: by 2002:adf:9793:: with SMTP id s19mr17457425wrb.139.1603709735858; Mon, 26 Oct 2020 03:55:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJys/aSw6t9RJAorHXht+rIzJ8mb8Gig6JGeaVHaPsoeZO6xf5jx5zSDcBZHmDslg4IPZm+3Cg== X-Received: by 2002:adf:9793:: with SMTP id s19mr17457396wrb.139.1603709735635; Mon, 26 Oct 2020 03:55:35 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b5sm21563988wrs.97.2020.10.26.03.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 06/19] util/vfio-helpers: Trace PCI I/O config accesses Date: Mon, 26 Oct 2020 11:54:51 +0100 Message-Id: <20201026105504.4023620-7-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We sometime get kernel panic with some devices on Aarch64 hosts. Alex Williamson suggests it might be broken PCIe root complex. Add trace event to record the latest I/O access before crashing. In case, assert our accesses are aligned. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 8 ++++++++ util/trace-events | 2 ++ 2 files changed, 10 insertions(+) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 14a549510fe..1d4efafcaa4 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -227,6 +227,10 @@ static int qemu_vfio_pci_read_config(QEMUVFIOState *s, void *buf, { int ret; + trace_qemu_vfio_pci_read_config(buf, ofs, size, + s->config_region_info.offset, + s->config_region_info.size); + assert(QEMU_IS_ALIGNED(s->config_region_info.offset + ofs, size)); do { ret = pread(s->device, buf, size, s->config_region_info.offset + ofs); } while (ret == -1 && errno == EINTR); @@ -237,6 +241,10 @@ static int qemu_vfio_pci_write_config(QEMUVFIOState *s, void *buf, int size, int { int ret; + trace_qemu_vfio_pci_write_config(buf, ofs, size, + s->config_region_info.offset, + s->config_region_info.size); + assert(QEMU_IS_ALIGNED(s->config_region_info.offset + ofs, size)); do { ret = pwrite(s->device, buf, size, s->config_region_info.offset + ofs); } while (ret == -1 && errno == EINTR); diff --git a/util/trace-events b/util/trace-events index 24c31803b01..c048f85f828 100644 --- a/util/trace-events +++ b/util/trace-events @@ -85,3 +85,5 @@ qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %p host %p size 0x%zx iova 0x%"PRIx64 qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d iova %p" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" +qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" +qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" From patchwork Mon Oct 26 10:54: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: 302055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD80BC2D0A3 for ; Mon, 26 Oct 2020 11:03:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3664B2224A for ; Mon, 26 Oct 2020 11:03:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q+Lxxypv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3664B2224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0HP-0007Oh-7D for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:03:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0AG-0007NP-LC for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0AD-0008IH-4s for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709743; 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=jJzeX7lyaDemOB2QTG1Y3n+OWt54ICMjUzceGOoInIo=; b=Q+LxxypvE6g+ZM+ktQfVwLlihNtVGZcnBAv9xMHHsdJwVSCM+8TcJ40nKUmTzVE7y6OcUT z78jYvU2+x9mCpYGgjvensyE9SkGoC+HGv440Ay9BGBcsaGP5FjKy69Nsy9DhtpkoEipZR kC6edl97NJewPXaZbmrdFNyOT3xgLsk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-577-oQB53aw1PDOqW1BfcWTBUA-1; Mon, 26 Oct 2020 06:55:42 -0400 X-MC-Unique: oQB53aw1PDOqW1BfcWTBUA-1 Received: by mail-wr1-f69.google.com with SMTP id r8so8183841wrp.5 for ; Mon, 26 Oct 2020 03:55: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=jJzeX7lyaDemOB2QTG1Y3n+OWt54ICMjUzceGOoInIo=; b=IuCFA1BQHMblhgKTMnmhQB1gw8t7kCuLTqrOc/+uEgxCHPJCDvcuh6yOXVT3cdi/lg ZO6fTpLNv0j5QwyzYY09xCB/LwJ23zbhDMoFflGM/OJ6kC/bsXpAEgHlHpID8UxjeXRb 0sEn6GcGUzQ0E2CMbD2b8nu4J8F2VVQjbN/wyM7F3A7SmRkFTZvmjTe1teMFbyykGtAU Ay+r2k8mQsmxKKVf3/Vq+cmm/htDYEpKEA1DXfaqkZNN8FjZuUc3H58/nGbb48a9FFbg ukIzy/gEjyUf+dyZsbedl5lvp9ZoTVTlFSddEsI/+oH8A/uvtVHgdJCJNqBjZ6x/YmFJ dAJg== X-Gm-Message-State: AOAM531Lzytwx+qLpEV93NAEX2JXwqf+OI/cD3c/Kp0JF5DlxwydgQyP /UviN87of17egN4jVFwZvssyGxqh7r2vui70lOclUccuVN1gql5sM6C5eyzVY98gWERGlWr2Zqt W8ZZa3lA5b+b/5Go= X-Received: by 2002:a7b:c3da:: with SMTP id t26mr16284941wmj.154.1603709740674; Mon, 26 Oct 2020 03:55:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe2y0OyvBqzoh3Dpf17wbm5M1CkR3WwDvAihIJrU9Z14iJ8ablrFpUKe264tnVOoW2Gu1G8g== X-Received: by 2002:a7b:c3da:: with SMTP id t26mr16284916wmj.154.1603709740480; Mon, 26 Oct 2020 03:55:40 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b131sm1160966wmc.3.2020.10.26.03.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 07/19] util/vfio-helpers: Trace PCI BAR region info Date: Mon, 26 Oct 2020 11:54:52 +0100 Message-Id: <20201026105504.4023620-8-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For debug purpose, trace BAR regions info. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 8 ++++++++ util/trace-events | 1 + 2 files changed, 9 insertions(+) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 1d4efafcaa4..cd6287c3a98 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -136,6 +136,7 @@ static inline void assert_bar_index_valid(QEMUVFIOState *s, int index) static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **errp) { + g_autofree char *barname = NULL; assert_bar_index_valid(s, index); s->bar_region_info[index] = (struct vfio_region_info) { .index = VFIO_PCI_BAR0_REGION_INDEX + index, @@ -145,6 +146,10 @@ static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **errp) error_setg_errno(errp, errno, "Failed to get BAR region info"); return -errno; } + barname = g_strdup_printf("bar[%d]", index); + trace_qemu_vfio_region_info(barname, s->bar_region_info[index].offset, + s->bar_region_info[index].size, + s->bar_region_info[index].cap_offset); return 0; } @@ -416,6 +421,9 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, ret = -errno; goto fail; } + trace_qemu_vfio_region_info("config", s->config_region_info.offset, + s->config_region_info.size, + s->config_region_info.cap_offset); for (i = 0; i < ARRAY_SIZE(s->bar_region_info); i++) { ret = qemu_vfio_pci_init_bar(s, i, errp); diff --git a/util/trace-events b/util/trace-events index c048f85f828..4d40c74a21f 100644 --- a/util/trace-events +++ b/util/trace-events @@ -87,3 +87,4 @@ qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *io qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" +qemu_vfio_region_info(const char *desc, uint64_t offset, uint64_t size, uint32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PRId32 From patchwork Mon Oct 26 10:54: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: 270441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FD71C4363A for ; Mon, 26 Oct 2020 11:05:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D5E352224A for ; Mon, 26 Oct 2020 11:05:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Tkv23GZ5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5E352224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Ji-00017b-Ru for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:05:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0AL-0007SO-MO for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41294) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0AH-0008Jv-76 for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709748; 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=isOyGHI7YG22yBJfURVToP+mUwE5y2Znz4P6pSCuvUw=; b=Tkv23GZ5o32w7zS+mlXb5jFySrGIiFnvSQpEv7YyUP3AI33PUd3E+i1AiqwTKWnuxd7c6W y84d11yniwjqHqafjicbOA2ZVtfS0fIIzhnW3i6W0x/M9xtbA8kdbzZwp2EjPo/NI6cnyY eL9c2uiLQE6U8ep7vZ8yenpAFtZ/tkc= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-QuKfS_NRNB6HHqXYMulH2w-1; Mon, 26 Oct 2020 06:55:46 -0400 X-MC-Unique: QuKfS_NRNB6HHqXYMulH2w-1 Received: by mail-wr1-f71.google.com with SMTP id t17so8210879wrm.13 for ; Mon, 26 Oct 2020 03:55:46 -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=isOyGHI7YG22yBJfURVToP+mUwE5y2Znz4P6pSCuvUw=; b=nh9i5o7m40x/n4QfBXkB7mMEetJvFLAFQAi0zt6jtTJfA4wCrOb2hUfFnyLXHmZev7 tl1s6KDPgPFPgFavQ8InMOH0BacaSVtZ1tI4oyrmNBCEfGGgzZKfNz+yhxip9qXWrhTy 7KaBiZ0bU9CmYszxIz+oAU/AvqFaH9gvTsvyd5oA02RHsVUI+g0g9ZyseAMy3x9pNsfi 6TTihC3WHWDdCdGRJg8TbzjbL9wD52dkwU6I2VJOjj8/lhp9xKcikuDDOkbkHCOaowqL xNMqID862WbKSXd9bk+gYmf/5BzcgkVRlpk0mu13MlElUklaXNpFD2UGnDlYDhA64WGN YHKw== X-Gm-Message-State: AOAM5326dLzpFP87yiDJwIc5HVl5zbq1C2YBcrj+K1Can0N01StVQI6j /uoozrr55KPz0hlDATSzC45hNv2P8diyTh4cRL4svrB3TPDkRxevx/6TXbJVsJEbNrWJpyXHZ2Q jvONoufnkw5yPRa4= X-Received: by 2002:adf:979c:: with SMTP id s28mr16987782wrb.62.1603709745509; Mon, 26 Oct 2020 03:55:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4uVRXAgqCRafveEWRhY/2RI8BHRsJQOhKlSUDghUTKUVh3YiudCiZuB7eVHY8s4odg/WsFg== X-Received: by 2002:adf:979c:: with SMTP id s28mr16987755wrb.62.1603709745334; Mon, 26 Oct 2020 03:55:45 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id 26sm7671180wmk.42.2020.10.26.03.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 08/19] util/vfio-helpers: Trace where BARs are mapped Date: Mon, 26 Oct 2020 11:54:53 +0100 Message-Id: <20201026105504.4023620-9-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For debugging purpose, trace where a BAR is mapped. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 2 ++ util/trace-events | 1 + 2 files changed, 3 insertions(+) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index cd6287c3a98..278c54902e7 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -166,6 +166,8 @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, p = mmap(NULL, MIN(size, s->bar_region_info[index].size - offset), prot, MAP_SHARED, s->device, s->bar_region_info[index].offset + offset); + trace_qemu_vfio_pci_map_bar(index, s->bar_region_info[index].offset , + size, offset, p); if (p == MAP_FAILED) { error_setg_errno(errp, errno, "Failed to map BAR region"); p = NULL; diff --git a/util/trace-events b/util/trace-events index 4d40c74a21f..50652761a58 100644 --- a/util/trace-events +++ b/util/trace-events @@ -88,3 +88,4 @@ qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_region_info(const char *desc, uint64_t offset, uint64_t size, uint32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PRId32 +qemu_vfio_pci_map_bar(int index, uint64_t region_ofs, uint64_t region_size, int ofs, void *host) "map region bar#%d ofs 0x%"PRIx64" size %"PRId64" ofs %d host %p" From patchwork Mon Oct 26 10:54: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: 302053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D830BC4363A for ; Mon, 26 Oct 2020 11:07:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 60C732224A for ; Mon, 26 Oct 2020 11:07:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UYLoZ6UT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60C732224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0LC-0002ni-E0 for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:07:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0AP-0007ZN-Dl for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0AM-0008LC-Jz for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:55:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709753; 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=tTDiCm1rGvrFJ5fByXHjKqVGr/b2mgKYh7ZyBSdCJu4=; b=UYLoZ6UTja/A+FbLJf6r8HusvrbyAhupsMc8usACRhlbhW4wAO6r5ASLtBh4rBZzhv3eeX FtrycBbRoUVVLfsvo3GhOJ0Qj4qBHJOYp80ZeUyMMCGFqyfpYf1tISPB59tMDMzMfv1lpZ zEsLcl5SVYzwvWBNsdEt3Bmn6CV4jzE= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-471-Pk5LbRDMPQCXJdJ6ZkKIEw-1; Mon, 26 Oct 2020 06:55:51 -0400 X-MC-Unique: Pk5LbRDMPQCXJdJ6ZkKIEw-1 Received: by mail-wm1-f69.google.com with SMTP id l22so5568593wmi.4 for ; Mon, 26 Oct 2020 03:55:51 -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=tTDiCm1rGvrFJ5fByXHjKqVGr/b2mgKYh7ZyBSdCJu4=; b=IOMKJoXgbxFuZ6xkx4c32I05ZShIBWpn8dVgoa00Zuc3LXYZYpm9XrY+kKeJxs5EoN 5vHiiCRYXsk09sAExUMeQfX2Dypz1iA+Mz5v6syJzKrjhaRodCGpvNydcmkXbWmF/0qU DCoztpuxHWgVZ/Nelqf0n4nSnI7MMdkOWUmXxcgNk53ydf2LEmQw88QdtxO8K5yiEMzD WpJAxgFve7dq3N888qHoeHzPUadcziMuIKT3qxkzSOdP3b1ToaQ6AUxSyJh2xB1erloi WRx4ibt6HyofeQsPR2lPRqjq8aMedkdYYQrWGyLxnrQyOr+2q5XNSPi++gYgAhE5L6Wf VRcQ== X-Gm-Message-State: AOAM532CGQ/H8Yxed8ByBtCllYQw7Tw7GpqK8nqYzyfEg2Y9sabwhgye xNKG8hQ2VvHJOlZraGFP7lC+CeRExoWN9oxgljLbPcvqDUzOvn30euKtAr9guPGS0sm5SxwQ7HO HAkgE6tI6yMsLpjo= X-Received: by 2002:a1c:7d0f:: with SMTP id y15mr15097207wmc.84.1603709750345; Mon, 26 Oct 2020 03:55:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyymAlvMQrr5qixfkbvEz7AL/qM/tKYWyHCGrZgKjdmFtEVSJ64vxNFaoeMP9kiqfdFHz8WZg== X-Received: by 2002:a1c:7d0f:: with SMTP id y15mr15097191wmc.84.1603709750217; Mon, 26 Oct 2020 03:55:50 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id v189sm19982587wmg.14.2020.10.26.03.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/19] util/vfio-helpers: Improve DMA trace events Date: Mon, 26 Oct 2020 11:54:54 +0100 Message-Id: <20201026105504.4023620-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" For debugging purpose, trace where DMA regions are mapped. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 3 ++- util/trace-events | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 278c54902e7..c24a510df82 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -627,7 +627,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size, .vaddr = (uintptr_t)host, .size = size, }; - trace_qemu_vfio_do_mapping(s, host, size, iova); + trace_qemu_vfio_do_mapping(s, host, iova, size); if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) { error_report("VFIO_MAP_DMA failed: %s", strerror(errno)); @@ -783,6 +783,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, } } } + trace_qemu_vfio_dma_mapped(s, host, iova0, size); if (iova) { *iova = iova0; } diff --git a/util/trace-events b/util/trace-events index 50652761a58..8598066acdb 100644 --- a/util/trace-events +++ b/util/trace-events @@ -82,8 +82,9 @@ qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%z qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx" qemu_vfio_find_mapping(void *s, void *p) "s %p host %p" qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64 -qemu_vfio_do_mapping(void *s, void *host, size_t size, uint64_t iova) "s %p host %p size 0x%zx iova 0x%"PRIx64 -qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d iova %p" +qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64 " size 0x%zx" +qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d &iova %p" +qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64" size 0x%zx" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" From patchwork Mon Oct 26 10:54: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: 270442 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71893C55178 for ; Mon, 26 Oct 2020 11:04:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C02C22224A for ; Mon, 26 Oct 2020 11:04:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CSKqDEi+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C02C22224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Ik-0000QM-Kh for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:04:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0AT-0007kh-Qy for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0AS-0008NM-5T for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709759; 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=oHVBY2K3BEOh3WYNJplbtMVpgw2LML5s1ozFmG/8CV0=; b=CSKqDEi+MvozPrO0aeOIp72Fc/yYIQRuSV+V3j/5Onzqz898ks5zRy5vGWVBtj0dwK6GnF baCko2vrmLy0GZ+V/cH6KuXC/LxSucZVZBGre6Z15HueWoMc+XQYntL9rHxTR6vnzhxR+g qkp3Pc00kwm2QoIxAZMJs2vPUcek+EQ= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-SwhKkUP4P22wvltBZT1Fkg-1; Mon, 26 Oct 2020 06:55:57 -0400 X-MC-Unique: SwhKkUP4P22wvltBZT1Fkg-1 Received: by mail-wr1-f71.google.com with SMTP id j15so835268wro.4 for ; Mon, 26 Oct 2020 03:55: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=oHVBY2K3BEOh3WYNJplbtMVpgw2LML5s1ozFmG/8CV0=; b=YpHJEuqndVmaXTVv/BnV0VmlX8yayjMniTVvYqsEZONjBvhTuegPkE5lZKGJM303ua GE81uSVqT/dUcnGicF4QIuVPJKPYC+P2pcuB3JcBAFULkU/FH0n9poxyuKTwmcWH4Ntf hBaprBXxq4yB9wljYK1lw9TK2IE5u8x5QKLw6dNGmE+yIuPWh94UB0p5K6j+MdHCbMEo yZB4zPNG6np2pCRHMFYX2T8aTzun+/K73Pli7jw0+X0POwLa3juQmX1CfUTNkxIoXdPp Rd+SGuQ82+BM0dqARteoVNMxiftg835L5ym3Yjm4/IYoES0kFBN+yXoiYOvoPvnyznO/ Vrlg== X-Gm-Message-State: AOAM531Xw6InFmY0kn0gATCM57OQM9N/qcGypGlKG/4wPAFoHsVKhrED nUVA5C+DOha2mzi8ImEvW7BVAKsPe7l3JVfPj9xymWtPlf0TNfoxCKfkke4Ut7IUoAa5a54Yfw9 5y1ijUL+7WM9fXFo= X-Received: by 2002:a1c:f417:: with SMTP id z23mr14729766wma.57.1603709755329; Mon, 26 Oct 2020 03:55:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCwY2JOp0h6FKsVOdUTCO82Wo6A+ht+zGe4PvsjEl46DKFMTvOXPgQlVs5gWNyFd2CvfrfxQ== X-Received: by 2002:a1c:f417:: with SMTP id z23mr14729747wma.57.1603709755185; Mon, 26 Oct 2020 03:55:55 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id o4sm21504181wrv.8.2020.10.26.03.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 10/19] util/vfio-helpers: Convert vfio_dump_mapping to trace events Date: Mon, 26 Oct 2020 11:54:55 +0100 Message-Id: <20201026105504.4023620-11-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The QEMU_VFIO_DEBUG definition is only modifiable at build-time. Trace events can be enabled at run-time. As we prefer the latter, convert qemu_vfio_dump_mappings() to use trace events instead of fprintf(). Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 19 ++++--------------- util/trace-events | 1 + 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index c24a510df82..73f7bfa7540 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -521,23 +521,12 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp) return s; } -static void qemu_vfio_dump_mapping(IOVAMapping *m) -{ - if (QEMU_VFIO_DEBUG) { - printf(" vfio mapping %p %" PRIx64 " to %" PRIx64 "\n", m->host, - (uint64_t)m->size, (uint64_t)m->iova); - } -} - static void qemu_vfio_dump_mappings(QEMUVFIOState *s) { - int i; - - if (QEMU_VFIO_DEBUG) { - printf("vfio mappings\n"); - for (i = 0; i < s->nr_mappings; ++i) { - qemu_vfio_dump_mapping(&s->mappings[i]); - } + for (int i = 0; i < s->nr_mappings; ++i) { + trace_qemu_vfio_dump_mapping(s->mappings[i].host, + s->mappings[i].iova, + s->mappings[i].size); } } diff --git a/util/trace-events b/util/trace-events index 8598066acdb..7faad2a718c 100644 --- a/util/trace-events +++ b/util/trace-events @@ -80,6 +80,7 @@ qemu_mutex_unlock(void *mutex, const char *file, const int line) "released mutex qemu_vfio_dma_reset_temporary(void *s) "s %p" qemu_vfio_ram_block_added(void *s, void *p, size_t size) "s %p host %p size 0x%zx" qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p size 0x%zx" +qemu_vfio_dump_mapping(void *host, uint64_t iova, size_t size) "vfio mapping %p to iova 0x%08" PRIx64 " size 0x%zx" qemu_vfio_find_mapping(void *s, void *p) "s %p host %p" qemu_vfio_new_mapping(void *s, void *host, size_t size, int index, uint64_t iova) "s %p host %p size 0x%zx index %d iova 0x%"PRIx64 qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64 " size 0x%zx" From patchwork Mon Oct 26 10:54: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: 302051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07F6CC4363A for ; Mon, 26 Oct 2020 11:09:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96CCB2224A for ; Mon, 26 Oct 2020 11:09:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WaJ3v6Fq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96CCB2224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Nr-0006wa-Ge for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:09:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51212) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0AY-0007vV-5l for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28839) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0AW-0008Os-6a for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709763; 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=nFpAvnhzKFUahLqtIDcPSll9W0TpjYlTTuISswcMLmQ=; b=WaJ3v6Fq0QI2EOJD+XY5P4zvTx8ODsNtKELsPVC7zJttwLyb2JmqXnTyMPVu6hA+WNL/TX PkT1X7Onqw2SnaxMWlJMRrCo9LkYFNgHSGnKIbOBUWXWKhCX6CeLRf5pNjanZe706kBQCw xUlrC9Uw41TwNt0/MmIp72euGBhEBI0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-AH5FnfSYNmufBk6guIBQyA-1; Mon, 26 Oct 2020 06:56:02 -0400 X-MC-Unique: AH5FnfSYNmufBk6guIBQyA-1 Received: by mail-wr1-f72.google.com with SMTP id t11so8201341wrv.10 for ; Mon, 26 Oct 2020 03:56:01 -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=nFpAvnhzKFUahLqtIDcPSll9W0TpjYlTTuISswcMLmQ=; b=BgmUhccGta/RdNshCCx1OoUVagx97Yut6N0+gFVoi1cJz9CV0BBl0QHF9pEPmfyo+L HU+A/qP5BuJQ+GMLmNf8tujs4U0/TbghKF6O7jy/cfDQdH3nlhgdlM6UvxubU78tqioL 9L63EviwIc/rQn4vAPLBIQbk/7gmYVF+Hz3GhD5frtU/3u6rRpdEr2DUeSrEMwTbdMuV dr+HfzQZYvCKadUGgX9/KKCVAvYLaHZwujHTuhqk0dGwSw35KJmmrcFEOcDcKat7zT+w /uJPKS8Ny54L1cXK9/zXseMoOaUhcUT/cqCQF6ikt9w/i7DhHV+WFWc1koqGwjzA3fIa PC1Q== X-Gm-Message-State: AOAM532uDJFzOU+WKhRVQc3abSk1lVk2WaXTSJcGFmB/FPbm+jUOWpeH EIcQZ71TudZZj2u2FLv2YuLyelkUXuABtnpuOp7GcUUaWgh/P85LnNMeeY2UXAGAPUlZ2w9C7bj 8BNCLjWI6vWksBmY= X-Received: by 2002:adf:a50e:: with SMTP id i14mr17333459wrb.121.1603709760293; Mon, 26 Oct 2020 03:56:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8GK1OLplsiLuQMJxuiurJRsDQasKsAKfLItgMABPsNy9NlED7VnK9OxF8sRAIiKLQ26jIdA== X-Received: by 2002:adf:a50e:: with SMTP id i14mr17333431wrb.121.1603709760085; Mon, 26 Oct 2020 03:56:00 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id n6sm22440143wrj.60.2020.10.26.03.55.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:55:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 11/19] util/vfio-helpers: Let qemu_vfio_dma_map() propagate Error Date: Mon, 26 Oct 2020 11:54:56 +0100 Message-Id: <20201026105504.4023620-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Currently qemu_vfio_dma_map() displays errors on stderr. When using management interface, this information is simply lost. Pass qemu_vfio_dma_map() an Error* argument so it can propagate the error to callers. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/vfio-helpers.h | 2 +- block/nvme.c | 14 +++++++------- util/vfio-helpers.c | 12 +++++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 4491c8e1a6e..bde9495b254 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -18,7 +18,7 @@ typedef struct QEMUVFIOState QEMUVFIOState; QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp); void qemu_vfio_close(QEMUVFIOState *s); int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, - bool temporary, uint64_t *iova_list); + bool temporary, uint64_t *iova_list, Error **errp); int qemu_vfio_dma_reset_temporary(QEMUVFIOState *s); void qemu_vfio_dma_unmap(QEMUVFIOState *s, void *host); void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, diff --git a/block/nvme.c b/block/nvme.c index 3b6d3972ec2..6f1ebdf031f 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -167,9 +167,9 @@ static void nvme_init_queue(BDRVNVMeState *s, NVMeQueue *q, return; } memset(q->queue, 0, bytes); - r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); + r = qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, errp); if (r) { - error_setg(errp, "Cannot map queue"); + error_prepend(errp, "Cannot map queue: "); } } @@ -223,7 +223,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeState *s, 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, - false, &prp_list_iova); + false, &prp_list_iova, errp); if (r) { goto fail; } @@ -514,9 +514,9 @@ static void nvme_identify(BlockDriverState *bs, int namespace, Error **errp) 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, sizeof(*id), true, &iova, errp); if (r) { - error_setg(errp, "Cannot map buffer for DMA"); + error_prepend(errp, "Cannot map buffer for DMA: "); goto out; } @@ -1003,7 +1003,7 @@ try_map: r = qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, qiov->iov[i].iov_len, - true, &iova); + true, &iova, NULL); if (r == -ENOMEM && retry) { retry = false; trace_nvme_dma_flush_queue_wait(s); @@ -1450,7 +1450,7 @@ static void nvme_register_buf(BlockDriverState *bs, void *host, size_t size) int ret; BDRVNVMeState *s = bs->opaque; - ret = qemu_vfio_dma_map(s->vfio, host, size, false, NULL); + ret = qemu_vfio_dma_map(s->vfio, host, size, false, NULL, NULL); if (ret) { /* FIXME: we may run out of IOVA addresses after repeated * bdrv_register_buf/bdrv_unregister_buf, because nvme_vfio_dma_unmap diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 73f7bfa7540..c03fe0b7156 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -462,7 +462,7 @@ static void qemu_vfio_ram_block_added(RAMBlockNotifier *n, { QEMUVFIOState *s = container_of(n, QEMUVFIOState, ram_notifier); trace_qemu_vfio_ram_block_added(s, host, size); - qemu_vfio_dma_map(s, host, size, false, NULL); + qemu_vfio_dma_map(s, host, size, false, NULL, NULL); } static void qemu_vfio_ram_block_removed(RAMBlockNotifier *n, @@ -477,6 +477,7 @@ static void qemu_vfio_ram_block_removed(RAMBlockNotifier *n, static int qemu_vfio_init_ramblock(RAMBlock *rb, void *opaque) { + Error *local_err = NULL; void *host_addr = qemu_ram_get_host_addr(rb); ram_addr_t length = qemu_ram_get_used_length(rb); int ret; @@ -485,10 +486,11 @@ static int qemu_vfio_init_ramblock(RAMBlock *rb, void *opaque) if (!host_addr) { return 0; } - ret = qemu_vfio_dma_map(s, host_addr, length, false, NULL); + ret = qemu_vfio_dma_map(s, host_addr, length, false, NULL, &local_err); if (ret) { - fprintf(stderr, "qemu_vfio_init_ramblock: failed %p %" PRId64 "\n", - host_addr, (uint64_t)length); + error_reportf_err(local_err, + "qemu_vfio_init_ramblock: failed %p %" PRId64 ":", + host_addr, (uint64_t)length); } return 0; } @@ -724,7 +726,7 @@ qemu_vfio_find_temp_iova(QEMUVFIOState *s, size_t size, uint64_t *iova) * mapping status within this area is not allowed). */ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, - bool temporary, uint64_t *iova) + bool temporary, uint64_t *iova, Error **errp) { int ret = 0; int index; From patchwork Mon Oct 26 10:54: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: 270439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DD91C2D0A3 for ; Mon, 26 Oct 2020 11:08:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 884CF2224A for ; Mon, 26 Oct 2020 11:08:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jGgWPvez" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 884CF2224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Mf-00050b-K8 for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:08:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0Ac-000868-RO for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42510) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0Ab-0008Rj-04 for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709768; 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=drjwmQSo3TPMr2yqHnKgPcr0+zGutJeRfAQssJrVzdY=; b=jGgWPvezLWxa0MXv7qRaRIUfyYXAUK3W2W1+xANL06ytiA+Jt1CYHMI0AXVZpyCgglTcOS LRvJk8lNdfZT3Du7dtOsMzgnUzciqFWUnmjmSKiEclrs06CvhsVRYOd0fXdTCnb9LVcdv3 qqCFkgzHwVasc8S8EYDUsxg0d3Fxsb8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-jU2GC6TyOcWMmDYnQQzkfQ-1; Mon, 26 Oct 2020 06:56:06 -0400 X-MC-Unique: jU2GC6TyOcWMmDYnQQzkfQ-1 Received: by mail-wr1-f69.google.com with SMTP id j15so8203172wrd.16 for ; Mon, 26 Oct 2020 03:56:06 -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=drjwmQSo3TPMr2yqHnKgPcr0+zGutJeRfAQssJrVzdY=; b=gcujwz/5VM0Dx9tGnvVjiSJAFqbWVVXdR+UMA00SEvDDjfi6Fp7rhTk9Ov94EokaJ9 z4aCUAfAxt9VQyMU7B2Cjux3NJK1sldoEbkFDK3piWUGfAb6cRWRTecxdVEmXqn7PDmG ahkJSWMwc3Gc4xjkeAeH8i+ZwlOt1tAcv3+5GH2GI5PonWbxWX3eiyEoaO9E2i8bNOjM U5pvvgSK2nAySRweNXtP2hW3cAfcr7IZifiKEA2fVRPeZC2t+bFbvZFOpfj6cbPySj62 beHa4qzsyQqcPT5YWSimM2M2KqMvj8KBwX9bWo4xzovLlsNxrVw/PsoKhcnbuQxVUrd7 M8tg== X-Gm-Message-State: AOAM533XdEyfENX65u+rA1FRXHdOIpajFFeI5jVHEmIBd6fcgTsnsBgj 97w1pQKmBVm7l+dkRFR7+a27AQmTuwkqf9k52+0VE93wa0eA4cgaabDDYd/VOdG1H/BF7Qp1lgq V+iQDDHw27H9DL8g= X-Received: by 2002:adf:fe89:: with SMTP id l9mr17280969wrr.264.1603709765030; Mon, 26 Oct 2020 03:56:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHRe3awfpH73MG7A/5OOqXAxovuCJFl1y6Y0demSgVXpYmRrwIMyFpa1uHINWPVbZ8vXezFA== X-Received: by 2002:adf:fe89:: with SMTP id l9mr17280941wrr.264.1603709764820; Mon, 26 Oct 2020 03:56:04 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id e11sm22193488wrj.75.2020.10.26.03.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:56:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 12/19] util/vfio-helpers: Let qemu_vfio_do_mapping() propagate Error Date: Mon, 26 Oct 2020 11:54:57 +0100 Message-Id: <20201026105504.4023620-13-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Pass qemu_vfio_do_mapping() an Error* argument so it can propagate any error to callers. Replace error_report() which only report to the monitor by the more generic error_setg_errno(). Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index c03fe0b7156..2c4598d7faa 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -609,7 +609,7 @@ static IOVAMapping *qemu_vfio_add_mapping(QEMUVFIOState *s, /* Do the DMA mapping with VFIO. */ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size, - uint64_t iova) + uint64_t iova, Error **errp) { struct vfio_iommu_type1_dma_map dma_map = { .argsz = sizeof(dma_map), @@ -621,7 +621,7 @@ static int qemu_vfio_do_mapping(QEMUVFIOState *s, void *host, size_t size, trace_qemu_vfio_do_mapping(s, host, iova, size); if (ioctl(s->container, VFIO_IOMMU_MAP_DMA, &dma_map)) { - error_report("VFIO_MAP_DMA failed: %s", strerror(errno)); + error_setg_errno(errp, errno, "VFIO_MAP_DMA failed"); return -errno; } return 0; @@ -757,7 +757,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, goto out; } assert(qemu_vfio_verify_mappings(s)); - ret = qemu_vfio_do_mapping(s, host, size, iova0); + ret = qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret) { qemu_vfio_undo_mapping(s, mapping, NULL); goto out; @@ -768,7 +768,7 @@ int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, ret = -ENOMEM; goto out; } - ret = qemu_vfio_do_mapping(s, host, size, iova0); + ret = qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret) { goto out; } From patchwork Mon Oct 26 10:54: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: 302054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61C60C4363A for ; Mon, 26 Oct 2020 11:04:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DE7CF22263 for ; Mon, 26 Oct 2020 11:04:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c9aEUPaQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE7CF22263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Ik-0000RY-Vb for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:04:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0Ah-0008FP-0J for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0Af-0008So-EH for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709772; 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=BidoL8dEegdrM2deUWRHfDO/6zWVfLj47EJ1lH5mvto=; b=c9aEUPaQq+48Q8xhhH5/wTmTXxdYNtQiCE6ZzBs5jttEfRN6deR8p5fcQBp3946yw1qegh fRtMO7W3iINlDqv/NV7L870Cuom95uI7+e6XAOcE0thXLRvIU35KjY3x6u1FnuHmk7jvVR 6bD8rpWBFizo/HU1/uBnCLJ59dfvVwA= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-375-I15IZh5HND-fk6UsdLxm4Q-1; Mon, 26 Oct 2020 06:56:11 -0400 X-MC-Unique: I15IZh5HND-fk6UsdLxm4Q-1 Received: by mail-wm1-f71.google.com with SMTP id s140so147229wme.3 for ; Mon, 26 Oct 2020 03:56:10 -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=BidoL8dEegdrM2deUWRHfDO/6zWVfLj47EJ1lH5mvto=; b=iGncK7io4lEWo5u99MMwTA56FHX++PEfCHZIKiN+9ueUw/BxY9mHqt8ujbUaBRMc0j dDwpOgKl7OCs3/OCUEMBEfG9UJ2jcrcDpUB4hgo6bs3iKDZUs6ABinBwGMJYfYHx4inQ CGfKpbKogQo2FH+KJr5nNNQVh2cfnGb+lGpi9AxelPoyjcoik+PreBByVGnxZSovxUy3 U2thb+YNl0/EIBXu0uhsLPXxlvF/xaG/mIMpux3K/zOwkDEHk1Z9NgJyzqn0ABS2vqKC t4W7BtsiVd43wJ/TG7U2wPhV3lQHvOS91MrsE926wXOTrQanAfwjuPAonOQEoAQMcEzC Ulrg== X-Gm-Message-State: AOAM5324Z6jVScbCGvZ4z6+MLKD2KHcG8u+jwUpmFqKSQPHFm6lKA2M0 Anyuqbep6nbyIgFmEG1fBMSKE3b4Xd5am/olqZNX80ydDI9C8iqSNr6KR4nVYlJgBt6DcXJFq0O QXkSNo9UsxSmWjY0= X-Received: by 2002:a05:600c:24d:: with SMTP id 13mr14575999wmj.99.1603709769694; Mon, 26 Oct 2020 03:56:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvib1sr9e0v6WzW/KFg2T/nJ/r7jrV/iPkNrvuKzj0bl/9aXsjVL4B2fzpWr8yyHH4Qkn7nQ== X-Received: by 2002:a05:600c:24d:: with SMTP id 13mr14575991wmj.99.1603709769565; Mon, 26 Oct 2020 03:56:09 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id e25sm22898049wra.71.2020.10.26.03.56.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:56:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 13/19] util/vfio-helpers: Let qemu_vfio_verify_mappings() use error_report() Date: Mon, 26 Oct 2020 11:54:58 +0100 Message-Id: <20201026105504.4023620-14-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Instead of displaying the error on stderr, use error_report() which also report to the monitor. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 2c4598d7faa..488ddfca2a9 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -661,13 +661,13 @@ static bool qemu_vfio_verify_mappings(QEMUVFIOState *s) if (QEMU_VFIO_DEBUG) { for (i = 0; i < s->nr_mappings - 1; ++i) { if (!(s->mappings[i].host < s->mappings[i + 1].host)) { - fprintf(stderr, "item %d not sorted!\n", i); + error_report("item %d not sorted!", i); qemu_vfio_dump_mappings(s); return false; } if (!(s->mappings[i].host + s->mappings[i].size <= s->mappings[i + 1].host)) { - fprintf(stderr, "item %d overlap with next!\n", i); + error_report("item %d overlap with next!", i); qemu_vfio_dump_mappings(s); return false; } From patchwork Mon Oct 26 10:54: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: 302052 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43677C4363A for ; Mon, 26 Oct 2020 11:08:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B3A8E2224A for ; Mon, 26 Oct 2020 11:08:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gjdd9PqG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3A8E2224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0MX-0004of-Fk for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:08:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0Ap-0008Kg-9q for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0Al-0008VH-A3 for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709777; 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=UF5uHhXgkWDHbzk6PtUz47NRa7jF7pKRdhEOKMwbuvA=; b=gjdd9PqGqmZoTZPJQ3lh4l+hmL61KuokV2rgNp2zQxpJnq4JV4R1dbpiXA3zqnw0s8cDYk x7V7Y7rlXC5gDdRfK3eOYK4XbhGKXfUA7SAUiFYVBSOLDYtq9AzD3mF5y5fqe5KhUlLFKB F+DW3i5tdv/4PXxUK1ws1eZhAlXm7f8= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-X3HoYiYgNDap-0OSVto8Hw-1; Mon, 26 Oct 2020 06:56:16 -0400 X-MC-Unique: X3HoYiYgNDap-0OSVto8Hw-1 Received: by mail-wr1-f71.google.com with SMTP id t17so8211348wrm.13 for ; Mon, 26 Oct 2020 03:56: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=UF5uHhXgkWDHbzk6PtUz47NRa7jF7pKRdhEOKMwbuvA=; b=a+HbVQwb5nPZh1AfEL8t8lnE3+IpsYQNptFOEQuqtlD1b9v76QopLkQHX0uxRR8ofX WEglbdNxw1hS6NcVoHl2xKYezByNbE0kDCxc+JzcnXnrUL/8ITylzjRPrq25CbnCRyRK znW7yFiJ1p+xcIOieSFrAboxnJ//CVgNfTEjlN+N5ednFfTHjGWYnXcAfAihh8o9R3pa JENyrA3FvZOj8wNnyIBsp/nlYuX2l/osSeqFwSafuwMsI7MAltzGdgWKXKLP1GbAj1Jz DGt7SnmW1UMi0kG9uPvvbjonhrXRev3+zACd0Ipz+JgfbBkM2/pOR3zx2mGeNU2smJ/S aoTQ== X-Gm-Message-State: AOAM532k6/U6ibx2Q2A9zHtzShWrWRucXKgPMWox1b+Au/c4gshDXOSI mh3eq8CqmvqB7Jub1BjfKspcYfbnGdDO2cIt6OFzCg5CFvK6jOT7+9dKiQd6OBTGYZBuIlVwwIZ 29Jz0l4nCDDTE2Og= X-Received: by 2002:adf:f88a:: with SMTP id u10mr17132043wrp.1.1603709774610; Mon, 26 Oct 2020 03:56:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9JCsH/KUKoyBhse/sZJWxBtqDn9/yrz4mU+ECSJwOjgtXkz/k0SG8tlYRPFwdQ4Guuu6T8Q== X-Received: by 2002:adf:f88a:: with SMTP id u10mr17132029wrp.1.1603709774381; Mon, 26 Oct 2020 03:56:14 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id w7sm24667479wre.9.2020.10.26.03.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:56:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 14/19] util/vfio-helpers: Pass minimum page size to qemu_vfio_open_pci() Date: Mon, 26 Oct 2020 11:54:59 +0100 Message-Id: <20201026105504.4023620-15-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The block driver asks for a minimum page size, but it might not match the minimum IOMMU requirement. In the next commit qemu_vfio_init_pci() will be able to report the minimum IOMMU page size back to the block driver. In preparation, pass the minimum page size as argument to qemu_vfio_open_pci(). Add a check to be sure the IOMMU minimum page size is in range with our NVMe device maximum page size. Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/vfio-helpers.h | 3 ++- block/nvme.c | 14 +++++++++++++- util/vfio-helpers.c | 8 +++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index bde9495b254..4b97a904e93 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -15,7 +15,8 @@ typedef struct QEMUVFIOState QEMUVFIOState; -QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp); +QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_size, + Error **errp); void qemu_vfio_close(QEMUVFIOState *s); int qemu_vfio_dma_map(QEMUVFIOState *s, void *host, size_t size, bool temporary, uint64_t *iova_list, Error **errp); diff --git a/block/nvme.c b/block/nvme.c index 6f1ebdf031f..46b09b3a3a7 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -691,6 +691,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, Error *local_err = NULL; volatile NvmeBar *regs = NULL; size_t device_page_size_min; + size_t device_page_size_max; size_t iommu_page_size_min = 4096; qemu_co_mutex_init(&s->dma_map_lock); @@ -704,7 +705,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, return ret; } - s->vfio = qemu_vfio_open_pci(device, errp); + s->vfio = qemu_vfio_open_pci(device, &iommu_page_size_min, errp); if (!s->vfio) { ret = -EINVAL; goto out; @@ -737,6 +738,17 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } device_page_size_min = 1u << (12 + NVME_CAP_MPSMIN(cap)); + device_page_size_max = 1u << (12 + NVME_CAP_MPSMAX(cap)); + if (iommu_page_size_min > device_page_size_max) { + g_autofree char *iommu_page_size_s = size_to_str(iommu_page_size_min); + g_autofree char *device_page_size_s = size_to_str(device_page_size_max); + + error_setg(errp, "IOMMU minimum page size (%s)" + " too big for device (max %s)", + iommu_page_size_s, device_page_size_s); + ret = -EINVAL; + goto out; + } s->page_size = MAX(iommu_page_size_min, device_page_size_min); s->doorbell_scale = (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment = s->page_size; diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 488ddfca2a9..5e288dfa113 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -508,8 +508,14 @@ static void qemu_vfio_open_common(QEMUVFIOState *s) /** * Open a PCI device, e.g. "0000:00:01.0". + * + * @min_page_size: Pointer holding the minimum page size requested + * + * If the IOMMU can not be configured with @min_page_size, the minimum + * page size is stored in @min_page_size and -EINVAL is returned. */ -QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp) +QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_size, + Error **errp) { int r; QEMUVFIOState *s = g_new0(QEMUVFIOState, 1); From patchwork Mon Oct 26 10:55: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: 270438 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29340C4363A for ; Mon, 26 Oct 2020 11:12:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 98C732067B for ; Mon, 26 Oct 2020 11:12:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WmFoSbhq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 98C732067B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0QK-0002BT-Ck for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:12:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0Av-0008Mq-04 for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0Ar-00006I-HH for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709784; 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=UchhDxvfvK9mvljYS5+MFH11t7RpYY2MHNXuIXgkVCI=; b=WmFoSbhqEzWpB1uV4QnWWNT07jNzoBdLJgujKNGpHZm9JuvdTJJrR2bnD36p2sdcn5tr3j XCPL9RB3JTnNulLVpqZorAr5DvLvImDnTa+SyBRcE8Nxr90f4TBIi6cqSI/ilYc/RB8FlJ IHELs31E0JzdkbLodYUZJi+QtLUDRJE= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-380-C6nYZDcMPg2MNr-ORblXjQ-1; Mon, 26 Oct 2020 06:56:21 -0400 X-MC-Unique: C6nYZDcMPg2MNr-ORblXjQ-1 Received: by mail-wr1-f70.google.com with SMTP id 47so8217483wrc.19 for ; Mon, 26 Oct 2020 03:56: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=UchhDxvfvK9mvljYS5+MFH11t7RpYY2MHNXuIXgkVCI=; b=QQ6YrTCy5K5X/YaMghssAlQqj5g/of1LE18SfeKEo/V3thwR5Xi1On8G7+WsP6Didq Cke6nk5lK9bqWGHkJ9uDppylVZRAXmNl1iMKi0QCtP0MCafd4LjCEFj45iCxCxhXIkjC 0hWhQhpD6nxCQD/IbL3R27g5C6nYWZ3gnxxaBTqySE7jAnaK9J/S1pwY/bCPA2r5YdqJ JknNT+wix05RRBK0Si/lBPSxk6PGuFkeV5FBWvam1R5iE7zTk1d5pi6P+JZYiAP0VesY oGB53jG5ve3Tb8QhN2IQzdvz3Qg4ezaCi/cfqhjpG8unyxWQbiGCEV1+AW651dQUQjCz zFgg== X-Gm-Message-State: AOAM530LoLYNPrMR2MCEl8glxq+4I9hiSy08q5W+Ax7GezqJ55wCTbjf +Yemzg56ddycxgHiy+ElCRyamztTvsx9VSnFJpXvNg62iMHN3IlN9BBav8txk85CmaABrSL5vyA YijKltu3H2tPVX34= X-Received: by 2002:a7b:c3d3:: with SMTP id t19mr10792121wmj.139.1603709779454; Mon, 26 Oct 2020 03:56:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK+reWy6GKPqc0RXEbvbCmYmcLuekj14GSWO7nIOUhrD91W9ScTna0LeoOJcD4rgpvatBiKA== X-Received: by 2002:a7b:c3d3:: with SMTP id t19mr10792101wmj.139.1603709779242; Mon, 26 Oct 2020 03:56:19 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id z15sm10503227wmk.4.2020.10.26.03.56.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:56:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 15/19] util/vfio-helpers: Report error when IOMMU page size is not supported Date: Mon, 26 Oct 2020 11:55:00 +0100 Message-Id: <20201026105504.4023620-16-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This driver uses the host page size to align its memory regions, but this size is not always compatible with the IOMMU. Add a check if the size matches, and bails out providing a hint what is the minimum page size the driver should use. Suggested-by: Alex Williamson Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- util/vfio-helpers.c | 28 ++++++++++++++++++++++++++-- util/trace-events | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 5e288dfa113..874d76c2a2a 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include #include #include "qapi/error.h" @@ -288,7 +289,7 @@ static void collect_usable_iova_ranges(QEMUVFIOState *s, void *buf) } static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, - Error **errp) + size_t *requested_page_size, Error **errp) { int ret; int i; @@ -299,6 +300,8 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, struct vfio_device_info device_info = { .argsz = sizeof(device_info) }; char *group_file = NULL; + assert(requested_page_size && is_power_of_2(*requested_page_size)); + s->usable_iova_ranges = NULL; /* Create a new container */ @@ -373,6 +376,27 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, ret = -errno; goto fail; } + if (!(iommu_info->flags & VFIO_IOMMU_INFO_PGSIZES)) { + error_setg(errp, "Failed to get IOMMU page size info"); + ret = -EINVAL; + goto fail; + } + trace_qemu_vfio_iommu_iova_pgsizes(iommu_info->iova_pgsizes); + if (!(iommu_info->iova_pgsizes & *requested_page_size)) { + g_autofree char *req_page_size_str = size_to_str(*requested_page_size); + g_autofree char *min_page_size_str = NULL; + uint64_t pgsizes_masked; + + pgsizes_masked = MAKE_64BIT_MASK(0, ctz64(*requested_page_size)); + *requested_page_size = 1U << ctz64(iommu_info->iova_pgsizes + & ~pgsizes_masked); + min_page_size_str = size_to_str(*requested_page_size); + error_setg(errp, "Unsupported IOMMU page size: %s", req_page_size_str); + error_append_hint(errp, "Minimum IOMMU page size: %s\n", + min_page_size_str); + ret = -EINVAL; + goto fail; + } /* * if the kernel does not report usable IOVA regions, choose @@ -520,7 +544,7 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_size, int r; QEMUVFIOState *s = g_new0(QEMUVFIOState, 1); - r = qemu_vfio_init_pci(s, device, errp); + r = qemu_vfio_init_pci(s, device, min_page_size, errp); if (r) { g_free(s); return NULL; diff --git a/util/trace-events b/util/trace-events index 7faad2a718c..3c36def9f30 100644 --- a/util/trace-events +++ b/util/trace-events @@ -87,6 +87,7 @@ qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d &iova %p" qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64" size 0x%zx" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" +qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_region_info(const char *desc, uint64_t offset, uint64_t size, uint32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PRId32 From patchwork Mon Oct 26 10:55: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: 270440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 100B5C4363A for ; Mon, 26 Oct 2020 11:08:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 20FED2224A for ; Mon, 26 Oct 2020 11:08:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d2PNgGCv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20FED2224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:42154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0ME-0004Tq-6X for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:08:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0Ax-0008Pn-Nw for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:35283) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0Au-00007Q-OL for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709787; 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=na09npuagCae1jkRDHu8fQc6bmdR06DBBHFCPQpb2ds=; b=d2PNgGCvdToR9UWJ6zyAJ81Y+zZvpT24w2qaAtY4zRjDVSGMaMfOBkAXcscLz0pgvRVao/ CIclbcGSiEm8YiqaAUNpJexn3hfdX2exzW4lktnOpCHprDInPib4noQcFOJKhRFqq8ENAa iJjsg7oIhQR7DTs1voJfPP10sm3xew4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-324-WZm5aZsoPsCIaGvaeYbKKA-1; Mon, 26 Oct 2020 06:56:26 -0400 X-MC-Unique: WZm5aZsoPsCIaGvaeYbKKA-1 Received: by mail-wm1-f72.google.com with SMTP id z62so3951425wmb.1 for ; Mon, 26 Oct 2020 03:56: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=na09npuagCae1jkRDHu8fQc6bmdR06DBBHFCPQpb2ds=; b=oe2GJjow6FAZqsaVbkpavNTvJUeM+i35gg3s4dqxj/Xu0Phpb06OJ4P6on/eCUw1bB kCZe7UouB4dK6dXCfVKtMdcYT+raqHIZvDy7d1kqACGEpVxVZi96xkcK9q+EFtQVnFrQ thgzBZbEUCmK3bskT3bP8yJyARpjtQxdooe3hcrZTV1PTjsHUlXf6uLs7bTFQdwXekr0 6UrsW9rxeIjYkV/ZvuR+yKta+fLS6ggzZRjqhpy9QM6op5a3C+l1eUcoP0EaByWmHltK slZsT8m23JUUxJ0whmFz86pzcU6NLoBVuS0Xzd4vIFI5fQWs7rwMqLuJV57/HigcLVrR 6Aig== X-Gm-Message-State: AOAM530Zc2TnJh0puTRAwclU8oJ31vzde/ctJ39jlepUeD6PfgItTWQI qyaLUpdUg+9JgLrwd5GM0btoSzcv85yjc4fJUbUK8oOMW7qALTLFvHrU+W2lrGgFDM7aplX1aNw baak71aEq9K3GGd0= X-Received: by 2002:adf:f043:: with SMTP id t3mr16377498wro.234.1603709784431; Mon, 26 Oct 2020 03:56:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpt9jt5u2ibRJg874zc7T/p1gdb7BGoBhmVbY5NvnSjELDjLyNuFmNU/z1wQKaS0Mf/U8enQ== X-Received: by 2002:adf:f043:: with SMTP id t3mr16377473wro.234.1603709784176; Mon, 26 Oct 2020 03:56:24 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b18sm560318wmj.41.2020.10.26.03.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:56:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 16/19] util/vfio-helpers: Introduce qemu_vfio_pci_msix_init_irqs() Date: Mon, 26 Oct 2020 11:55:01 +0100 Message-Id: <20201026105504.4023620-17-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" qemu_vfio_pci_init_irq() allows us to initialize any type of IRQ, but only one. Introduce qemu_vfio_pci_msix_init_irqs() which is specific to MSIX IRQ type, and allow us to use multiple IRQs (thus passing multiple eventfd notifiers). All eventfd notifiers are initialized with the special '-1' value meaning "un-assigned". Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/vfio-helpers.h | 6 +++- util/vfio-helpers.c | 65 ++++++++++++++++++++++++++++++++++++- util/trace-events | 1 + 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 4b97a904e93..492072cba2f 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -1,11 +1,13 @@ /* * QEMU VFIO helpers * - * Copyright 2016 - 2018 Red Hat, Inc. + * Copyright 2016 - 2020 Red Hat, Inc. * * Authors: * Fam Zheng + * Philippe Mathieu-Daudé * + * SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ @@ -29,5 +31,7 @@ void qemu_vfio_pci_unmap_bar(QEMUVFIOState *s, int index, void *bar, uint64_t offset, uint64_t size); int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, int irq_type, Error **errp); +int qemu_vfio_pci_msix_init_irqs(QEMUVFIOState *s, + unsigned *irq_count, Error **errp); #endif diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 874d76c2a2a..d88e2c7dc1f 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -1,11 +1,13 @@ /* * VFIO utility * - * Copyright 2016 - 2018 Red Hat, Inc. + * Copyright 2016 - 2020 Red Hat, Inc. * * Authors: * Fam Zheng + * Philippe Mathieu-Daudé * + * SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ @@ -230,6 +232,67 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, return 0; } +/** + * Initialize device MSIX IRQs and register event notifiers. + * @irq_count: pointer to number of MSIX IRQs to initialize + * + * If the number of IRQs requested exceeds the available on the device, + * store the number of available IRQs in @irq_count and return -EOVERFLOW. + */ +int qemu_vfio_pci_msix_init_irqs(QEMUVFIOState *s, + unsigned *irq_count, Error **errp) +{ + int r; + size_t irq_set_size; + struct vfio_irq_set *irq_set; + struct vfio_irq_info irq_info = { + .argsz = sizeof(irq_info), + .index = VFIO_PCI_MSIX_IRQ_INDEX + }; + + if (ioctl(s->device, VFIO_DEVICE_GET_IRQ_INFO, &irq_info)) { + error_setg_errno(errp, errno, "Failed to get device interrupt info"); + return -errno; + } + trace_qemu_vfio_msix_info_irqs(irq_info.count, *irq_count); + if (irq_info.count < *irq_count) { + error_setg(errp, "Not enough device interrupts available"); + *irq_count = irq_info.count; + return -EOVERFLOW; + } + if (!(irq_info.flags & VFIO_IRQ_INFO_EVENTFD)) { + error_setg(errp, "Device interrupt doesn't support eventfd"); + return -EINVAL; + } + + irq_set_size = sizeof(*irq_set) + *irq_count * sizeof(int32_t); + irq_set = g_malloc0(irq_set_size); + + /* Get to a known IRQ state */ + *irq_set = (struct vfio_irq_set) { + .argsz = irq_set_size, + .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, + .index = VFIO_PCI_MSIX_IRQ_INDEX, + .start = 0, + .count = *irq_count, + }; + + for (unsigned i = 0; i < *irq_count; i++) { + ((int32_t *)&irq_set->data)[i] = -1; /* un-assigned: skip */ + } + r = ioctl(s->device, VFIO_DEVICE_SET_IRQS, irq_set); + g_free(irq_set); + if (r < 0) { + error_setg_errno(errp, errno, "Failed to setup device interrupts"); + return -errno; + } else if (r > 0) { + error_setg(errp, "Not enough device interrupts available"); + *irq_count = r; + return -EOVERFLOW; + } + return 0; +} + static int qemu_vfio_pci_read_config(QEMUVFIOState *s, void *buf, int size, int ofs) { diff --git a/util/trace-events b/util/trace-events index 3c36def9f30..ec93578b125 100644 --- a/util/trace-events +++ b/util/trace-events @@ -87,6 +87,7 @@ qemu_vfio_do_mapping(void *s, void *host, uint64_t iova, size_t size) "s %p host qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *iova) "s %p host %p size 0x%zx temporary %d &iova %p" qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64" size 0x%zx" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" +qemu_vfio_msix_info_irqs(uint32_t count, unsigned asked) "msix irqs %"PRIu32" (asked: %u)" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" From patchwork Mon Oct 26 10:55: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: 302050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17830C4363A for ; Mon, 26 Oct 2020 11:11:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D60B2224A for ; Mon, 26 Oct 2020 11:11:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i/qy+zz+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D60B2224A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Pg-0000uP-8B for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:11:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0B4-0000DD-0S for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0B2-00009f-1I for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709795; 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=ydqt7ygZQ+vGx48L3P+H0ZAxD/ypFxd/RVZSJiZUfNY=; b=i/qy+zz+F6R3hytz1qmlDMHNDjZkz+aRQHqN+9NEblGaLIIhAHN+CHClYPTH02izvQTz75 Guk1//a46I9f3wlrngJYwf0hnEFA4rVila9Ye4WIe537y+BbFpY/OTAa7q50Z105XiJ9Mc K4vz3WrAoWO2ENhB0+Z7iZ5OcP7SDa4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-DUT0NfGUMbSz8Q1DmqC5xQ-1; Mon, 26 Oct 2020 06:56:33 -0400 X-MC-Unique: DUT0NfGUMbSz8Q1DmqC5xQ-1 Received: by mail-wr1-f70.google.com with SMTP id m20so8188965wrb.21 for ; Mon, 26 Oct 2020 03:56:33 -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=ydqt7ygZQ+vGx48L3P+H0ZAxD/ypFxd/RVZSJiZUfNY=; b=DGZVhr4EewhviDszB8aZcWEN69yAogRf+Sx08xJasSUXw2QLXY/A/8OuD+aCLRO3Nb JE1RxE9LeyEvGHQDWArhOk4nIOdTKc8jG0SSZr6y4+jXZgH73JfREuRhcVNcledsEJEQ /S7Hl8WW7nO/+hp+NNUjBe77TxtH2SvpmO5m/9P6nYgMpxFa8xK+G3vMRtL+GhZspjyX uWShfKXeKk/TH+zLofKHEZp8YETEi6r2rFvH4T7rYIT17/4GKT65VI6YFjuJPEvqtO1K il2skL5ViFFxFVY4FCRfTkOF8U/nk7fKQ+Qf/7AqJMVfOTpXZJeKjV8FFFNbU+Sa6Hwl Mc7Q== X-Gm-Message-State: AOAM530EOMQajAj+YDS0StIfZ0etvpjHpZlybFE7+myTf/Qu+CBb1/Zz ZAK6/P7S48SIZjOrsLmkt3E4ed1jZP7I6uRS0ja0soxXkZk86PD/o6wFlH7g8edNwY+txGP/Pdr uMOiVfYVSh4DTa0E= X-Received: by 2002:a1c:2e0d:: with SMTP id u13mr15163900wmu.179.1603709789225; Mon, 26 Oct 2020 03:56:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPFE5fIdETrd2j5V94vFl6M6DfV5yIMRzBqLdbfj1qvPlySncn2YE2eVEohtVt+EE23O6jNA== X-Received: by 2002:a1c:2e0d:: with SMTP id u13mr15163877wmu.179.1603709789067; Mon, 26 Oct 2020 03:56:29 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id b18sm560693wmj.41.2020.10.26.03.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:56:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 17/19] util/vfio-helpers: Introduce qemu_vfio_pci_msix_set_irq() Date: Mon, 26 Oct 2020 11:55:02 +0100 Message-Id: <20201026105504.4023620-18-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Introduce qemu_vfio_pci_msix_set_irq() to set the event notifier of a specific MSIX IRQ. All other registered IRQs are left unmodified. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Eric Auger --- include/qemu/vfio-helpers.h | 2 ++ util/vfio-helpers.c | 35 +++++++++++++++++++++++++++++++++++ util/trace-events | 1 + 3 files changed, 38 insertions(+) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 492072cba2f..4c06694e03a 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -33,5 +33,7 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, int irq_type, Error **errp); int qemu_vfio_pci_msix_init_irqs(QEMUVFIOState *s, unsigned *irq_count, Error **errp); +int qemu_vfio_pci_msix_set_irq(QEMUVFIOState *s, unsigned irq_index, + EventNotifier *notifier, Error **errp); #endif diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index d88e2c7dc1f..18142e6be86 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -232,6 +232,41 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, return 0; } +/** + * Initialize a MSIX IRQ and register its event notifier. + * @irq_index: MSIX IRQ index + * @notifier: notifier for the MSIX IRQ + */ +int qemu_vfio_pci_msix_set_irq(QEMUVFIOState *s, unsigned irq_index, + EventNotifier *notifier, Error **errp) +{ + int r; + int fd = event_notifier_get_fd(notifier); + size_t irq_set_size; + struct vfio_irq_set *irq_set; + + trace_qemu_vfio_pci_msix_set_irq(irq_index, fd); + irq_set_size = sizeof(*irq_set) + sizeof(int32_t); + irq_set = g_malloc0(irq_set_size); + /* Get to a known IRQ state */ + *irq_set = (struct vfio_irq_set) { + .argsz = irq_set_size, + .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, + .index = VFIO_PCI_MSIX_IRQ_INDEX, + .start = irq_index, + .count = 1, + }; + ((int32_t *)&irq_set->data)[0] = fd; + r = ioctl(s->device, VFIO_DEVICE_SET_IRQS, irq_set); + g_free(irq_set); + if (r) { + error_setg_errno(errp, errno, "Failed to setup device interrupt #%u", + irq_index); + return -errno; + } + return 0; +} + /** * Initialize device MSIX IRQs and register event notifiers. * @irq_count: pointer to number of MSIX IRQs to initialize diff --git a/util/trace-events b/util/trace-events index ec93578b125..3a56c542a94 100644 --- a/util/trace-events +++ b/util/trace-events @@ -88,6 +88,7 @@ qemu_vfio_dma_map(void *s, void *host, size_t size, bool temporary, uint64_t *io qemu_vfio_dma_mapped(void *s, void *host, uint64_t iova, size_t size) "s %p host %p <-> iova 0x%"PRIx64" size 0x%zx" qemu_vfio_dma_unmap(void *s, void *host) "s %p host %p" qemu_vfio_msix_info_irqs(uint32_t count, unsigned asked) "msix irqs %"PRIu32" (asked: %u)" +qemu_vfio_pci_msix_set_irq(unsigned irq_index, int fd) "msix irq %u notifier_fd %d" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitmask: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "read cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" qemu_vfio_pci_write_config(void *buf, int ofs, int size, uint64_t region_ofs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x%"PRIx64" size %"PRId64")" From patchwork Mon Oct 26 10:55: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: 302049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3278C4363A for ; Mon, 26 Oct 2020 11:13:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 53F0222263 for ; Mon, 26 Oct 2020 11:13:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZDGq7RtE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53F0222263 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0RU-0004SU-WE for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:13:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51494) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0B5-0000HC-Gt for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0B3-00009r-Oe for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709797; 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=owqIkSbFHgdfPD7uMP3x2r37Kgl7CGcfC6ZJAfrhmJc=; b=ZDGq7RtErFHi3aNctJOhV6/b4tHE86VWn+rYLVe7Zb3Xnbhkpd3vDGOlgV7Wn/2LOxHR9s fwC9c8hNV5Cs/22beLjvM3jo1tTaMmiQ5pWCA+aFUIe1cQL4o7LkXZxGc0qACKnQFt25m6 5cDXp9IrWaL2YxF8mC/Swdh/UQm9oAk= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-339-ypyj7U-xMC6-QStvdKCjEA-1; Mon, 26 Oct 2020 06:56:35 -0400 X-MC-Unique: ypyj7U-xMC6-QStvdKCjEA-1 Received: by mail-wr1-f72.google.com with SMTP id 31so8159199wrg.12 for ; Mon, 26 Oct 2020 03:56:35 -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=owqIkSbFHgdfPD7uMP3x2r37Kgl7CGcfC6ZJAfrhmJc=; b=D4KCHvX1f30qIA1kER/x3L7I50RkopHi0Hii3hvOqt0P4ywJ4JNRlCeLVxuMcGAYwp kUdZ4uP0tsrUjxFYmSpbNxeu0LCz/MHrHeAfyXQ5J596+s+8SXsOqnDt6Cp/4eI7JISw Cqoz6rGWg9L9HnpAJFXx60oP0zOKxqFMfjiNGMXu6BjbtLji0UCc+xZUQTJQatNTIWC8 ayHZ5s0FArQ8zQmrfSh4YaPaomfyNolAUTQ+8LKDD25bJlpkiSEpsR6z6jZupqO6NGb1 RdCRK96I2Sk5n7h95G62iVbSKAiA+yRRJ5KqjJsi9unNObj6Vkl77cMhgCLCHKxxLL/D o3aA== X-Gm-Message-State: AOAM532FrriYEMqgwCn8ON4/HMxnDVHjySf6u9Z5k1/DbW34yls3cbKn PI3feKlmK56Oy3sLtV+kvnX+3FC8qji33KkA3KhlHalMCoLkGiom/VVN648o/NrPWse/0QQAm/Z qRaZqu3UL/vzzxJY= X-Received: by 2002:adf:cd8d:: with SMTP id q13mr16960612wrj.268.1603709794047; Mon, 26 Oct 2020 03:56:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyStCr9GxFzTzPbqA2g6ofgt9QpElmIywQhpDNkYRmZvTibmFmzj5jiI6159FHxiZD587MCGQ== X-Received: by 2002:adf:cd8d:: with SMTP id q13mr16960590wrj.268.1603709793897; Mon, 26 Oct 2020 03:56:33 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id k18sm21115302wrx.96.2020.10.26.03.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:56:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 18/19] block/nvme: Switch to using the MSIX API Date: Mon, 26 Oct 2020 11:55:03 +0100 Message-Id: <20201026105504.4023620-19-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/26 02:39:09 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.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" In preparation of using multiple IRQs, switch to using the recently introduced MSIX API. Instead of allocating and assigning IRQ in a single step, we now have to use two distinct calls. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- block/nvme.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 46b09b3a3a7..191678540b6 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -693,6 +693,7 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, size_t device_page_size_min; size_t device_page_size_max; size_t iommu_page_size_min = 4096; + unsigned irq_count = MSIX_IRQ_COUNT; qemu_co_mutex_init(&s->dma_map_lock); qemu_co_queue_init(&s->dma_flush_queue); @@ -809,8 +810,17 @@ static int nvme_init(BlockDriverState *bs, const char *device, int namespace, } } - ret = qemu_vfio_pci_init_irq(s->vfio, s->irq_notifier, - VFIO_PCI_MSIX_IRQ_INDEX, errp); + ret = qemu_vfio_pci_msix_init_irqs(s->vfio, &irq_count, errp); + if (ret) { + if (ret == -EOVERFLOW) { + error_append_hint(errp, "%u IRQs requested but only %u available\n", + MSIX_IRQ_COUNT, irq_count); + } + goto out; + } + + ret = qemu_vfio_pci_msix_set_irq(s->vfio, MSIX_SHARED_IRQ_IDX, + s->irq_notifier, errp); if (ret) { goto out; } From patchwork Mon Oct 26 10:55: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: 302047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70B19C4363A for ; Mon, 26 Oct 2020 11:18:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF7A52223C for ; Mon, 26 Oct 2020 11:18:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="StnC6G3k" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF7A52223C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX0Vv-0000BY-8m for qemu-devel@archiver.kernel.org; Mon, 26 Oct 2020 07:18:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX0BA-0000U7-8c for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20248) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kX0B8-0000Cc-JM for qemu-devel@nongnu.org; Mon, 26 Oct 2020 06:56:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709801; 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=tjiqDTNg6IlVQRDX7FtGh0Vb3qFf/kKU7hA/I3jkchg=; b=StnC6G3k3oKDoyEiERmBwd1a2fWIs19sJaZHolWAvkoR2veVgQDflhPkn6kTAV7VFG+CoB KvZngkgt9KkvctXjz0srT/tU4cBfqn/TPI3mf1Equc+Qv9WOmQ6Duq0jKKUtADY8GJcUOl HVibXKy0Wn5JCJxUpNdxUFIqB4P63Rg= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-Zhda4dpxOLqySREpofiuAQ-1; Mon, 26 Oct 2020 06:56:40 -0400 X-MC-Unique: Zhda4dpxOLqySREpofiuAQ-1 Received: by mail-wr1-f69.google.com with SMTP id p6so8126966wrm.23 for ; Mon, 26 Oct 2020 03:56:40 -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=tjiqDTNg6IlVQRDX7FtGh0Vb3qFf/kKU7hA/I3jkchg=; b=iEhsO/6fB5R4Hg+ZT7TGugaN1WqUn1GJ/L17PR7SiKk2mPacmz88qmNUv1xPWXtckS PQmw4J9k6/7Y1lAr2dRGmvqWGgC7P8lGBLq94cpMLrwXMaeCQFdtbUwbXch5QxnJgfOu W1oY9KXEIkdoqP0TOr/AaoQwZMiYNE1LHP9HcGpp5oYybIdLgTrNbg+Su/Vu02GaGbn/ 7KMs8H24Oqq0gxaNj4B6MXBqPPmMkAtizsrYbZwXWaRPHKVyVQWpz1x+CqI8qov86TwC ph688Daygy1ldy9+NqQRaBsb0fi2rj/9IbQctCQaCLyHE/5Hp8JpWlwsfJLWNip9k42N dc0w== X-Gm-Message-State: AOAM532OBgwsQriF+r2skVc7RMVGh4jKJLKU4ZnGK1bsdqY0SS+vEZzf NgrSo9lOSkuwAeDCVCC+MvUQBZse8LgYQICh04dCmvhmeqyIWG1QRl+1jwZC4nqfRce/Hb8ERud 4MVjckdcYVbV8l8w= X-Received: by 2002:adf:df91:: with SMTP id z17mr16494475wrl.379.1603709798839; Mon, 26 Oct 2020 03:56:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytN3mEF4Hc6GaEYj3Y6qef4YQsPeZ8djC15U7IdK3PastNYOq167V0jsz8okdHtd5QnArKWg== X-Received: by 2002:adf:df91:: with SMTP id z17mr16494463wrl.379.1603709798676; Mon, 26 Oct 2020 03:56:38 -0700 (PDT) Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id x22sm23311138wmj.25.2020.10.26.03.56.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:56:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 19/19] util/vfio-helpers: Remove now unused qemu_vfio_pci_init_irq() Date: Mon, 26 Oct 2020 11:55:04 +0100 Message-Id: <20201026105504.4023620-20-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026105504.4023620-1-philmd@redhat.com> References: <20201026105504.4023620-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/25 21:03:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.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=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Eric Auger , Alex Williamson , Stefan Hajnoczi , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Our only user, the NVMe block driver, switched to the MSIX API. As this function is now unused, remove it. Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daudé --- include/qemu/vfio-helpers.h | 2 -- util/vfio-helpers.c | 43 ------------------------------------- 2 files changed, 45 deletions(-) diff --git a/include/qemu/vfio-helpers.h b/include/qemu/vfio-helpers.h index 4c06694e03a..f42371d25d6 100644 --- a/include/qemu/vfio-helpers.h +++ b/include/qemu/vfio-helpers.h @@ -29,8 +29,6 @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index, Error **errp); void qemu_vfio_pci_unmap_bar(QEMUVFIOState *s, int index, void *bar, uint64_t offset, uint64_t size); -int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, - int irq_type, Error **errp); int qemu_vfio_pci_msix_init_irqs(QEMUVFIOState *s, unsigned *irq_count, Error **errp); int qemu_vfio_pci_msix_set_irq(QEMUVFIOState *s, unsigned irq_index, diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c index 18142e6be86..83d6eef13fb 100644 --- a/util/vfio-helpers.c +++ b/util/vfio-helpers.c @@ -189,49 +189,6 @@ void qemu_vfio_pci_unmap_bar(QEMUVFIOState *s, int index, void *bar, } } -/** - * Initialize device IRQ with @irq_type and register an event notifier. - */ -int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNotifier *e, - int irq_type, Error **errp) -{ - int r; - struct vfio_irq_set *irq_set; - size_t irq_set_size; - struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info) }; - - irq_info.index = irq_type; - if (ioctl(s->device, VFIO_DEVICE_GET_IRQ_INFO, &irq_info)) { - error_setg_errno(errp, errno, "Failed to get device interrupt info"); - return -errno; - } - if (!(irq_info.flags & VFIO_IRQ_INFO_EVENTFD)) { - error_setg(errp, "Device interrupt doesn't support eventfd"); - return -EINVAL; - } - - irq_set_size = sizeof(*irq_set) + sizeof(int); - irq_set = g_malloc0(irq_set_size); - - /* Get to a known IRQ state */ - *irq_set = (struct vfio_irq_set) { - .argsz = irq_set_size, - .flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, - .index = irq_info.index, - .start = 0, - .count = 1, - }; - - *(int *)&irq_set->data = event_notifier_get_fd(e); - r = ioctl(s->device, VFIO_DEVICE_SET_IRQS, irq_set); - g_free(irq_set); - if (r) { - error_setg_errno(errp, errno, "Failed to setup device interrupt"); - return -errno; - } - return 0; -} - /** * Initialize a MSIX IRQ and register its event notifier. * @irq_index: MSIX IRQ index