From: Conor Dooley <conor@kernel.org>
To: Maxim Kochetkov <fido_max@inbox.ru>
Cc: Christoph Hellwig <hch@lst.de>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
robh@kernel.org, mpe@ellerman.id.au, aou@eecs.berkeley.edu,
palmer@dabbelt.com, paul.walmsley@sifive.com
Subject: Re: [PATCH 1/1] riscv: set ARCH_DMA_DEFAULT_COHERENT if RISCV_DMA_NONCOHERENT is not set
Date: Fri, 22 Dec 2023 14:54:19 +0000 [thread overview]
Message-ID: <20231222-outburst-spoiling-75082a7826dd@spud> (raw)
In-Reply-To: <c53c22dd-c482-4808-bdd7-e81c01c04f9e@inbox.ru>
[-- Attachment #1: Type: text/plain, Size: 3719 bytes --]
On Fri, Dec 22, 2023 at 05:39:34PM +0300, Maxim Kochetkov wrote:
>
>
> On 22.12.2023 07:14, Christoph Hellwig wrote:
> > On Thu, Dec 21, 2023 at 10:27:33PM +0000, Jiaxun Yang wrote:
> > >
> > >
> > > 在 2023/12/21 20:29, Conor Dooley 写道:
> > > > + Christoph
> > > >
> > > > I don't think this patch is correct. Regardless of whether we support
> > > > cache management operations, DMA is assumed to be coherent unless
> > > > peripherals etc are specified to otherwise in DT (or however ACPI deals
> > > > with that kind of thing).
> > > >
> > > > What problem are you trying to solve here?
> > > >
> > > > On Thu, Dec 21, 2023 at 09:51:52PM +0300, Maxim Kochetkov wrote:
> > > > > Not all the RISCV are DMA coherent by default.
> > >
> > > Sorry for chime in here.
> > > IMO if your platform is not coherent by default, just insert
> > > "dma-noncoherent"
> > > at devicetree root node.
> >
> > Exactly. ARCH_DMA_DEFAULT_COHERENTis a setting that just says for
> > a given architecture assumes coherent unless otherwise specified,
> > which has historically been the case for mips. Not setting it means
> > non-coherent unless specified, which has historially been the case
> > for arm.
> >
> > RISC-V starte out without support for non-coherent DMA, and high ups
> > in RISCV still told me in 2019 that RISC-V doesn't need cache
> > management instructions because no new hardware would ever not be
> > dma coherent. Yeah, right..
> >
> > Anyay, Linux for RISC-V has historically been coherent only and then
> > coherent default, so this option is wrong, and you need to mark
> > you platform as non-coherent by inserting dma-noncoherent somewhere.
> >
> Conor, Christoph, Jiaxun, thanks for quick feedback!
>
> The problem is very simple:
> For non mips platforms dma_default_coherent is used at of_dma_is_coherent()
> and device_initialize().
> of_dma_is_coherent() affects only DT devices. And we can override it with
> "dma-coherent"/"dma-noncoherent". ACPI devices can specify by
> "attr == DEV_DMA_COHERENT". But all other devices (platform_device, usb,
I would have expected that usb devices "inherit" the value from the usb
controller whose bus they are on. Similarly, platform devices are on a
bus that should be marked as non-coherent if that is the case.
Christoph certainly knows better how things operate here however.
> etc..) do not have this feature. These devices will use value from
> device_initialize(). And we have no possibility to change
> dma_default_coherent value by disabling ARCH_DMA_DEFAULT_COHERENT.
> Moreover, changing dma_default_coherent from false to true may cause
> regression for other devices.
How can there be a regression when dma has been coherent by default for
the RISC-V kernel from day 1?
> That is why I suggest possibility to disable
> ARCH_DMA_DEFAULT_COHERENT by RISCV_DMA_NONCOHERENT option.
> It will works like for PPC:
> .....
> config PPC
> bool
> default y
> #
> # Please keep this list sorted alphabetically.
> #
> select ARCH_32BIT_OFF_T if PPC32
> select ARCH_DISABLE_KASAN_INLINE if PPC_RADIX_MMU
> select ARCH_DMA_DEFAULT_COHERENT if !NOT_COHERENT_CACHE
> .....
> Doesn't the option RISCV_DMA_NONCOHERENT say the DMA should be non-coherent
> by default?
No. That option only controls whether or not support for cache
management operations is built into the kernel. It is expected that this
option can be enabled for multiplatform kernels, like those used by
distributions, that will run on systems that are entirely coherent as
well as those that are not.
It does not work the same was as this PPC option appears to.
Cheers,
Conor.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-12-22 14:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 18:51 Maxim Kochetkov
2023-12-21 20:29 ` Conor Dooley
2023-12-21 22:27 ` Jiaxun Yang
2023-12-22 4:14 ` Christoph Hellwig
2023-12-22 14:39 ` Maxim Kochetkov
2023-12-22 14:54 ` Conor Dooley [this message]
2023-12-22 15:04 ` Christoph Hellwig
2023-12-22 15:38 ` Maxim Kochetkov
2023-12-22 15:45 ` Jiaxun Yang
2023-12-22 15:53 ` Maxim Kochetkov
2023-12-22 16:01 ` Jiaxun Yang
2023-12-23 4:59 ` Christoph Hellwig
2023-12-25 6:47 ` Maxim Kochetkov
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=20231222-outburst-spoiling-75082a7826dd@spud \
--to=conor@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=fido_max@inbox.ru \
--cc=hch@lst.de \
--cc=jiaxun.yang@flygoat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mpe@ellerman.id.au \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh@kernel.org \
/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
all inboxes | Powered by JetHome®