Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1871774ybt; Sun, 28 Jun 2020 00:25:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgTTYvazzZ7n7wV8eVJys4Q9+cbKvvsdrZOwW9N6IUCkQpd1V8m0Dc2vgm2t4gVzD5tNPc X-Received: by 2002:a17:907:2108:: with SMTP id qn8mr5215360ejb.16.1593329119499; Sun, 28 Jun 2020 00:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593329119; cv=none; d=google.com; s=arc-20160816; b=Ufhlenp44hTLdRxMKEjRM+7M/J2rTOKciVc2nAWl8dJTQ7/pQo+PQiDJmOmsStzd1c R5mqqyS/73r+S6gOoTR4TpOxONktLZnlHIoytgCQ+MrXcHA4GyQ+gUnHd9E+GcdVleBW 5GMfTBEsiRrGgF8EX1y5H/CWbLNSqcLoTaBFf9mhHlOrGZcLdM15/WJQeDbkcmTyWckn rHuKYuiNETYMCO69Jy5jQP8lVKQq2FHkEAdr8dvXRsy+Se5cIDzqJQIX0jPzQqBSlMBS JO/+pgBoRX3IaYhCB4+gFG48jZwNZH+xVlEuk4bibGHlfnHx9ILKnOZqX0aaIS/FlYHO 2qdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZjdXndOxKGmmvBrpi+378QbaxE23oSFHD+Vw5kO0TXM=; b=I1XZ3kc9yulXuL4iie53lIlfQPGocYNxhEAlA2Bap4q1y4iFgJc1MPM78y6RFpsCKd zOlLrHSb/UNiOCW3XdMr9GJPL3LDmJrLHnjgP7RPSPFmV/1cMv/uLRREsANxkORQVM1V REHnX0LDagev+WDV3Kw0vpoWrSwSBZVa/Z+cd/ujHq7MgBzy2PnqT8bQ3ZovPsNHzOFW 4yt8t9YgkgQpzxWmVSXB/Ps6NSMriwINw0+xWqRL1FijrwhpMzrVwG4o6XMK4uGBzjn5 9kJE/E6TbU1uHYTJyHOdN6F5r7OFhCv62GA2y+iw6k9HqbM0nZRILoJNFOngUeH/5iEs 1XHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si11940236edo.175.2020.06.28.00.24.56; Sun, 28 Jun 2020 00:25:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726097AbgF1HYu (ORCPT + 99 others); Sun, 28 Jun 2020 03:24:50 -0400 Received: from verein.lst.de ([213.95.11.211]:55606 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725958AbgF1HYu (ORCPT ); Sun, 28 Jun 2020 03:24:50 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 1D36368AFE; Sun, 28 Jun 2020 09:24:47 +0200 (CEST) Date: Sun, 28 Jun 2020 09:24:46 +0200 From: Christoph Hellwig To: Rob Landley Cc: Christoph Hellwig , Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 09/10] sh: don't allow non-coherent DMA for NOMMU Message-ID: <20200628072446.GB16344@lst.de> References: <20200626080717.1999041-1-hch@lst.de> <20200626080717.1999041-10-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 27, 2020 at 08:01:17PM -0500, Rob Landley wrote: > On 6/26/20 3:07 AM, Christoph Hellwig wrote: > > The code handling non-coherent DMA depends on being able to remap code > > as non-cached. But that can't be done without an MMU, so using this > > option on NOMMU builds is broken. > > I'm working on a nommu j-core board that's doing DMA behind the OS's back at the > moment, which I have a todo item to teach the kernel about. The DMA does not go > through the cache, there's currently a cache flush before looking at the result > instead. > > How should this be wired up after your patch? The problem with nommu and non-coherent dma is the dma_alloc_coherent calls. Most platforms with an mmu set a nocache bit through the page tables (including sh), but that option obviously doesn't exist for nommu. Some hardware has an uncached window where access is uncached automatically if access through specific kernel virtual addresses, for that the architecture needs to impement the arch_dma_set_uncached helper and select CONFIG_ARCH_HAS_DMA_SET_UNCACHED. If that also doesn't exist you'll need some sort of pool of always uncached memory (set by the firmware or early startup code). That currently doesn't exist in generic code, but we have a bunch of architectures implementing that in arch_dma_alloc. I plan to have a common implementation of the pool soon hopefully. Streaming DMA just works if you reuse the existing arch_sync_dma_for_device implementation.