From patchwork Mon Apr 13 12:29:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 47110 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A19F520553 for ; Mon, 13 Apr 2015 12:32:57 +0000 (UTC) Received: by lbdc7 with SMTP id c7sf15227551lbd.2 for ; Mon, 13 Apr 2015 05:32:56 -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=ga3WJ7ohnqRswLPG0GeMOVCdJ1DQZrdUx5tZh0E/NMQ=; b=jy3Tuc8iqjVW8r1Xb4ldfdMyrddnr4fV3vVhjzw5m5omeLiVFMGt3HWYLvNTE8zhvO b61OlyG9Fw8huw0S+EKyEdR35Q8PzRuVSAJSO4VFfxiNjhBHigWtdTbaqB5FQMZ9VySu hciQMVvWnAjYtgR1drMdA1FvIpK/sJWl4zlrAvZJNpZK5rjFZKyMCvwvR3BaY/V+R4dt u174cv3KGyEhTEO9jJ774NUx9GE+WYtg0oXz/qXmeoaO8GHcJD/rtIS8U0D3l/gp1rXC ewXiJ2wedOkAgKppiPXkQYoSaFhQEMHn74WiLH2jQgKCK4PjpCSlrv2Q9PCTaa+jMBbt WVIQ== X-Gm-Message-State: ALoCoQmM37zQPqMox6t+0ryIa+oTOPwiUYeIdyq1Dga0ZWRauTn6S+We/Ir5L+zt9gDBypa2qCXV X-Received: by 10.112.17.105 with SMTP id n9mr2113612lbd.8.1428928376699; Mon, 13 Apr 2015 05:32:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.228 with SMTP id v4ls640391lav.26.gmail; Mon, 13 Apr 2015 05:32:56 -0700 (PDT) X-Received: by 10.152.19.199 with SMTP id h7mr13497226lae.32.1428928376559; Mon, 13 Apr 2015 05:32:56 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id o7si7994987lbw.36.2015.04.13.05.32.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 05:32:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbqq2 with SMTP id qq2so57227538lbb.3 for ; Mon, 13 Apr 2015 05:32:56 -0700 (PDT) X-Received: by 10.152.26.34 with SMTP id i2mr12911685lag.117.1428928376440; Mon, 13 Apr 2015 05:32:56 -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.112.67.65 with SMTP id l1csp1175134lbt; Mon, 13 Apr 2015 05:32:56 -0700 (PDT) X-Received: by 10.180.186.3 with SMTP id fg3mr20779864wic.79.1428928367694; Mon, 13 Apr 2015 05:32:47 -0700 (PDT) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com. [74.125.82.43]) by mx.google.com with ESMTPS id y1si13808947wiw.27.2015.04.13.05.32.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 05:32:47 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.43 as permitted sender) client-ip=74.125.82.43; Received: by wgsk9 with SMTP id k9so79021115wgs.3 for ; Mon, 13 Apr 2015 05:32:47 -0700 (PDT) X-Received: by 10.194.63.225 with SMTP id j1mr5813255wjs.120.1428928367425; Mon, 13 Apr 2015 05:32: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 fl14sm2879910wjc.11.2015.04.13.05.32.45 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 13 Apr 2015 05:32: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, pbonzini@redhat.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, feng.wu@intel.com, b.reynal@virtualopensystems.com Subject: [RFC v6 09/16] VFIO: add vfio_external_{mask|is_active|set_automasked} Date: Mon, 13 Apr 2015 14:29:24 +0200 Message-Id: <1428928171-18884-10-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428928171-18884-1-git-send-email-eric.auger@linaro.org> References: <1428928171-18884-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.217.172 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: , Introduces 3 new external functions aimed at doing actions on VFIO devices: - mask VFIO IRQ - get the active status of VFIO IRQ (active at interrupt controller level or masked by the level-sensitive automasking). - change the automasked property and switch the IRQ handler (between automasked/ non automasked) Their implementation is based on bus specific callbacks. Note there is no way to discriminate between user-space masking and automasked handler masking. As a consequence, is_active will return true in case the IRQ was masked by the user-space. Signed-off-by: Eric Auger --- v5 -> v6: - implementation now uses external ops - prototype changed (index, start, count) and returns int V4: creation --- drivers/vfio/vfio.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/vfio.h | 16 ++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 33ae8c5..a36188e 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1526,6 +1526,45 @@ long vfio_external_check_extension(struct vfio_group *group, unsigned long arg) } EXPORT_SYMBOL_GPL(vfio_external_check_extension); +int vfio_external_mask(struct vfio_device *vdev, unsigned index, + unsigned start, unsigned count) +{ + if (vdev->ops->external_ops && + vdev->ops->external_ops->mask) + return vdev->ops->external_ops->mask(vdev->device_data, + index, start, count); + else + return -ENXIO; +} +EXPORT_SYMBOL_GPL(vfio_external_mask); + +int vfio_external_is_active(struct vfio_device *vdev, unsigned index, + unsigned start, unsigned count) +{ + if (vdev->ops->external_ops && + vdev->ops->external_ops->is_active) + return vdev->ops->external_ops->is_active(vdev->device_data, + index, start, count); + else + return -ENXIO; +} +EXPORT_SYMBOL_GPL(vfio_external_is_active); + +int vfio_external_set_automasked(struct vfio_device *vdev, + unsigned index, unsigned start, + unsigned count, bool automasked) +{ + if (vdev->ops->external_ops && + vdev->ops->external_ops->set_automasked) + return vdev->ops->external_ops->set_automasked( + vdev->device_data, + index, start, + count, automasked); + else + return -ENXIO; +} +EXPORT_SYMBOL_GPL(vfio_external_set_automasked); + /** * Module/class support */ diff --git a/include/linux/vfio.h b/include/linux/vfio.h index b0ec474..a740392 100644 --- a/include/linux/vfio.h +++ b/include/linux/vfio.h @@ -123,6 +123,22 @@ 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); +extern int vfio_external_mask(struct vfio_device *vdev, unsigned index, + unsigned start, unsigned count); +/* + * returns whether the VFIO IRQ is active: + * true if not yet deactivated at interrupt controller level or if + * automasked (level sensitive IRQ). Unfortunately there is no way to + * discriminate between handler auto-masking and user-space masking + */ +extern int vfio_external_is_active(struct vfio_device *vdev, + unsigned index, unsigned start, + unsigned count); + +extern int vfio_external_set_automasked(struct vfio_device *vdev, + unsigned index, unsigned start, + unsigned count, bool automasked); + struct pci_dev; #ifdef CONFIG_EEH extern void vfio_spapr_pci_eeh_open(struct pci_dev *pdev);