Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp263736ybt; Mon, 6 Jul 2020 08:46:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz67qd3myiX6IH3gik8nQaeRwHsVM0emIWq1jS5AwoOfkAm1LG4ZEoGUMt/hB5EMqlrOqnM X-Received: by 2002:a50:ab52:: with SMTP id t18mr57801226edc.195.1594050370694; Mon, 06 Jul 2020 08:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594050370; cv=none; d=google.com; s=arc-20160816; b=XiTCTK2n847CAZ9WvArBS6OWMXHpwVOCnhL+dr3clY/quOzHxWfAFad1Yg6ik901pE BALTRYhqlm9LUz5AMysSHv7rMNXcsMQMNIvyNgqymW4cpq/Qiq55GMY147wR3NLQEYHl dBGLbfJDKdGLojq4F3cCmBlicToB56rZprb3nmiktQ0o9gx5E3VsbjHeJyvw51UCDNyX siZ60VT/hcfa5cpju2OaI6xpkwVuNB4KWpx8Q9hVDbMFSJaE6u8HMXwk5WSKJpfAku1Y 5O77XHuQQLr0spX++UwhjCqsq7zzoyB6aU1zsZDbzs96LacnNshpOwNqGNiKjRrD+aLa icQA== 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=WYBwCSi8r+BreQtddTP5rpHHY9qJxSmL625JiZYLggo=; b=vVdtI0dDwWA1gXP5t2UIF/N/jBrX4+B1byTgartjaiBKw8AbTa6j14cFysdPikELWz UozTlqA9/Lvw7oWYAXVw7b16xxdtMdzCxDEgfueeufQmMkmY3RoqRqjj3sayHczlWric 6sLUneSuWOHuw1PDOHda+WfDUy/rq7LwZtTGLcdw7+k1xXK2kAVnjZ0TJYKnJeO7MIHu r2DM7NMaVe+bWsZAJmGXAs2mXhlAf4aFc1NNuzxrQJkX2yk5NDGJwLZaahibvMyBrqFL xuxKC5pZV5ZUALS/eoBxOhz9Df7nvdqzLzOLp+wQqBhJFGG0plZHiRh8KzyL0/Zxn0nC uZOg== 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 k19si13469985ejk.27.2020.07.06.08.45.48; Mon, 06 Jul 2020 08:46:10 -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 S1729461AbgGFPmP (ORCPT + 99 others); Mon, 6 Jul 2020 11:42:15 -0400 Received: from inva021.nxp.com ([92.121.34.21]:36180 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729358AbgGFPmP (ORCPT ); Mon, 6 Jul 2020 11:42:15 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 72BA92004F0; Mon, 6 Jul 2020 17:42:13 +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 66C2D2004F7; Mon, 6 Jul 2020 17:42:13 +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 10168203C3; Mon, 6 Jul 2020 17:42:13 +0200 (CEST) From: Diana Craciun To: alex.williamson@redhat.com, kvm@vger.kernel.org Cc: bharatb.linux@gmail.com, linux-kernel@vger.kernel.org, laurentiu.tudor@nxp.com, Diana Craciun , Bharat Bhushan Subject: [PATCH v3 3/9] vfio/fsl-mc: Implement VFIO_DEVICE_GET_INFO ioctl Date: Mon, 6 Jul 2020 18:41:47 +0300 Message-Id: <20200706154153.11477-4-diana.craciun@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200706154153.11477-1-diana.craciun@oss.nxp.com> References: <20200706154153.11477-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 ad8d06cceb71..937b6eddc71a 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