From patchwork Mon Sep 1 12:52:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 36361 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 08B662032B for ; Mon, 1 Sep 2014 12:53:50 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id uq10sf29966767igb.7 for ; Mon, 01 Sep 2014 05:53:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=EKKbPJ52Asqq8h4V99P80uNpLlrNm2l9ke2K4ow7ONY=; b=kMiKhxaRi55j97zhhksM6BFTOHZfj9mLdXXzZKj8ZqNv4X4rxhpKdWKt2mOGP3Wp9W LgaZesg4OEdYeRyWX0+twA1+NtU1dK/w/WK5+EkV5u8BhBzJsgMsOmy6syAvoXO6nKIG kdydJRkx7I7BxPW9j0AoJNm1Kek54Bb9hUCRKOVUiDCB4rJ4C5LhWDXi4Pht8x+EX3gO yKj89eYjvLYEU2gyfqDc6gpAAYbt8qky4tEIqSipbioj+fU9sKKknD7jshEyCB1ShXSo jwFDoDi6x9nV3iLMbCteOjkdDSu08765Q4ceDwf3rVOBqRTpISa6OwCPikfqSGCu3GhN Q0ig== X-Gm-Message-State: ALoCoQlIdQspnpeP8HYKqeiR6zv57g2e9219PRsp3t+VLLL9x41k5/+R19knGBlY0xHDzgX+EfkV X-Received: by 10.182.45.197 with SMTP id p5mr15484876obm.2.1409576029421; Mon, 01 Sep 2014 05:53:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.36.168 with SMTP id p37ls1929943qgp.12.gmail; Mon, 01 Sep 2014 05:53:49 -0700 (PDT) X-Received: by 10.52.89.211 with SMTP id bq19mr52444vdb.93.1409576029339; Mon, 01 Sep 2014 05:53:49 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id cf5si302482vcb.46.2014.09.01.05.53.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 05:53:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lf12so5321113vcb.6 for ; Mon, 01 Sep 2014 05:53:49 -0700 (PDT) X-Received: by 10.52.3.40 with SMTP id 8mr21236235vdz.24.1409576029260; Mon, 01 Sep 2014 05:53:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp383154vcb; Mon, 1 Sep 2014 05:53:48 -0700 (PDT) X-Received: by 10.180.210.231 with SMTP id mx7mr21087531wic.42.1409576027987; Mon, 01 Sep 2014 05:53:47 -0700 (PDT) Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by mx.google.com with ESMTPS id xu7si993777wjb.136.2014.09.01.05.53.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 05:53:47 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.177 as permitted sender) client-ip=74.125.82.177; Received: by mail-we0-f177.google.com with SMTP id u56so5331957wes.8 for ; Mon, 01 Sep 2014 05:53:47 -0700 (PDT) X-Received: by 10.180.11.193 with SMTP id s1mr20983584wib.49.1409576027487; Mon, 01 Sep 2014 05:53:47 -0700 (PDT) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id y5sm1928678wje.32.2014.09.01.05.53.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 05:53:46 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, joel.schopp@amd.com, kim.phillips@freescale.com, paulus@samba.org, gleb@kernel.org, pbonzini@redhat.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, will.deacon@arm.com, a.motakis@virtualopensystems.com, a.rigo@virtualopensystems.com, john.liuli@huawei.com Subject: [RFC v2 6/9] VFIO: Extend external user API Date: Mon, 1 Sep 2014 14:52:45 +0200 Message-Id: <1409575968-5329-7-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409575968-5329-1-git-send-email-eric.auger@linaro.org> References: <1409575968-5329-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , New functions are added to be called from ARM KVM-VFIO device. - vfio_device_get_external_user enables to get a vfio device from its fd - vfio_device_put_external_user puts the vfio device - vfio_external_base_device returns the struct device*, useful to access the platform_device Signed-off-by: Eric Auger --- v1 -> v2: - vfio_external_get_base_device renamed into vfio_external_base_device - vfio_external_get_type removed --- drivers/vfio/vfio.c | 24 ++++++++++++++++++++++++ include/linux/vfio.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 8e84471..282814e 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1401,6 +1401,30 @@ void vfio_group_put_external_user(struct vfio_group *group) } EXPORT_SYMBOL_GPL(vfio_group_put_external_user); +struct vfio_device *vfio_device_get_external_user(struct file *filep) +{ + struct vfio_device *vdev = filep->private_data; + + if (filep->f_op != &vfio_device_fops) + return ERR_PTR(-EINVAL); + + vfio_device_get(vdev); + return vdev; +} +EXPORT_SYMBOL_GPL(vfio_device_get_external_user); + +void vfio_device_put_external_user(struct vfio_device *vdev) +{ + vfio_device_put(vdev); +} +EXPORT_SYMBOL_GPL(vfio_device_put_external_user); + +struct device *vfio_external_base_device(struct vfio_device *vdev) +{ + return vdev->dev; +} +EXPORT_SYMBOL_GPL(vfio_external_base_device); + int vfio_external_user_iommu_id(struct vfio_group *group) { return iommu_group_id(group->iommu_group); diff --git a/include/linux/vfio.h b/include/linux/vfio.h index ffe04ed..bd4b6cb 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -99,6 +99,9 @@ extern void vfio_group_put_external_user(struct vfio_group *group); extern int vfio_external_user_iommu_id(struct vfio_group *group); extern long vfio_external_check_extension(struct vfio_group *group, unsigned long arg); +extern struct vfio_device *vfio_device_get_external_user(struct file *filep); +extern void vfio_device_put_external_user(struct vfio_device *vdev); +extern struct device *vfio_external_base_device(struct vfio_device *vdev); struct pci_dev; #ifdef CONFIG_EEH