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 951CDC282DD for ; Thu, 23 May 2019 15:53:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7197A217D9 for ; Thu, 23 May 2019 15:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730760AbfEWPxz (ORCPT ); Thu, 23 May 2019 11:53:55 -0400 Received: from ale.deltatee.com ([207.54.116.67]:49658 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730752AbfEWPxz (ORCPT ); Thu, 23 May 2019 11:53:55 -0400 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.89) (envelope-from ) id 1hTq2U-0007Ph-6a; Thu, 23 May 2019 09:53:54 -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> From: Logan Gunthorpe Message-ID: <252313a9-9af4-14bd-1bfa-1c2327baf2b2@deltatee.com> Date: Thu, 23 May 2019 09:53:53 -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: <20190523095057.GA15185@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 3:50 a.m., Christoph Hellwig wrote: > On Thu, May 23, 2019 at 09:48:40AM +0000, Koenig, Christian wrote: >> I don't adjust the address manually anywhere. I just call >> dma_map_resource() and use the resulting DMA address to access the other >> devices PCI BAR. >> >> At least on my test system (AMD CPU + AMD GPUs) this seems to work >> totally fine. Currently trying to find time and an Intel box to test it >> there as well. > > The problem shows up if pci_bus_address() returns a different address > than pci_resource_start(), should be easy to check if that happens. > IIRC it is something mostly seen on embedded SOCs. > I think it's a bit more complicated then that: If you're calling dma_map_resource() to program the IOMMU then I'm pretty sure you'd want to use the pci_resource_start() address as the phys_addr_t. If you're bypassing the root complex (like the current p2pdma code enforces), then you'd simply use a pci_bus_address() directly as the dma_addr and would not program the IOMMU at all seeing it's not involved (which is what is currently done). Logan