From patchwork Thu Jun 11 12:08:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 49757 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4B97520C81 for ; Thu, 11 Jun 2015 12:09:14 +0000 (UTC) Received: by laboh3 with SMTP id oh3sf1643493lab.0 for ; Thu, 11 Jun 2015 05:09:13 -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=OK5fcHMo0WMFQ9dk59GgyTR24VOOoX/B4WvfbDNRZDM4heiLeXviNEd2DOGx7m8s+U ClQ60dhBOZY40NQpR8dGDoRSgCY0gZJ1/qaK15lZqCWnAauRwL0z1w6HKGbTEVWlIVtp BAVSwoo+HZOmRjY3EZyTlzcGp3VsQ72xk39hyjVh1UXqmxk7mKzlBjdElGhoJm5lWslO fuiImAilXMEtE8a4Bz8c946mfD7CWhJCh8AmT0UUiE68Lq4DE1g+5D7qqO4+PBwlCLSY 1Gh7lO7hcybmH3lXsawEVjnVA3ipJEh4QbACjLtjSvCBj89AbBbhnVdzpIrwMDRMdu4r phcg== X-Gm-Message-State: ALoCoQnz5Ap+jKUAUP/SD4IzFM0HlFciTwqxCYOl/eUIeSRi5bT+IxuDoHtctRWMedliT18imCjz X-Received: by 10.180.216.12 with SMTP id om12mr9009752wic.1.1434024553350; Thu, 11 Jun 2015 05:09:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.168 with SMTP id w8ls398226lae.41.gmail; Thu, 11 Jun 2015 05:09:13 -0700 (PDT) X-Received: by 10.112.42.16 with SMTP id j16mr9352742lbl.98.1434024553188; Thu, 11 Jun 2015 05:09:13 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id y5si418279lay.123.2015.06.11.05.09.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2015 05:09:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laew7 with SMTP id w7so3344463lae.1 for ; Thu, 11 Jun 2015 05:09:13 -0700 (PDT) X-Received: by 10.112.41.196 with SMTP id h4mr9559385lbl.36.1434024553083; Thu, 11 Jun 2015 05:09:13 -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 hn6csp3995602lbb; Thu, 11 Jun 2015 05:09:12 -0700 (PDT) X-Received: by 10.180.13.5 with SMTP id d5mr29026823wic.65.1434024552248; Thu, 11 Jun 2015 05:09:12 -0700 (PDT) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com. [209.85.212.171]) by mx.google.com with ESMTPS id k8si1530383wia.75.2015.06.11.05.09.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2015 05:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.171 as permitted sender) client-ip=209.85.212.171; Received: by wiga1 with SMTP id a1so73850464wig.0 for ; Thu, 11 Jun 2015 05:09:12 -0700 (PDT) X-Received: by 10.194.120.106 with SMTP id lb10mr16322192wjb.54.1434024551996; Thu, 11 Jun 2015 05:09:11 -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 vz2sm796336wjc.18.2015.06.11.05.09.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2015 05:09:10 -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 v3 2/4] VFIO: platform: add reset callback Date: Thu, 11 Jun 2015 14:08:45 +0200 Message-Id: <1434024527-13869-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1434024527-13869-1-git-send-email-eric.auger@linaro.org> References: <1434024527-13869-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.53 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 {