From patchwork Thu May 7 14:27:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 6358841 Return-Path: X-Original-To: patchwork-linux-arm@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 645729F399 for ; Thu, 7 May 2015 14:34:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E694E20225 for ; Thu, 7 May 2015 14:34:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 15A122020F for ; Thu, 7 May 2015 14:34:20 +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 1YqMpm-0004Re-1p; Thu, 07 May 2015 14:31:30 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YqMp0-00041B-PV for linux-arm-kernel@lists.infradead.org; Thu, 07 May 2015 14:30:43 +0000 Received: by wiun10 with SMTP id n10so62188563wiu.1 for ; Thu, 07 May 2015 07:30:20 -0700 (PDT) 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=PlAuJmXWzCkEitglLRvW/w1OkL9eIrVsGPdePI+yF0w=; b=d0Po6rjhf1cqdcY8Dqj/CxIZRP1EjTseeYmAs18y6YROQGdF/XpNS76SmOu6yyNao3 poow8bDf7r4SdkTY7FyYkMnAK+QW6mthpImeYOJbmDgPVFZI39ix3tO98+izHhG3kGfY BuIu0ER6HoevRUC9LAfhDhr3gLiuxvA+/5mTX/M40N0HcJd8D2Vou9Oqq1LYDzydpSuH X0kKyBialSUhtHofEq3NN0QJI79yXF0fgyUrupkwderTSn81Q59Y86PoivFHaofy54iX OsDxfBGeAlRYfwAwab9FDMk5nno3NsR84/BZCXCtNNji4otcG5NeMxMukuAER+N4xXaA DZ4A== X-Gm-Message-State: ALoCoQlpPUDHw6uRCGj8OhsRAFapd1zmT3UXeH48gp51spQ8abFXv9xjkRnhu6Dfr3CWMPjUN+hJ X-Received: by 10.180.80.10 with SMTP id n10mr7384017wix.82.1431009020153; Thu, 07 May 2015 07:30:20 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id z12sm3704874wjw.39.2015.05.07.07.30.18 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 May 2015 07:30:19 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, b.reynal@virtualopensystems.com Subject: [PATCH 3/5] VFIO: platform: add reset callback Date: Thu, 7 May 2015 16:27:21 +0200 Message-Id: <1431008843-28411-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431008843-28411-1-git-send-email-eric.auger@linaro.org> References: <1431008843-28411-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150507_073043_017678_9843D271 X-CRM114-Status: GOOD ( 13.22 ) X-Spam-Score: -0.7 (/) Cc: Bharat.Bhushan@freescale.com, agraf@suse.de, linux-kernel@vger.kernel.org, patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 A new reset callback is introduced. If this callback is populated, the reset is invoked on device release or upon userspace ioctl. The modality is exposed on VFIO_DEVICE_GET_INFO. Signed-off-by: Eric Auger --- v2 -> v3: - change patch title and commit message. Use IS_ERR_OR_NULL to anticipate for getter returned value. v1 -> v2: - On VFIO_DEVICE_RESET returns -EINVAL in case the callback is not populated (instead of -ENOTTY) --- drivers/vfio/platform/vfio_platform_common.c | 12 ++++++++++-- drivers/vfio/platform/vfio_platform_private.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index edbf24c..0d10018 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -103,6 +103,8 @@ static void vfio_platform_release(void *device_data) mutex_lock(&driver_lock); if (!(--vdev->refcnt)) { + if (!IS_ERR_OR_NULL(vdev->reset)) + vdev->reset(vdev); vfio_platform_regions_cleanup(vdev); vfio_platform_irq_cleanup(vdev); } @@ -162,6 +164,8 @@ static long vfio_platform_ioctl(void *device_data, if (info.argsz < minsz) return -EINVAL; + if (!IS_ERR_OR_NULL(vdev->reset)) + vdev->flags |= VFIO_DEVICE_FLAGS_RESET; info.flags = vdev->flags; info.num_regions = vdev->num_regions; info.num_irqs = vdev->num_irqs; @@ -255,8 +259,12 @@ static long vfio_platform_ioctl(void *device_data, return ret; - } else if (cmd == VFIO_DEVICE_RESET) - return -EINVAL; + } else if (cmd == VFIO_DEVICE_RESET) { + if (!IS_ERR_OR_NULL(vdev->reset)) + return vdev->reset(vdev); + else + return -EINVAL; + } return -ENOTTY; } diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index 68909a4..84ccf6d 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -68,6 +68,7 @@ struct vfio_platform_device { (*get_resource)(struct vfio_platform_device *vdev, int i); int (*get_irq)(struct vfio_platform_device *vdev, int i); struct device *(*get_device)(struct vfio_platform_device *vdev); + int (*reset)(struct vfio_platform_device *vdev); }; typedef int (*vfio_platform_reset_fn_t)(struct vfio_platform_device *vdev);