Received: by 10.223.176.46 with SMTP id f43csp2152537wra; Thu, 25 Jan 2018 05:49:56 -0800 (PST) X-Google-Smtp-Source: AH8x227LqNNjZsmt+W4v9o2JhpKGLrNFoPPldjlwe79ZZdX2cDTXWKVW9CvYIovp6xqSXwDikQ0b X-Received: by 2002:a17:902:868f:: with SMTP id g15-v6mr8902633plo.137.1516888196327; Thu, 25 Jan 2018 05:49:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516888196; cv=none; d=google.com; s=arc-20160816; b=XRtXz6x96C5XKSKOrCBYdWqtYx993dZ7Unf0oiQO3YXVYrgkHlVUYA7KOzeD991Gn3 NrbUtTNXVlx+VPBAafLYCFv/AX7ZjNZdoRF4O592jrUQ8MKQpxd+2RCDkPRih1T+xMi9 OmgCTily6GYpESaxjeuzJ/HDgSsDgy6cY6ZXxy+5H5GYGp/BzLJYpTW6sL3osSTXE9F2 0XfpoNtnI0/CPPgdE1S9BJpiQ6LINFZsetThbRc892oPEgs09xkYf5rxNv2GEzVRhHMq NKKjvHW3ik6li8CP2B250yZsVqeu8Zc8RGfCIs+JxFflBhnqXF3pGkffmM0hTMKTVyFe 8RbA== 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=57EzkaZVDwo/UAg3qOUuQFa0yiIEF7i25aKY+cTN5/M=; b=V9gU/bze6gM+Jm4eqmHJSe83PJTMkCLSojX2nzTqUkS4H3Pk2DOuicg/USJk/T1jFB wlJXIV1owCcEMAGyQIja6lRszbxYC3i34R1/56xRKzYjU8CkekOgx0/EIb9dWFNwIMQd v+kV+ww4F67rEsJU5TwFlvyRLqQ7mrUFgqc76H5tUjtP+k2fM2bgZ5PSUZotRr4BDZB1 v6AUW5cStPRPkzAnTt9GACXVNcUn+m54+bguVGPUKpsU6RMzgFjuqVLk5Cbx7HD3EtCl kuN1jx5zG3aD8nDft2mF7cXaw5M5+sezV6TmRoCqkMkDyTX0IpFFoHex0GRllD0Wkh/s WlPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=A3f79s7f; 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 c3si2086800pfi.244.2018.01.25.05.49.41; Thu, 25 Jan 2018 05:49:56 -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=A3f79s7f; 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 S1751405AbeAYNsq (ORCPT + 99 others); Thu, 25 Jan 2018 08:48:46 -0500 Received: from mail-ua0-f193.google.com ([209.85.217.193]:38045 "EHLO mail-ua0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750763AbeAYNsn (ORCPT ); Thu, 25 Jan 2018 08:48:43 -0500 Received: by mail-ua0-f193.google.com with SMTP id e25so2676489uan.5; Thu, 25 Jan 2018 05:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=57EzkaZVDwo/UAg3qOUuQFa0yiIEF7i25aKY+cTN5/M=; b=A3f79s7fc7z57Ul8n+Tx47rvmuElQgzsxFCX3P9NXmTk/h5g7omW9rLOvwqok+ZcJs L4MV+kHHmiP4V7Mf3gryfKQQ0DriMHBYBA/RRpaVnfl2uyLQ7J01zLaeJXhn1dlx2kNr gq5F0JnHiIk2XYmYpSQAc8NpH3zvGVzPqfwjakpFygb+eKW5ekjxFtS8rvLyRtofAul3 nWi+6YHMI4Km2tQsdWUQC6H0myWZMFJYy2vLE3JgN++JrRoKGWncjY47b0lMxXQr4Kfi JXsWtzIUXikDcDVFqwI95Wh+1XZ17RQfMNuP4HFEEq9Akyd7zYjq85Nu07cxNdXm5vjV JUqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=57EzkaZVDwo/UAg3qOUuQFa0yiIEF7i25aKY+cTN5/M=; b=Zv1DcQmcqF4z+biOzekMKbvyKJUJNFNaD2ylByKD8mvTVBGEfuLTyNaiEIWi3rnVaf OjHHghPwnSk4kKqcab7xkAkI2auSQXzDLR7BsBw+LIgg4dJgJg0kbkUVV69Y9YZCxLgC xEIuqDx7tJvCabuK9x9R3Oz2EqN2wcrX2xqEoosf8QXDbs1Ylo7xwaMl/4CPAxmZapUM +FYZggtAlFobgRMkyQLbMv0cRSNPxKHhlCzk+/dwRa1jnNGxEWXy6Wa2aSDvgJx2PPh3 4KUvdpy3WjsmAHXE84v5ihBFjGKRx26SIPZqOhc8Sx3eBlaU8n87Wne1EDFogrOj7L3/ hiQA== X-Gm-Message-State: AKwxytdiuVZC1P9ID10FhcAUPNYVxB3M7C9+Ny9syZ097KLoO9Z/fmLS oOqGuaF7M1qOiPemm0xyOBZjM9PR3DxmGihk92I= X-Received: by 10.159.43.4 with SMTP id p4mr7141431uaj.142.1516888121674; Thu, 25 Jan 2018 05:48:41 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.42.194 with HTTP; Thu, 25 Jan 2018 05:48:01 -0800 (PST) In-Reply-To: References: From: Greentime Hu Date: Thu, 25 Jan 2018 21:48:01 +0800 Message-ID: Subject: Re: [PATCH v6 16/36] nds32: DMA mapping API To: Arnd Bergmann 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 Hi, Arnd: 2018-01-25 18:42 GMT+08:00 Arnd Bergmann : > 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. Thank you for this suggestion. We have optimized in cpu_dcache_wb_range() and it will be called from cpu_dma_wb_range(). It will do nothing if it is a write-through config cache. >>> - 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 Thank you. :)