Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4975919imu; Tue, 29 Jan 2019 10:37:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN7t5Wp2wk0B8opqDzN7/BHsEAXXZNCEZKx/M5AgIT9cn9cBeeL+ZmKSzJHNwZN4aD2LtC14 X-Received: by 2002:a63:4002:: with SMTP id n2mr24395264pga.137.1548787055747; Tue, 29 Jan 2019 10:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548787055; cv=none; d=google.com; s=arc-20160816; b=Do4srv9YDBV/FHt/P1pD+9zrEo1bfX4/+Vu6Xq43dsuwxRLbsj2GElgBqPb4ilUR7j +yWJ3snFhnC0xMJ9L2w/iZ47anDWa9Tp/BeWL3idW0LONx1TJ9d5PG1eI1cBu/UUqCRm FMzDF9mjQXS41rq9s/z2mDuADKUcrtUZ2fPk+w+5VY+PWDJPJi6KGbSYvJmE5LBgkxhF uojCz9B6EZ+EISYZYw1Sn30kqzU/XZU/PTpr1jhHVxPjL7F/MCgjF/DkkEFGok8CI7fo Lc988nbYfIfls0+0f1cdRCw5Ur7tM904RRxLBzR7QhkieInMqVxHd9vSi6+HNekQx3k3 vdNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=V6Z/wRHo/U8m5UN+kVHpwNydZnYAX4xhGlD7cv4FSiU=; b=HUyVVT2X25ERflMdFqiV0/YoHm5pSNf3eIh1O5CJt5+YZvcRRE31UUWWNcAhH7VRlS ewtx0bIvLjadN2OFXXy1SvcvDn1s+oqsj7rzFcrl0YTn2ZDRrfjt+vFX5lu11h0Hje6x EFPX5Zi0n1+1z9RALdoxQ7ehKBP1M+oOGv38+NNelO4nqybIvCkjSdjnsnv9lrS1YriT f854CEOOplMWZ9lfZkqJbTtC8F84fcvJw/yW45SByUirTsl95ekeobn5VBq97RtKD9r0 cUyjiO8iEOk53RbCVw4FqBOnyv/065yvs9AYh+LbggStbqQfukBooH6dAwm0FE2oGjX7 eY5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o6si32421233plh.23.2019.01.29.10.37.19; Tue, 29 Jan 2019 10:37:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728017AbfA2ShD (ORCPT + 99 others); Tue, 29 Jan 2019 13:37:03 -0500 Received: from ale.deltatee.com ([207.54.116.67]:58860 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727229AbfA2ShC (ORCPT ); Tue, 29 Jan 2019 13:37:02 -0500 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1goYFK-00057p-St; Tue, 29 Jan 2019 11:36:31 -0700 To: jglisse@redhat.com, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , "Rafael J . Wysocki" , Bjorn Helgaas , Christian Koenig , Felix Kuehling , Jason Gunthorpe , linux-pci@vger.kernel.org, dri-devel@lists.freedesktop.org, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Joerg Roedel , iommu@lists.linux-foundation.org References: <20190129174728.6430-1-jglisse@redhat.com> <20190129174728.6430-4-jglisse@redhat.com> From: Logan Gunthorpe Message-ID: Date: Tue, 29 Jan 2019 11:36:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190129174728.6430-4-jglisse@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: iommu@lists.linux-foundation.org, jroedel@suse.de, robin.murphy@arm.com, m.szyprowski@samsung.com, hch@lst.de, dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, jgg@mellanox.com, Felix.Kuehling@amd.com, christian.koenig@amd.com, bhelgaas@google.com, rafael@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, jglisse@redhat.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-01-29 10:47 a.m., jglisse@redhat.com wrote: > + /* > + * Optional for device driver that want to allow peer to peer (p2p) > + * mapping of their vma (which can be back by some device memory) to > + * another device. > + * > + * Note that the exporting device driver might not have map anything > + * inside the vma for the CPU but might still want to allow a peer > + * device to access the range of memory corresponding to a range in > + * that vma. > + * > + * FOR PREDICTABILITY IF DRIVER SUCCESSFULY MAP A RANGE ONCE FOR A > + * DEVICE THEN FURTHER MAPPING OF THE SAME IF THE VMA IS STILL VALID > + * SHOULD ALSO BE SUCCESSFUL. Following this rule allow the importing > + * device to map once during setup and report any failure at that time > + * to the userspace. Further mapping of the same range might happen > + * after mmu notifier invalidation over the range. The exporting device > + * can use this to move things around (defrag BAR space for instance) > + * or do other similar task. > + * > + * IMPORTER MUST OBEY mmu_notifier NOTIFICATION AND CALL p2p_unmap() > + * WHEN A NOTIFIER IS CALL FOR THE RANGE ! THIS CAN HAPPEN AT ANY > + * POINT IN TIME WITH NO LOCK HELD. > + * > + * In below function, the device argument is the importing device, > + * the exporting device is the device to which the vma belongs. > + */ > + long (*p2p_map)(struct vm_area_struct *vma, > + struct device *device, > + unsigned long start, > + unsigned long end, > + dma_addr_t *pa, > + bool write); > + long (*p2p_unmap)(struct vm_area_struct *vma, > + struct device *device, > + unsigned long start, > + unsigned long end, > + dma_addr_t *pa); I don't understand why we need new p2p_[un]map function pointers for this. In subsequent patches, they never appear to be set anywhere and are only called by the HMM code. I'd have expected it to be called by some core VMA code and set by HMM as that's what vm_operations_struct is for. But the code as all very confusing, hard to follow and seems to be missing significant chunks. So I'm not really sure what is going on. Logan