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=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 21C13C7618B for ; Wed, 24 Jul 2019 06:32:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 040AD229ED for ; Wed, 24 Jul 2019 06:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbfGXGcj (ORCPT ); Wed, 24 Jul 2019 02:32:39 -0400 Received: from verein.lst.de ([213.95.11.211]:48050 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbfGXGci (ORCPT ); Wed, 24 Jul 2019 02:32:38 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 40A0E68C65; Wed, 24 Jul 2019 08:32:36 +0200 (CEST) Date: Wed, 24 Jul 2019 08:32:36 +0200 From: Christoph Hellwig To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org, Bjorn Helgaas , Christoph Hellwig , Christian Koenig , Jason Gunthorpe , Sagi Grimberg , Keith Busch , Jens Axboe , Dan Williams , Eric Pilmore , Stephen Bates Subject: Re: [PATCH 14/14] PCI/P2PDMA: Introduce pci_p2pdma_[un]map_resource() Message-ID: <20190724063235.GC1804@lst.de> References: <20190722230859.5436-1-logang@deltatee.com> <20190722230859.5436-15-logang@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190722230859.5436-15-logang@deltatee.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org > diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c > index baf476039396..20c834cfd2d3 100644 > --- a/drivers/pci/p2pdma.c > +++ b/drivers/pci/p2pdma.c > @@ -874,6 +874,91 @@ void pci_p2pdma_unmap_sg_attrs(struct device *dev, struct scatterlist *sg, > } > EXPORT_SYMBOL_GPL(pci_p2pdma_unmap_sg_attrs); > > +static pci_bus_addr_t pci_p2pdma_phys_to_bus(struct pci_dev *dev, > + phys_addr_t start, size_t size) > +{ > + struct pci_host_bridge *bridge = pci_find_host_bridge(dev->bus); > + phys_addr_t end = start + size; > + struct resource_entry *window; > + > + resource_list_for_each_entry(window, &bridge->windows) { > + if (window->res->start <= start && window->res->end >= end) > + return start - window->offset; > + } > + > + return DMA_MAPPING_ERROR; This does once again look very expensive for something called in the hot path.