Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp575596pxk; Thu, 3 Sep 2020 07:23:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2wb+cQ6BfuAarvr5HOlL5yZzVHmBbyMbx3DhrRvOeRqDP99+3B/Sdsuv6m/tBYy8D5jzJ X-Received: by 2002:a50:f418:: with SMTP id r24mr3332980edm.295.1599142980393; Thu, 03 Sep 2020 07:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599142980; cv=none; d=google.com; s=arc-20160816; b=HY3OD3E80pa19c51/ZEw8gg+L/ljuPc3CKykF1mpTqr34qFQlUrcmLu5tiuO6BJ1sR CuPbizs+NrpYkxsnkhrXEKUmA4YluGhc8rKA5PtTNNUw+9svWhJ+Xbi5uQ2f7rc+8llG 5M2g2N3AY2+ROZA/VNQwnQ7tT2b8UdxfjhRecmsBC2+TG5kKr++T3WeRJTvl3mwRrX3S qnK55eBrCPwQ7jw7uiQb58gZNHt7DWhhrwEJbF4mmsZ4mIG/E7dQf00+PYzXZT1CxH7Z 06uw0iJv31lXRgFSnQWb9ayQfsrGmcLKTQFCjXZyKtC9N2SvBoGVttQPHIMSpIDnMrLj 5hHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=I0HZj8Fjtd+TJ8+nY3F25eaagzLSvWKMqED4dPK0Qo8=; b=i/+2U2X7UVLZgzlfXY+jQCdP58FnrpIl9tstsNiMDb9SXlwDHZZNzbsRgHKMeANdvo Qquvk8UhbVXCP6N872sXKNU5gFigdVvE4GJg04OvU/eoHbodIsbkRqgofsMrlqbmiSvU C6G94EvSvmIqB8x0hNNIKUwdGW55pILGfxrJvR7V+jF6NPc+uYZt050X9kQZwRm5PC4i XJ7PGyTTlt89MvHAc+TnPSOleBPIfrNyvufVpcC59etR1ggD2o8p5PqaxGXucL2zfhx0 DaAbquSdc5QfS3d2uuctJX8zqd+Y+zXe6uWh0fWhG3eFfR1v5vbk+/2U+BbXxvAEOcO9 s+2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AUH7edDx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ok21si2166401ejb.373.2020.09.03.07.22.37; Thu, 03 Sep 2020 07:23:00 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AUH7edDx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729244AbgICOQm (ORCPT + 99 others); Thu, 3 Sep 2020 10:16:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39896 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729207AbgICONs (ORCPT ); Thu, 3 Sep 2020 10:13:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599142427; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I0HZj8Fjtd+TJ8+nY3F25eaagzLSvWKMqED4dPK0Qo8=; b=AUH7edDxvyXxmaA4o/KEAnueoYM9XrcNvJRYFlTUWCKScjg6PmklOhfxDH6cDiKr02wMB0 Fz3Wkq14s7dVuXofDfKV2lP/Q9qAwkh5LkQy/agdpjUYjAAO2yWhYTa7RPaQO30n6hm0c0 sT+uMiUfa6v66hkNuj+o9sBIpgKpaOQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-434-0_InniYDM--af73vdO89cw-1; Thu, 03 Sep 2020 10:13:46 -0400 X-MC-Unique: 0_InniYDM--af73vdO89cw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1594C10ABDD9; Thu, 3 Sep 2020 14:13:45 +0000 (UTC) Received: from [10.36.112.51] (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82E1E7E408; Thu, 3 Sep 2020 14:13:43 +0000 (UTC) Subject: Re: [PATCH v4 03/10] vfio/fsl-mc: Implement VFIO_DEVICE_GET_INFO ioctl To: Diana Craciun , alex.williamson@redhat.com, kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, bharatb.linux@gmail.com, laurentiu.tudor@nxp.com, Bharat Bhushan References: <20200826093315.5279-1-diana.craciun@oss.nxp.com> <20200826093315.5279-4-diana.craciun@oss.nxp.com> From: Auger Eric Message-ID: Date: Thu, 3 Sep 2020 16:13:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200826093315.5279-4-diana.craciun@oss.nxp.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Diana, On 8/26/20 11:33 AM, Diana Craciun wrote: > 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 Thanks Eric > --- > 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 85e007be3a5d..5a5460d01f00 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: > { >