linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Guo Ren <guoren@kernel.org>
Cc: linux-arch@vger.kernel.org, Palmer Dabbelt <palmer@sifive.com>,
	tech-privileged@lists.riscv.org, Arnd Bergmann <arnd@arndb.de>,
	Anup Patel <anup.patel@wdc.com>,
	Xiang Xiaoyan <xiaoyan_xiang@c-sky.com>,
	linux-kernel@vger.kernel.org, Mike Rapoport <rppt@linux.ibm.com>,
	Vincent Chen <vincentc@andestech.com>,
	Greentime Hu <green.hu@gmail.com>,
	ren_guo@c-sky.com, Scott Wood <swood@redhat.com>,
	linux-riscv@lists.infradead.org,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Christoph Hellwig <hch@lst.de>,
	Andrew Waterman <andrew@sifive.com>
Subject: Re: [PATCH] riscv: Support non-coherency memory model
Date: Tue, 23 Apr 2019 07:55:48 +0200	[thread overview]
Message-ID: <20190423055548.GA12365@lst.de> (raw)
In-Reply-To: <20190423001348.GA31639@guoren-Inspiron-7460>

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.

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2019-04-23  5:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22 15:44 [PATCH] riscv: Support non-coherency memory model guoren
2019-04-22 16:18 ` Christoph Hellwig
2019-04-23  0:13   ` Guo Ren
2019-04-23  5:55     ` Christoph Hellwig [this message]
2019-04-23 15:46       ` Guo Ren
2019-04-23 15:57         ` Gary Guo
2019-04-24  2:08           ` Guo Ren
2019-04-24  3:21             ` Gary Guo
2019-04-24  5:57               ` Guo Ren
2019-04-24 12:45                 ` Gary Guo
2019-04-24 14:23                   ` Christoph Hellwig
2019-04-25  9:50                     ` Arnd Bergmann
2019-04-26 16:05                       ` Guo Ren
2019-04-26 18:42                         ` Arnd Bergmann
2019-04-26 19:05                           ` [tech-privileged] " Bill Huffman
2019-04-23  0:31 ` kbuild test robot
2019-04-29 20:11 ` Palmer Dabbelt
2019-04-30  3:29   ` Guo Ren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190423055548.GA12365@lst.de \
    --to=hch@lst.de \
    --cc=andrew@sifive.com \
    --cc=anup.patel@wdc.com \
    --cc=arnd@arndb.de \
    --cc=green.hu@gmail.com \
    --cc=guoren@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=m.szyprowski@samsung.com \
    --cc=palmer@sifive.com \
    --cc=ren_guo@c-sky.com \
    --cc=robin.murphy@arm.com \
    --cc=rppt@linux.ibm.com \
    --cc=swood@redhat.com \
    --cc=tech-privileged@lists.riscv.org \
    --cc=vincentc@andestech.com \
    --cc=xiaoyan_xiang@c-sky.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).