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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7C93C433EF for ; Tue, 7 Jun 2022 05:40:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230090AbiFGFkD (ORCPT ); Tue, 7 Jun 2022 01:40:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbiFGFkB (ORCPT ); Tue, 7 Jun 2022 01:40:01 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B5FC6FA0F; Mon, 6 Jun 2022 22:40:00 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 4704568AFE; Tue, 7 Jun 2022 07:39:56 +0200 (CEST) Date: Tue, 7 Jun 2022 07:39:55 +0200 From: Christoph Hellwig To: Jason Gunthorpe Cc: Alexander Gordeev , David Airlie , Tony Krowiak , Alex Williamson , Christian Borntraeger , Cornelia Huck , Daniel Vetter , dri-devel@lists.freedesktop.org, Eric Farman , Harald Freudenberger , Vasily Gorbik , Heiko Carstens , intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, Jani Nikula , Jason Herne , Joonas Lahtinen , kvm@vger.kernel.org, linux-s390@vger.kernel.org, Matthew Rosato , Peter Oberparleiter , Halil Pasic , Rodrigo Vivi , Sven Schnelle , Tvrtko Ursulin , Vineeth Vijayan , Zhenyu Wang , Zhi Wang , Christoph Hellwig Subject: Re: [PATCH 1/2] vfio: Replace the DMA unmapping notifier with a callback Message-ID: <20220607053955.GA8508@lst.de> References: <0-v1-896844109f36+a-vfio_unmap_notif_jgg@nvidia.com> <1-v1-896844109f36+a-vfio_unmap_notif_jgg@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1-v1-896844109f36+a-vfio_unmap_notif_jgg@nvidia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, Jun 06, 2022 at 09:34:35PM -0300, Jason Gunthorpe wrote: > +static void intel_vgpu_dma_unmap(struct vfio_device *vfio_dev, u64 iova, > + u64 length) > { > + struct intel_vgpu *vgpu = vfio_dev_to_vgpu(vfio_dev); > + struct gvt_dma *entry; > + u64 iov_pfn, end_iov_pfn; > > + iov_pfn = iova >> PAGE_SHIFT; > + end_iov_pfn = iov_pfn + length / PAGE_SIZE; I'd just initialize these at declaration time. The mix between shifting and division here is also kind weird, but we probably shouldn't change too much from the original version. > + /* Vendor drivers MUST unpin pages in response to an invalidation. */ s/Vendor//g > /** > + * vfio_ap_mdev_dma_unmap - Notifier that IOVA has been unmapped > + * @vdev: The VFIO device > + * @unmap: IOVA range unmapped > * > + * Unpin the guest IOVA (the NIB guest address we pinned before). > */ kerneldoc comments for method instances are a bit silly.. > +static int vfio_iommu_notifier(struct notifier_block *nb, unsigned long action, > + void *data) > +{ > + struct vfio_device *vfio_device = > + container_of(nb, struct vfio_device, iommu_nb); > + struct vfio_iommu_type1_dma_unmap *unmap = data; Using the iommu type 1 UAPI structure in the core vfio code for a subset of its field is kinda weird. But we can fix this later. Otherwise looks good: Reviewed-by: Christoph Hellwig