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=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_MUTT 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 7FCF7C282DD for ; Thu, 23 May 2019 15:59:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E04720851 for ; Thu, 23 May 2019 15:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730893AbfEWP7p (ORCPT ); Thu, 23 May 2019 11:59:45 -0400 Received: from verein.lst.de ([213.95.11.211]:47707 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730790AbfEWP7p (ORCPT ); Thu, 23 May 2019 11:59:45 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 09BBF68AFE; Thu, 23 May 2019 17:59:23 +0200 (CEST) Date: Thu, 23 May 2019 17:59:22 +0200 From: Christoph Hellwig To: Logan Gunthorpe Cc: Christoph Hellwig , "Koenig, Christian" , "linux-pci@vger.kernel.org" , Bjorn Helgaas Subject: Re: [PATCH] PCI/P2PDMA: Root complex whitelist should not apply when an IOMMU is present Message-ID: <20190523155922.GA21552@lst.de> References: <97aa52fc-f062-acf1-0e0c-5a4d1d505777@deltatee.com> <20190523094322.GA14986@lst.de> <20190523095057.GA15185@lst.de> <252313a9-9af4-14bd-1bfa-1c2327baf2b2@deltatee.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <252313a9-9af4-14bd-1bfa-1c2327baf2b2@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 On Thu, May 23, 2019 at 09:53:53AM -0600, Logan Gunthorpe wrote: > > 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). True. What we need is: if (both device are behind the same root port (using a switch)) { use the current direct map + offset code } else { call ->map_resource() }