From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709716; cv=none; d=zohomail.com; s=zohoarc; b=L0aD3aYovNZWuZEoCZHRvwmdXRDMpsXZ/vSqIAg1K9jbC8a+xxnD5Oa67IdX1lnpWw0px/DfWjmJom3dAzei2aVCq3yKmhcnSR+8e+lJw+KNPcDTNKHGGOGHlM0lPmaCXVwOS8Ff2iAMtOEFDjw1h6SV2vR/1PzpqDdEXugkwu0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709716; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=RehUHE9smya/dLsky2IXktduYA/iO28rTmGbzKYGc9c=; b=EVNQ6yrGP/FzPbOwlJ/qZXnfINKBOHM9f2rMHnzy5+k9MSlqJuHr0Ur3jgJOV5doxNiDo3tVHsE0Cz3IUgvhk8HzxKgmgL4U79f1uNoozGzUZapHqh9qczItN8NSG5tOBWg8Dy++z7VR9QFd4Jfbx3FAdaoVH7BaJXxboqOLl9s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603709716126134.51529127208278; Mon, 26 Oct 2020 03:55:16 -0700 (PDT) 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-472-NpN6jayXNpykGbK8W6I3yg-1; Mon, 26 Oct 2020 06:55:13 -0400 Received: by mail-wr1-f69.google.com with SMTP id 31so8157919wrg.12 for ; Mon, 26 Oct 2020 03:55:12 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709715; 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=Q04GQ6UBZhUh8ZCsOQu58IXGmYZvMpuEVu84GK+LN3E6jjoBxbUsDirWWG34/XUZDrDJCa EPf98r0kFNJYnTti04FlvEdgI2f2cNCrMEsgTWoLLsJK0dkiCrOyiEVsKe4vcOL04Uq3+C gsOy9kPbX1eXw4xpmLmx2KpFVml47hs= X-MC-Unique: NpN6jayXNpykGbK8W6I3yg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RehUHE9smya/dLsky2IXktduYA/iO28rTmGbzKYGc9c=; b=QbXKaPelUEJ/DBynbOJ2m7R5aQ8gD+PYrPfzRhcMYSaZ5U4eNPgydJatVzFqrzDEhm 5bz4FK9HlOt/0VWcyqbyCdKHpPZCC++Xc1DRWosUM+FXYgSclsnHk5/Q8VcBR0VsYiST 7+Fu0nsQCG2odRcxjNLdnEpeuRVoxJKBye7aCSe1Iv+Fl5Myg3HWvUxr06z90ySbZdJK D+xfGSg9NkpEvyJCbOeLObH1KbH+N+odSVIi5XEKlZi/liFyd5PpEWkuY1X4Z0tSv8EV 7cVfR4CMzlhAF15YPHK8tVQ6hN0kSgEgRKF6scV7VnfwTUyYWK05/dugply+aWH4sXyS 27EQ== X-Gm-Message-State: AOAM531w4P7GfrIPA55D889tzdJ8OMVcFt5uxFiDHuaMFUVwfOFouxgh OsMF6J/XNYBsEfsRt89aUopge98U+xJx+BPX6QMsvIjeEXpRf0bcpYDd5FPKKGnxVCG0i88Zi4N SAGMkwSdxwCDt3g== X-Received: by 2002:a1c:3d0b:: with SMTP id k11mr16527952wma.155.1603709711811; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 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; } =20 - s->page_size =3D MAX(4096, 1 << NVME_CAP_MPSMIN(cap)); + s->page_size =3D MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap))); s->doorbell_scale =3D (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment =3D s->page_size; timeout_ms =3D MIN(500 * NVME_CAP_TO(cap), 30000); --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709720; cv=none; d=zohomail.com; s=zohoarc; b=gZjLVgPlt1muUVcoe1NtGzpeiIQaGPzhttfGYYm6PdtD7YJxtwrMMsK1SDT07FCpfYmkg7gLNNQMDN94DlkFuvpakcJLFNg/vw9cBfWn9xhrznlcRaxQ90Yg3uoXAU/Unu1m5NQ6wfHnEBTbfVS8ezh2G0EdKEYqSpl17yFw0XM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709720; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ffM492hetK8u/GqoMVkU0TJmIWrPk8dUIU3q04M7GGw=; b=IJPraaQ5brszSVHJrLUQvXjPTLASSf0RnF+hm/KmB0xNoR/Od5E0LrPk3ZtG6Bqo/Iyql6sBzRvFMMzkLlJs1/GP2GEUgN66GTamrSPWTxqi+ULRrilc+eOR+BTzQ5cmuun6PZHeF3YCobzQYqGlzhBgc8R4EI+Odc8FHkwQ2B0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603709720659101.43888243367485; Mon, 26 Oct 2020 03:55:20 -0700 (PDT) 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-309-pgpoQXAiPx-jqLLImu6PHw-1; Mon, 26 Oct 2020 06:55:17 -0400 Received: by mail-wr1-f69.google.com with SMTP id p6so8125765wrm.23 for ; Mon, 26 Oct 2020 03:55:17 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709719; 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=Hw5BQAAAE838N0zxUjDnwvrHTxjmhWL7cEdxvzW+qZcJ21BTx3E34qEJvDr33AbPIPdv0x /MueeF1blyxmK9tA7aQv6Z8J5auU86LOriA+3YNez/rqazaP7hipCJ8RM1Z4BTQE8gf13f GT6y7nXfaOkHFCoxF6mHQbJV+twsgSw= X-MC-Unique: pgpoQXAiPx-jqLLImu6PHw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ffM492hetK8u/GqoMVkU0TJmIWrPk8dUIU3q04M7GGw=; b=gmAXJsBjqxvIRefGcmRyNgn+y6bOCdE8k8V4G2ip3VTdzp3S4w6xxCzKQiFQJ5rnry kQuYWP0HY2Z2ctrGPswu7psdHtxXyrsZcltiRFrHurwmXkGhdWVMmixNUHRuNWZf3WWo 0grZMUH4zqGuH1F1NZc6WRLqwCAOq+hs0m7m7BYuHIoC/Cqs26LzXiIaY2Dj1yEmrL8C iIWUqceYqhwlZj7mEK28D5HVoxEY0HmQWjTI+qYKJhPpqa2YJ5u0AL3ptYjdskRjJ7Zc KymTCrK0D8ikZUX6Q9/5VRQKzwrFWQRBjDdO8AdB0hsdirPRDoXvwa3wmXqqfUbbEkS/ NG6A== X-Gm-Message-State: AOAM531qsvPioQWBdxzTrrG73ZexDU2HLq1aTxixUzhu0gcj0fiC/7O+ k9xacj6oRL4JBTc4+aM6QbnFRSmH1bsoJ3pOf+tJNJ1XFhf+YJFcAJRKWkm4/tEw5/gmL8pfomb bDQw3JvyE7sOsmw== X-Received: by 2002:a1c:e1c2:: with SMTP id y185mr14956764wmg.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 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 =3D MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap))); s->doorbell_scale =3D (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment =3D s->page_size; + bs->bl.request_alignment =3D s->page_size; timeout_ms =3D MIN(500 * NVME_CAP_TO(cap), 30000); =20 /* Reset device to get a clean state. */ --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709725; cv=none; d=zohomail.com; s=zohoarc; b=W6rT5oJssqr6Lp7YV33Xbyt5ozkzSpxWFAWyJIxtMYBa2nBR3Bmiiyu0q45mbGZaLUIJ7zQhPwNDsf7YFzZ4gcxOJOTkk/K3fRMBX9zzTlw0Y7fQc5GpqUgvyqpNo6KmV4eEJMbNTSkgby0CaeNZIhKbZU11o9SbKWAYAnbEo0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709725; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=TR2vPgke7yC3Tw04v9RRPAjEqIwyrI6NV8B8irqGPbU=; b=DTlrT0u75NEt32zUcX/M3v6FXcOdWzbAmaB2uvE1S1KEy1UqNu1G0OlhkUXI196UxYflLIr0awStBGWV/uMeJQQ3auI5I9v1rSHxgneOIkZyD0rA0k3Tn2lIfT9RiGFIxWVzCZewy3xrpiAHMBN5SB4Ap2PqNTcDOwTtjt4PhHI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603709725412592.293410221756; Mon, 26 Oct 2020 03:55:25 -0700 (PDT) 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-531-scRzRVGOPRKktM5SJZRSVw-1; Mon, 26 Oct 2020 06:55:22 -0400 Received: by mail-wr1-f70.google.com with SMTP id b6so8177592wrn.17 for ; Mon, 26 Oct 2020 03:55:22 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: scRzRVGOPRKktM5SJZRSVw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TR2vPgke7yC3Tw04v9RRPAjEqIwyrI6NV8B8irqGPbU=; b=X12rtG7zKybjfnY8WXWxuxlhm3pT0d9sp95oIvex7ISQATcYG8Ay0DVOGxVmN703w4 +ViPNufYxvnZQSh4SSMuS/Ca3IG5l1AZn0O2Km4qqpeMPxiaIu9kpA40AkxKuotFrq/6 X+kjzgYG7dzSNhrCPyVFrPqHZGeEQBXT3fgmBDGQTLjl4vHWOqviqU1QMxhym+mQ4+RE j7SCnpRnvy8xotktTCh8ja70TD2yF0djSp2esEMn6nxz5c4FVzlBu+EP3096vUIavQZ6 8boWjSvys4E85gTfxVlP/k1Lu0BEIy2+qnxxYTAU29uf0tkA7saAWAuGZPHQ2dH1K3I0 t5lA== X-Gm-Message-State: AOAM531rMeuPplFZqV77+lFSC55o38cfpSWtA5vYDRyvBPMdBnJPodKw 4zuxHGVqRRiTxUhdU8bzRqbvLYeVskRpKb4VsK9uoo/5892BTsn68BXkFlAbpoof1vdp+RJD4GH 0nuQ08UOzoqzNlA== X-Received: by 2002:adf:fac3:: with SMTP id a3mr16453391wrs.240.1603709721580; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Introduce device/iommu 'page_size_min' variables to make the code clearer. Signed-off-by: Philippe Mathieu-Daud=C3=A9 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 =3D NULL; volatile NvmeBar *regs =3D NULL; + size_t device_page_size_min; + size_t iommu_page_size_min =3D 4096; =20 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; } =20 - s->page_size =3D MAX(4096, 1u << (12 + NVME_CAP_MPSMIN(cap))); + device_page_size_min =3D 1u << (12 + NVME_CAP_MPSMIN(cap)); + s->page_size =3D MAX(iommu_page_size_min, device_page_size_min); s->doorbell_scale =3D (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment =3D s->page_size; bs->bl.request_alignment =3D s->page_size; --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709732; cv=none; d=zohomail.com; s=zohoarc; b=SxnD9uvtj4vVfIQGzsqHNf9KS9c91Y5hKF/I/0hJfLOzpYi3hGUR5KlSvOPrqyB/8a3dOfA4G5pqaCDyk/RL2E6dz3oP6dBbSK09x2xLRtPV1eNaFi0BKx4VaiMHytwz08TXX+s/W0uX0luiynX0jgb3MoSYnjV+D3bjWBAzR9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709732; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=W5p4tPu2TXjCzyH8ugJtEh2K4jonp6V4FsAYE5GR61Q=; b=Vx11DIutp8fa4ilVU9tLO1cp0iePB6evBRrMg/JfjFdt8GCqr9ZsykOzzb34aTWGeu6cl763X7DCSjFOZ0rT2u2UNQuKQy8URpL8Qu1LbD8TiTRG8pBREH4geQV3x/ha++7vx4ZOyYdeSJLp3rXQmEFcZMwQFe5r/BUjcwDlK50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603709732351877.806322269094; Mon, 26 Oct 2020 03:55:32 -0700 (PDT) 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-511-z0IhbgkIMbeX9FZQbyLg_w-1; Mon, 26 Oct 2020 06:55:27 -0400 Received: by mail-wm1-f69.google.com with SMTP id s140so146653wme.3 for ; Mon, 26 Oct 2020 03:55:27 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: z0IhbgkIMbeX9FZQbyLg_w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W5p4tPu2TXjCzyH8ugJtEh2K4jonp6V4FsAYE5GR61Q=; b=qsN8n43TIIhD2UUndnjEwVmX+LIF+cntLgiFnJUcy1YF/a7gwfdROBTAcmNBuIyHki QNYWdLXHK3cLWH1Ffs5ATPt88r5IzGLj6qmCGNsbi0EJFzMOusUCdJv1dv7tpeNzNV62 2RjC1q/rrPfmQPxOaXPcJGSxkhyJ4q0BCniKpBk9CGtG/WFu5hR9GgXvsJOp+jvoKu9I 5jzS63OKSqFB80yW/leuzXI/pL1HnY3wFWh1Hg9A5RZOmR/DZJZaCWaSfxhB7Hmkkge6 D6rs5hi5eAxpc+JYziAsg4oDSF174zr0vlxfl1LmifOQpjM/ycD+LiiE6W016ee8ryf3 E3fQ== X-Gm-Message-State: AOAM5303CYYOYFM8F2KmsnibOvT8F/N2A6Zj4YFUnoFP/i4UhZAX0rtW hhc4kLbnpDh31lOJBo1mQs3IoIGwPsBUJK/+Jva7SOvd9ynO9+D0AVxYRgJpZYzYdHNqLr/lflc thBzrWsjSBsRqZg== X-Received: by 2002:a5d:4c4f:: with SMTP id n15mr16563048wrt.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 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". */ =20 cap =3D 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 =3D -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 sta= rt, size_t len, uint64_t qed_aio_write_main(void *s, void *acb, int ret, uint64_t offset, size_t le= n) "s %p acb %p ret %d offset %"PRIu64" len %zu" =20 # 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" --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709735; cv=none; d=zohomail.com; s=zohoarc; b=jPaJeNpD+r5FTB3tOc1zdWumVhy+gge1jDx6adPdiEr9WSo+8PlOD6mULLratIoEevjTdNXhUteNlrw1PL1VNl0WcOsrMzEFDO44ZRT7mJGVHWZyb3JPwPsGfpVnauz5/XC2mPzhkSJiTl+Yq5F6CPYvGbI90OWa9Jk+k3D1zVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709735; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=v40hj3qY78whRoPdfOU/jnlm9Vu0+VmOWNSL1HaIBaY=; b=EoteR7q+VfJBC+CGdynQUjAfQdPWtNmEKRJnUdqD41+lJC0lnZy7qnywGpSKX0oOxKMuuKSV7e9Yn7DiPK6DPQJvMYM5UiP1yF6l2TlGgFmd3sRT2Dn4I6ssiS8G5PJnTt9KJ1dY9atjjHvZpU0NsNuxeb9g8VMxrMZOnZHHxpw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603709735088145.22751126791013; Mon, 26 Oct 2020 03:55:35 -0700 (PDT) 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-327-JpxlU-gyObyxJOEU5LRhvg-1; Mon, 26 Oct 2020 06:55:32 -0400 Received: by mail-wr1-f71.google.com with SMTP id i6so8168504wrx.11 for ; Mon, 26 Oct 2020 03:55:32 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: JpxlU-gyObyxJOEU5LRhvg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v40hj3qY78whRoPdfOU/jnlm9Vu0+VmOWNSL1HaIBaY=; b=ZT4//xkCi01ZvS+aeAq9ybgJ1aCESTC+6X30HnBZ9qH3emCF2mAMvkM19wAblYswFm i9qODPgtXVxEz6+dG6a/7+4HBE6Pcvi9KUNAW4vNA6ApYqhAndI5/jNbzPcLNwXwP0vG feh0autQRyIuZAeiB8ZkT+eKPhNGpmpCYsiMh2n5y8wdqxgI7GTNIHHQ1PLUnFsMeuSh wK04TZ3jZLbAJ5Ot1G09emAkEVDuUlmggaqpSydzQGqj+xjrbxiZMNfvqDhiIZ/SVdUr 4P5rp+rfGcoTw37c+QpTkDyAKcAay2OZTI3dz5wQrw24sHERIoxTriS08nh2bbi3ZfOQ IINw== X-Gm-Message-State: AOAM532dMiLWA93ixHrFXubDGgmtpelzeOBdmCzygVotnmZ/k7CMOz38 GuRwFL7pcryx+rNmkQcS36Fe8WOPJQTVaRQKLXD3YL5c1dwwNQe0nV9s2eqPRAagw4elQjUdLcx 7Lz/y0R8qDpWRyA== X-Received: by 2002:adf:b787:: with SMTP id s7mr18080750wre.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=3Dnone,id=3Dnvme0,file=3Dnvme://0001:01:00.0= /1,format=3Draw qemu-system-ppc64: -drive if=3Dnone,id=3Dnvme0,file=3Dnvme://0001:01:00.0/= 1,format=3Draw: VFIO IOMMU Type1 is not supported Suggested-by: Alex Williamson Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 c= har *device, } =20 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 =3D -EINVAL; goto fail_container; } --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709741; cv=none; d=zohomail.com; s=zohoarc; b=EfqfszdtJ9McxyjL6LK9NrUoWmePr9K2nKpsrjkZmug6RGBA2THXotAeaqauR1VvTKeYBo+pA3S2osUOqNBF9WFadb0wr4fSrSfvsEakyMjSbaban601yGt3bu1qhK6Z8e08nDoCz5qP6+ktjAPiwHiHPnl3MZ1IJ7skDlBR8Sw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709741; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Xorc1cOMXgP1kep2uzooHQ3r71AwjF7u/vtY5+daI0U=; b=jX+7CIYBn+cjpKqhGAtuGQ+1h1NwOj5lxZ/gaxbjSDjOicSLib4Lmv/q1XD/b0yE2ZpDZSTc5VC3DfcMDlhVHuPqTgO+a9C0j+9UUIH0QmWdOoHRvaDyGNGtZczc0Wx5qTwY5ecMqIH7sihUREgoV1IxNHxmNQvX1vAyDjhbzF4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16037097413141022.7063130685807; Mon, 26 Oct 2020 03:55:41 -0700 (PDT) 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-513-6yOG10WiNuq3PXehATG0Tw-1; Mon, 26 Oct 2020 06:55:37 -0400 Received: by mail-wr1-f71.google.com with SMTP id q15so8182401wrw.8 for ; Mon, 26 Oct 2020 03:55:36 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: 6yOG10WiNuq3PXehATG0Tw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xorc1cOMXgP1kep2uzooHQ3r71AwjF7u/vtY5+daI0U=; b=IsisFzyfR/g6dYMK2p8bx3pWqJ5l4TWSjW6B8DhWtsyIkvzmob0uaYC+mzYfbMGoT9 eK7JfAOwwgaTdENVXWV11aNQCoAqT8hkH4xYmImX7EOYgstaZr1lUjU71Pkl8HSOa+GF BMyRqrSNgpV5/KieJueJ1tN0UKyL1WRDubezPFo+oB9T2Hwt5Wbp7GvXBImOn80uyA90 ydu9lE7ARiVYgn+/s5E1Sf6EHWVB9/1iUyn7z2mtS5rWJfuHu0M9DJ8/pzPxBKNx0ryU Im0wHfXRDRbGjRMw7qDyZL4+wvO7AYY0b70cDx85wGTAAm/nD6IetHAsTkPzIWnDsMnF t4BA== X-Gm-Message-State: AOAM532YOTZpJL+3tMQ7EM5UHb2f75z4tPNtsi27lAr6woMxZCY+Hb/s UamZG8aWkpnKIIqIFib3hxzgfn8mxgZ/Y0DJutIZiyMEF5ZwCD2tZLnGuulueYfyf0sJqt+GBon Kosm7/pQ0dgSwFg== X-Received: by 2002:adf:9793:: with SMTP id s19mr17457422wrb.139.1603709735857; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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; =20 + 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 =3D pread(s->device, buf, size, s->config_region_info.offset += ofs); } while (ret =3D=3D -1 && errno =3D=3D EINTR); @@ -237,6 +241,10 @@ static int qemu_vfio_pci_write_config(QEMUVFIOState *s= , void *buf, int size, int { int ret; =20 + 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 =3D pwrite(s->device, buf, size, s->config_region_info.offset = + ofs); } while (ret =3D=3D -1 && errno =3D=3D 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, i= nt 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_of= s, 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_o= fs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x= %"PRIx64" size %"PRId64")" --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709744; cv=none; d=zohomail.com; s=zohoarc; b=ggfFMDND1AoUxCEdLSwIfd19ek0erA5M7z/jm1pe0wh/aLCqAbGF83q2FZ/zg5obM/Zd6VSrKp/ZSqypdkvs9vdmu4JTkVSFHKrPg0o/O+nCQVHgP/b4u5/JcSIRABbtry2y9WnrNA2+LgiEiJm4qC3uHUx6AaeKGJyqok5ikaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709744; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=jJzeX7lyaDemOB2QTG1Y3n+OWt54ICMjUzceGOoInIo=; b=LG6Qti9nHMdT1pFE+IeNBQqrc+CAmhoCPBmhiAh8FnDDHi+LJCITDk8Jj53IyLlLjvAZpl5KFT1OoQChreOUtciUCB/4OyJTwbDYPOz6s1xWFTK27RHfSD3l6bbdSPDeGGjwGCe1HzilvZoLDHxFNlnJ25v44nplpYZh9d8Via8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 16037097447571008.4075412884363; Mon, 26 Oct 2020 03:55:44 -0700 (PDT) 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-575-ms2s5c3jPb-L6Zs_524b6g-1; Mon, 26 Oct 2020 06:55:41 -0400 Received: by mail-wr1-f71.google.com with SMTP id i6so8168663wrx.11 for ; Mon, 26 Oct 2020 03:55:41 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: ms2s5c3jPb-L6Zs_524b6g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jJzeX7lyaDemOB2QTG1Y3n+OWt54ICMjUzceGOoInIo=; b=KVO1YFEjFz/msdcQg8516fijYr/iKfesNT4gTjKTbXYkTCXv0G0IFEY5foHcB5irqb mZYFHcerfjly122v2/ixRW7mL4eARZNNsWTs+2breUb6NKdzPhB0kTLV9ObImsPDNPSq m09Iv6twGaqgykGYzDG4ppe1lYyY7z+YkaD8sgGypydDZJAi6p05XfvHs2rVV/cYJZ0C Q4k1uy+6PEM0lysPZMvtQcdTdkrAlqud7k5f+K7Tg7l5O7a5Z36JcZTTaowUSuugLZsb O9X9BQM8/nMt74N+kcRJxqhzzslLxrNz5cOyg/XxqBsCdkGtgIpQi7sjBPl+WYCjznkZ 4rMQ== X-Gm-Message-State: AOAM5301YoyhX3yZhnbabl4LGcIYxivJydNrSkYoeLcgwVvNBxyoY8kE u8/MFdwNH8hF/oY52iYvHBReuOI2n02YbkpL/vHnZOaZrWOGWWlbe0AmzqaXRFDkiSe2H3w2lJb 4r3OUfBX9QB1qFA== X-Received: by 2002:a7b:c3da:: with SMTP id t26mr16284935wmj.154.1603709740673; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For debug purpose, trace BAR regions info. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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) =20 static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **err= p) { + g_autofree char *barname =3D NULL; assert_bar_index_valid(s, index); s->bar_region_info[index] =3D (struct vfio_region_info) { .index =3D VFIO_PCI_BAR0_REGION_INDEX + index, @@ -145,6 +146,10 @@ static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, in= t index, Error **errp) error_setg_errno(errp, errno, "Failed to get BAR region info"); return -errno; } + barname =3D 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); =20 return 0; } @@ -416,6 +421,9 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const c= har *device, ret =3D -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); =20 for (i =3D 0; i < ARRAY_SIZE(s->bar_region_info); i++) { ret =3D 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_of= s, 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_o= fs, 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, ui= nt32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PR= Id32 --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709751; cv=none; d=zohomail.com; s=zohoarc; b=V5ZQI8sKaDEtwvieBSu0RFSvsl/YKhp1Ob7EKtw8Du8WDii7IYfYxZ9RokVfJmH/0nyyCkeXHyPcKondFPOJxG82LQI38fOQq8MBD59rh0JAyIqPjmaa83f8fNabkdvqjp8AI6/1PfYpk2/bfiRN9TAulgLVEDm4mUrS4mXyPAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709751; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=isOyGHI7YG22yBJfURVToP+mUwE5y2Znz4P6pSCuvUw=; b=E9PpEPH1rO87aUhvWezwU4NH2L5jjepO3SxMqJQFOd1NXfW5i4gmx508fO7YPo6YvBqnivy3Koo9hGaDpCH8ZZZCBNRPa+8ipoRhrSGqlUwOkV08WY5MmxDze903A7iVQWklH/60UYrGm70BWyP6ox+f0VIITPKF2VsdFeoxlaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160370975140473.27195402298457; Mon, 26 Oct 2020 03:55:51 -0700 (PDT) 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-299-UtmIHlP5Okql1gMbEWHsYg-1; Mon, 26 Oct 2020 06:55:46 -0400 Received: by mail-wr1-f70.google.com with SMTP id 2so8209126wrd.14 for ; Mon, 26 Oct 2020 03:55:46 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709750; 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=B89vDx31vGv6m2F/+Gf7OYPe1rqHZmsPxK8qP1WsXyGeySIT8WdZelUcfcf9IRlUJU1S2W sA+o/BNj6AlE+Q3zmnCdEMkO8ASQHXgH+8hAzDO79ctDv7oqJRP41ErJp+/1QqP/afOwOx jr5ZiY+JdkYDaKCKRFcUhnOIWLz4xs0= X-MC-Unique: UtmIHlP5Okql1gMbEWHsYg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=isOyGHI7YG22yBJfURVToP+mUwE5y2Znz4P6pSCuvUw=; b=P97xN5Gt0QrQKspntBr1TTu8LBslymDM3neFJNByZdqek7sEcbNtplBKToXKthm9vf i3vgbySEEhoYOCV8mrfYk5harI9piaue+/EfZEdXGqfbxm4voM5eXkvcpIvEw47SviJ3 /KRlzaZipUPfEqweaSRZ03uGibmN2nhT2pX88giYPnzNmJoeG8BRjmO3qCVp04DcMgsu DDRNZO0mxq9VBA8TWdmZK9KKBe5Q895XXl8wAJqrddCTM1TLSymHCw0QOEJJT1dz2U6F 2FMkKBT6ftOGnjb7vxVR190S3fAdQBNL/cNQU8NIwLHt8TjZUBlEybpThO9rdupexETH BfMg== X-Gm-Message-State: AOAM533xRtpyKWyyCK5R4pFi/Oatdn2s/pnkkE2gsbf4qMkHim2E/nJ1 WUyWmpNnp67NvKedj6AUE5WdXCDtsQ8WUSWYWf27SEu+rOsE2kky40pBQMvU0tQdnRN6yfuS7o8 4a2wKCrS/16SyiA== X-Received: by 2002:adf:979c:: with SMTP id s28mr16987779wrb.62.1603709745508; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For debugging purpose, trace where a BAR is mapped. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D 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 =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, "Failed to map BAR region"); p =3D 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_of= s, 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_o= fs, 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, ui= nt32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PR= Id32 +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" of= s %d host %p" --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709754; cv=none; d=zohomail.com; s=zohoarc; b=lk+HkvV8UJqsZ94TMlIh+gC4bmXvP0uCS7Qaf3fQJOm06fmcRiSE4c3gK/EBKkddrab4fWyIPdZKLq8pCJ/+59FRgESXBhplHsAdG069j6VHYES68JCeJAp62i19ef9P1GtE3C4HMhDdRMfU5zflFUi+H0aIPGBl0MiozuvIi3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709754; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=tTDiCm1rGvrFJ5fByXHjKqVGr/b2mgKYh7ZyBSdCJu4=; b=kYPdE2RJwbouaQB+qFamV3VffmgWVTT1+Y80TKRwn24iNt1bnj1+tML/WvEmqK4SS3p9yQxA9FEB2cW5isbvhCgOMSkEUJubLPTnIUSQDbM0fdlMJbOpzEA4Mukbr2g7xtEaOE0b32l2WtS4XjijGHz4SOxGChl/jT+XNQoTCB8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603709754145329.0971640473448; Mon, 26 Oct 2020 03:55:54 -0700 (PDT) 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-288-cVT_IuwWNYWOpELtyYWGSQ-1; Mon, 26 Oct 2020 06:55:51 -0400 Received: by mail-wr1-f70.google.com with SMTP id b6so8178045wrn.17 for ; Mon, 26 Oct 2020 03:55:51 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: cVT_IuwWNYWOpELtyYWGSQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tTDiCm1rGvrFJ5fByXHjKqVGr/b2mgKYh7ZyBSdCJu4=; b=tsIaS7fvTrcVLf1TSKlA5cXCJ/gqUdeDrT3LZv4VLgZQ9+vJy07wGUvNhrn15hbjQe JHsg55Ze57DA81U6dOj5I/j53E64DY7M5jMCkuSf63MRoGs6S6wj8Wua6zNodn92ppBR P4Lu11adEwv7WDz4knL9URl0gySYuLZ7OtBgBPzUj8oVfSTjiWmG+HviAUJDUI41E9Sv 78h0l60jeN34NwG4QHLmBofxobT0ZTQSQsKX0VjB4JFnOzDxdYkRFmYdi3If/YfIxhuA GL10cVuAnGzeGggmTkR6vFLwnmceFc29gIPBUM5O9/AtMbqMhT8PWXemV8IYCzIN3TOg 77jw== X-Gm-Message-State: AOAM531O1Izzls0q8EWw9739fYhmZrOhIPfIcHFB6ae6moZ/mn5pF7SC Eu8GI7vs+S8Vcr2pBqJfMYAExpVIrIPX831hG5p/R2iuO/NrgX6hSuO3N5dTAmUWrAgnnstVtLv +c4OYcOejWI2YMw== X-Received: by 2002:a1c:7d0f:: with SMTP id y15mr15097209wmc.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For debugging purpose, trace where DMA regions are mapped. Reviewed-by: Fam Zheng Reviewed-by: Stefan Hajnoczi Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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 =3D (uintptr_t)host, .size =3D size, }; - trace_qemu_vfio_do_mapping(s, host, size, iova); + trace_qemu_vfio_do_mapping(s, host, iova, size); =20 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, siz= e_t size, } } } + trace_qemu_vfio_dma_mapped(s, host, iova0, size); if (iova) { *iova =3D 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 s= ize 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_of= s, 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_o= fs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x= %"PRIx64" size %"PRId64")" --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709759; cv=none; d=zohomail.com; s=zohoarc; b=k2/8ZqfKhwZZadQYrJQ2RcXE/S8cbb1SH27M3Vcgj/bjahGnQoZxgQGM3KhVnFaffWNBeMHjFPOcTgfUnF6eMSO5ywk1n8KodPf8fdHECbcU63CRC+gPXck1N71zB79D3wqqBrN26MBZd9I/+zZ9Eg3OP9H2z/EW+WjCmbMde9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709759; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=oHVBY2K3BEOh3WYNJplbtMVpgw2LML5s1ozFmG/8CV0=; b=BVCNJA5VYM9dUViNanIURKgi9ccol/JQ4/s13Q9sfgqq8YD9+uvysA3sTkBtM7boeOEQCaHY9az6hB7i77KKbq3ajQwwG7NBReqRtJENUAik9XyYDrXMlDO0KLIADXf7DmtDimM0X6DoWacF6JCTFHexGsC4fdyNqgHRWE8t/Go= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603709759968453.9349599933811; Mon, 26 Oct 2020 03:55:59 -0700 (PDT) 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-482-ksuuc6bNOv-llE61apdt_w-1; Mon, 26 Oct 2020 06:55:56 -0400 Received: by mail-wm1-f72.google.com with SMTP id l12so5560315wme.2 for ; Mon, 26 Oct 2020 03:55:56 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709758; 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=Lqc9LZ04zqZ9H1UtSMf7HhOnPi1xdoXvO8qlBxZXeX7WkS7pGYeJFmBngR0jQodSclZVtO dNMU1ApEXSB+YnWu4SNK62sC1DTJ8tZ2h/XJtywoplmzKPex7d9N45+rrhBDC/apdkjOI1 vkrP9lMe/7/OncZtL7JHu4nQULKivM8= X-MC-Unique: ksuuc6bNOv-llE61apdt_w-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oHVBY2K3BEOh3WYNJplbtMVpgw2LML5s1ozFmG/8CV0=; b=UzAN9WRYm4LEonPU7AI4Las3dnnG5FvhYxHpT+pJx+ClbZwlp3puAVyA+TUH6Tf34Y VvtILSdz3pheIB2Ql3g2ePjJgsF6hQmb3YP5u1bTGRRZ7gMsgU3FgHs0jdNCOXxppKsq qHxg9e42El4KpWVaSslPGoHsYjZDIIbAX2Fethjs7TkMoFP6Gxq3yRst8DffJVxThE+7 bWcpavM1Ko1C/1jKyUeAYd8mThvpfsyht5sjG385fpbqvB/Nyl+wF5LQsQDuwQVOA0UC 0qA1ZOVT7KMYRPvqasojGrZoE4uKOY+ewCmKqxFZL9qgdNLynhk//Lxo4XAEcjkkBnVu UpVA== X-Gm-Message-State: AOAM530yYaRgyB39ovvm4eOK7qlv6H+PjgYrJiHZUT4BDgJQpo4HdUD/ 1V///o9GjZJYk2jYW4qXgU1nbIare7NSYTjXxlnH6A5Fr+AhlqDL3YQVUGg96SfsIJm9vrMPfIM ijEcWvVi16LuAhg== X-Received: by 2002:a1c:f417:: with SMTP id z23mr14729760wma.57.1603709755328; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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; } =20 -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 =3D 0; i < s->nr_mappings; ++i) { - qemu_vfio_dump_mapping(&s->mappings[i]); - } + for (int i =3D 0; i < s->nr_mappings; ++i) { + trace_qemu_vfio_dump_mapping(s->mappings[i].host, + s->mappings[i].iova, + s->mappings[i].size); } } =20 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 in= t 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 siz= e 0x%zx" qemu_vfio_ram_block_removed(void *s, void *p, size_t size) "s %p host %p s= ize 0x%zx" +qemu_vfio_dump_mapping(void *host, uint64_t iova, size_t size) "vfio mappi= ng %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" --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709765; cv=none; d=zohomail.com; s=zohoarc; b=TAedjx1N0J6m3Eqp/Rn20CnN9tUW1KHmql1Fo+pqkM9Oj+7MzwXyIc3ZYdZz0koBx4hnv/o8jNxoDaK4fpWbi0sXR8lkS8i+Vi/80oYDFwu+OY/JBRgVQGPZCn7/dxLyjA5ea3ZQxsvK+aSlFLPBH7Wl8hAREjpomcp1Yos4HiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709765; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=nFpAvnhzKFUahLqtIDcPSll9W0TpjYlTTuISswcMLmQ=; b=mo253RgiamExc0dCbT22/HsIyj72xkVKLNT22adufnLcQ5BUxwKgOO3jZfTf/2Bh6t4X6uzBkdSgzqV54XmgC7EDmmLT27MzbjeAtPVzp8fvUkB7rnq/wQ7BfpJHXuhI58OwIohEDUKgplMo76UBG4kMAGrQ+Us3eaXFpnzmRKI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603709765230108.89756600069188; Mon, 26 Oct 2020 03:56:05 -0700 (PDT) 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-427-7bp0afYLNumwHuEqhnhnIg-1; Mon, 26 Oct 2020 06:56:02 -0400 Received: by mail-wr1-f71.google.com with SMTP id n14so8189825wrp.1 for ; Mon, 26 Oct 2020 03:56:02 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709764; 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=cGfTRYWibqZhesj9PkPKcCmPuCHPxzMklLOpWTctCn0HqM65VNYTVqOmBXLXoGGoClT5h0 BJtEkGgFEleouBfJGhLKWmU9et4eyn58pnBqQa173zC+8nuK83rd6VWh2j9CYTjnKq3MKP 5/WC3ep5zFxvAg1QlMP/UUP38JZuApI= X-MC-Unique: 7bp0afYLNumwHuEqhnhnIg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nFpAvnhzKFUahLqtIDcPSll9W0TpjYlTTuISswcMLmQ=; b=d0/LWVEIgo3UtxKZqG443tAWbaYqZwVDqI+rtNUCO2W0UUddZ4gFYmA8v7Sr/zuBCc bFX7JI9WnNw+AwJmEqFPq/P5YpHYDTJgk/wwhFjYWwiGVqrPcJ6P0vP4R37kGjExjf4Y 0s0C1AWLWd1vxKu6kkpsE/AWL4y960i4wnIBY2XAwQ5rU+3yCPcjQrn/DLPC+OVOJq7g THoVGf3OEHe65KPIUprzOa68fsDKOs+LV/Y6oO95gRdaf27sEz3aqtQVttSCQjROw9y8 +Lczu4u37KVGY7pxx9otEoAeviDNdmmQK7hFrLgSQwsnVK5sbzmmpZq7pQeca+uwfCof tUEw== X-Gm-Message-State: AOAM5305V5xvuLPJlaT4bFZEBCIqInm/1MQkxWT/6zf7k7L5fmXEh4S5 ZWy4Tct1miM1qd254jKipf/opbNCoFoiitMo0Mi6NmIuemjyXwW+GQn4e6B5ioyYRzDoYDHBXKe i95RBGwauljvL5w== X-Received: by 2002:adf:a50e:: with SMTP id i14mr17333463wrb.121.1603709760358; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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 =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); + r =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova, err= p); if (r) { - error_setg(errp, "Cannot map queue"); + error_prepend(errp, "Cannot map queue: "); } } =20 @@ -223,7 +223,7 @@ static NVMeQueuePair *nvme_create_queue_pair(BDRVNVMeSt= ate *s, q->completion_bh =3D aio_bh_new(aio_context, nvme_process_completion_b= h, q); r =3D 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 nam= espace, Error **errp) error_setg(errp, "Cannot allocate buffer for identify response"); goto out; } - r =3D qemu_vfio_dma_map(s->vfio, id, sizeof(*id), true, &iova); + r =3D 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; } =20 @@ -1003,7 +1003,7 @@ try_map: r =3D qemu_vfio_dma_map(s->vfio, qiov->iov[i].iov_base, qiov->iov[i].iov_len, - true, &iova); + true, &iova, NULL); if (r =3D=3D -ENOMEM && retry) { retry =3D false; trace_nvme_dma_flush_queue_wait(s); @@ -1450,7 +1450,7 @@ static void nvme_register_buf(BlockDriverState *bs, v= oid *host, size_t size) int ret; BDRVNVMeState *s =3D bs->opaque; =20 - ret =3D qemu_vfio_dma_map(s->vfio, host, size, false, NULL); + ret =3D 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_un= map 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 =3D 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); } =20 static void qemu_vfio_ram_block_removed(RAMBlockNotifier *n, @@ -477,6 +477,7 @@ static void qemu_vfio_ram_block_removed(RAMBlockNotifie= r *n, =20 static int qemu_vfio_init_ramblock(RAMBlock *rb, void *opaque) { + Error *local_err =3D NULL; void *host_addr =3D qemu_ram_get_host_addr(rb); ram_addr_t length =3D 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 =3D qemu_vfio_dma_map(s, host_addr, length, false, NULL); + ret =3D qemu_vfio_dma_map(s, host_addr, length, false, NULL, &local_er= r); 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 =3D 0; int index; --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709771; cv=none; d=zohomail.com; s=zohoarc; b=EY3LPP0AGLHOCa4x5l4fvj9Uo+JuAEWu4tSNsKTYmYhEOWWrOQoy4QojAYa+Qn6ik0KScNkpOwl43iFeMmTbs1jY/jlR0ruW/stiSdr9rKnD2ozRmTyVG94GrpA2ihh4JQiREQar7PFdVWAyZmZQnJm4IgZPOPz+W5fqgAqZa44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709771; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=drjwmQSo3TPMr2yqHnKgPcr0+zGutJeRfAQssJrVzdY=; b=c0fxddJQiEvc8niYCMKw7jiIBgDkIjR1/mlwY+TR+S9kOuezAfxk0GO+ElHvEmZDXmDoGNHFL2Mr38g0vSqfAC8ykwSEJ/xBv0XA7KSuiFVliu5eNyuEk5d//EDJnj6Ok6YQhl7U33m0eBIcyy4Bbt6kUcmBpkTjSa5UV2yOF8w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603709771125973.3152582098048; Mon, 26 Oct 2020 03:56:11 -0700 (PDT) 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-408-ivDYRvmbOHSxQAo1vsKc9g-1; Mon, 26 Oct 2020 06:56:06 -0400 Received: by mail-wm1-f69.google.com with SMTP id s140so147161wme.3 for ; Mon, 26 Oct 2020 03:56:06 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709770; 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=XKcwTRWJvi63HBqN4xbeyHhD/gILO6G2hJdvSLsTKnxaQonYN1/IDpfExGf4kp6/n4mjY4 sZvQhk/I+L5x/Wfr2dGN14FU+HaySjhWxKDMvKJi+AjRS3fr+atNHQ6XmEXmr/B81Tlppp i1ny/lHNnadOaoCxaihdbQ/xHeW2TJ4= X-MC-Unique: ivDYRvmbOHSxQAo1vsKc9g-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=drjwmQSo3TPMr2yqHnKgPcr0+zGutJeRfAQssJrVzdY=; b=FeAP2RRU2Ex113Dtihvilom0AhwEK0fUaI+hqSQo46F00ubCBjyh2DhdZ0FFNh9A2f Ru7k6BqnodjsfeHpUBgFviwXOW9J02qtXeqV88QwynKyUm4mcJrvRY/s416v1m5ZXc67 PFUH/fXGMDKoj2E/SLcQX81/XP+2gP9EWqY3ac0WrZEsY/eOxowTlQv4f7QM62y+nwAZ ZchqiGSBnKUh+tMtPJHIr2NOmcJo/IgkEo5gO5GXp70c0+I2lifp+yi6Di72tn2zdQsb 6O4t6rx6ma6TKa78jQaNKVE5+E8AICLshyI0ImbWOsUDeDL/BxWy9vlIMY+fEyA3MezN usTQ== X-Gm-Message-State: AOAM530/XQ1hzET0+aB4ecpQEfHbFCOMCm9PyViwrpBgTX2t8EHNzHO/ 3FWgGH+TsMpVmJ1aGdREPMwBY8q19HazTBzGAbrPOd8lxn9S2ShnuLNLE+qdEAspkTmdC2stzts 10veMATY9UIFfuw== X-Received: by 2002:adf:fe89:: with SMTP id l9mr17280964wrr.264.1603709765029; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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, =20 /* 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 =3D { .argsz =3D 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); =20 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, siz= e_t size, goto out; } assert(qemu_vfio_verify_mappings(s)); - ret =3D qemu_vfio_do_mapping(s, host, size, iova0); + ret =3D 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, siz= e_t size, ret =3D -ENOMEM; goto out; } - ret =3D qemu_vfio_do_mapping(s, host, size, iova0); + ret =3D qemu_vfio_do_mapping(s, host, size, iova0, errp); if (ret) { goto out; } --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709773; cv=none; d=zohomail.com; s=zohoarc; b=jrtT0DgiOU/UEpQIWznF5lhyC2/TqsxVY6yL8UBIwMF9LFoSiNlz71psG2hZVY/iPBtF1TKMUePE24dwPe8uLd7Kx8AOTPAHPPbfAhzZQPE0RIWUkJxQdg0Uq2wqzh54wLL6E6jnguHKhBzqRcYbhssiqtWPQjBSGL7yP/Ushc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709773; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BidoL8dEegdrM2deUWRHfDO/6zWVfLj47EJ1lH5mvto=; b=IBLjODQh2alW0fL0v0NnHZLZ3pL8IxzqCQRkdueYTVfhGAAP062SdcbaYtnDSaWwCgNEAF+1YSl+70CCTXoeqv/5e4D9BT6CWayIOWEpBaY+qGxbE0S0p2GERBbrtUfYLTIE4QtYTJW5nAW1Z28+AviNgR1vwqHJtFRjkIkhakw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603709773599570.4222210625612; Mon, 26 Oct 2020 03:56:13 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-315-R2uGNcTZOZCdcW9RoxImGQ-1; Mon, 26 Oct 2020 06:56:10 -0400 Received: by mail-wm1-f70.google.com with SMTP id c204so6200255wmd.5 for ; Mon, 26 Oct 2020 03:56:10 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: R2uGNcTZOZCdcW9RoxImGQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BidoL8dEegdrM2deUWRHfDO/6zWVfLj47EJ1lH5mvto=; b=sDu0sEhrYxix+z/xmVYT5gEWLrpMkWPWH/JvwxV4gGvXB067RwXXHfaW2nnurTwXVI D7cRVNVuXOQDh1Ld51iGOrX3pc2w8iHhpQdegQvRb7HU8sqB7q7mYkngXp/2He3mv8ww UGSmYxiO/VZU1XEiHPD6ObMLBczSNM/gYoAYYnwIFYC2SSEx3yxkCpvZ99V1SdiEr4Ed p1EPKUOxpnCq55pMHXOb/r3k20fWC/OhoXv14R5zD/U/j03SOg742nyMyDBlJVzmWeB5 7raMPxSy2LJwT2RvYQntHUriBaj1StJz3tvsEuPxTR2OStWYqWQWyfgWGwUBxbKKZ1AD TiAw== X-Gm-Message-State: AOAM533VELpvSWHusWyl7KRrTwRdJ/Uc7gWoFnpyJLGRGr/NrwwHN4lp 8bmfn+uGYFZQTYO4fcwXf2xCDD1Y2yzxFqD+8IsXEd/ZL/ZdPeSqrNwwwldmOWFPSXSRWncX1ko IXQLIqIqMcOQo5Q== X-Received: by 2002:a05:600c:24d:: with SMTP id 13mr14576002wmj.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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 =3D 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 <=3D 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; } --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709778; cv=none; d=zohomail.com; s=zohoarc; b=eDxP3gsTnv9+q3bEsM/117s68Mugv27bbqiTYRjOJAz6p1StAm5wBBjgzLGgqov5Dn3gJvp1dr+s5tkrv5dLKlisr/9QMbeHEcx8sHA36BhKWSVU1NNQn39bESdRHgbzShfTkObkJXGaTOtu64JQXR9uBZGxXFZ9l12ljwY9TNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709778; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=UF5uHhXgkWDHbzk6PtUz47NRa7jF7pKRdhEOKMwbuvA=; b=XbTXiKU5bzWCF38FeX8QpX/lpEzEmBaMa3osIlUgqpaBqGoMIDATMzlYjUaZnDYTEErhrsXMGOm4CqA/OVUVsh8VBcaaBCfwlxRZ+NU5hdGb7doFgDStiWAjo210hnCmpEVH8QWLXXVYvYfP2v8XqQwPgSY60NAIbjRFmRFCHuA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603709778454764.9797250327696; Mon, 26 Oct 2020 03:56:18 -0700 (PDT) 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-455-j4iZ7Q3LMsCzjcAA7bN7Tg-1; Mon, 26 Oct 2020 06:56:15 -0400 Received: by mail-wr1-f71.google.com with SMTP id j15so835538wro.4 for ; Mon, 26 Oct 2020 03:56:15 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: j4iZ7Q3LMsCzjcAA7bN7Tg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UF5uHhXgkWDHbzk6PtUz47NRa7jF7pKRdhEOKMwbuvA=; b=IeE4cNu0qSLlWWwcSLaWUaUtiWbg33MAqyXWqixAhxzm+1DMbkspInSmch33I7PXqx OpHy5zRPliQTHdplL6aFeagyA27Ei2IaqH00JfPHDnDCw7ZcAN+zBW7XSYeSCcE5BABP RZfam2Z++26PmqjMbrE+Al4zlQA+W4fBJ2YjaxqxfsY3B4zIpcqh1NKPIy0NLLvgJ1B2 xijYAzvscm6jS6f3dOpVcSBx3f+1SzFepT6mPj/KhRlBXEy6CCLg+ENxinOij6HDhdg1 zyk79KUl9wTOmrFYeDHnrvAHy6loDYVOl2q8+o5JrBRTpLN+Vm/xdFKKSbsmFVHCqgfp tK4A== X-Gm-Message-State: AOAM5311qy0hqPkn+Xtx27r1dQhkNLezaQSqf9DZNxUmgcJZLVTlX2VI m6vxz7wR04pD8Z44akqLknd8QC7owmOUgC+wfVQ+gzn5vqtF1Hhy/3lQGLKJt3ezHE7LZd0H57x p6ukysu78LSK+NQ== X-Received: by 2002:adf:f88a:: with SMTP id u10mr17132044wrp.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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 @@ =20 typedef struct QEMUVFIOState QEMUVFIOState; =20 -QEMUVFIOState *qemu_vfio_open_pci(const char *device, Error **errp); +QEMUVFIOState *qemu_vfio_open_pci(const char *device, size_t *min_page_siz= e, + 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 =3D NULL; volatile NvmeBar *regs =3D NULL; size_t device_page_size_min; + size_t device_page_size_max; size_t iommu_page_size_min =3D 4096; =20 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; } =20 - s->vfio =3D qemu_vfio_open_pci(device, errp); + s->vfio =3D qemu_vfio_open_pci(device, &iommu_page_size_min, errp); if (!s->vfio) { ret =3D -EINVAL; goto out; @@ -737,6 +738,17 @@ static int nvme_init(BlockDriverState *bs, const char = *device, int namespace, } =20 device_page_size_min =3D 1u << (12 + NVME_CAP_MPSMIN(cap)); + device_page_size_max =3D 1u << (12 + NVME_CAP_MPSMAX(cap)); + if (iommu_page_size_min > device_page_size_max) { + g_autofree char *iommu_page_size_s =3D size_to_str(iommu_page_size= _min); + g_autofree char *device_page_size_s =3D size_to_str(device_page_si= ze_max); + + error_setg(errp, "IOMMU minimum page size (%s)" + " too big for device (max %s)", + iommu_page_size_s, device_page_size_s); + ret =3D -EINVAL; + goto out; + } s->page_size =3D MAX(iommu_page_size_min, device_page_size_min); s->doorbell_scale =3D (4 << NVME_CAP_DSTRD(cap)) / sizeof(uint32_t); bs->bl.opt_mem_alignment =3D 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) =20 /** * 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_siz= e, + Error **errp) { int r; QEMUVFIOState *s =3D g_new0(QEMUVFIOState, 1); --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709783; cv=none; d=zohomail.com; s=zohoarc; b=QsVzUkjVkNwlToJmwodo595dYZIP5Zy2kITcNiU7MloqRobRz/5ycjDulC8z/vHDoHttdQXE1H4vt78/sy2PTTI1/3tp7LZOPOYjQyaUnrIlzNSgMOeaYpg7uVDnW7gqwRRJZ/+CbnFx6XxHCGjj5ZMB8gvpK7+N9XRxNoRM/yA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709783; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=UchhDxvfvK9mvljYS5+MFH11t7RpYY2MHNXuIXgkVCI=; b=HljbLhOKy9Izxkpyksa6ceMWoY8xcL1Ko6mzZo81/V0HxzK15XjJlb4nwfVDSQX+4IBZ6g/OzPu6nSE/w1JqLSFeazljiT+0KTKmfFsmJQP4nDiDTXEoc3rEgRI22iES8DhfJtj09k0KtNvGOhxzcAX69PPH4/9TYM3EVaHei2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603709783484254.13009206261916; Mon, 26 Oct 2020 03:56:23 -0700 (PDT) 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-360-T3BevwncOk66H9mdFQifzA-1; Mon, 26 Oct 2020 06:56:20 -0400 Received: by mail-wr1-f69.google.com with SMTP id b11so8227755wrm.3 for ; Mon, 26 Oct 2020 03:56:20 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709782; 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=dfX1mlrNygF7zmzQY+nl64oST0YhBbjhUgJTDPmOjqsMyfhYD8E3Tv11xq4hsxc1jZPta+ I90ZWGDGWsKOXscZGYzRY9dgwupeXG7Qqd1ZVME2tJgCw1sITrg56+pt+PLtwPGlEmsU09 TRZQARo2V/EIMh0a1Jt015rR8hnbR+4= X-MC-Unique: T3BevwncOk66H9mdFQifzA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UchhDxvfvK9mvljYS5+MFH11t7RpYY2MHNXuIXgkVCI=; b=iYfZWnZTqiARmAxxkswNNWbLwzTeKusqrWeKrzIifvBJzwBpa7c1k0juqrnsJ8KyM0 xmgjEIrzCV8ePj1XxbW/aSn7dJsfb6QhzDET8pvO71TeUOidYR/qtg74N2jN4EfEj92r d3jzYTZp6OHoQGPEEurajuCwzEW1UHd9Dl0MBtdQKQOXtZkM4RmbTMuZ3SSiLXrJmH63 BQBJ+wZ90o0C3g3B7aGfR4ldQvV4zVK+rt6br4Bm5cl4kJkh8S60vc9eOGfh4towsx9U vDlfn6TIdweWD9lpNZ8H7eS9FOLMyqJLfPP41UKEyjblydKDs9ydbMnEqe7NT7obmcRh NDQg== X-Gm-Message-State: AOAM532sHlikC9ipcUvQwMGLO3p5B1UapN9l9PxbnsZQqDDTcYD3u0CZ /S5nbbJycudK29PhMoEq1EkAeDDEhg0x7Jlm4jzbMVb9WOPPcfke0KOw1SqO2CSMv1PvP1tnEcE JFqIUywVX98BkxA== X-Received: by 2002:a7b:c3d3:: with SMTP id t19mr10792126wmj.139.1603709779455; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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 @@ */ =20 #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) } =20 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 c= har *device, struct vfio_device_info device_info =3D { .argsz =3D sizeof(device_inf= o) }; char *group_file =3D NULL; =20 + assert(requested_page_size && is_power_of_2(*requested_page_size)); + s->usable_iova_ranges =3D NULL; =20 /* Create a new container */ @@ -373,6 +376,27 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const = char *device, ret =3D -errno; goto fail; } + if (!(iommu_info->flags & VFIO_IOMMU_INFO_PGSIZES)) { + error_setg(errp, "Failed to get IOMMU page size info"); + ret =3D -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 =3D size_to_str(*requested_page= _size); + g_autofree char *min_page_size_str =3D NULL; + uint64_t pgsizes_masked; + + pgsizes_masked =3D MAKE_64BIT_MASK(0, ctz64(*requested_page_size)); + *requested_page_size =3D 1U << ctz64(iommu_info->iova_pgsizes + & ~pgsizes_masked); + min_page_size_str =3D 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 =3D -EINVAL; + goto fail; + } =20 /* * if the kernel does not report usable IOVA regions, choose @@ -520,7 +544,7 @@ QEMUVFIOState *qemu_vfio_open_pci(const char *device, s= ize_t *min_page_size, int r; QEMUVFIOState *s =3D g_new0(QEMUVFIOState, 1); =20 - r =3D qemu_vfio_init_pci(s, device, errp); + r =3D 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 bitma= sk: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_of= s, 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_o= fs, 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, ui= nt32_t cap_offset) "region '%s' ofs 0x%"PRIx64" size %"PRId64" cap_ofs %"PR= Id32 --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709788; cv=none; d=zohomail.com; s=zohoarc; b=CzkMSSu2OjWgRUK4w+lzJRZ4m8are+Lmenzkl8TjSyovKVkaNaIIg9WpP0/h/2hnjUFHTGuP3dZe98NjugDXSAlT8Ivw0gwteegzOZQoOTf/yFn3xGtZ3ALkW7YdrPGxg/6Ktrk1u4jxWs4n0aohmgrj9myPv3m4q9dwgfuF4yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709788; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=na09npuagCae1jkRDHu8fQc6bmdR06DBBHFCPQpb2ds=; b=O4lDHV3USnWpiDdSfhJXpKVVqzKjO7eOWHlPKVNjJhiIJfagoRRA+3xi7eHIYzRQErlEo2u+QRGQMvudEKcpIOSUy72i0aZ6EM08t7GJqpK3KQ7zp5B4qGVX0b0yYa4CMkFcqD1hnrFJNGijHkujMgzdhUYJSggxa60PKKfp6qA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160370978834121.19320099607478; Mon, 26 Oct 2020 03:56:28 -0700 (PDT) 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-335-jqQSB3SoOEu49e6lsjXqjA-1; Mon, 26 Oct 2020 06:56:25 -0400 Received: by mail-wr1-f72.google.com with SMTP id 47so8217565wrc.19 for ; Mon, 26 Oct 2020 03:56:25 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: jqQSB3SoOEu49e6lsjXqjA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=na09npuagCae1jkRDHu8fQc6bmdR06DBBHFCPQpb2ds=; b=p70NoO686qGPPBp7knwIQw5a6HULFi+zxbWe8XX0Z3XTqlMbzOraMZNZixgm64d6SF HtvB1t1qGHlYXHL0AaNnec8BRhuDs8+d2tHZogffiJTK4gtS1gEM9FsnEF/Q3nYZffO9 s86B0brXuUFiLnvTMBnspyu7d2gVDXlqYMJLhtn2lbUsk16j7/SEjLs59Axmd1MHud+c o3YmbVSLND0SUXBhGL+G51M/WnaXlfiP1rivKGYS0t1rM2AuJQCzYXLCO8Jvr+KD5E21 fVmZckzLygHw5PCvD3vYWa6qtN7D6uYH3lxx4MBDsRceUBb3NJLAG0EOATbKmvlfoiQ/ kr8Q== X-Gm-Message-State: AOAM533FyrOtwkG+HotitCsWbYeBtvVQCCeErKGz/ciqsGjNvXw8qKaw Js32LCjCzvGTPIe5sqZB4ebocEamTFwfSoCYfLDtqTRX1AwhoKOhDB+S0blyK8T2Lou+9S0CglS GDudsfERWryaW0w== X-Received: by 2002:adf:f043:: with SMTP id t3mr16377497wro.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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=C3=A9 * + * SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * 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); =20 #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=C3=A9 * + * SPDX-License-Identifier: GPL-2.0-or-later * This work is licensed under the terms of the GNU GPL, version 2 or late= r. * See the COPYING file in the top-level directory. */ @@ -230,6 +232,67 @@ int qemu_vfio_pci_init_irq(QEMUVFIOState *s, EventNoti= fier *e, return 0; } =20 +/** + * 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 =3D { + .argsz =3D sizeof(irq_info), + .index =3D 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 =3D 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 =3D sizeof(*irq_set) + *irq_count * sizeof(int32_t); + irq_set =3D g_malloc0(irq_set_size); + + /* Get to a known IRQ state */ + *irq_set =3D (struct vfio_irq_set) { + .argsz =3D irq_set_size, + .flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, + .index =3D VFIO_PCI_MSIX_IRQ_INDEX, + .start =3D 0, + .count =3D *irq_count, + }; + + for (unsigned i =3D 0; i < *irq_count; i++) { + ((int32_t *)&irq_set->data)[i] =3D -1; /* un-assigned: skip */ + } + r =3D 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 =3D 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 %"PRIu= 32" (asked: %u)" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitma= sk: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_of= s, 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_o= fs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x= %"PRIx64" size %"PRId64")" --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709795; cv=none; d=zohomail.com; s=zohoarc; b=bVfTGcu0X44ghSdLJJAP9rL+9Wvwi5xHi+JzNeYgxzRikA7FA/X7wK9Pzf6WIOqXStphakjo0RqjD6wQ7U8Ru8DrO5plEjcsJZIaPBCbv6S6wkjR4twFqGGRjgALQiARybLgwuZ0wKttkoTnezQit7uQQtvAp8h4BpgMgvZyp3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709795; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=ydqt7ygZQ+vGx48L3P+H0ZAxD/ypFxd/RVZSJiZUfNY=; b=WPVzFXicavanSWGT1/m3mVFdVsf8AYFOPLy6y3CCGeMKQAhlXHhiVjcIdu2scyi/aR330pb7i8PO9h0cUlpxWOLPoAS6Ko9uubleRXBOcXbHisoL4m5x3tdyazbu+/0KhPMlDOACRATlqlYjHd4NsFk6t72tYVHipHlFXqedTXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603709795205981.0864295323261; Mon, 26 Oct 2020 03:56:35 -0700 (PDT) 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-284-qV0OuJoHM72-O-RbqTInBQ-1; Mon, 26 Oct 2020 06:56:30 -0400 Received: by mail-wr1-f72.google.com with SMTP id j15so835803wro.4 for ; Mon, 26 Oct 2020 03:56:30 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709794; 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=jLtDIb89LONPj/pHFtydONP8sLmeF1AUkmNHQTwV1turXLRgyDQ6rOEV3/TTYURL+oOLqR PsgU+EZReMRavwjDYcAvZwcJFIPVErJNS4UD5DRoTO+1OpA67+d0d+UpnsJulkTDgh5giC 7UCxisLjbj+FxtfaPHTlsFIVAVHesu4= X-MC-Unique: qV0OuJoHM72-O-RbqTInBQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ydqt7ygZQ+vGx48L3P+H0ZAxD/ypFxd/RVZSJiZUfNY=; b=LiCUMcOr2DpLhXg6aXBOYMtAc2Arcnk3DNMYlbnF0saqDrysV9/5OW0B+w0cpSiPZe OXhfnvTPomDMD3juMh3a7uQ5V/LLmQ9e3JXUeVpHTUd9+kUtsprrKdFPv7YAlUBESC6x beJrhRJBE6SzfR6/jXjFfVCfNa6lHtks/Yuid9/z32IRVt9sCJ2soafiYH1OxtKSfd9A hv5ZcNjjJ/qsW6ySn4ycsn9oo6B4Co5FFSrrjNVI2cpg6PNbg00Fm36Rv/4LKvelFi6H HtvMxc6QzbbzWNO2zsGYefMReGjj8A3dAwsDWovKkXjcSgLl9TKsLgAkXxzHk1HxnR2O 6jMw== X-Gm-Message-State: AOAM533HAgXfMq2QdqNs3SjGbzrJDhlqVVJCEKwTNRs3GHBqGfuondq5 0MNPdiJoTeGtmBu469bmg2PjChFQR1MgFSHEIGu+i4vf0DgHpVtoW1+4krd8h4Xj/qfPxkcFeZq SXFydsQW02cMaHg== X-Received: by 2002:a1c:2e0d:: with SMTP id u13mr15163895wmu.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 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, EventNotifie= r *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); =20 #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, EventNoti= fier *e, return 0; } =20 +/** + * 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 =3D 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 =3D sizeof(*irq_set) + sizeof(int32_t); + irq_set =3D g_malloc0(irq_set_size); + /* Get to a known IRQ state */ + *irq_set =3D (struct vfio_irq_set) { + .argsz =3D irq_set_size, + .flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, + .index =3D VFIO_PCI_MSIX_IRQ_INDEX, + .start =3D irq_index, + .count =3D 1, + }; + ((int32_t *)&irq_set->data)[0] =3D fd; + r =3D 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 %"PRIu= 32" (asked: %u)" +qemu_vfio_pci_msix_set_irq(unsigned irq_index, int fd) "msix irq %u notifi= er_fd %d" qemu_vfio_iommu_iova_pgsizes(uint64_t iova_pgsizes) "iommu page size bitma= sk: 0x%08"PRIx64 qemu_vfio_pci_read_config(void *buf, int ofs, int size, uint64_t region_of= s, 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_o= fs, uint64_t region_size) "write cfg ptr %p ofs 0x%x size %d (region ofs 0x= %"PRIx64" size %"PRId64")" --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709800; cv=none; d=zohomail.com; s=zohoarc; b=NJxcz/Elzt8hFlrqenwQ9fKvG7tSC2Y2pH+NZMMmlSkr271uAoeef/NKB7N+fgrCpcGP0Uo1vXWNPsmMxluwSz3p3xW2L22EknFbwhML1mcnoUi9OOu8CwkfDIb5iBM4Y+n1v2vOpOAqjpkJzJSsmqnvspeY2fJqtYb1PTlVqRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709800; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=owqIkSbFHgdfPD7uMP3x2r37Kgl7CGcfC6ZJAfrhmJc=; b=Mp9CzfDvAuLzbF6fsr4L29iSxoT+MCGFhegggHd0XvndUcZy1uT6bO2s5oCpjkmh2q4ZutmaJl9zGbhTw4oENns+HCwOo3Kmf8WW6tJy47xzOK0T+I7IM3owvBhL2bYhBEBmzpayZNTImi3j9ZjbE8xmVejkaEVmq4aJP/0jyIU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1603709800094731.7198112928033; Mon, 26 Oct 2020 03:56:40 -0700 (PDT) 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-308-qUGN-wcvMUGYcvqwElCzzg-1; Mon, 26 Oct 2020 06:56:35 -0400 Received: by mail-wr1-f72.google.com with SMTP id k14so8193022wrd.6 for ; Mon, 26 Oct 2020 03:56:35 -0700 (PDT) Return-Path: Return-Path: 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603709799; 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=CW1JXs/784fF5OGSpUPX2bNvFna8Xjfx3enXkDIC1yAGXyYWw/uwtHtKAnfMNpQMnpjdQP vnMHvCRe6d6fgHqQ8nC2l+tG5ZGSss6XQbmfG1dS1MzVanLc2WkZa6KujiVEO2wVKtpO+m nY/NajctC+ySfK+Qs9rxIFBr7Cz5yNw= X-MC-Unique: qUGN-wcvMUGYcvqwElCzzg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=owqIkSbFHgdfPD7uMP3x2r37Kgl7CGcfC6ZJAfrhmJc=; b=W0Tk00t2iB59GjkB+7thOgw6d0IPoTtOWSsZeYJ6pmo5wkpAcME9wXciMcvlUF6MiI DO3drXheS+r7FhlNwhZVvVvfsmigWtXU42pkYtvILAtpZI8WgzPXF6Z74zDzZJtkUy7v MZvLy9+Yz533RyZe+fH14taF5rxxvhe2KFRoa59rWzwdci5xmxt9CUfGzSCqfBLb1L+3 Om9+7pWPcWn0d4oq99AaSor30da15aKDG6dG2WvsSPzCBEUGTFkkJ7i+ixrjivcPY/bm jVPZEhHB04UrHyCs3p2rRrvoG6qIFlVwMef/1puBbMIYMs0Ht0J4nH1wQlSkr1GijFt9 P8ug== X-Gm-Message-State: AOAM533MZ6f6Z8csl45g2KqSNRMhsfoA4VwvVI1Bn/FQ3HxwXyx3qcWc 9qb6z8SeSYFmBo8+CinbV6W/X08Vbx7aHgO0o7dhHd4ct1j0o9Mip6PQEk2MW2aizPyzXY8U5mN wG0E9zqH5FOKdUg== X-Received: by 2002:adf:cd8d:: with SMTP id q13mr16960609wrj.268.1603709794046; 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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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 =3D 4096; + unsigned irq_count =3D MSIX_IRQ_COUNT; =20 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, } } =20 - ret =3D qemu_vfio_pci_init_irq(s->vfio, s->irq_notifier, - VFIO_PCI_MSIX_IRQ_INDEX, errp); + ret =3D qemu_vfio_pci_msix_init_irqs(s->vfio, &irq_count, errp); + if (ret) { + if (ret =3D=3D -EOVERFLOW) { + error_append_hint(errp, "%u IRQs requested but only %u availab= le\n", + MSIX_IRQ_COUNT, irq_count); + } + goto out; + } + + ret =3D qemu_vfio_pci_msix_set_irq(s->vfio, MSIX_SHARED_IRQ_IDX, + s->irq_notifier, errp); if (ret) { goto out; } --=20 2.26.2 From nobody Sun May 19 15:20:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603709802; cv=none; d=zohomail.com; s=zohoarc; b=AlbT/5nx4f0nuMv/Kvr6IZkDKQxs/Wuzb6A1bI74ouaVK6Y44EdvYDzf8P7470UgZzHj2+sJKXHGpxiZ7UOsw8/0agNxEgXaCsOJ6ByhUf8fqyYPRImbBi8FQeo7g4FC0TIiTNWyqb2GK8CmvdiIAMjUD3UiOM98qX0jb6dh0CA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603709802; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=tjiqDTNg6IlVQRDX7FtGh0Vb3qFf/kKU7hA/I3jkchg=; b=MQfzIVYGcqRatqPHIxIKN1yphT748qhj7lnNLxC/TysxL3uMtXQZwVJ3LMJRAIRPl3FVnhPSWVCAUZgmn7+DILapyCz/+ZPd89yjf3L8vEj19NJjHJxfA1m64tahGY4kVeJcqW5pLIg5X84MpMTSmwRnkKAza0zm78ybG5NxlZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603709802633966.9462098249297; Mon, 26 Oct 2020 03:56:42 -0700 (PDT) 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-45-AFxgSn_NNqWq1piPBy5fWw-1; Mon, 26 Oct 2020 06:56:40 -0400 Received: by mail-wr1-f72.google.com with SMTP id k14so8193101wrd.6 for ; Mon, 26 Oct 2020 03:56:39 -0700 (PDT) Return-Path: Return-Path: 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) 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= X-MC-Unique: AFxgSn_NNqWq1piPBy5fWw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tjiqDTNg6IlVQRDX7FtGh0Vb3qFf/kKU7hA/I3jkchg=; b=ekUONjUQC/I1WCYWN8K65m4uSRbxUG4xQeTnLcuJhew3AN+z0IX9tChJff3bd55MsK uF8lWAX30VoBB8IRmPFdjhwSa0RCtMq6IlzF3prm0/8QH/fsPlyb2aDCZC3GZJ9BN24A 92qn9PANHk6xFTKh1RxXSnzcf8sDppU262zOBq/wnWSbHrI5q5atuhEDGpqIJU4guUJJ 67rb2Evu0vA8lqT9fvR3BnrQSVv4WG1G64qW7YB47yWzFjBOuBQuJHFkBkm5ctuDs5yi 5GdOka5+njuXxh2XU9XEJyhKHlNHZF9/ab8QAR183jYKt1jRNjoX8Wk+SoQofwBCmYDM p5uA== X-Gm-Message-State: AOAM531+iWA3e/uE3B/DAyLvakowju9RJo1lIIk7LaQjTqdDC0o/Kllo LG+3Yq3sMOAd6R5hWbsRCTCN3nk+D3PJpvntk8UmDXghLqvZQ8wh3Clanw0LtIzdLbVPs5J7HBB Ka03zQIxbF6I2bA== X-Received: by 2002:adf:df91:: with SMTP id z17mr16494479wrl.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) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eric Auger , Alex Williamson , qemu-block@nongnu.org, Fam Zheng , Max Reitz , Stefan Hajnoczi , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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 ind= ex, void *bar, } } =20 -/** - * 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 =3D { .argsz =3D sizeof(irq_info) }; - - irq_info.index =3D 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 =3D sizeof(*irq_set) + sizeof(int); - irq_set =3D g_malloc0(irq_set_size); - - /* Get to a known IRQ state */ - *irq_set =3D (struct vfio_irq_set) { - .argsz =3D irq_set_size, - .flags =3D VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER, - .index =3D irq_info.index, - .start =3D 0, - .count =3D 1, - }; - - *(int *)&irq_set->data =3D event_notifier_get_fd(e); - r =3D 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 --=20 2.26.2