Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3737502yba; Tue, 23 Apr 2019 08:48:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxU/2Lup8+bb9AcZ5Zj34sJIg9Cv43KlYZFDqpSypwrSF9P687u1H5VoibHFJgK1AskBSKx X-Received: by 2002:a63:494f:: with SMTP id y15mr25264140pgk.56.1556034507867; Tue, 23 Apr 2019 08:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556034507; cv=none; d=google.com; s=arc-20160816; b=qxLSrywhkF77Pu4r0/pzn+c4EzpXokmU6Rs/HQehbo4EM+XOeUX2CwCGCrVJLc7/bp XWrogMs/JQKej38ihw0pj2VBjzW0y3eVMqrMEP+PHMIoAWJGTkJndb7SqQAXObgvIBQ4 mA7UQKcw21JNgANPZ/230NwtuTex3X7du/qH6TkeDxto6KfDeqOQubzxI+0qpDPrh10y rOauMyn4M2WlTrpirtMTaBRgwTSIULxuUcps/NX11TuvVivQ+sR58j8dWeiE8Ol0v8TN lS5D+rMfyJsRp57gGj/RLJPEPi4FUV4x8Lz0vVB0KB/sABCTsHsgtnB+9UUMFzL0mYYL 1ljA== 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:dkim-signature; bh=A4iIhnsZU7J2vll0d0zWkLIhjY/2bJSoCVPuO7unpSw=; b=pAa2g8/U7eEDbjh2hzWYEkajAefJKG9p3etXBpahjsPAQ/Hd4OGLRs4xlXk8W466S2 AuRnyKG/giQ5Gc3ueGzrBRakkJ/EfhLNYuNR2BcrmSjglaOOG/f8NewBwqDGUhc1ZFXB k8vdI1wcaJhcauif0GCH0bA5ipg/D4xWhRDDN8wJ0qf7liqF2MAT03D8nt3kSWRDWsz6 G0uLt18xP4IiVYc75TBIGrtLN+V43P8JVU0h3mCvsmcski80RZ5SZjvSotYxH/Q+Wefm wv3g0laXxDGrimjsNhKCOLZZmIu8oE4GTBjPuimQS17mUJVPUSa/QsxjbhKvI77k55nV EA7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="sxjGlt/R"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1si16855581pff.158.2019.04.23.08.48.12; Tue, 23 Apr 2019 08:48:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b="sxjGlt/R"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728497AbfDWPq5 (ORCPT + 99 others); Tue, 23 Apr 2019 11:46:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:41048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727467AbfDWPq4 (ORCPT ); Tue, 23 Apr 2019 11:46:56 -0400 Received: from guoren-Inspiron-7460 (23.83.240.247.16clouds.com [23.83.240.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E36B02175B; Tue, 23 Apr 2019 15:46:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556034415; bh=xlGscSs9dL++G38J6mR9vhBpBgSSGaJk6NuPAmkk4ZY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sxjGlt/RLN5FWJu3zm9yn7ED1H8Wq1e8MepLObKBUMimx+34tJgixpBn+zxiMcgdo tu7FzUwnpdYI7OVVF28cPpdmDsB6FN5xOUi2vFZeigTCAgcEJ556VywrxjCHFr0qF2 rBMnPVss4iyiv2MPvrB5GQIkiGcFw4Ds6gd6F/kQ= Date: Tue, 23 Apr 2019 23:46:42 +0800 From: Guo Ren To: Christoph Hellwig Cc: 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: <20190423154642.GA16001@guoren-Inspiron-7460> References: <1555947870-23014-1-git-send-email-guoren@kernel.org> <20190422161814.GA30694@lst.de> <20190423001348.GA31639@guoren-Inspiron-7460> <20190423055548.GA12365@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190423055548.GA12365@lst.de> User-Agent: Mutt/1.5.24 (2015-08-30) 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 07:55:48AM +0200, Christoph Hellwig wrote: > 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: dcache.c/iva means three instructions: - dcache.cva %0 : writeback by virtual address cacheline - dcache.iva %0 : invalid by virtual address cacheline - dcache.civa %0 : writeback+inv by virtual address cacheline We also have memory barrier instructions, ref: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/csky/include/asm/barrier.h > > 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. I think using sbi_call as a temporary solution is a good choice before the instruction is determined. > > > > 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. Yes, memory don't need strong order and strong order in PMA also implies uncached, unbuffered for IO address. If the entry of PMA is strong order, the page mapping must be uncached + unbuffered + strong-order without _PAGE_COHENCY in PTE. > > > 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. Yes, but hardware could ignore one of them and in riscv linux _PAGE_GLOBAL is no use at all, see: grep _PAGE_GLOBAL arch/riscv -r In fact, the _PAGE_KERNEL for pte doesn't contain _PAGE_GLOBAL and it works on FU540 and qemu. As I've mentioned page attribute bits is very precious, define a useless bit make people confused. > > > - 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. Agree. Best Regards Guo Ren