From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030398AbdADN31 (ORCPT ); Wed, 4 Jan 2017 08:29:27 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:56269 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936089AbdADN3U (ORCPT ); Wed, 4 Jan 2017 08:29:20 -0500 From: Arnd Bergmann To: Nikita Yushchenko Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Catalin Marinas , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Simon Horman , linux-pci@vger.kernel.org, Bjorn Helgaas , artemi.ivanov@cogentembedded.com Subject: Re: [PATCH 1/2] arm64: dma_mapping: allow PCI host driver to limit DMA mask Date: Wed, 04 Jan 2017 14:29:01 +0100 Message-ID: <2104402.puPT8SttTe@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <4bbc3494-bf95-9765-ccaf-cc3b3e1cd297@cogentembedded.com> References: <1483044304-2085-1-git-send-email-nikita.yoush@cogentembedded.com> <5224989.KFLmAz9Gqk@wuerfel> <4bbc3494-bf95-9765-ccaf-cc3b3e1cd297@cogentembedded.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:vFnjJxfaCWP5X3kDJP3qLtPmZIOtTYHOLZB7zqF2sw3NFeFz4Da ynTeHqRKd9gmKTZZebNJRIMO6w4LRp9Z8vDjwDRaEHfdIf85zBxOcCyL0xm+K56tDE5RWeS RQzLo/TzEqah3+9XBM9whfg8tjUtNxxeQKw5PbrHSQ2Nt9FPoPDDU1KYNZFwnPrHM26+n45 elY+/S/Wh0XhgUHTef4JQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:+V2o5FUi3wM=:P61S98+tcZRtaSNQ9PwZaK QofTrU5bGiHKZzFv5oNhLI91zIhvPqfX5ZHkLgzfKEk8foJcos/EiqzWZCmIew76McuNiQ+N2 tD5yJ+AWilOpz9aKya3ape/xquIW3dj4SFnFlnuPM9wf2uwz0sn23VPQhjQdt0lXUQl/NhKM5 zNtSgSfjsGj8FAt4DV+aSeMQaN3dFMF1NvS0DSFMihznnXwBe2jTFbL1XWY44LA+H7V77hIrb VDrdEjnXxjKorC97ik9NudvjVIFyRjcvkQDa8hE8Os/U3oFR/+gruxW9DWJyR2F+kaT9AZNoI 1c7ozepGPxyBZzbJiHtvQH19Ox8V5ps5A1LEh9+h2KZshwjPLXrsztRBHlk6IztQACIGICvbQ oSHkry+8S8k6+l10v1RMm8j6Djx9sMNTCKveUnMW1/FfKev7phxRA3adkn5ciZIGTpDvFyCxc +pU3zRF6QCYlX0p+XDLLwyfet/yE2UILT5E9Rwph4ra5a51agtD+uUkkzkv4YTaXWJY5estL3 DTQbD+7UHHpDY9zvU2Y5d91u0F8z9HWGdkJsXwT+A5fIOjT9J6z/ZLwsVpoglhuJMtNjjp9zt sqESFN2chQCOLA24zFxgVVGCPA37pcgmgiByksoRL2TEskUkr28PJyyyT4fLWIquN9JlXi1r0 9VMWfAA2LhNSYU4KiBCFRnS1RILxGSxGC+rKjWIJaZ3jcc6FqAF9K/v+oABO7HaOjyhjkL8TR uxkybEH41VvYQBAX Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, January 4, 2017 9:24:09 AM CET Nikita Yushchenko wrote: > > commit 9a57d58d116800a535510053136c6dd7a9c26e25 > > Author: Arnd Bergmann > > Date: Tue Nov 17 14:06:55 2015 +0100 > > > > [EXPERIMENTAL] ARM64: check implement dma_set_mask > > > > Needs work for coherent mask > > > > Signed-off-by: Arnd Bergmann > > Unfortunately this is far incomplete > > > @@ -957,6 +983,18 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, > > if (!dev->archdata.dma_ops) > > dev->archdata.dma_ops = &swiotlb_dma_ops; > > > > + /* > > + * we don't yet support buses that have a non-zero mapping. > > + * Let's hope we won't need it > > + */ > > + WARN_ON(dma_base != 0); > > + > > + /* > > + * Whatever the parent bus can set. A device must not set > > + * a DMA mask larger than this. > > + */ > > + dev->archdata.parent_dma_mask = size; > > + > > ... because size/mask passed here for PCI devices are meaningless. > > For OF platforms, this is called via of_dma_configure(), that checks > dma-ranges of node that is *parent* for host bridge. Host bridge > currently does not control this at all. We need to think about this a bit. Is it actually the PCI host bridge that limits the ranges here, or the bus that it is connected to. In the latter case, the caller needs to be adapted to handle both. > In current device trees no dma-ranges is defined for nodes that are > parents to pci host bridges. This will make of_dma_configure() to fall > back to 32-bit size for all devices on all current platforms. Thus > applying this patch will immediately break 64-bit dma masks on all > hardware that supports it. No, it won't break it, it will just fall back to swiotlb for all the ones that are lacking the dma-ranges property. I think this is correct behavior. > Also related: dma-ranges property used by several pci host bridges is > *not* compatible with "legacy" dma-ranges parsed by of_get_dma_range() - > former uses additional flags word at beginning. Can you elaborate? Do we have PCI host bridges that use wrongly formatted dma-ranges properties? Arnd