Received: by 10.223.176.46 with SMTP id f43csp1186819wra; Wed, 24 Jan 2018 12:05:54 -0800 (PST) X-Google-Smtp-Source: AH8x2253QJqKwFIsft+mgSg3fJqjJ7RL8XNChfnff3IZ9Cicg0v7wA5u4IrSbM5ro8zS1XVlAGLa X-Received: by 2002:a17:902:8d88:: with SMTP id v8-v6mr9360263plo.47.1516824354070; Wed, 24 Jan 2018 12:05:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516824354; cv=none; d=google.com; s=arc-20160816; b=o4IRGm7PqylWmpHt6ZdVbTqeQAar50yjKoJbojot9Lig8IBsqHX8ytHC2RRliOHStS euCeznX07p3KkSqHCwN4QsZ0Ux7Jc4nOIOOyBkuVawMMtsl9pKC02HGGVhrPMJap864H 12CK98hkCmuh++qebeKIUrpj7Dwxd+G3f8qhLEO+8/FrmmqAtYs3zyz2LmyHImIcBRGF J+AFRYuTAG/Fu/gA2nizq9cyZCxxi6VY4iacw6aFVl53Pzf2eF+IMJ60QJw0FQ3Epjh8 0KGdgnS3KwHn8se0jqMO9ocfoPNaeus625wxvGPCW3rfJmkjFL+306XaqqxtF0IQpgsy nsuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=nIHN/4Vgk1QjDI8Zjl2FUUGwE7mGDAVyADiOnl9956E=; b=L4qeS/JrYCtrhuRRTX1qn2widCXK9ilKtyCKX+Oq3eSuHfIWR5O7tVzEnWvThIgxdZ FVZbKHjrv4apMZu5alEXRMzf0VvlGObUXPSW6o0I8BzTbXKxYrYlbR1e2ph+5/8lPSc/ hSBLWUFrEpxB9QWrs1bm1hEMGIvyLYjx+82Mc5QB6BwdspMf9yLVfSMyrZOneaz4u6ig Qb3lZzBwu0rd09K4qv2ZStW19oIUGhwRP0+8kAijMMsjHF8bItDk03y+vifnRqpT4Rx1 sgTHZfIgWxhbf8691VIbnyVQCVsS3J/8ZmnplfsuHO8WLTcUB/kCer5fp2hUKOQ6/dnv Lpsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S+WX6hfF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3-v6si660552pld.374.2018.01.24.12.05.39; Wed, 24 Jan 2018 12:05:54 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S+WX6hfF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932541AbeAXUFG (ORCPT + 99 others); Wed, 24 Jan 2018 15:05:06 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:37765 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932072AbeAXUFE (ORCPT ); Wed, 24 Jan 2018 15:05:04 -0500 Received: by mail-qt0-f194.google.com with SMTP id d54so13593628qtd.4; Wed, 24 Jan 2018 12:05:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nIHN/4Vgk1QjDI8Zjl2FUUGwE7mGDAVyADiOnl9956E=; b=S+WX6hfFnQHsS+aJeBJiHjYejgYX1G0arFPNnhHXZG5ZmBUXaHLzuvtjGWI/vgyqKP St6HBX18ybJG3KpsK4DvQHRzRogU2CrLG33CkLBXFCeA/LhHfCZ/MevlvNmjcb73EW7F nWLU29YjDoLjwRzfyV2GeJZuMbsypOH7USqui4UvJcUF4Dz7/SaoHwRs4z2i/ReFvKAj JlhEU/rz90zxmcapeICHeoZ7qpM+r8OSzUjZjuYzM9x0O4BcBfhb6i+3AddbqvJa52lv lKgC5yKkaOWoglrW40LnEVzeVN3tvbB0zZwqO37OcvNuvR108DgqkQvW+lfTwozotROc ruoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nIHN/4Vgk1QjDI8Zjl2FUUGwE7mGDAVyADiOnl9956E=; b=DokFdW4HR88a1a6xyfJOXobPlTbPWuR3Ff/4xpG3nqyGpv8sA15nWONy/Y64Q0qDLp Vx/5ZdUnG/bP6LTzjvQYpFQObZohvVCl6aLrA1kwt9t/KdR74sMvhN6uOxzMeYIj3u1u VnYBnGBF/GmpyvqESjUGIpGbpF7ELZH/iONlDIrFOc4Ajo8cBLKZH02zVhaEzZOSYGG/ JvEd1fyMSWNl2CMwdz5OuDFfZeJVZBOk1OHJAUHGalWDEUO8L0wyxJcdRFt/csuZsbbK SJF7aZCqUrV44Ng7xcrVh5V27xnath4ojHMbmuM+LZiSKe+va/Y+0eKsWp/kTs6OQAzA mEqA== X-Gm-Message-State: AKwxytc0utD97fwWrve8fNrSfIVquIsPktei5JsZPCm2O0pZa4GA2Dg/ wC9yNn8AYLDKumLfQx7YbHM= X-Received: by 10.55.129.195 with SMTP id c186mr11115163qkd.352.1516824303503; Wed, 24 Jan 2018 12:05:03 -0800 (PST) Received: from [10.69.41.93] ([192.19.223.250]) by smtp.googlemail.com with ESMTPSA id m1sm762038qkf.8.2018.01.24.12.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 12:05:02 -0800 (PST) Subject: Re: [PATCH v4 4/8] PCI: brcmstb: Add dma-range mapping for inbound traffic To: Christoph Hellwig Cc: Rob Herring , Jim Quinlan , "linux-kernel@vger.kernel.org" , Bjorn Helgaas , Catalin Marinas , Will Deacon , Brian Norris , Russell King , Robin Murphy , Jonas Gorski , Lorenzo Pieralisi , Mark Rutland , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux-MIPS , linux-pci@vger.kernel.org, Kevin Cernekee , Ralf Baechle , bcm-kernel-feedback-list@broadcom.com, Gregory Fong , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" References: <1516058925-46522-1-git-send-email-jim2101024@gmail.com> <1516058925-46522-5-git-send-email-jim2101024@gmail.com> <20180118073123.GA15766@lst.de> <20180118152331.GA24461@lst.de> <20180123132033.GA21438@lst.de> From: Florian Fainelli Message-ID: Date: Wed, 24 Jan 2018 12:04:58 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180123132033.GA21438@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/23/2018 05:20 AM, Christoph Hellwig wrote: > On Fri, Jan 19, 2018 at 11:47:54AM -0800, Florian Fainelli wrote: >> How can this work well in the context of a loadable module for instance? >> For MIPS, this would mean that we have to override phys_to_dma() and >> dma_to_phys() in the platform that is *susceptible* to use this PCIe >> controller (arch/mips/bmips) which is fine, but there, we essentially >> need to find a way to make this dynamic based on whether the PCIe >> controller is loaded or not. >> >> As you might have seen from this patch, what needs to be done is highly >> dependent on the processor architecture and its memory controller >> physical memory map, so I don't see how we are in any better situation >> if we need to replicate 3 times across MIPS, ARM and ARM64 how the >> addresses need to be mangled. >> >> Are you suggesting we somehow decouple the memory mangling part into a >> portion that can be built into the kernel image (so phys_to_dma() and >> dma_to_phys() is resolved at vmlinux link time) and can be selected by >> different architectures that need it? If so, yikes. > > On architectures with crazy PCIe controllers (this seems to include > mips, arm, arm64 and x86 thanks to the weird SOCs) we will need a > a few different memory maps, yes. Take a look at > arch/x86/pci/sta2x11-fixup.c, preferably from a tree where the worst > issues are fixed: > > http://git.infradead.org/users/hch/misc.git/blob/refs/heads/dma-direct-all:/arch/x86/pci/sta2x11-fixup.c > > Overriding phys_to_dma and dma_to_phys is required if you need to > support swiotlb, and chances are with a broken PCIe controller on > arm64 or mips64 you eventuall will. > > This sta2x11 code should probably be lifted to common code in > one form or another eventually, althought it will need another > fair round of cleanups for now. This looks nicer than the current shape, but this still requires to register a PCI fixup to override phys_to_dma() and dma_to_phys(), and it would appear that you have dodged my question about how this is supposed to fit with an entirely modular PCIe root complex driver? Are you suggesting that we split the module into a built-in part and a modular part? > >> I can see value in having a generic mechanism, ala X86_DMA_REMAP >> allowing architectures to have the ability to override phys_to_dma() and >> dma_to_phys() but right now, especially if we look at >> arch/x86/pci/sta2x11-fixup.c this really appears to be quite messy and >> equally ugly than stacking operations... >> >> What is the actual problem you want to avoid with the stacking of DMA >> operations, is it because it becomes harder to audit, or are there are >> other reasons? > > Audit, consolidate into a single dma-direct implementation and properly > support swiotlb out of the box. > OK. -- Florian