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: Auger Eric X-Patchwork-Id: 48128 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2B2552121F for ; Thu, 7 May 2015 14:30:22 +0000 (UTC) Received: by wixv7 with SMTP id v7sf16294645wix.0 for ; Thu, 07 May 2015 07:30:21 -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=PlAuJmXWzCkEitglLRvW/w1OkL9eIrVsGPdePI+yF0w=; b=Sv1AdaBxC/expvT38mGjuTHDqylHQnp07iKmw1FRzV/iEgmHAFjj9OfckM9nl0aadP zyBJ2lCcWUS5n8awpC4ae3J9NP2XLlZXYWLeZYHWN2SdzqEGTu7tpFJblwV/8NCpo1nm lyt2aBbfgK3B0A3y7RaEBj3SafrcZudlCafO9nsV72+rBwsEzxZIW0o/SNrKCC9dTndF 6i/lUS2j9PaxgNe+pKx3T2qSKT9ihCSBIS2yTZq7y64Pjjh7JI5E6rMww0qpLJjzMY7k Z9eyxx7wdHYO7L06I1OzYnnE7/1KDrfFd5KWPC2B64ME4+OJhsiSliZ9ZN7k6tdDiUOl NDXw== X-Gm-Message-State: ALoCoQkwvl93soTsn8IETkc+sLy7Vsf+kutADPg8nrp/4aavaTIrpdgLG/ltVQZJLArWTnbBUL1U X-Received: by 10.152.4.194 with SMTP id m2mr2357650lam.1.1431009021394; Thu, 07 May 2015 07:30:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.169 with SMTP id r9ls204004laj.86.gmail; Thu, 07 May 2015 07:30:21 -0700 (PDT) X-Received: by 10.112.204.199 with SMTP id la7mr3256010lbc.114.1431009021188; Thu, 07 May 2015 07:30:21 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id li1si1414000lbc.19.2015.05.07.07.30.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 07:30:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by labbd9 with SMTP id bd9so32033827lab.2 for ; Thu, 07 May 2015 07:30:21 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr3206955lak.117.1431009021068; Thu, 07 May 2015 07:30:21 -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 l1csp3476066lbt; Thu, 7 May 2015 07:30:20 -0700 (PDT) X-Received: by 10.194.121.135 with SMTP id lk7mr8295841wjb.26.1431009020420; Thu, 07 May 2015 07:30:20 -0700 (PDT) Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com. [209.85.212.175]) by mx.google.com with ESMTPS id ui9si3577492wjc.132.2015.05.07.07.30.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 07:30:20 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.175 as permitted sender) client-ip=209.85.212.175; Received: by wicmx19 with SMTP id mx19so15273138wic.1 for ; Thu, 07 May 2015 07:30:20 -0700 (PDT) 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 Cc: linux-kernel@vger.kernel.org, patches@linaro.org, agraf@suse.de, Bharat.Bhushan@freescale.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-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.215.49 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: , 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);