From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938471AbdDSQtH (ORCPT ); Wed, 19 Apr 2017 12:49:07 -0400 Received: from ale.deltatee.com ([207.54.116.67]:57458 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938450AbdDSQs7 (ORCPT ); Wed, 19 Apr 2017 12:48:59 -0400 To: Jason Gunthorpe , Benjamin Herrenschmidt References: <1492381396.25766.43.camel@kernel.crashing.org> <20170418164557.GA7181@obsidianresearch.com> <20170418190138.GH7181@obsidianresearch.com> <20170418210339.GA24257@obsidianresearch.com> <1492564806.25766.124.camel@kernel.crashing.org> <20170419155557.GA8497@obsidianresearch.com> From: Logan Gunthorpe Cc: Dan Williams , Bjorn Helgaas , Christoph Hellwig , Sagi Grimberg , "James E.J. Bottomley" , "Martin K. Petersen" , Jens Axboe , Steve Wise , Stephen Bates , Max Gurtovoy , Keith Busch , linux-pci@vger.kernel.org, linux-scsi , linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, linux-nvdimm , "linux-kernel@vger.kernel.org" , Jerome Glisse Message-ID: <4899b011-bdfb-18d8-ef00-33a1516216a6@deltatee.com> Date: Wed, 19 Apr 2017 10:48:51 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170419155557.GA8497@obsidianresearch.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.111 X-SA-Exim-Rcpt-To: jglisse@redhat.com, linux-kernel@vger.kernel.org, linux-nvdimm@ml01.01.org, linux-rdma@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, linux-pci@vger.kernel.org, keith.busch@intel.com, maxg@mellanox.com, sbates@raithlin.com, swise@opengridcomputing.com, axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, sagi@grimberg.me, hch@lst.de, helgaas@kernel.org, dan.j.williams@intel.com, benh@kernel.crashing.org, jgunthorpe@obsidianresearch.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/04/17 09:55 AM, Jason Gunthorpe wrote: > I was thinking only this one would be supported with a core code > helper.. Pivoting slightly: I was looking at how HMM uses ZONE_DEVICE. They add a type flag to the dev_pagemap structure which would be very useful to us. We could add another MEMORY_DEVICE_P2P type to distinguish p2p pages. Then, potentially, we could add a dma_map callback to the structure (possibly unioned with an hmm field). The dev_ops providers would then just need to do something like this (enclosed in a helper): if (is_zone_device_page(page)) { pgmap = get_dev_pagemap(page_to_pfn(page)); if (!pgmap || pgmap->type != MEMORY_DEVICE_P2P || !pgmap->dma_map) return 0; dma_addr = pgmap->dma_map(dev, pgmap->dev, page); put_dev_pagemap(pgmap); if (!dma_addr) return 0; ... } The pci_enable_p2p_bar function would then just need to call devm_memremap_pages with the dma_map callback set to a function that does the segment check and the offset calculation. Thoughts? @Jerome: my feedback to you would be that your patch assumes all users of devm_memremap_pages are MEMORY_DEVICE_PERSISTENT. It would be more useful if it was generic. My suggestion would be to have the caller allocate the dev_pagemap structure, populate it and pass it into devm_memremap_pages. Given that pretty much everything in that structure are already arguments to that function, I feel like this makes sense. This should also help to unify hmm_devmem_pages_create and devm_memremap_pages which look very similar to each other. Logan