Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3210962yba; Mon, 22 Apr 2019 22:58:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqxixrrnnnbO28GsVI5B7jmBnyzj1ITMCdTRfflwMye+c+XBIzJP33SRE8O6OMYvttMsigCe X-Received: by 2002:a17:902:28a9:: with SMTP id f38mr23998171plb.295.1555999122479; Mon, 22 Apr 2019 22:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555999122; cv=none; d=google.com; s=arc-20160816; b=xqEKkfO+TYcaQ1feXhDV0en46TRgUDFkIsPFT//u1o6TsVpYsOr61877Luwj4jKl07 udnaJUtl1w6T6y8tKJDGrl9ZVORfprMBMv6HIs3ocRKSC7q66vGF/87s/qvXCH0PknTW 8JkQNmngoTyMHXZkzsK1ZVDmifUqTm4uUOyPilAfrO5o0CzS2T933X5K4SCOZYhu87Ea +CWhB2poYWnbocEjCbeXS9ixvWgYId/P7+oiHS+nGFltlukLX/BiUgVF30Jx7h+WrdwJ 4U48TCGncGLhGxweET+7vqsGvBLHlxRHgAUNlILFWIKSnsrEifv5nWAqoyIx+5DMxGLe Biaw== 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=NDS0LdehnnyNS23GSYAL3GkV3sXm+Njoc/MU9tyKLQs=; b=eP/u9JXTOc7Bhm5DHoO3uEG4dnGiXlDRh2Xh2PMddGhVkSqRjVVfoVvCczNH/RYJzE H1tdjAv2tkR3UT3XWyUBqjhG7yK6nSlJ+AX9G3vM7Ei0ZujIhlLFo5JNnXoUAppkJczf gNk++docYvpJYcesr/MVVGTSEZEHF5HkLmJHScUpI//v8p9TBuYuNChqtUt7QD07Iu3E 00qJigcXfLkNrkJ/kmjEwRNGyeSs/LRAzcEXVLjREpxOgxyHYvXY0kwUR1UCLjiGuMsn 5lXmCmVsiB2jq1Ha6PdUQgTKiRni1aGeTXX1mNnOXD8FIVMd/LbWc5a6YdOY6dov/qiT CynQ== ARC-Authentication-Results: i=1; mx.google.com; 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 b17si15741491pfj.200.2019.04.22.22.58.27; Mon, 22 Apr 2019 22:58:42 -0700 (PDT) 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; 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 S1726155AbfDWF4H (ORCPT + 99 others); Tue, 23 Apr 2019 01:56:07 -0400 Received: from verein.lst.de ([213.95.11.211]:44208 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfDWF4H (ORCPT ); Tue, 23 Apr 2019 01:56:07 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 4150C68B02; Tue, 23 Apr 2019 07:55:49 +0200 (CEST) Date: Tue, 23 Apr 2019 07:55:48 +0200 From: Christoph Hellwig To: Guo Ren Cc: Christoph Hellwig , ren_guo@c-sky.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, tech-privileged@lists.riscv.org, Andrew Waterman , Anup Patel , Arnd Bergmann , Greentime Hu , Marek Szyprowski , Mike Rapoport , Palmer Dabbelt , Robin Murphy , Scott Wood , Vincent Chen , Xiang Xiaoyan Subject: Re: [PATCH] riscv: Support non-coherency memory model Message-ID: <20190423055548.GA12365@lst.de> References: <1555947870-23014-1-git-send-email-guoren@kernel.org> <20190422161814.GA30694@lst.de> <20190423001348.GA31639@guoren-Inspiron-7460> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190423001348.GA31639@guoren-Inspiron-7460> 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 Tue, Apr 23, 2019 at 08:13:48AM +0800, Guo Ren wrote: > > We should probably start a working group for this ASAP unless we can > > get another working group to help taking care of it. > Good news, I prefer to use instructions directly instead of SBI_CALL. > > Our instruction is "dcache.c/iva %0" (one cache line) and the parameter is > virtual address in S-state. When get into M-state by SBI_CALL, we could > let dcache.c/iva use physical addres directly and it needn't kmap page > for RV32 with highmem (Of cause highmem is not ready in RV32 now). So you only have one instruction variant? Normally we'd have two or three to implement the non-coherent DMA (or pmem) semantics: cache writeback, cache invalidate and potentially cache writeback + invalidate to optimize that case. Here is the table how Linux uses them for DMA: | map == for_device | unmap == for_cpu |---------------------------------------------------------------- TO_DEV | writeback writeback | none none FROM_DEV | invalidate invalidate | invalidate* invalidate* BIDI | writeback+inv writeback+inv | invalidate invalidate [*] needed for CPU speculative prefetches We already have a discussion on isa-dev on something like these instructions: https://groups.google.com/a/groups.riscv.org/forum/#!msg/isa-dev/qXbzqaQbDXU/4ThcEAeCCAAJ It got a little side tracked, both due to the usual noise on isa-dev and due to the proposal including a lot more instructions that might be a little more contentious, but it might be a good start to bring this into a working group. > > Also is this really a coherent flag, or an 'uncached' flag like in > > many other architectures? > There are a lot of features about coherency attributes, eg: cacheable, > bufferable, strong order ..., and coherency is a more abstract name to > contain all of these. In our hardware, coherence = uncached + > unbufferable + (stong order). > > But I'm not very care about the name is, uncached is also ok. My key > point is the bits of page attributes is very precious and this patch > will use the last unused attribute bit in PTE. I don't care about the name actually, more about having defined semantics. Totally uncached should include unbuffered. I don't think we need the strong ordering for DMA memory either. > Another point is we could get more attribute bits by modify the riscv > spec: > - Remove Global bit, I think it's duplicate with the User bit in linux. It is in Linux, but it is conceptually very different. > - Change _PAGE_PFN_SHIFT from 10 to 12, because the huge pfn in RV32 is > very useless and current RV32 linux doesn't even implement highmem. This would seem sensible to me, but I'm not sure everyone agrees. Even then we are very late in the game for changes like that.