From patchwork Fri Jun 5 15:06:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 49578 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A431C2154F for ; Fri, 5 Jun 2015 15:06:59 +0000 (UTC) Received: by wgez8 with SMTP id z8sf18054278wge.2 for ; Fri, 05 Jun 2015 08:06:59 -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=eZfEE9IkdYQHY7WMLYVekS5H5w3U5gmAbeCqoS3mZ2g=; b=OeNvoZYAGxbjWGDYwS9FWBygsbL+evh43C+YlPSqvRAick+kaVTHH83gb0f/gFTv4I tqZnDgFCpn8TilESz00Ih+K83g7XJXZGoKWFAXM4qJvql17UicYWeTSZ5GOXMY19EQQI Dse8lVLTGGOR7C+g6Gf3t3o7zxym1QHkIbfsnG+xd6DIb7U4yDtPsnGWdYOyC5v7wKHo YaD2XE5qYhpm1t6fVJXGxCAsoD1u+qy3HTDJxB1hnfASCzLYetLExHx/mdPkbDoLnM1E bojjh5sEiDcXZp+o/TG+rSdlkOmgqbr6poJvaGnNDY+sJs5B7KRlh/6lJlTLcI+rUuQu gYXw== X-Gm-Message-State: ALoCoQnUWVNm3CJK8QFzjojSGzcfuZaW+DvG+j4HbytHeNDftGbXaain627NesqfCbzNQfwSvVEz X-Received: by 10.112.122.13 with SMTP id lo13mr3540471lbb.5.1433516818996; Fri, 05 Jun 2015 08:06:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.35 with SMTP id lt3ls345332lac.38.gmail; Fri, 05 Jun 2015 08:06:58 -0700 (PDT) X-Received: by 10.152.30.34 with SMTP id p2mr3815668lah.89.1433516818889; Fri, 05 Jun 2015 08:06:58 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id pz9si5032849lbb.92.2015.06.05.08.06.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2015 08:06:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbqq2 with SMTP id qq2so47786626lbb.3 for ; Fri, 05 Jun 2015 08:06:58 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr3746473lbc.72.1433516818768; Fri, 05 Jun 2015 08:06:58 -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 hn6csp1507214lbb; Fri, 5 Jun 2015 08:06:58 -0700 (PDT) X-Received: by 10.194.77.179 with SMTP id t19mr7228056wjw.30.1433516812502; Fri, 05 Jun 2015 08:06:52 -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 h9si13817368wje.62.2015.06.05.08.06.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2015 08:06:52 -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 wifx6 with SMTP id x6so23785040wif.0 for ; Fri, 05 Jun 2015 08:06:52 -0700 (PDT) X-Received: by 10.180.215.8 with SMTP id oe8mr2703369wic.0.1433516812193; Fri, 05 Jun 2015 08:06:52 -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 dz4sm3827133wib.17.2015.06.05.08.06.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2015 08:06:50 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, linux-arm-kernel@lists.infradead.org, alex.williamson@redhat.com, b.reynal@virtualopensystems.com Cc: christoffer.dall@linaro.org, linux-kernel@vger.kernel.org, patches@linaro.org, agraf@suse.de Subject: [PATCH v2 2/4] VFIO: platform: add reset callback Date: Fri, 5 Jun 2015 17:06:30 +0200 Message-Id: <1433516792-16397-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433516792-16397-1-git-send-email-eric.auger@linaro.org> References: <1433516792-16397-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.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: , 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 d970776..995929b 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -106,6 +106,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); } @@ -133,6 +135,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++; @@ -165,6 +170,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; @@ -258,8 +265,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 d864124..cccb3ba 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -72,6 +72,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 {