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 B0823CFD2F6 for ; Mon, 24 Nov 2025 01:40:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B63D10E07A; Mon, 24 Nov 2025 01:40:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.b="bbDJ6jpD"; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="bbDJ6jpD"; dkim-atps=neutral Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5F08C10E07A; Mon, 24 Nov 2025 01:40:08 +0000 (UTC) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=hnm9pRQxiCRqBNWTAp9RAPNEqoXGWQJUekQPmyavL7I=; b=bbDJ6jpDeUZG5QVe2227oxIrO4p439oDPRvMaLZT4N5q03GC+mFYiMAhvwUWD0cFuCTT2SV0c m7qrS3Z7zX5DNSRPTVPU4TjSrlwpm0IN2iW07NY6FohM7elXzd//8s8R72w5i047LFe8VkNfLso jQ3ypNi5F3foMB29Y4R/asM= Received: from canpmsgout01.his.huawei.com (unknown [172.19.92.178]) by szxga01-in.huawei.com (SkyGuard) with ESMTPS id 4dF7ls2nzjz1BGLY; Mon, 24 Nov 2025 09:39:21 +0800 (CST) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=hnm9pRQxiCRqBNWTAp9RAPNEqoXGWQJUekQPmyavL7I=; b=bbDJ6jpDeUZG5QVe2227oxIrO4p439oDPRvMaLZT4N5q03GC+mFYiMAhvwUWD0cFuCTT2SV0c m7qrS3Z7zX5DNSRPTVPU4TjSrlwpm0IN2iW07NY6FohM7elXzd//8s8R72w5i047LFe8VkNfLso jQ3ypNi5F3foMB29Y4R/asM= Received: from mail.maildlp.com (unknown [172.19.163.48]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4dF7kj6kgpz1T4Jf; Mon, 24 Nov 2025 09:38:21 +0800 (CST) Received: from dggpemf500015.china.huawei.com (unknown [7.185.36.143]) by mail.maildlp.com (Postfix) with ESMTPS id 73F7F18047D; Mon, 24 Nov 2025 09:40:01 +0800 (CST) Received: from [10.67.121.110] (10.67.121.110) by dggpemf500015.china.huawei.com (7.185.36.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 24 Nov 2025 09:39:59 +0800 Subject: Re: [PATCH v2 02/22] vfio/hisi: Convert to the get_region_info op To: Jason Gunthorpe , Alexander Gordeev , David Airlie , Alex Williamson , Ankit Agrawal , Christian Borntraeger , Brett Creeley , , Eric Auger , Eric Farman , Giovanni Cabiddu , Vasily Gorbik , Heiko Carstens , , Jani Nikula , Joonas Lahtinen , , Kirti Wankhede , , Matthew Rosato , Nikhil Agarwal , Nipun Gupta , Peter Oberparleiter , Halil Pasic , , Rodrigo Vivi , Simona Vetter , Shameer Kolothum , Sven Schnelle , Tvrtko Ursulin , , Vineeth Vijayan , Yishai Hadas , Zhenyu Wang , Zhi Wang CC: Kevin Tian , , Pranjal Shrivastava , Mostafa Saleh References: <2-v2-2a9e24d62f1b+e10a-vfio_get_region_info_op_jgg@nvidia.com> From: liulongfang Message-ID: Date: Mon, 24 Nov 2025 09:39:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <2-v2-2a9e24d62f1b+e10a-vfio_get_region_info_op_jgg@nvidia.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.110] X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To dggpemf500015.china.huawei.com (7.185.36.143) X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 2025/11/8 1:41, Jason Gunthorpe wrote: > Change the function signature of hisi_acc_vfio_pci_ioctl() > and re-indent it. > > Reviewed-by: Kevin Tian > Acked-by: Pranjal Shrivastava > Signed-off-by: Jason Gunthorpe > --- > .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 57 +++++++++---------- > 1 file changed, 27 insertions(+), 30 deletions(-) > > diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c > index fde33f54e99ec5..899db4d742a010 100644 > --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c > +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c > @@ -1324,43 +1324,39 @@ static ssize_t hisi_acc_vfio_pci_read(struct vfio_device *core_vdev, > return vfio_pci_core_read(core_vdev, buf, new_count, ppos); > } > > -static long hisi_acc_vfio_pci_ioctl(struct vfio_device *core_vdev, unsigned int cmd, > - unsigned long arg) > +static int hisi_acc_vfio_ioctl_get_region(struct vfio_device *core_vdev, > + struct vfio_region_info __user *arg) > { > - if (cmd == VFIO_DEVICE_GET_REGION_INFO) { > - struct vfio_pci_core_device *vdev = > - container_of(core_vdev, struct vfio_pci_core_device, vdev); > - struct pci_dev *pdev = vdev->pdev; > - struct vfio_region_info info; > - unsigned long minsz; > + struct vfio_pci_core_device *vdev = > + container_of(core_vdev, struct vfio_pci_core_device, vdev); > + struct pci_dev *pdev = vdev->pdev; > + struct vfio_region_info info; > + unsigned long minsz; > > - minsz = offsetofend(struct vfio_region_info, offset); > + minsz = offsetofend(struct vfio_region_info, offset); > > - if (copy_from_user(&info, (void __user *)arg, minsz)) > - return -EFAULT; > + if (copy_from_user(&info, arg, minsz)) > + return -EFAULT; > > - if (info.argsz < minsz) > - return -EINVAL; > + if (info.argsz < minsz) > + return -EINVAL; > > - if (info.index == VFIO_PCI_BAR2_REGION_INDEX) { > - info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); > + if (info.index != VFIO_PCI_BAR2_REGION_INDEX) > + return vfio_pci_ioctl_get_region_info(core_vdev, arg); > > - /* > - * ACC VF dev BAR2 region consists of both functional > - * register space and migration control register space. > - * Report only the functional region to Guest. > - */ > - info.size = pci_resource_len(pdev, info.index) / 2; > + info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index); > Please adapt based on the latest code in the Next branch. Code updates have already been made here. Thanks Longfang. > - info.flags = VFIO_REGION_INFO_FLAG_READ | > - VFIO_REGION_INFO_FLAG_WRITE | > - VFIO_REGION_INFO_FLAG_MMAP; > + /* > + * ACC VF dev BAR2 region consists of both functional > + * register space and migration control register space. > + * Report only the functional region to Guest. > + */ > + info.size = pci_resource_len(pdev, info.index) / 2; > > - return copy_to_user((void __user *)arg, &info, minsz) ? > - -EFAULT : 0; > - } > - } > - return vfio_pci_core_ioctl(core_vdev, cmd, arg); > + info.flags = VFIO_REGION_INFO_FLAG_READ | VFIO_REGION_INFO_FLAG_WRITE | > + VFIO_REGION_INFO_FLAG_MMAP; > + > + return copy_to_user(arg, &info, minsz) ? -EFAULT : 0; > } > > static int hisi_acc_vf_debug_check(struct seq_file *seq, struct vfio_device *vdev) > @@ -1557,7 +1553,8 @@ static const struct vfio_device_ops hisi_acc_vfio_pci_migrn_ops = { > .release = vfio_pci_core_release_dev, > .open_device = hisi_acc_vfio_pci_open_device, > .close_device = hisi_acc_vfio_pci_close_device, > - .ioctl = hisi_acc_vfio_pci_ioctl, > + .ioctl = vfio_pci_core_ioctl, > + .get_region_info = hisi_acc_vfio_ioctl_get_region, > .device_feature = vfio_pci_core_ioctl_feature, > .read = hisi_acc_vfio_pci_read, > .write = hisi_acc_vfio_pci_write, >