Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3635532pxk; Tue, 29 Sep 2020 02:07:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwU5zP/7GHK2NTrsowkIG4HpW30nfk1GyR9MdvA0Dc2h5ZmEA+dTt8lAlJKnVj1+CuPtsX X-Received: by 2002:a05:6402:8d3:: with SMTP id d19mr2176178edz.68.1601370444983; Tue, 29 Sep 2020 02:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601370444; cv=none; d=google.com; s=arc-20160816; b=RYzlslyKfyc4ZyYnPGASY/+wcf1u9yVCPPGCZ/zM/SW1Y8yKMrqHIPvGeQIog2cwgP sVdn2EhrRgDS2ud3ybtr53cCg2W1bCRCa9Xis/de+k0g43NJAUpObiqUukfCgrFukXdx feSNmKy5LhzfUh5NeqEySfi/tQ/uSg2rVfXJ8iB5b9uc6OsXNnVJXHxANkNfbibGdgft wOOHx5iG+OfwV9reBzAzdSCrq5UEPU8t4UgqBgd10Mye5+jXn4aqhnZ1kqBbYRqD9UEW pU41Kap9LxYccUDz0yvFqGH8tTkYX+p+9p1dg7hfCl/9dGGmF4SIlZQ7iAlbK9QVdOcv 4knQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=o16uKr6zd7RwzxhxQOQyfCrPAtgyHdTwdg6UQC3ED1Y=; b=Z/0LVMCppCchiKZr71P14mEuKECwRsA3vmV0RrLgNx6QabUDuKxay9diAVp1s+90RO 3NpV8vLIKKpcNx0enruEHL+5WcIuHCWUG3MBFd6Rv3oFo8FUbsUe0Jvd3TGOWIVvswkj JewSpndEcDM3MECygro5p5oiwVku1YhicI+nBD1BAh1dfyjalKnhDWVg1nJxi2OGt14O Qq28nnns3WCqIqTIE0RHQT23b7pym3velVQZ92CJcSzh+ALkGjKsEHH5pjmCfQJ5+0qN QUDGo6vAW+5pybcsj+tRDSwsvwIsCK5FP/6uo0lprSARc+8cBaqNKnzAltnG4buYcsdo qGgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u59si2687122edc.226.2020.09.29.02.07.02; Tue, 29 Sep 2020 02:07:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbgI2JEB (ORCPT + 99 others); Tue, 29 Sep 2020 05:04:01 -0400 Received: from inva021.nxp.com ([92.121.34.21]:41222 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725320AbgI2JD7 (ORCPT ); Tue, 29 Sep 2020 05:03:59 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 788062015A0; Tue, 29 Sep 2020 11:03:57 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 6AB5F201094; Tue, 29 Sep 2020 11:03:57 +0200 (CEST) Received: from fsr-ub1864-111.ea.freescale.net (fsr-ub1864-111.ea.freescale.net [10.171.82.141]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 174222032C; Tue, 29 Sep 2020 11:03:57 +0200 (CEST) From: Diana Craciun To: alex.williamson@redhat.com, kvm@vger.kernel.org Cc: bharatb.linux@gmail.com, linux-kernel@vger.kernel.org, eric.auger@redhat.com, Diana Craciun , Bharat Bhushan Subject: [PATCH v5 03/10] vfio/fsl-mc: Implement VFIO_DEVICE_GET_INFO ioctl Date: Tue, 29 Sep 2020 12:03:32 +0300 Message-Id: <20200929090339.17659-4-diana.craciun@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200929090339.17659-1-diana.craciun@oss.nxp.com> References: <20200929090339.17659-1-diana.craciun@oss.nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow userspace to get fsl-mc device info (number of regions and irqs). Signed-off-by: Bharat Bhushan Signed-off-by: Diana Craciun Reviewed-by: Eric Auger --- drivers/vfio/fsl-mc/vfio_fsl_mc.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c index ba44d6d01cc9..fa46676c735b 100644 --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c @@ -33,10 +33,29 @@ static void vfio_fsl_mc_release(void *device_data) static long vfio_fsl_mc_ioctl(void *device_data, unsigned int cmd, unsigned long arg) { + unsigned long minsz; + struct vfio_fsl_mc_device *vdev = device_data; + struct fsl_mc_device *mc_dev = vdev->mc_dev; + switch (cmd) { case VFIO_DEVICE_GET_INFO: { - return -ENOTTY; + struct vfio_device_info info; + + minsz = offsetofend(struct vfio_device_info, num_irqs); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + info.flags = VFIO_DEVICE_FLAGS_FSL_MC; + info.num_regions = mc_dev->obj_desc.region_count; + info.num_irqs = mc_dev->obj_desc.irq_count; + + return copy_to_user((void __user *)arg, &info, minsz) ? + -EFAULT : 0; } case VFIO_DEVICE_GET_REGION_INFO: { -- 2.17.1