From: vladimir.murzin@arm.com (Vladimir Murzin)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC v2 PATCH 0/3] Fix dma_alloc_coherent() and friends for NOMMU
Date: Fri, 16 Dec 2016 15:00:41 +0000 [thread overview]
Message-ID: <58540199.6000002@arm.com> (raw)
In-Reply-To: <82f0d72e-7029-ad88-3e44-ab48784297fa@st.com>
Hi Alexandre,
On 16/12/16 14:57, Alexandre Torgue wrote:
> Hi Vladimir,
>
> On 12/13/2016 02:45 PM, Vladimir Murzin wrote:
>> Hi,
>>
>> It seem that addition of cache support for M-class cpus uncovered
>> latent bug in DMA usage. NOMMU memory model has been treated as being
>> always consistent; however, for R/M classes of cpu memory can be
>> covered by MPU which in turn might configure RAM as Normal
>> i.e. bufferable and cacheable. It breaks dma_alloc_coherent() and
>> friends, since data can stuck in caches now or be buffered.
>>
>> This patch set is trying to address the issue by providing region of
>> memory suitable for consistent DMA operations. It is supposed that such
>> region is marked by MPU as non-cacheable. Since we have MPU support in
>> Linux for R-class only and M-class setting MPU in bootloader, proposed
>> interface to advertise such memory is via "memdma=size at start" command
>> line option, to avoid clashing with normal memory (which usually comes
>> from dts) it'd be safer to use it together with "mem=" command line
>> option. Meanwhile, I'm open to suggestions for the better way telling
>> Linux of such memory.
>>
>> For configuration without cache support (like Cortex-M3/M4) dma
>> operations are forced to be coherent and wired with dma-noop. Such
>> decision is made based on cacheid global variable. In case cpu
>> supports caches and no coherent memory region is given - dma is
>> disallowed. Probably, some other important checks are missing, so I'll
>> all my ears :)
>>
>> To make life easier NOMMU dma operations are kept in separate
>> compilation unit.
>>
>> Thanks!
>>
>> Changelog:
>>
>> RFC v1 -> RFC v2
>> - s/dmac_unmap_area/dmac_map_area in __dma_page_cpu_to_dev()
>> - removed unrelated changes in nommu.c
>>
>> Vladimir Murzin (3):
>> ARM: NOMMU: introduce dma operations for noMMU
>> ARM: NOMMU: set ARM_DMA_MEM_BUFFERABLE for M-class cpus
>> ARM: dma-mapping: remove traces of NOMMU code
>>
>> arch/arm/include/asm/dma-mapping.h | 3 +-
>> arch/arm/mm/Kconfig | 2 +-
>> arch/arm/mm/Makefile | 5 +-
>> arch/arm/mm/dma-mapping-nommu.c | 262 ++++++++++++++++++++++++++++++++++++
>> arch/arm/mm/dma-mapping.c | 26 +---
>> arch/arm/mm/mm.h | 3 +
>> arch/arm/mm/nommu.c | 6 +
>> 7 files changed, 278 insertions(+), 29 deletions(-)
>> create mode 100644 arch/arm/mm/dma-mapping-nommu.c
>>
>
> First, thanks for this series.
>
> I tested it on stm32f746 platform. Main issues related to cache and DMA are fixed but I still have an issue using dma_zalloc_alloc API. Allocated memory is not set to zero.
> Can you have a look on it please?
Thanks for testing! I think following diff should fix dma_zalloc_alloc():
diff --git a/arch/arm/mm/dma-mapping-nommu.c b/arch/arm/mm/dma-mapping-nommu.c
index f92d98a..1f97bb8 100644
--- a/arch/arm/mm/dma-mapping-nommu.c
+++ b/arch/arm/mm/dma-mapping-nommu.c
@@ -38,6 +38,7 @@ static void *arm_nommu_dma_alloc(struct device *dev, size_t size,
ptr = (void *)gen_pool_alloc(dma_pool, size);
if (ptr) {
+ memset(ptr, 0, size);
*dma_handle = __pa(ptr);
dmac_flush_range(ptr, ptr + size);
outer_flush_range(__pa(ptr), __pa(ptr) + size);
Cheers
Vladimir
>
> Thanks
> Alex
>
>
next prev parent reply other threads:[~2016-12-16 15:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-13 13:45 [RFC v2 PATCH 0/3] Fix dma_alloc_coherent() and friends for NOMMU Vladimir Murzin
2016-12-13 13:45 ` [RFC v2 PATCH 1/3] ARM: NOMMU: introduce dma operations for noMMU Vladimir Murzin
2017-01-02 15:26 ` Benjamin Gaignard
2017-01-04 10:33 ` Vladimir Murzin
2017-01-06 13:58 ` Benjamin Gaignard
2017-01-09 13:54 ` Vladimir Murzin
2016-12-13 13:45 ` [RFC v2 PATCH 2/3] ARM: NOMMU: set ARM_DMA_MEM_BUFFERABLE for M-class cpus Vladimir Murzin
2016-12-13 13:45 ` [RFC v2 PATCH 3/3] ARM: dma-mapping: remove traces of NOMMU code Vladimir Murzin
2016-12-13 14:07 ` [RFC v2 PATCH 0/3] Fix dma_alloc_coherent() and friends for NOMMU Russell King - ARM Linux
2016-12-13 14:14 ` Vladimir Murzin
2016-12-13 14:25 ` Robin Murphy
2016-12-13 15:02 ` Vladimir Murzin
2016-12-13 18:32 ` Robin Murphy
2016-12-14 10:15 ` Vladimir Murzin
2016-12-13 14:33 ` Szemző András
2016-12-13 15:04 ` Vladimir Murzin
2016-12-16 14:57 ` Alexandre Torgue
2016-12-16 15:00 ` Vladimir Murzin [this message]
2016-12-16 15:33 ` Alexandre Torgue
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=58540199.6000002@arm.com \
--to=vladimir.murzin@arm.com \
--cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.