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 X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BF21C432BE for ; Tue, 10 Aug 2021 09:02:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D57A60C51 for ; Tue, 10 Aug 2021 09:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238537AbhHJJCh (ORCPT ); Tue, 10 Aug 2021 05:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233487AbhHJJCg (ORCPT ); Tue, 10 Aug 2021 05:02:36 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F2EEC0613D3; Tue, 10 Aug 2021 02:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=LWjSXu3ag5kZHehwObZvJyOfxlECQy71l/VsOzHy64g=; b=lOdtPS3Id1gpdVmol+wdQrsfGl SAoE3F7nLroPIqyU6puNVVRcRPlGlVqdktfpysA+cvpw6zCX1PfpaRKEyBWeNKYk3kMkANpYVEj61 McYSW5DrtE3/0XRQ89rF8ztTVBTdzXOcmdGG0sBPpHxrd4QzZGwyIKUZxgXz/acY++d2EdtnI2PYl +szib6uDRbZrGseaPx9JIuF030P2yPuWYxaz+rvxMmRyA750KvXSp0+PxZXPk3CIsxM4MYDZyEI3w GIE1C9E+VF0zYCComF0DruSrZevTAnAybSR2uJsG3rfr/g5XFebc0AZ5N+tvw/I2tLkSfvX2Y/mF0 N0iL6mXQ==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mDNcL-00BvAw-0p; Tue, 10 Aug 2021 09:00:27 +0000 Date: Tue, 10 Aug 2021 10:00:13 +0100 From: Christoph Hellwig To: Jason Gunthorpe Cc: Alex Williamson , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, peterx@redhat.com Subject: Re: [PATCH 4/7] vfio,vfio-pci: Add vma to pfn callback Message-ID: References: <162818167535.1511194.6614962507750594786.stgit@omen> <162818326742.1511194.1366505678218237973.stgit@omen> <20210806010146.GE1672295@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210806010146.GE1672295@nvidia.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 05, 2021 at 10:01:46PM -0300, Jason Gunthorpe wrote: > On Thu, Aug 05, 2021 at 11:07:47AM -0600, Alex Williamson wrote: > > diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c > > index 1e4fc69fee7d..42ca93be152a 100644 > > +++ b/drivers/vfio/vfio.c > > @@ -875,6 +875,22 @@ struct vfio_device *vfio_device_get_from_dev(struct device *dev) > > } > > EXPORT_SYMBOL_GPL(vfio_device_get_from_dev); > > > > +static const struct file_operations vfio_device_fops; > > + > > +int vfio_device_vma_to_pfn(struct vfio_device *device, > > + struct vm_area_struct *vma, unsigned long *pfn) > > A comment here describing the locking conditions the caller must meet > would be a good addition.. It looks like this can only work under the > i_mmap_lock and the returned pfn can only be taken outside that lock > if it is placed in a VMA > > Maybe this is not a great API then? Should it be 'populate vma' and > call io_remap_pfn_range under the op? Yes, I think that would be a better API.