Received: by 10.223.176.46 with SMTP id f43csp1958014wra; Thu, 25 Jan 2018 02:43:57 -0800 (PST) X-Google-Smtp-Source: AH8x22429uMDsveFCLV8YYmXkUCntE6vXWk5Z/JEOjJRsQ3QyY4ibRETGMCxiunlUvJIdfb5rLNf X-Received: by 10.101.80.72 with SMTP id k8mr11939531pgo.361.1516877037214; Thu, 25 Jan 2018 02:43:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516877037; cv=none; d=google.com; s=arc-20160816; b=GZ2aA1kkX8cnxOf9xuAOSD2CAQ/cwaENFFtj8uq3WBYg8TJ5PHTv4WxC59HHJAZmpa oc394KMOO2+2xjqV2fPc3oV+gkHxrRjLM6XDt0w/E1FoTMqwjyFsgWzHthBikmUIarNW Bz04cRArblt3k10TFx7GTHYSKmBYowQmbGmpZXt1mR/GiIw73aGkxTKTK2HydpAb5srz j9MMUXMArf5t1XlurFxlo36ExlOj+mXmeD0UM4VcJ0ZAZ2aRSSPNcengeY3dLAvrwsP2 lFKUASjd6TZ3KqZP1vutNNZYF+ZqVPviTvmdBbOCjKyQL88TKRNFGkYlod63RIjfShuE +NJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=fRu2IgCEBBqNq8wG6QmvDbWGpB5J0+Hhn46P7SJAL4I=; b=zZuSYue/6I4KN6GWxg6I2XwlPsBQFM0idNezjhxLfNqXbpehe9WE/PycE8wXrHZjDE 9GKqaC4tuJ93vZWfNyFV4upGd6muYXT0DB9oK788EsWMiUzK9kumqOyZZ69Kj2T9DpYf I6GZzOMeYXHleKPv0isy4SwUh6Oibmybnp0pJ2r9B/mAVcP/Hbe0fYCgqwoHLvnxi+/3 ECUVrntnoi1gE4p+73wqbmYHo7Ilj1TVvS+yOEBwkqezdQUlUsLnZRxJdq8/VIwY886k 0N6KxnyGKykWrg8Dc6uMMv23oPbDD1XCbGLjNzDYr9IH4gptObX65wg4viRbqt6eCixE HY1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=SB2vgqE4; 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 a15si1417471pgd.21.2018.01.25.02.43.43; Thu, 25 Jan 2018 02:43:57 -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=fail header.i=@gmail.com header.s=20161025 header.b=SB2vgqE4; 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 S1751480AbeAYKmp (ORCPT + 99 others); Thu, 25 Jan 2018 05:42:45 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:36213 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbeAYKmk (ORCPT ); Thu, 25 Jan 2018 05:42:40 -0500 Received: by mail-oi0-f68.google.com with SMTP id w135so4953698oie.3; Thu, 25 Jan 2018 02:42:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=fRu2IgCEBBqNq8wG6QmvDbWGpB5J0+Hhn46P7SJAL4I=; b=SB2vgqE4G5+GAQQ9zvmhDAp0XWFee0t6U7hrYBYB40pThItRlur9Ds5glH9f3mEklY zHdGDjJEx7U8JXQAAcYoTxy4g5HND/kqmIeplz3uyNP0Fe+v5g7Ks3iVYrTZZt6q2u19 ZN2hKUVr9w6ljYBMaQ8CTAtlKrT+JQpW6yg1/YHJlshs1ag+qmLdeO6xyMMlLpVCihgW kHu5nucRoyoCOdAGolokQRmqngaHeua1sDuWrMW8lpsxPrezU+mk0XXcJKeq5p1d0aoa vXQVQDedKSqLZ+GHK17ASHjmZZbrrH0N/Gm94txRDL/gO+WZ9oibSSMf0aVNncVApb4Z fbCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=fRu2IgCEBBqNq8wG6QmvDbWGpB5J0+Hhn46P7SJAL4I=; b=cGayNX0q1vQhrD9ZANrixgkHH3vZoLcFoNsxb2Q9UOjl/VyH39CuOxUxOD+keOLPff CBf7o1HLFa2+Lh7iOzSi45MsSxS4N6pOAZi73GeYAL2+MyJm8YTILQ4nejVdNpX2QLu6 W6YTxzUF/41xd8449/34zLLhxrDP7YppXixYSkDbx3Y4o74yEyiK+5+lgVTBCSJFq+LD HEryBS/mw6nY+riX2bhxUGCpt5+HC9+wUpsFVxo9fp/Q+WKirsZfKqbGN0ksFNfPsO8q o0eYRM97ModlACx5CDZauRmUaqyTafJQSoG24wLXix0AD7suyQEPDKqVXDsYpAmi5VNj /yxg== X-Gm-Message-State: AKwxytd7nJV6CZKWXXimRZQe8IwSgl7paQT2W+e0Y9Sxh6QkrK7kDXnz 2jU2CzIOV2XRInge6zS+ZA/kOhIMoaBXw94htJY= X-Received: by 10.202.114.22 with SMTP id p22mr10298559oic.228.1516876959376; Thu, 25 Jan 2018 02:42:39 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.68.119 with HTTP; Thu, 25 Jan 2018 02:42:38 -0800 (PST) In-Reply-To: References: From: Arnd Bergmann Date: Thu, 25 Jan 2018 11:42:38 +0100 X-Google-Sender-Auth: uIlxy_B-Q55Ceuw8fg5o3OJds6A Message-ID: Subject: Re: [PATCH v6 16/36] nds32: DMA mapping API To: Greentime Hu Cc: Greentime , Linux Kernel Mailing List , linux-arch , Thomas Gleixner , Jason Cooper , Marc Zyngier , Rob Herring , Networking , Vincent Chen , DTML , Al Viro , David Howells , Will Deacon , Daniel Lezcano , linux-serial@vger.kernel.org, Geert Uytterhoeven , Linus Walleij , Mark Rutland , Greg KH , Guo Ren , Randy Dunlap , David Miller , Jonas Bonn , Stefan Kristiansson , Stafford Horne , Vincent Chen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 25, 2018 at 4:45 AM, Greentime Hu wrote: > 2018-01-24 19:36 GMT+08:00 Arnd Bergmann : >> On Tue, Jan 23, 2018 at 12:52 PM, Greentime Hu wrote: >>> 2018-01-23 16:23 GMT+08:00 Greentime Hu : >>>> 2018-01-18 18:26 GMT+08:00 Arnd Bergmann : >>>>> On Mon, Jan 15, 2018 at 6:53 AM, Greentime Hu wrote: >> >> That looks reasonable enough, but it does depend on a number of factors, >> and the dma-mapping.h implementation is not just about cache flushes. >> >> As I don't know the microarchitecture, can you answer these questions: >> >> - are caches always write-back, or could they be write-through? > Yes, we can config it to write-back or write-through. Ok. If a WT-cache is common enough, you could optimize for that case by skipping the explicit writeback here and just doing a synchronizing instruction. Usually if the cache is configurable, one would pick the writeback option though, so it's probably not important. >> - is the CPU physical address always the same as the address visible to the >> device? > Yes, it is always the same unless the CPU uses local memory. The > physical address of local memory will overlap the original bus > address. > I think the local memory case can be ignored because we don't use it for now. Ok, makes sense. >> - are there devices that can only see a subset of the physical memory? > All devices are able to see the whole physical memory in our current > SoC, but I think other SoC may support such kind of HW behavior. This is one area that might need a more complex implementation then, depending on what devices are used in other SoCs. For network or storage devices, it's usually sufficient to configure a DMA mask from the "dma-ranges" property of the parent bus in the device tree, the kernel code will then use bounce buffers. For other types of drivers, using the streaming DMA interfaces can require using the swiotlb helper that performs the bounce buffering at in place of the cache operations. With a bit of luck, you won't ever need to worry about it, just mentioning it here in case you run into that problem later. The consistent_sync() implementaiton you showed earlier should be good enough then. With that change, Acked-by: Arnd Bergmann