Received: by 10.213.65.68 with SMTP id h4csp609077imn; Fri, 30 Mar 2018 11:48:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/kQ6Xjwz9WGtu1/khXN5pHnnInXQk5/Et75Buc/410ri0ILf1FNIxf09LjP5NZgnlZkZKK X-Received: by 10.99.101.198 with SMTP id z189mr79374pgb.97.1522435690892; Fri, 30 Mar 2018 11:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522435690; cv=none; d=google.com; s=arc-20160816; b=U50DgHLFe/guaKomAYtp/Tu9S0Cnposdk9aYTTqvfyWHlx4jT6ODkVaJ+KjCpltrDx LJ07QgFYk6Jsq7SPNcr1CL/bmwJ/xBxQkHjL8VGp3DIABedAymK9rhPsd8t3mTKx1kSZ TGugcmfDjDPghUjRgVbr1PyOrcrx4toqI8QPIRkR52ILDFUvbpinTlxudXwCYX6WMqql C2/16T5Wkw70RrMBAPEXDALOUaWJh6dweJqah+S2Wzlbm/xAf1PoD1rkduhaOK3t5orP dzRv96i7Xa442voV6xSc79wT35BvcaRJnfWs/T2+ozGiSX7MtRYJEJrlofix6cIIJP6Y VVHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:arc-authentication-results; bh=ifxdjcOXs2eyt63baWDHnVOxTv3q/6WuQawnvNFFi3g=; b=Ey1JpYg7sMB1KsGlI99OY/cke3QrrGBusioHzN8Qs4wqaydHip3qBiCEdGqyew7XvF oSeRH0KZaudv6/RnlY+GufAzZboMe3c+8QZaHGdmkgE8kNTziaJRFj9xYs282K6huZE/ tHZTo3ne5lNO3Lnl2uFlyaOiSflS2bcFjQ91EZ3ggpU/jFoXJFEzlYf5IYoNUJZUcPds dF6tmvRz43oVjfCYTMcjLv3oFe8FX+0XI5AuL0pNPsiL2JMbiaVdjkkpZzbqoWMmpnBt TvzcuAlNZMrP8dRyCsiE79jtoOD5g2JmAPR6dtOQ+2i62uNFviCDWQ3FPD82z3gBy3n9 DcDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5-v6si9327501plk.567.2018.03.30.11.47.57; Fri, 30 Mar 2018 11:48:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752511AbeC3Sqx (ORCPT + 99 others); Fri, 30 Mar 2018 14:46:53 -0400 Received: from ale.deltatee.com ([207.54.116.67]:53108 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752303AbeC3Sqv (ORCPT ); Fri, 30 Mar 2018 14:46:51 -0400 Received: from s0106602ad0811846.cg.shawcable.net ([68.147.191.165] helo=[192.168.0.18]) by ale.deltatee.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1f1z31-0006Wc-J8; Fri, 30 Mar 2018 12:46:48 -0600 To: Jerome Glisse Cc: =?UTF-8?Q?Christian_K=c3=b6nig?= , Christoph Hellwig , linaro-mm-sig@lists.linaro.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, Bjorn Helgaas References: <5498e9b5-8fe5-8999-a44e-f7dc483bc9ce@amd.com> <16c7bef8-5f03-9e89-1f50-b62fb139a36f@deltatee.com> <6a5c9a10-50fe-b03d-dfc1-791d62d79f8e@amd.com> <73578b4e-664b-141c-3e1f-e1fae1e4db07@amd.com> <1b08c13e-b4a2-08f2-6194-93e6c21b7965@deltatee.com> <70adc2cc-f7aa-d4b9-7d7a-71f3ae99f16c@gmail.com> <98ce6cfd-bcf3-811e-a0f1-757b60da467a@deltatee.com> <8d050848-8970-b8c4-a657-429fefd31769@amd.com> <20180330015854.GA3572@redhat.com> From: Logan Gunthorpe Message-ID: <0234bc5e-495e-0f68-fb0a-debb17a35761@deltatee.com> Date: Fri, 30 Mar 2018 12:46:42 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180330015854.GA3572@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 68.147.191.165 X-SA-Exim-Rcpt-To: bhelgaas@google.com, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, hch@infradead.org, christian.koenig@amd.com, jglisse@redhat.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.8 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_EXCLUSIVE autolearn=no autolearn_force=no version=3.4.1 Subject: Re: [PATCH 2/8] PCI: Add pci_find_common_upstream_dev() 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/03/18 07:58 PM, Jerome Glisse wrote: > On Thu, Mar 29, 2018 at 10:25:52AM -0600, Logan Gunthorpe wrote: >> >> >> On 29/03/18 10:10 AM, Christian König wrote: >>> Why not? I mean the dma_map_resource() function is for P2P while other >>> dma_map_* functions are only for system memory. >> >> Oh, hmm, I wasn't aware dma_map_resource was exclusively for mapping >> P2P. Though it's a bit odd seeing we've been working under the >> assumption that PCI P2P is different as it has to translate the PCI bus >> address. Where as P2P for devices on other buses is a big unknown. > > dma_map_resource() is the right API (thought its current implementation > is fill with x86 assumptions). So i would argue that arch can decide to > implement it or simply return dma error address which trigger fallback > path into the caller (at least for GPU drivers). SG variant can be added > on top. > > dma_map_resource() is the right API because it has all the necessary > informations. It use the CPU physical address as the common address > "language" with CPU physical address of PCIE bar to map to another > device you can find the corresponding bus address from the IOMMU code > (NOP on x86). So dma_map_resource() knows both the source device which > export its PCIE bar and the destination devices. Well, as it is today, it doesn't look very sane to me. The default is to just return the physical address if the architecture doesn't support it. So if someone tries this on an arch that hasn't added itself to return an error they're very likely going to just end up DMAing to an invalid address and loosing the data or causing a machine check. Furthermore, the API does not have all the information it needs to do sane things. A phys_addr_t doesn't really tell you anything about the memory behind it or what needs to be done with it. For example, on some arm64 implementations if the physical address points to a PCI BAR and that BAR is behind a switch with the DMA device then the address must be converted to the PCI BUS address. On the other hand, if it's a physical address of a device in an SOC it might need to be handled in a completely different way. And right now all the implementations I can find seem to just assume that phys_addr_t points to regular memory and can be treated as such. This is one of the reasons that, based on feedback, our work went from being general P2P with any device to being restricted to only P2P with PCI devices. The dream that we can just grab the physical address of any device and use it in a DMA request is simply not realistic. Logan