From patchwork Tue Jan 26 13:12:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8121831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AA84DBEEE5 for ; Tue, 26 Jan 2016 13:19:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C60B22020F for ; Tue, 26 Jan 2016 13:19:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA3BB201F2 for ; Tue, 26 Jan 2016 13:19:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aO3Uy-00045g-Hm; Tue, 26 Jan 2016 13:17:32 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aO3Rc-0000BP-0C for linux-arm-kernel@lists.infradead.org; Tue, 26 Jan 2016 13:14:05 +0000 Received: by mail-wm0-x235.google.com with SMTP id r129so103642812wmr.0 for ; Tue, 26 Jan 2016 05:13:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lRpWY68FpowGvlutVYtQvLSaft3mD0wjeriLWIHKzso=; b=A8RET0QN6aj6WOg8LSkJTLBWtcDE98b9MbmGLc5VhnL+9J363OYuX88D66/Nj31Q+X hEF3g0rvyNCqicMZtHMVubXNokQU/7yDrTO+x2aRd69AJUii8Nn/Y8tVP/Ybb90gUKy9 nxaA3WRLeFvm/NjotJwRKOAFVCMd7vqwevOCs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lRpWY68FpowGvlutVYtQvLSaft3mD0wjeriLWIHKzso=; b=L4TM4ql7NGsQvq73TLjh0Lx7LxLzN686buvpScNNbwFURpRk36iNcVV6sDHzcifuOL q584W5Ido22jRiF5EWWpu+GGxjds4r0aIlYAHF/e3Ac0hSK5PJvq4iR7bg6zb9d2sRlQ aSsRjpzFuZMe0inpAVZ/XB4I1R4IXq08pY35mt2JbmX9CaLETqVR3H2f3AxaihvKzZMP RCRoeprJ0sx9NKGdTB6WNuTlPDpddN/vvPQBHySqSONTj1qCp6QN6D94u1T4FH+H9rgG Kklukvi/WPoxfPNqdVAZp6jzFpzqPc72qr9c9pKXoYg/d0iab7gZ/8q467XJSZ3lU0XQ 3Aow== X-Gm-Message-State: AG10YORthLfKvedwJjQXEtCB+XFrgPUvVOqnqkazVorZwKpxZwC9RHPkN3EzwKlbR3s+UwZx X-Received: by 10.28.141.10 with SMTP id p10mr23506319wmd.83.1453814022374; Tue, 26 Jan 2016 05:13:42 -0800 (PST) Received: from localhost.localdomain (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id ct2sm1388885wjb.46.2016.01.26.05.13.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Jan 2016 05:13:41 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, will.deacon@arm.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH 08/10] vfio: introduce vfio_group_require_msi_mapping Date: Tue, 26 Jan 2016 13:12:46 +0000 Message-Id: <1453813968-2024-9-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453813968-2024-1-git-send-email-eric.auger@linaro.org> References: <1453813968-2024-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160126_051404_347391_80B2F573 X-CRM114-Status: GOOD ( 13.37 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: patches@linaro.org, p.fedin@samsung.com, linux-kernel@vger.kernel.org, Bharat.Bhushan@freescale.com, iommu@lists.linux-foundation.org, pranav.sawargaonkar@gmail.com, suravee.suthikulpanit@amd.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This new function enables to know whether msi write transaction addresses must be mapped. Signed-off-by: Eric Auger --- drivers/vfio/vfio.c | 22 ++++++++++++++++++++++ drivers/vfio/vfio_iommu_type1.c | 8 ++++++++ include/linux/vfio.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2760d4c..f3df5a10 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -793,6 +793,28 @@ static int vfio_iommu_group_notifier(struct notifier_block *nb, return NOTIFY_OK; } +bool vfio_group_require_msi_mapping(struct vfio_group *group) +{ + struct vfio_container *container = group->container; + struct vfio_iommu_driver *driver; + bool ret; + + down_read(&container->group_lock); + + driver = container->iommu_driver; + if (!driver || !driver->ops || !driver->ops->require_msi_mapping) { + ret = -EINVAL; + goto up; + } + + ret = driver->ops->require_msi_mapping(container->iommu_data); + +up: + up_read(&container->group_lock); + return ret; +} +EXPORT_SYMBOL_GPL(vfio_group_require_msi_mapping); + /** * VFIO driver API */ diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index a79e2a8..2f085d3 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1179,6 +1179,13 @@ unlock: return ret; } +static bool vfio_iommu_type1_require_msi_mapping(void *iommu_data) +{ + struct vfio_iommu *iommu = iommu_data; + + return vfio_domains_require_msi_mapping(iommu); +} + static void *vfio_iommu_type1_open(unsigned long arg) { struct vfio_iommu *iommu; @@ -1336,6 +1343,7 @@ static const struct vfio_iommu_driver_ops vfio_iommu_driver_ops_type1 = { vfio_iommu_type1_alloc_map_reserved_iova, .unmap_free_reserved_iova = vfio_iommu_type1_unmap_free_reserved_iova, + .require_msi_mapping = vfio_iommu_type1_require_msi_mapping, }; static int __init vfio_iommu_type1_init(void) diff --git a/include/linux/vfio.h b/include/linux/vfio.h index f7eaf30..3e6cbeb 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -58,6 +58,7 @@ extern void *vfio_del_group_dev(struct device *dev); extern struct vfio_device *vfio_device_get_from_dev(struct device *dev); extern void vfio_device_put(struct vfio_device *device); extern void *vfio_device_data(struct vfio_device *device); +extern bool vfio_group_require_msi_mapping(struct vfio_group *group); /** * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks @@ -85,6 +86,7 @@ struct vfio_iommu_driver_ops { int (*unmap_free_reserved_iova)(void *iommu_data, struct iommu_group *group, dma_addr_t iova); + bool (*require_msi_mapping)(void *iommu_data); }; extern int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);