From: Ley Foon Tan <lftan@altera.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Michal Simek <monstr@monstr.eu>,
linux-mips@vger.kernel.org, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] nios2: use the generic uncached segment support in dma-direct
Date: Tue, 25 Jun 2019 13:29:40 +0800 [thread overview]
Message-ID: <CAFiDJ5-HwPR-SWUkYA9=Jn_iHnZ+xWzx6RrcHPNy8kA0jmeZfw@mail.gmail.com> (raw)
In-Reply-To: <20190603065324.9724-2-hch@lst.de>
On Mon, Jun 3, 2019 at 2:54 PM Christoph Hellwig <hch@lst.de> wrote:
>
> Stop providing our own arch alloc/free hooks and just expose the segment
> offset and use the generic dma-direct allocator.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Ley Foon Tan <ley.foon.tan@intel.com>
> ---
> arch/nios2/Kconfig | 1 +
> arch/nios2/include/asm/page.h | 6 ------
> arch/nios2/mm/dma-mapping.c | 34 +++++++++++++++-------------------
> 3 files changed, 16 insertions(+), 25 deletions(-)
>
> diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
> index 26a9c760a98b..44b5da37e8bd 100644
> --- a/arch/nios2/Kconfig
> +++ b/arch/nios2/Kconfig
> @@ -4,6 +4,7 @@ config NIOS2
> select ARCH_32BIT_OFF_T
> select ARCH_HAS_SYNC_DMA_FOR_CPU
> select ARCH_HAS_SYNC_DMA_FOR_DEVICE
> + select ARCH_HAS_UNCACHED_SEGMENT
> select ARCH_NO_SWAP
> select TIMER_OF
> select GENERIC_ATOMIC64
> diff --git a/arch/nios2/include/asm/page.h b/arch/nios2/include/asm/page.h
> index f1fbdc47bdaf..79fcac61f6ef 100644
> --- a/arch/nios2/include/asm/page.h
> +++ b/arch/nios2/include/asm/page.h
> @@ -101,12 +101,6 @@ static inline bool pfn_valid(unsigned long pfn)
> # define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \
> VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
>
> -# define UNCAC_ADDR(addr) \
> - ((void *)((unsigned)(addr) | CONFIG_NIOS2_IO_REGION_BASE))
> -# define CAC_ADDR(addr) \
> - ((void *)(((unsigned)(addr) & ~CONFIG_NIOS2_IO_REGION_BASE) | \
> - CONFIG_NIOS2_KERNEL_REGION_BASE))
> -
> #include <asm-generic/memory_model.h>
>
> #include <asm-generic/getorder.h>
> diff --git a/arch/nios2/mm/dma-mapping.c b/arch/nios2/mm/dma-mapping.c
> index 4af9e5b5ba1c..9cb238664584 100644
> --- a/arch/nios2/mm/dma-mapping.c
> +++ b/arch/nios2/mm/dma-mapping.c
> @@ -60,32 +60,28 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
> }
> }
>
> -void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
> - gfp_t gfp, unsigned long attrs)
> +void arch_dma_prep_coherent(struct page *page, size_t size)
> {
> - void *ret;
> + unsigned long start = (unsigned long)page_address(page);
>
> - /* optimized page clearing */
> - gfp |= __GFP_ZERO;
> + flush_dcache_range(start, start + size);
> +}
>
> - if (dev == NULL || (dev->coherent_dma_mask < 0xffffffff))
> - gfp |= GFP_DMA;
> +void *uncached_kernel_address(void *ptr)
> +{
> + unsigned long addr = (unsigned long)ptr;
>
> - ret = (void *) __get_free_pages(gfp, get_order(size));
> - if (ret != NULL) {
> - *dma_handle = virt_to_phys(ret);
> - flush_dcache_range((unsigned long) ret,
> - (unsigned long) ret + size);
> - ret = UNCAC_ADDR(ret);
> - }
> + addr |= CONFIG_NIOS2_IO_REGION_BASE;
>
> - return ret;
> + return (void *)ptr;
> }
>
> -void arch_dma_free(struct device *dev, size_t size, void *vaddr,
> - dma_addr_t dma_handle, unsigned long attrs)
> +void *cached_kernel_address(void *ptr)
> {
> - unsigned long addr = (unsigned long) CAC_ADDR((unsigned long) vaddr);
> + unsigned long addr = (unsigned long)ptr;
> +
> + addr &= ~CONFIG_NIOS2_IO_REGION_BASE;
> + addr |= CONFIG_NIOS2_KERNEL_REGION_BASE;
>
> - free_pages(addr, get_order(size));
> + return (void *)ptr;
> }
> --
> 2.20.1
>
next prev parent reply other threads:[~2019-06-25 5:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 6:53 switch nios2 and microblaze to use the generic uncached segement support Christoph Hellwig
2019-06-03 6:53 ` [PATCH 1/2] nios2: use the generic uncached segment support in dma-direct Christoph Hellwig
2019-06-25 5:29 ` Ley Foon Tan [this message]
2019-06-25 5:52 ` Christoph Hellwig
2019-06-03 6:53 ` [PATCH 2/2] microblaze: " Christoph Hellwig
2019-06-14 1:40 ` switch nios2 and microblaze to use the generic uncached segement support Ley Foon Tan
2019-06-14 5:44 ` Christoph Hellwig
2019-06-14 6:11 ` Tan, Ley Foon
2019-06-14 6:52 ` hch
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='CAFiDJ5-HwPR-SWUkYA9=Jn_iHnZ+xWzx6RrcHPNy8kA0jmeZfw@mail.gmail.com' \
--to=lftan@altera.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=monstr@monstr.eu \
/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).