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 48800CCFA06 for ; Mon, 3 Nov 2025 12:46:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B474810E3CC; Mon, 3 Nov 2025 12:46:07 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="gM1OvX9T"; dkim-atps=neutral Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id E73AA10E359 for ; Mon, 3 Nov 2025 06:06:18 +0000 (UTC) Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2959197b68eso184825ad.1 for ; Sun, 02 Nov 2025 22:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1762149978; x=1762754778; darn=lists.freedesktop.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=daEhgCusceEtpwe81ptEC+bKqGITwloFYe7hKEHFGD0=; b=gM1OvX9Ttw+flCMj0pZRLbRhdMPBKR/u1W4HPuifagCBIFO5RIQ5ZBcSA2sDXICxJW FR9KpVlYOftZMzX1RyDVITZn8gS3gAznV6kNdk2DXYn3QhjHv14pO7FxEWQWYJOFSHhm 3b83RGMI+TsOmaJNcbYN7jhZAY2Q5Ia3y+YhFGN5PigRQKhiHHqIUYzKDpCBLnFYAKOp VXnxWQLcmGCgkk0Xg75q016IXbqTBFRoGSfnRUBW/w4ofZ0ajeE+vVEJjxuDtwwE8+kI 4qQ+Fc/A3rhrOvjvaOcLFHTvsxhFdtjlxPugWVKvOU4JYAlGufoK1X6PSGWb7W3rQ6GF VP3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762149978; x=1762754778; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=daEhgCusceEtpwe81ptEC+bKqGITwloFYe7hKEHFGD0=; b=gtlvNhLpm8Myiya1Qo2GWla0BcRA+21lHvBeQ4NOJKyMJttaNBO7tZu2REyArm28Yc zJlf/ObWV2198GRLRWr6tvlUznom1vIbCuMKY5WgbBdq0gimjZG1cGEUxkl+yhXJWM0w wz7qIwJxTDBL/WbY3kp/R5han7Eekrj8RqWp2lR2D+4JVNSYSdg5OQVicFpK+j0DGThO Hsa9bDfLhQJ5HZoSC+5YA5m3W59V+v/CJWboU3nR2ZpD6zgjYsEK+e7+xYtx4Zb2tWL6 TWc8yiy/Mkau2fYlxRq1xioLy01+aABZCpQaAG9to++laq/egy59WFD9mBmQhVxS6Svn B6vA== X-Forwarded-Encrypted: i=1; AJvYcCWFEGPyCttmI8yrZj4Z3addnJJSXH/cIvdqDte7s1O+jtMemBZGnsJXFg/EpWsz55ZvJQQvtSfUakk=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yz0/RzJFw8qT1KOv53rCM/qiqUzC/yF3bbk99+gazlKAN3j/uPZ XqnQs0qdvUbOdaBBWhUq4QsVrQHM2ojXR9PNtBIgK9T4wwSFZvsDh1yXfn24ji/xIg== X-Gm-Gg: ASbGncsKglgT1PFFnmwY6HigXQ3NwO585s8RNC6bUn7gYwwN71jKPeFxfa0qg7LMsR8 bFWJ/m0EsKnA4P7xjIC81mOPLMAb3bN/BwVfWPizKDOTfj4OsGASbeaarN6FX8SOQaOrxrpl1Jo rWuHBLyHi8Sviz1/jgwYzBmw3IqN1oM6eTq8F9bDJYcmkCkLOQPRd2I1EIsQOFgaO3JJUyUxZks jRC06mZD0dLgD4EUsACwYNfXP15mhgKBF0USnWv8xUCoZeY2mFvJqxeEWXCY6Us79Nq3H8+quQZ qJRcikmXr9hsQo+9gGPOEpsGVFg/aGZAKbug3wbERRXeh/P61kG5jVuzRqBIAwuZOCjcytPthrP tRkeyc3KRHLYahTGy+HatNpi+nqpFq7WUPT5V9EpipIUdoT8nS4WwP3ys1Ok3SJgUcO6P45Q2WO lt0F7g4KmwE6fxAt1K8HI7ZRrzZdyIzoSODMc9qw== X-Google-Smtp-Source: AGHT+IEluRFzLqUGHbmfa87kzbGcxD4xtCtUDt3Aesdz6fP5oqFYMacpJF/LHmpqMlg6+1lRT50KTA== X-Received: by 2002:a17:902:ea08:b0:294:faad:8cb4 with SMTP id d9443c01a7336-29554b85496mr5533065ad.8.1762149977826; Sun, 02 Nov 2025 22:06:17 -0800 (PST) Received: from google.com (164.210.142.34.bc.googleusercontent.com. [34.142.210.164]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7a9bad978c4sm5062872b3a.13.2025.11.02.22.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Nov 2025 22:06:17 -0800 (PST) Date: Mon, 3 Nov 2025 06:06:07 +0000 From: Pranjal Shrivastava To: Jason Gunthorpe Cc: Alexander Gordeev , David Airlie , Alex Williamson , Ankit Agrawal , Christian Borntraeger , Brett Creeley , dri-devel@lists.freedesktop.org, Eric Auger , 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 , 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 , patches@lists.linux.dev Subject: Re: [PATCH 02/22] vfio/hisi: Convert to the get_region_info op Message-ID: References: <0-v1-679a6fa27d31+209-vfio_get_region_info_op_jgg@nvidia.com> <2-v1-679a6fa27d31+209-vfio_get_region_info_op_jgg@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2-v1-679a6fa27d31+209-vfio_get_region_info_op_jgg@nvidia.com> X-Mailman-Approved-At: Mon, 03 Nov 2025 12:46:06 +0000 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 Thu, Oct 23, 2025 at 08:09:16PM -0300, Jason Gunthorpe wrote: > Change the function signature of hisi_acc_vfio_pci_ioctl() > and re-indent it. > > 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..f06dcfcf09599f 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_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); > I'm curious to learn the reason for flipping polarity here? (apart from readability). > - /* > - * 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); > > - 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_get_region, > .device_feature = vfio_pci_core_ioctl_feature, > .read = hisi_acc_vfio_pci_read, > .write = hisi_acc_vfio_pci_write, The change seems to maintain original functionality and LGTM. Acked-by: Pranjal Shrivastava Thanks, Praan