lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <E46E0161-24E3-4185-B408-9357C49F1B51@flygoat.com>
Date:   Wed, 22 Feb 2023 16:20:16 +0000
From:   Jiaxun Yang <jiaxun.yang@...goat.com>
To:     Conor Dooley <conor@...nel.org>
Cc:     "linux-mips@...r.kernel.org" <linux-mips@...r.kernel.org>,
        linux-kernel@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
        Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
        mpe@...erman.id.au, paul.walmsley@...ive.com, palmer@...belt.com,
        Rob Herring <robh+dt@...nel.org>,
        Christoph Hellwig <hch@....de>, m.szyprowski@...sung.com,
        robin.murphy@....com, linux-riscv@...ts.infradead.org
Subject: Re: [PATCH 2/3] riscv: Set dma_default_coherent to true



> 2023年2月22日 16:02,Conor Dooley <conor@...nel.org> 写道:
> 
> On Wed, Feb 22, 2023 at 03:55:19PM +0000, Jiaxun Yang wrote:
>> 
>> 
>>> 2023年2月22日 14:50,Conor Dooley <conor@...nel.org> 写道:
>>> 
>>> On Wed, Feb 22, 2023 at 01:37:11PM +0000, Jiaxun Yang wrote:
>>>> For riscv our assumption is unless a device states it is non-coherent,
>>>> we take it to be DMA coherent.
>>>> 
>>>> For devicetree probed devices that have been true since very begining
>>>> with OF_DMA_DEFAULT_COHERENT selected.
>>>> 
>>>> Signed-off-by: Jiaxun Yang <jiaxun.yang@...goat.com>
>>>> ---
>>>> arch/riscv/kernel/setup.c | 3 +++
>>>> 1 file changed, 3 insertions(+)
>>>> 
>>>> diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
>>>> index 376d2827e736..34b371180976 100644
>>>> --- a/arch/riscv/kernel/setup.c
>>>> +++ b/arch/riscv/kernel/setup.c
>>>> @@ -300,6 +300,9 @@ void __init setup_arch(char **cmdline_p)
>>>> riscv_init_cbom_blocksize();
>>>> riscv_fill_hwcap();
>>>> apply_boot_alternatives();
>>>> +#ifdef CONFIG_RISCV_DMA_NONCOHERENT
>>>> + dma_default_coherent = true;
>>>> +#endif
>>> 
>>> Do we really need to add ifdeffery for this here?
>>> It's always coherent by default, so why do we need to say set it in
>>> setup_arch() when we know that, regardless of options, it is true?
>> 
>> Because this symbol is only a variable when:
>> 
>> defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE) || \
>> defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU) || \
>> defined(CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU_ALL)
>> 
>> Which is only true if  CONFIG_RISCV_DMA_NONCOHERENT is selected.
>> 
>> Otherwise this symbol is defined to true and we can’t make a assignment to it.
> 
> Maybe I am just slow today, but I don't get why you need to add
> ifdeffery to setup_arch() to do something that is always true.
> Why can't you just set this in riscv/mm/dma-noncoherent.c? What am I
> missing?

Hmm that sounds like a good idea but I was unable to find a place for this.

riscv/mm/dma-noncoherent.c are just a bunch of callbacks, there is no initialisation
function that will always run on every boot. riscv_noncoherent_supported is only
called conditionally.

Perhaps I can add a initcall in dma-noncoherent.c but it seems to be a little bit
overkilling.

Actually I’d prefer to have a config option for the default value but it seems like
it’s not in Christoph’s flavour.

Thanks
- Jiaxun




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ