From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: dillon.minfei@gmail.com, robh+dt@kernel.org,
mcoquelin.stm32@gmail.com, alexandre.torgue@st.com,
linux@armlinux.org.uk, kstewart@linuxfoundation.org,
allison@lohutok.net, info@metux.net, tglx@linutronix.de,
devicetree@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] arm-nommu: Add use_reserved_mem() to check if device support reserved memory
Date: Wed, 10 Jun 2020 09:19:45 +0100 [thread overview]
Message-ID: <9c3a7b4e-0190-e9bb-91fe-6d5692559888@arm.com> (raw)
In-Reply-To: <20200610072444.GA6293@infradead.org>
On 6/10/20 8:24 AM, Christoph Hellwig wrote:
> Ok, I finally found the original patch from Vladimir. Comments below:
>
>> +++ b/kernel/dma/direct.c
>> @@ -456,14 +456,14 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
>> #else /* CONFIG_MMU */
>> bool dma_direct_can_mmap(struct device *dev)
>> {
>> - return false;
>> + return true;
>> }
>>
>> int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
>> void *cpu_addr, dma_addr_t dma_addr, size_t size,
>> unsigned long attrs)
>> {
>> - return -ENXIO;
>> + return vm_iomap_memory(vma, vma->vm_start, (vma->vm_end - vma->vm_start));;
>
> I think we should try to reuse the mmu dma_direct_mmap implementation,
> which does about the same. This version has been compile tested on
> arm-nommu only, let me know what you think: (btw, a nommu_defconfig of
> some kind for arm would be nice..)
Catch-all nommu_defconfig is not easy for ARM, AFAIK folk carry few hacks
for randconfig...
Meanwhile, known working NOMMU configs
$ git grep "# CONFIG_MMU is not set" arch/arm/configs/
arch/arm/configs/efm32_defconfig:# CONFIG_MMU is not set
arch/arm/configs/lpc18xx_defconfig:# CONFIG_MMU is not set
arch/arm/configs/mps2_defconfig:# CONFIG_MMU is not set
arch/arm/configs/stm32_defconfig:# CONFIG_MMU is not set
arch/arm/configs/vf610m4_defconfig:# CONFIG_MMU is not set
>
> diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig
> index d006668c0027d2..e0dae570a51530 100644
> --- a/kernel/dma/Kconfig
> +++ b/kernel/dma/Kconfig
> @@ -71,6 +71,7 @@ config SWIOTLB
> # in the pagetables
> #
> config DMA_NONCOHERENT_MMAP
> + default y if !MMU
> bool
Nit: def_bool !MMU
>
> config DMA_REMAP
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index 0a4881e59aa7d6..9ec6a5c3fc578c 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -459,7 +459,6 @@ int dma_direct_get_sgtable(struct device *dev, struct sg_table *sgt,
> return ret;
> }
>
> -#ifdef CONFIG_MMU
> bool dma_direct_can_mmap(struct device *dev)
> {
> return dev_is_dma_coherent(dev) ||
> @@ -485,19 +484,6 @@ int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
> return remap_pfn_range(vma, vma->vm_start, pfn + vma->vm_pgoff,
> user_count << PAGE_SHIFT, vma->vm_page_prot);
> }
> -#else /* CONFIG_MMU */
> -bool dma_direct_can_mmap(struct device *dev)
> -{
> - return false;
> -}
> -
> -int dma_direct_mmap(struct device *dev, struct vm_area_struct *vma,
> - void *cpu_addr, dma_addr_t dma_addr, size_t size,
> - unsigned long attrs)
> -{
> - return -ENXIO;
> -}
> -#endif /* CONFIG_MMU */
>
> int dma_direct_supported(struct device *dev, u64 mask)
> {
>
LGTM. FWIW:
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
next prev parent reply other threads:[~2020-06-10 8:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-08 8:30 [PATCH 0/2] Use 'arm_nommu_dma_ops' to handle dma memroy if device offer consistent dma memory region dillon.minfei
2020-06-08 8:30 ` [PATCH 1/2] ARM: dts: stm32: Setup 4M bytes reserved memory for mmap dillon.minfei
2020-06-09 15:58 ` dillon min
2020-06-08 8:30 ` [PATCH 2/2] arm-nommu: Add use_reserved_mem() to check if device support reserved memory dillon.minfei
2020-06-09 14:08 ` Vladimir Murzin
2020-06-09 15:22 ` dillon min
2020-06-09 15:36 ` Christoph Hellwig
2020-06-09 15:43 ` Vladimir Murzin
2020-06-09 16:25 ` Vladimir Murzin
2020-06-09 17:34 ` Christoph Hellwig
2020-06-10 2:24 ` dillon min
2020-06-10 7:24 ` Christoph Hellwig
2020-06-10 8:19 ` Vladimir Murzin [this message]
2020-06-11 15:45 ` Vladimir Murzin
2020-06-12 2:15 ` dillon min
2020-06-09 15:58 ` [PATCH 0/2] Use 'arm_nommu_dma_ops' to handle dma memroy if device offer consistent dma memory region dillon min
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=9c3a7b4e-0190-e9bb-91fe-6d5692559888@arm.com \
--to=vladimir.murzin@arm.com \
--cc=alexandre.torgue@st.com \
--cc=allison@lohutok.net \
--cc=devicetree@vger.kernel.org \
--cc=dillon.minfei@gmail.com \
--cc=hch@infradead.org \
--cc=info@metux.net \
--cc=kstewart@linuxfoundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=linux@armlinux.org.uk \
--cc=mcoquelin.stm32@gmail.com \
--cc=robh+dt@kernel.org \
--cc=tglx@linutronix.de \
/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).