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: Auger Eric X-Patchwork-Id: 60458 Delivered-To: patches@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1949183lbb; Tue, 26 Jan 2016 05:13:47 -0800 (PST) X-Received: by 10.194.105.99 with SMTP id gl3mr22306208wjb.90.1453814022544; Tue, 26 Jan 2016 05:13:42 -0800 (PST) Return-Path: Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com. [2a00:1450:400c:c09::233]) by mx.google.com with ESMTPS id 201si4299057wml.102.2016.01.26.05.13.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jan 2016 05:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::233 as permitted sender) client-ip=2a00:1450:400c:c09::233; Authentication-Results: mx.google.com; spf=pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::233 as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-wm0-x233.google.com with SMTP id n5so129561199wmn.0 for ; Tue, 26 Jan 2016 05:13:42 -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=cT8ULf8OY3TBCNGOW2C+9kOqYMYRuQAauAN+g3/a7V4hhzGOR/MtCZJHMoavwxJ8S+ iJIElcdME6SZoUR22Hlk3TFQtCw1JLDJ0ujfcQVMzOpoBnu5Sk8dxhu1axfx7tMNmWO2 FH3DUl3KIfTNuqX7rdnfrEqj3N01hbzB/w7uPWZXXLI+nLYjUBT97VPKzeDy6Ld8cx0o XhlW/NOeaIe5ojzGh2PyWTomFkieJ0sBQ4Nq5cnVVwhfIptlqlo3R0Nzjx4stirxfeeM OJOrfYcUSdNXWBwMpFmc4ZqGv02KCdfZIGcCFZFlIqe/bUdwcVZoKG5nGUAoZs7Vpg4l 6fyg== X-Gm-Message-State: AG10YOSP3QgZl53nAxZy81EokMqNJ7ZJHcYAjKmTiNs1YfGL9Pw98w63t2Ongf800tlyO4GpIC4= X-Received: by 10.28.141.10 with SMTP id p10mr23506319wmd.83.1453814022374; Tue, 26 Jan 2016 05:13:42 -0800 (PST) Return-Path: 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 Cc: Bharat.Bhushan@freescale.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, suravee.suthikulpanit@amd.com, linux-kernel@vger.kernel.org, patches@linaro.org, iommu@lists.linux-foundation.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> 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(+) -- 1.9.1 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);