From patchwork Fri Apr 17 13:37:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 47288 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 2007C20553 for ; Fri, 17 Apr 2015 13:40:08 +0000 (UTC) Received: by lbdc7 with SMTP id c7sf23959837lbd.2 for ; Fri, 17 Apr 2015 06:40:07 -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=gVE15eOiuGbdX6T9Me+yLnc76Ao4pmItIGKsC7hSSzg=; b=hkasVtmCfSqvgrV2yCRjWiAU3aNMqEfekZz7ZxEWgWnch/9Nz+S5oawPgSUJhIF3fB ZbOv3NoewqlzFIe0xt2yQ0LNy23a/aKLYIbCBWm027koCa4cSJtpviMbpriAuQ6+vnfR /gU9uRhbjaHNNMTvIpysQRtWpjqm0cS0WDBBeU7qOQDPestRLgbeEzTROcuCD/KtyJUP 0WG9r/UBqGMzc8m7nhYcsgIZGUkisaLm2yQh/IMDV3Js9Ze/TvKfdiOX8OQlxYUPn1W2 +TmjiH39HyNgq+oR5DnC03U5iS/fxqcQE8Gqqf0sXeZEuJbTyjfudzz4RfM+fuQ09Ine NR4Q== X-Gm-Message-State: ALoCoQkX3d0M0LXIWEx2fg98RZMHeO9HT7ikft8BFFv2QFPpDl44u7irVxiGysakIbYnsiBO/8jM X-Received: by 10.112.130.71 with SMTP id oc7mr1472672lbb.23.1429278007044; Fri, 17 Apr 2015 06:40:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.114 with SMTP id q18ls524724laa.8.gmail; Fri, 17 Apr 2015 06:40:06 -0700 (PDT) X-Received: by 10.152.115.173 with SMTP id jp13mr3650723lab.119.1429278006913; Fri, 17 Apr 2015 06:40:06 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id wv10si8809287lac.79.2015.04.17.06.40.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Apr 2015 06:40:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by labbd9 with SMTP id bd9so80597573lab.2 for ; Fri, 17 Apr 2015 06:40:06 -0700 (PDT) X-Received: by 10.152.36.2 with SMTP id m2mr3685341laj.72.1429278006834; Fri, 17 Apr 2015 06:40:06 -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 l1csp3743764lbt; Fri, 17 Apr 2015 06:40:06 -0700 (PDT) X-Received: by 10.112.172.35 with SMTP id az3mr3563424lbc.99.1429278004624; Fri, 17 Apr 2015 06:40:04 -0700 (PDT) Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com. [74.125.82.53]) by mx.google.com with ESMTPS id d10si3006139wix.109.2015.04.17.06.40.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Apr 2015 06:40:04 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.53 as permitted sender) client-ip=74.125.82.53; Received: by wgsk9 with SMTP id k9so113439694wgs.3 for ; Fri, 17 Apr 2015 06:40:04 -0700 (PDT) X-Received: by 10.194.90.47 with SMTP id bt15mr6296105wjb.41.1429278004353; Fri, 17 Apr 2015 06:40:04 -0700 (PDT) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id ub1sm14712357wjc.43.2015.04.17.06.40.02 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 Apr 2015 06:40:03 -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, agraf@suse.de, b.reynal@virtualopensystems.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, Bharat.Bhushan@freescale.com Subject: [RFC 1/3] VFIO: platform: add reset support Date: Fri, 17 Apr 2015 15:37:11 +0200 Message-Id: <1429277833-28663-2-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429277833-28663-1-git-send-email-eric.auger@linaro.org> References: <1429277833-28663-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.42 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: , This patch adds support for vfio platform reset. The modality only is exposed when a specialized VFIO driver populates the reset callback. For the generic vfio platform/amba driver, the modality is not supported since the driver is by essence a metadriver and does not know how to reset the underlying device. Signed-off-by: Eric Auger --- 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 4113d46..b989ce5 100644 --- a/drivers/vfio/platform/vfio_platform_common.c +++ b/drivers/vfio/platform/vfio_platform_common.c @@ -100,6 +100,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); } @@ -159,6 +161,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; @@ -252,8 +256,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 -ENOTTY; + } return -ENOTTY; } diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index 253caa3..0a20028 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 { 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); }; extern int vfio_platform_probe_common(struct vfio_platform_device *vdev,