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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 EED5EC433DB for ; Tue, 16 Mar 2021 08:14:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7399164FD1 for ; Tue, 16 Mar 2021 08:14:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7399164FD1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 088CF6B006E; Tue, 16 Mar 2021 04:14:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 05EB86B0071; Tue, 16 Mar 2021 04:14:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E685A6B0072; Tue, 16 Mar 2021 04:14:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id C95D36B006E for ; Tue, 16 Mar 2021 04:14:20 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8D9D68249980 for ; Tue, 16 Mar 2021 08:14:20 +0000 (UTC) X-FDA: 77925025080.30.412A508 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf05.hostedemail.com (Postfix) with ESMTP id 05FA1E0011ED for ; Tue, 16 Mar 2021 08:14:19 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 0CBD768C4E; Tue, 16 Mar 2021 09:14:17 +0100 (CET) Date: Tue, 16 Mar 2021 09:14:16 +0100 From: Christoph Hellwig To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , Jason Gunthorpe , Christian =?iso-8859-1?Q?K=F6nig?= , Ira Weiny , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter , Jakowski Andrzej , Minturn Dave B , Jason Ekstrand , Dave Hansen , Xiong Jianxin Subject: Re: [RFC PATCH v2 04/11] PCI/P2PDMA: Introduce pci_p2pdma_should_map_bus() and pci_p2pdma_bus_offset() Message-ID: <20210316081416.GB16595@lst.de> References: <20210311233142.7900-1-logang@deltatee.com> <20210311233142.7900-5-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210311233142.7900-5-logang@deltatee.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Stat-Signature: n79k3duujixyeogbssapcrozibuyoqdg X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 05FA1E0011ED Received-SPF: none (lst.de>: No applicable sender policy available) receiver=imf05; identity=mailfrom; envelope-from=""; helo=verein.lst.de; client-ip=213.95.11.211 X-HE-DKIM-Result: none/none X-HE-Tag: 1615882459-392682 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Mar 11, 2021 at 04:31:34PM -0700, Logan Gunthorpe wrote: > Introduce pci_p2pdma_should_map_bus() which is meant to be called by > DMA map functions to determine how to map a given p2pdma page. > > pci_p2pdma_bus_offset() is also added to allow callers to get the bus > offset if they need to map the bus address. > > Signed-off-by: Logan Gunthorpe > --- > drivers/pci/p2pdma.c | 50 ++++++++++++++++++++++++++++++++++++++ > include/linux/pci-p2pdma.h | 11 +++++++++ > 2 files changed, 61 insertions(+) > > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > index 7f6836732bce..66d16b7eb668 100644 > --- a/drivers/pci/p2pdma.c > +++ b/drivers/pci/p2pdma.c > @@ -912,6 +912,56 @@ void pci_p2pdma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, > } > EXPORT_SYMBOL_GPL(pci_p2pdma_unmap_sg_attrs); > > +/** > + * pci_p2pdma_bus_offset - returns the bus offset for a given page > + * @page: page to get the offset for > + * > + * Must be passed a PCI p2pdma page. > + */ > +u64 pci_p2pdma_bus_offset(struct page *page) > +{ > + struct pci_p2pdma_pagemap *p2p_pgmap = to_p2p_pgmap(page->pgmap); > + > + WARN_ON(!is_pci_p2pdma_page(page)); > + > + return p2p_pgmap->bus_offset; > +} > +EXPORT_SYMBOL_GPL(pci_p2pdma_bus_offset); I don't see why this would be exported. > +EXPORT_SYMBOL_GPL(pci_p2pdma_dma_map_type); Same here. Also the two helpers don't really look very related. I suspect you really want to move the p2p handling bits currenly added to kernel/dma/direct.c into drivers/pci/p2pdma.c instead, as that will allow direct access to the pci_p2pdma_pagemap and should thus simplify things quite a bit.