From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24626CCF9FE for ; Mon, 3 Nov 2025 13:59:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4428710E3F2; Mon, 3 Nov 2025 13:59:38 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="LsTQAlbT"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1586510E1A9 for ; Mon, 3 Nov 2025 13:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1762178375; h=from:from:reply-to: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=bsxzOKYHqHXC5PUWfDfFaZwNataXiFJtKNUMBtRzjIc=; b=LsTQAlbTKrE8RMQx3Aw8HB650kiRo5yWwXCbpN+2hhGZ3I8ILaCLSeDjuvQih9zJy5Fzob eUCINbG6UXcv3brhsttOpwT4rF7fOeGzi0Z5lPj+z4dSqJ4WNuAM/rSlAy/w+47NVyWoQ9 LxGDgXtBVIhQqhsZGXkONrxhN5UMHTM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-h5vbnMAfOC6OXg3hsyHvrQ-1; Mon, 03 Nov 2025 08:59:34 -0500 X-MC-Unique: h5vbnMAfOC6OXg3hsyHvrQ-1 X-Mimecast-MFC-AGG-ID: h5vbnMAfOC6OXg3hsyHvrQ_1762178373 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-47106a388cfso35366675e9.0 for ; Mon, 03 Nov 2025 05:59:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762178373; x=1762783173; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bsxzOKYHqHXC5PUWfDfFaZwNataXiFJtKNUMBtRzjIc=; b=d3QnUbeud9dojCJg/w6fI9mLZRrXxDgy0sbJEim7OYGBinq0K7cp2tkEpV+gJoAKpM meS6XqqH940Ynh/rZ4zKsyhaW5X++rlN6Afi0weM4KETEfwsyoVzEkBOwVPSLXvXMp35 Wq+kZUA5NRZAj5RcLyMXJTPShRGyGHVqov/Js5AvapoCTCIHuOk0TLjnd1w4R4WAAAYx 3B4rig/0KpOhS4jJdK7YufbRima7MhRYdsFVwRrc0IuR6U99R9ND1NnFf+7AaE8dmjQd 5Mbk5W4RHXBUpPCVQm11Z7ulW0WZCaBGq79jiJpbt5VYf8maL9xgRu4zgvn6I4dgYzE3 T77Q== X-Forwarded-Encrypted: i=1; AJvYcCXowD7eucG7l+RDSNGeAJCSNj1Y9bqIyy+6J9KWyN+68FQJeiKEjDxR+UA881g4SRcOhtsZHTCPArA=@lists.freedesktop.org X-Gm-Message-State: AOJu0YxMruznK75jzqMTNwc8npmMpvdoMJ8GWTMNV4tNmqIFw6252eFK ZSZJ2ZDBPdlJEVtn6gp52Uw9vAB+diCohZSlRjHdV55+sYnaFViC5BSZnWZVMqOmkvypLvtxxRW 8yHuGVpA9+tQvGiUStYRDuCDbtozj4PvM3+1EsxWn5jLgDsj3nkFGJRVbz2uog/xKv7pjqA== X-Gm-Gg: ASbGncsLWPxcN/4a31sMADLUBatFeAWFZtSvCibtg9jgaNkvsmnua/nLxCYFk1J7jjh toB9q6xYGh9NSadLqALPgROatFw7qy4SgnlSs2r7kba+lPw9ztimacO9x783ozKDrXizJlR1PUz n8mq/Ec0/brDBjSKu6RN0ySD+UbkwTEgoMa+GnvIM8LkM0IWg0uuN3GKwMoVLCwL3nGJ1hdT1UJ XiS1GCUwOsnwJj8dB/TuZ9mH2ZeqpalwFLVCcRpSQy1GU6OOns8T9/7fC93bFkp6OCZ7Bywl3Dx DeWhl2LqcuP4dtWJzY4hzK4eX+Ze7os1L2IcaEUSOp3d1YYjd9W8TYGEtE+j1+s17gXw4TnDVl9 Zl4ne2An4RhYdP/rhYitaP1Ay85Pfck8/mJTx3MFkAXpU0Q== X-Received: by 2002:a05:600c:3b15:b0:46e:48fd:a1a9 with SMTP id 5b1f17b1804b1-4773089cd1amr118451895e9.33.1762178373373; Mon, 03 Nov 2025 05:59:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKpOeJ3OCF2vnsxcvEkg/1eMNuJuaakX/5JjRbkHK8VRtwHXD8pikxeGoOHXlvFPGq9VVSPQ== X-Received: by 2002:a05:600c:3b15:b0:46e:48fd:a1a9 with SMTP id 5b1f17b1804b1-4773089cd1amr118451615e9.33.1762178372957; Mon, 03 Nov 2025 05:59:32 -0800 (PST) Received: from ?IPV6:2a01:e0a:f0e:9070:527b:9dff:feef:3874? ([2a01:e0a:f0e:9070:527b:9dff:feef:3874]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4773c2e6771sm156241435e9.2.2025.11.03.05.59.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Nov 2025 05:59:32 -0800 (PST) Message-ID: <0815321f-00d5-402c-b84d-99bc862b4575@redhat.com> Date: Mon, 3 Nov 2025 14:59:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 09/22] vfio/platform: Provide a get_region_info op To: Jason Gunthorpe , Alexander Gordeev , David Airlie , Alex Williamson , Ankit Agrawal , Christian Borntraeger , Brett Creeley , dri-devel@lists.freedesktop.org, Eric Farman , Giovanni Cabiddu , Vasily Gorbik , Heiko Carstens , intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Kevin Tian , kvm@vger.kernel.org, Kirti Wankhede , linux-s390@vger.kernel.org, Longfang Liu , Matthew Rosato , Nikhil Agarwal , Nipun Gupta , Peter Oberparleiter , Halil Pasic , Pranjal Shrivastava , qat-linux@intel.com, Rodrigo Vivi , Simona Vetter , Shameer Kolothum , Mostafa Saleh , Sven Schnelle , Tvrtko Ursulin , virtualization@lists.linux.dev, Vineeth Vijayan , Yishai Hadas , Zhenyu Wang , Zhi Wang Cc: patches@lists.linux.dev References: <9-v1-679a6fa27d31+209-vfio_get_region_info_op_jgg@nvidia.com> From: Eric Auger In-Reply-To: <9-v1-679a6fa27d31+209-vfio_get_region_info_op_jgg@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ojvy2fvRqMHIAhxqj4mILb3WpPJwpF2MOI5Nixt_SUk_1762178373 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: eric.auger@redhat.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Jason, On 10/24/25 1:09 AM, Jason Gunthorpe wrote: > Move it out of vfio_platform_ioctl() and re-indent it. Add it to all > platform drivers. > > Signed-off-by: Jason Gunthorpe > --- > drivers/vfio/platform/vfio_amba.c | 1 + > drivers/vfio/platform/vfio_platform.c | 1 + > drivers/vfio/platform/vfio_platform_common.c | 50 +++++++++++-------- > drivers/vfio/platform/vfio_platform_private.h | 2 + > 4 files changed, 32 insertions(+), 22 deletions(-) > > diff --git a/drivers/vfio/platform/vfio_amba.c b/drivers/vfio/platform/vfio_amba.c > index 9f5c527baa8a36..d600deaf23b6d7 100644 > --- a/drivers/vfio/platform/vfio_amba.c > +++ b/drivers/vfio/platform/vfio_amba.c > @@ -115,6 +115,7 @@ static const struct vfio_device_ops vfio_amba_ops = { > .open_device = vfio_platform_open_device, > .close_device = vfio_platform_close_device, > .ioctl = vfio_platform_ioctl, > + .get_region_info = vfio_platform_ioctl_get_region_info, Any rationale behind why using _ioctl naming in some drivers and not in some others? > .read = vfio_platform_read, > .write = vfio_platform_write, > .mmap = vfio_platform_mmap, > diff --git a/drivers/vfio/platform/vfio_platform.c b/drivers/vfio/platform/vfio_platform.c > index 512533501eb7f3..0e85c914b65105 100644 > --- a/drivers/vfio/platform/vfio_platform.c > +++ b/drivers/vfio/platform/vfio_platform.c > @@ -101,6 +101,7 @@ static const struct vfio_device_ops vfio_platform_ops = { > .open_device = vfio_platform_open_device, > .close_device = vfio_platform_close_device, > .ioctl = vfio_platform_ioctl, > + .get_region_info = vfio_platform_ioctl_get_region_info, > .read = vfio_platform_read, > .write = vfio_platform_write, > .mmap = vfio_platform_mmap, > diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c > index 3bf1043cd7957c..3ebd50fb78fbb7 100644 > --- a/drivers/vfio/platform/vfio_platform_common.c > +++ b/drivers/vfio/platform/vfio_platform_common.c > @@ -272,6 +272,34 @@ int vfio_platform_open_device(struct vfio_device *core_vdev) > } > EXPORT_SYMBOL_GPL(vfio_platform_open_device); > > +int vfio_platform_ioctl_get_region_info(struct vfio_device *core_vdev, > + struct vfio_region_info __user *arg) > +{ > + struct vfio_platform_device *vdev = > + container_of(core_vdev, struct vfio_platform_device, vdev); > + struct vfio_region_info info; > + unsigned long minsz; > + > + minsz = offsetofend(struct vfio_region_info, offset); > + > + if (copy_from_user(&info, arg, minsz)) > + return -EFAULT; > + > + if (info.argsz < minsz) > + return -EINVAL; > + > + if (info.index >= vdev->num_regions) > + return -EINVAL; > + > + /* map offset to the physical address */ > + info.offset = VFIO_PLATFORM_INDEX_TO_OFFSET(info.index); > + info.size = vdev->regions[info.index].size; > + info.flags = vdev->regions[info.index].flags; > + > + return copy_to_user(arg, &info, minsz) ? -EFAULT : 0; > +} > +EXPORT_SYMBOL_GPL(vfio_platform_ioctl_get_region_info); > + > long vfio_platform_ioctl(struct vfio_device *core_vdev, > unsigned int cmd, unsigned long arg) > { > @@ -300,28 +328,6 @@ long vfio_platform_ioctl(struct vfio_device *core_vdev, > return copy_to_user((void __user *)arg, &info, minsz) ? > -EFAULT : 0; > > - } else if (cmd == VFIO_DEVICE_GET_REGION_INFO) { > - struct vfio_region_info info; > - > - minsz = offsetofend(struct vfio_region_info, offset); > - > - if (copy_from_user(&info, (void __user *)arg, minsz)) > - return -EFAULT; > - > - if (info.argsz < minsz) > - return -EINVAL; > - > - if (info.index >= vdev->num_regions) > - return -EINVAL; > - > - /* map offset to the physical address */ > - info.offset = VFIO_PLATFORM_INDEX_TO_OFFSET(info.index); > - info.size = vdev->regions[info.index].size; > - info.flags = vdev->regions[info.index].flags; > - > - return copy_to_user((void __user *)arg, &info, minsz) ? > - -EFAULT : 0; > - > } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) { > struct vfio_irq_info info; > > diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h > index 8d8fab51684909..a6008320e77bae 100644 > --- a/drivers/vfio/platform/vfio_platform_private.h > +++ b/drivers/vfio/platform/vfio_platform_private.h > @@ -85,6 +85,8 @@ int vfio_platform_open_device(struct vfio_device *core_vdev); > void vfio_platform_close_device(struct vfio_device *core_vdev); > long vfio_platform_ioctl(struct vfio_device *core_vdev, > unsigned int cmd, unsigned long arg); > +int vfio_platform_ioctl_get_region_info(struct vfio_device *core_vdev, > + struct vfio_region_info __user *arg); > ssize_t vfio_platform_read(struct vfio_device *core_vdev, > char __user *buf, size_t count, > loff_t *ppos); Besides Reviewed-by: Eric Auger Thanks Eric