From: Christoph Hellwig <hch@infradead.org>
To: Vladimir Murzin <vladimir.murzin@arm.com>
Cc: kstewart@linuxfoundation.org, devicetree@vger.kernel.org,
alexandre.torgue@st.com, info@metux.net, linux@armlinux.org.uk,
linux-kernel@vger.kernel.org, robh+dt@kernel.org,
linux-arm-kernel@lists.infradead.org, mcoquelin.stm32@gmail.com,
tglx@linutronix.de, dillon.minfei@gmail.com,
linux-stm32@st-md-mailman.stormreply.com, allison@lohutok.net
Subject: Re: [PATCH 2/2] arm-nommu: Add use_reserved_mem() to check if device support reserved memory
Date: Wed, 10 Jun 2020 00:24:44 -0700 [thread overview]
Message-ID: <20200610072444.GA6293@infradead.org> (raw)
In-Reply-To: <90df5646-e0c4-fcac-d934-4cc922230dd2@arm.com>
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..)
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
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)
{
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-06-10 7:24 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 [this message]
2020-06-10 8:19 ` Vladimir Murzin
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=20200610072444.GA6293@infradead.org \
--to=hch@infradead.org \
--cc=alexandre.torgue@st.com \
--cc=allison@lohutok.net \
--cc=devicetree@vger.kernel.org \
--cc=dillon.minfei@gmail.com \
--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 \
--cc=vladimir.murzin@arm.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).