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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 175C1C282DE for ; Thu, 23 May 2019 15:59:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DFA1D20868 for ; Thu, 23 May 2019 15:59:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730752AbfEWP7X (ORCPT ); Thu, 23 May 2019 11:59:23 -0400 Received: from ale.deltatee.com ([207.54.116.67]:49754 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730790AbfEWP7X (ORCPT ); Thu, 23 May 2019 11:59:23 -0400 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1hTq7m-0007Se-4l; Thu, 23 May 2019 09:59:22 -0600 To: Christoph Hellwig , "Koenig, Christian" Cc: "linux-pci@vger.kernel.org" , Bjorn Helgaas References: <97aa52fc-f062-acf1-0e0c-5a4d1d505777@deltatee.com> <20190523094322.GA14986@lst.de> <20190523095057.GA15185@lst.de> <20190523102608.GA15800@lst.de> From: Logan Gunthorpe Message-ID: <9aa5753c-5b76-925f-3fc7-3d79b5aad5fd@deltatee.com> Date: Thu, 23 May 2019 09:59:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190523102608.GA15800@lst.de> 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: bhelgaas@google.com, linux-pci@vger.kernel.org, Christian.Koenig@amd.com, hch@lst.de X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH] PCI/P2PDMA: Root complex whitelist should not apply when an IOMMU is present 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-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On 2019-05-23 4:26 a.m., Christoph Hellwig wrote: > On Thu, May 23, 2019 at 10:06:28AM +0000, Koenig, Christian wrote: >> Ok, we certainly don't have a system which exercise this user case. >> Could ask around if we have an ARM SOC with that properties somewhere. >> >> But asking the other way around: Where is the right place to start >> fixing all this? dma_map_resource()? > > That is the the big gorrilla in the room. The offset applies to the > device whos BARs/resources we map. The current dma_map_resource API > does not even have the right information. So I think we need to > enhance the API to pass a second struct device and we could fix it > there and then in the next steps add a map_sg version of > dma_map_resource and eventually also convert the PCIe P2P map_sg > over to that. IMO, this logic belongs in pci_p2pdma_map_* helpers that call dma_map_* helpers when appropriate. Changing dma_map_resource() to take two devices won't always make sense. For example, there are existing use cases of dma_map_resource() that work with the Intel IOAT DMA engine and thus it's known that those transactions will always go through the IOMMU if it's enabled; and therefore the existing dma_map_resource() is appropriate. Logan