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: 8121621 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0BCA09F6DA for ; Tue, 26 Jan 2016 13:14:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 35F8420272 for ; Tue, 26 Jan 2016 13:14:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40FA120114 for ; Tue, 26 Jan 2016 13:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965836AbcAZNNx (ORCPT ); Tue, 26 Jan 2016 08:13:53 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:36570 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965935AbcAZNNo (ORCPT ); Tue, 26 Jan 2016 08:13:44 -0500 Received: by mail-wm0-f43.google.com with SMTP id l65so103479361wmf.1 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=Ve1z0whaWWMFpfS2GJjbqfJ+I3ucZhyJM025CN2jCtYItL8z+22V3G3vXngDN6sKId K+Do+OEpfKAzLnhYGrNATmaloUUwxTxEgYIA6Z4ChjkI/rMJ3qqrHuiJw5v1gETEtDDO tZqYmkePXUkOuisrcQ2Oz+ZRMwzWK94yqleFiQBnEeBk8UzP+OEmoPuIyGXmHZvB2bOF xTwcj5Do/ZJ50mprrKsjbebKuCFSjmRigpDi8WUFs1q/5kbjEXSsGYisU3FuWz57wEUk KBkVCaFcYxif/ikg9W5YCU2/cQRhggmSZmo10JzffW6+He1JKezKW8PLVAbwdUqn0QLq tf6w== X-Gm-Message-State: AG10YOSOWrPty6S6kw+29OO47y/P7WOWOCoGzotvFVnMqv7mhezqMljVi6NbKmMm47h2uIRA 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 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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);