From patchwork Mon Jun 15 09:09:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 49844 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 E2693211FD for ; Mon, 15 Jun 2015 09:10:12 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf23857236lbb.0 for ; Mon, 15 Jun 2015 02:10:12 -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=yrxQVTGB9kM0isrWe0YdgeY3cX/u/Xfy2KMprkjSzVM=; b=iTPt/5Lo/p+6mLyVGwZYsaBaFK2n+ObczsfC+Ys5kevBLN5CRfwNSQpl2KBnZKqK75 8VR+mz8l7mrgDLYQLt61zjpxYIuKqggOHk7KhWbANzZ7jImgIuyPIHiXQHcLYHZL0NXQ /mzjrBepy6bbw+dWLGI54WQK0zbA3dlaLsELaJ/e3gdw5pnSbMNbvjusWHjrN3sH7+Ba VfY361p2mp/gVvQsngeowK1xjmiQkdB4R4FljK8nTpqn+nTjRK+B18cUTHUfcTVyBQDS G7DoXxUGBa++I3P2Tr6qxwchUkauENuCIfJpTX+efixWuYbbxftmaWrJHQceV7pSTTkB FeaA== X-Gm-Message-State: ALoCoQlpzQJdDtZP4LaOAyoKUBsSVb0a7xSkFNN+AUqQvrBV1GeOPq3BMKwsO8FprzVaU28LwNDH X-Received: by 10.180.89.231 with SMTP id br7mr18725330wib.0.1434359411981; Mon, 15 Jun 2015 02:10:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.227 with SMTP id t3ls866447laj.72.gmail; Mon, 15 Jun 2015 02:10:11 -0700 (PDT) X-Received: by 10.112.24.233 with SMTP id x9mr26862505lbf.7.1434359411823; Mon, 15 Jun 2015 02:10:11 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id xa2si9967483lbb.156.2015.06.15.02.10.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 02:10:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by laka10 with SMTP id a10so5858777lak.0 for ; Mon, 15 Jun 2015 02:10:11 -0700 (PDT) X-Received: by 10.112.155.197 with SMTP id vy5mr25873585lbb.29.1434359411725; Mon, 15 Jun 2015 02:10:11 -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.108.230 with SMTP id hn6csp1275411lbb; Mon, 15 Jun 2015 02:10:11 -0700 (PDT) X-Received: by 10.194.103.130 with SMTP id fw2mr47801598wjb.130.1434359411053; Mon, 15 Jun 2015 02:10:11 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com. [209.85.212.178]) by mx.google.com with ESMTPS id y7si10360396wju.76.2015.06.15.02.10.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 02:10:11 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.178 as permitted sender) client-ip=209.85.212.178; Received: by wicnd19 with SMTP id nd19so17987081wic.1 for ; Mon, 15 Jun 2015 02:10:10 -0700 (PDT) X-Received: by 10.195.17.199 with SMTP id gg7mr25960343wjd.121.1434359410453; Mon, 15 Jun 2015 02:10:10 -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 12sm17920944wjw.17.2015.06.15.02.10.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 02:10:09 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, linux-arm-kernel@lists.infradead.org, b.reynal@virtualopensystems.com, alex.williamson@redhat.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, christoffer.dall@linaro.org Subject: [PATCH v4 2/4] VFIO: platform: add reset callback Date: Mon, 15 Jun 2015 11:09:43 +0200 Message-Id: <1434359385-19916-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434359385-19916-1-git-send-email-eric.auger@linaro.org> References: <1434359385-19916-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.48 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 first open/last close or upon userspace ioctl. The modality is exposed on VFIO_DEVICE_GET_INFO. Signed-off-by: Eric Auger --- v1 -> v2: - reset now is also called on first open on top of last close - remove IS_ERR_OR_NULL --- drivers/vfio/platform/vfio_platform_common.c | 15 +++++++++++++-- drivers/vfio/platform/vfio_platform_private.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c index 611597e..6393581 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 (vdev->reset) + vdev->reset(vdev); vfio_platform_regions_cleanup(vdev); vfio_platform_irq_cleanup(vdev); } @@ -130,6 +132,9 @@ static int vfio_platform_open(void *device_data) ret = vfio_platform_irq_init(vdev); if (ret) goto err_irq; + + if (vdev->reset) + vdev->reset(vdev); } vdev->refcnt++; @@ -162,6 +167,8 @@ static long vfio_platform_ioctl(void *device_data, if (info.argsz < minsz) return -EINVAL; + if (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 +262,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 (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 9e37b9f..1c9b3d5 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -67,6 +67,7 @@ struct vfio_platform_device { struct resource* (*get_resource)(struct vfio_platform_device *vdev, int i); int (*get_irq)(struct vfio_platform_device *vdev, int i); + int (*reset)(struct vfio_platform_device *vdev); }; struct vfio_platform_reset_combo {