Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1415641ybj; Fri, 8 May 2020 00:25:04 -0700 (PDT) X-Google-Smtp-Source: APiQypKJtC/0KYkUiSN++Ka0Yx35Gr1+2V0wHiWikmcRuPDov9ZyRw97jiSCLkPXxp5x9zIb26gI X-Received: by 2002:aa7:c306:: with SMTP id l6mr1029933edq.356.1588922704221; Fri, 08 May 2020 00:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588922704; cv=none; d=google.com; s=arc-20160816; b=yFrdnIGXEKhetLCfwbeZJuEZCP5dKKdpRbRlcj5NrfGsdWfRK3CEtHsZk0KMDsvuOK c+tJjugdJblJlYaDWxRY4My8Qm/4VZV9/lIYvdjj9pJQDP7V8SJwV8jrU1OXJft0Cw70 gy8e4uXI71brB4yKK1b6lmNU9xO1ruMrJ9f/lQTrcaL19+ODkVhEcyU/axhD6nqsEaRS kRWHGJIhfcHB2b3Cz2j/Y8E7jQsbFZtipNd40GA29KwRYelXAXzpd7dXfvzgHaVm4p8p emcXLYC+9VuilLGiuWeY7dSOKx37awDSEXw+Ww2h71rIFWtwzgHQUn6iATo5yotXK2KY m9HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=5QUAj2NvvDHL6Ps7M3XYzFdLo4/ZBIGrB38hWgmTtUk=; b=X3ggIQa6of2fjcMijkN+PWD1sDflLnnWX/iRct3TmvrB2MsPr9JmshBqawJG9X88TI 6LO2jpQugwvdK+alV8gohhtelVu9fdiHmqF25E54/XDj3NVV5GCWQeiZD3A7Y+qe775z yE0fNXSCJHJMONJS6BOWNtvhqGRjH03HftVOiI7Bt0uJ/2vX76aFgcFp/TCSDWhQKecl 2l5W8O+bRBzeAeWPv9mCeg6ca+4CO/SRJgcuQBx75DmSVGQ8ooj7pcS88+TSrlH6juRw yb/PRHsp/fIJuCD16ydXV7EDIk4pNReuK3GzvI9muTHb0L6GOWfjkrrMRDWZBvKUetQi zXwQ== 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 q24si454873ejb.184.2020.05.08.00.24.31; Fri, 08 May 2020 00:25:04 -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 S1726924AbgEHHUs (ORCPT + 99 others); Fri, 8 May 2020 03:20:48 -0400 Received: from inva021.nxp.com ([92.121.34.21]:59166 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726365AbgEHHUq (ORCPT ); Fri, 8 May 2020 03:20:46 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 469232012D3; Fri, 8 May 2020 09:20:45 +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 3A87320096A; Fri, 8 May 2020 09:20:45 +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 A53FD204BD; Fri, 8 May 2020 09:20:44 +0200 (CEST) From: Diana Craciun To: alex.williamson@redhat.com, kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, laurentiu.tudor@nxp.com, bharatb.linux@gmail.com, Diana Craciun , Bharat Bhushan Subject: [PATCH v2 3/9] vfio/fsl-mc: Implement VFIO_DEVICE_GET_INFO ioctl Date: Fri, 8 May 2020 10:20:33 +0300 Message-Id: <20200508072039.18146-4-diana.craciun@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508072039.18146-1-diana.craciun@oss.nxp.com> References: <20200508072039.18146-1-diana.craciun@oss.nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org 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 --- 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 ea301ba81225..8a4d3203b176 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