Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753784AbbKLQRU (ORCPT ); Thu, 12 Nov 2015 11:17:20 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:49313 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752627AbbKLQRR (ORCPT ); Thu, 12 Nov 2015 11:17:17 -0500 From: Arnd Bergmann To: Phil Edworthy Cc: "linux-arm-kernel@lists.infradead.org" , "Liviu.Dudau@arm.com" , Lorenzo Pieralisi , Magnus , "linux-pci@vger.kernel.org" , Will Deacon , "linux-kernel@vger.kernel.org" , Bjorn Helgaas Subject: Re: PCIe host controller behind IOMMU on ARM Date: Thu, 12 Nov 2015 17:16:41 +0100 Message-ID: <4169020.aC5VXkILQm@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: <6255198.JqytBn7T9E@wuerfel> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:0mmJTrrZBzd8EHJZCF8aKnx3VE21qNYujIoLhnn9QXTAjaUmUVx OGJerTU3b+FMDyBQIFZP9/iszC1YYXn2vpo7+p+0AW+DxN1c0Rn71z0O2igi3ta5FCp5VFc f/vWjz3UMQamq7KQBf8qpgTaV9IHOFy41KNSiDu24gCyvOCLBPnDmhz5OwT0SwjfgCug+5I 8jKk61DlW3jYq0ycL3EFw== X-UI-Out-Filterresults: notjunk:1;V01:K0:a5vDa12ml3M=:f0rpvU5R06tqfl8CFIEkMH tOShC9RckTKfb1m1fqmQ8XWaeJVq9rVfpU1FbKWkrs+52xkAzevTMNp4ibgqOYopggLhE6+MY Ipm5JdNs/oiybF2/sC8neZHyB/k2I/pzhZCsAabe/lBZzam1NemPMxZEXXg+jWb5Oy08EQgXg O4J/X5d2Z7q/XirbnI9tFZrHCJWsf7UcO6fQkNy6ZijR71WqaVcbdDm+oUqXKqp1CGMdvfRvs nmhcUX2b4MkXhYcb3YfEBQ/r4X4MJ3r0uKFm1h6YKTt8ABoYuALaD0+MxdIP9t1itkC0aoNDi 1TwDInv1Xw9LoVHvcbL3fVvqzrWvTFtjgmmuSqZidGRbSNccPyuRmUt6U28A0TclZln4Tseex LEWMcN0j4LcZlon5DVVc2oAMojAhKDt51NbefWFWUd0biBRkzqulCvv958lfODb3XiQmUcM9w RlcQJPSaaY9zrlTnedpx7OYKy3sjoEQFKTxG+zWDlOkKO47JmJcmJ3PybS4m6Bz9Phi01u9Iv tnO92uXD/9A1OTn7GhM74FQOLpgbPd4rRUpjhlxF65Fs6/6bfyI9CN7fNdoOUgFZsPcdpDAha 6/kJhPa312L5sQNHsLrDD8dnGR+H2ZrWJUTzxbI+X8QQdn6KNlDlX/jN5+Fx+KcxgvxtWGdAZ 26LlsMNNTp9R3hvXvXz7HvTn7MyuB5t23kkVeqU2B6FFy/Wk3Kn6vRhYrF+6wERteqw2BDxFn PkYcZwNanxCuSFFA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2284 Lines: 45 On Thursday 12 November 2015 15:33:41 Phil Edworthy wrote: > On 12 November 2015 09:49, Arnd Bergmann wrote: > > On Thursday 12 November 2015 09:26:33 Phil Edworthy wrote: > > > On 11 November 2015 18:25, LIviu wrote: > > > > On Mon, Nov 09, 2015 at 12:32:13PM +0000, Phil Edworthy wrote: > > > > of_dma_configure calls of_dma_get_range to do all this for the PCIe host, > > and then calls arch_setup_dma_ops() so the architecture specific code can > > enforce the limits in dma_set_mask and pick an appropriate set of dma > > operations. The missing part is in the implementation of arch_setup_dma_ops, > > which currently happily ignores the base and limit. > I don't think it's as simple as that, though I could be wrong! > > First off, of_dma_configure() sets a default coherent_dma_mask to 4GiB. > This default is set for the 'platform soc' device. For my own testing I increased > this to DMA_BIT_MASK(63). Note that setting it to DMA_BIT_MASK(64) causes > boot failure that I haven't looked into. Most platform devices actually need the 32-bit mask, so we intentionally followed what PCI does here and default to that and require platform drivers to explicitly ask for a larger mask if they need it. > Then pci_device_add() sets the devices coherent_dma_mask to 4GiB before > calling of_pci_dma_configure(). I assume it does this on the basis that this is a > good default for PCI drivers that don't call dma_set_mask(). > So if arch_setup_dma_ops() walks up the parents to limit the mask, you'll hit > this mask. arch_setup_dma_ops() does not walk up the hierarchy, of_dma_configure() does this before calling arch_setup_dma_ops(). The PCI devices start out with the 32-bit mask, but the limit should be whatever PCI host uses. > Finally, dma_set_mask_and_coherent() is called from the PCI card driver > but it doesn't check the parents dma masks either. The way I think this should work is that arch_setup_dma_ops() stores the allowed mask in the struct device, and that dma_set_mask compares the mask against that. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/