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 DB17EC43334 for ; Tue, 7 Jun 2022 05:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbiFGFkC (ORCPT ); Tue, 7 Jun 2022 01:40:02 -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: linux-s390@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 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 B4A30C433EF for ; Tue, 7 Jun 2022 05:48:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB432112D70; Tue, 7 Jun 2022 05:48:32 +0000 (UTC) X-Greylist: delayed 511 seconds by postgrey-1.36 at gabe; Tue, 07 Jun 2022 05:48:31 UTC Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2801C89F24; Tue, 7 Jun 2022 05:48:31 +0000 (UTC) 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 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) Subject: Re: [Intel-gfx] [PATCH 1/2] vfio: Replace the DMA unmapping notifier with a callback 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: , Cc: kvm@vger.kernel.org, David Airlie , dri-devel@lists.freedesktop.org, Vineeth Vijayan , Alexander Gordeev , Christoph Hellwig , linux-s390@vger.kernel.org, Matthew Rosato , Halil Pasic , Christian Borntraeger , intel-gfx@lists.freedesktop.org, Jason Herne , Eric Farman , Vasily Gorbik , Heiko Carstens , Harald Freudenberger , Rodrigo Vivi , intel-gvt-dev@lists.freedesktop.org, Tony Krowiak , Cornelia Huck , Peter Oberparleiter , Sven Schnelle Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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