Re: [PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-07 Thread Shawn Anastasio
On 8/7/19 8:04 AM, Christoph Hellwig wrote: Actually it is typical modern Linux style to just provide a prototype and then use "if (IS_ENABLED(CONFIG_FOO))" to guard the call(s) to it. I see. Also, like Will mentioned earlier, the function name isn't entirely accurate anymore. I second the su

[PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-06 Thread Christoph Hellwig
All the way back to introducing dma_common_mmap we've defaulted to mark the pages as uncached. But this is wrong for DMA coherent devices. Later on DMA_ATTR_WRITE_COMBINE also got incorrect treatment as that flag is only treated special on the alloc side for non-coherent devices. Introduce a new

Re: [PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-06 Thread Christoph Hellwig
On Tue, Aug 06, 2019 at 09:39:06PM +0200, Shawn Anastasio wrote: >> -#ifdef CONFIG_ARCH_HAS_DMA_MMAP_PGPROT >> pgprot_t arch_dma_mmap_pgprot(struct device *dev, pgprot_t prot, >> unsigned long attrs); >> -#else >> -# define arch_dma_mmap_pgprot(dev, prot, attrs) pgprot_noncached(

Re: [PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-06 Thread Shawn Anastasio
On 8/5/19 10:01 AM, Christoph Hellwig wrote: diff --git a/include/linux/dma-noncoherent.h b/include/linux/dma-noncoherent.h index 3813211a9aad..9ae5cee543c4 100644 --- a/include/linux/dma-noncoherent.h +++ b/include/linux/dma-noncoherent.h @@ -42,13 +42,8 @@ void arch_dma_free(struct device *dev,

Re: [PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-05 Thread Christoph Hellwig
On Mon, Aug 05, 2019 at 07:55:44PM -0700, Gavin Li wrote: > > /* create a coherent mapping */ > > ret = dma_common_contiguous_remap(page, size, VM_USERMAP, > > - arch_dma_mmap_pgprot(dev, PAGE_KERNEL, attrs), > > + dma_pgprot(dev, PAGE_KER

Re: [PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-05 Thread Gavin Li
> /* create a coherent mapping */ > ret = dma_common_contiguous_remap(page, size, VM_USERMAP, > - arch_dma_mmap_pgprot(dev, PAGE_KERNEL, attrs), > + dma_pgprot(dev, PAGE_KERNEL, attrs), > __builtin_return_address(0)

Re: [PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-05 Thread Catalin Marinas
On Mon, Aug 05, 2019 at 11:01:44AM +0300, Christoph Hellwig wrote: > All the way back to introducing dma_common_mmap we've defaulyed to mark s/defaultyed/defaulted/ > the pages as uncached. But this is wrong for DMA coherent devices. > Later on DMA_ATTR_WRITE_COMBINE also got incorrect treatment

[PATCH 1/2] dma-mapping: fix page attributes for dma_mmap_*

2019-08-05 Thread Christoph Hellwig
All the way back to introducing dma_common_mmap we've defaulyed to mark the pages as uncached. But this is wrong for DMA coherent devices. Later on DMA_ATTR_WRITE_COMBINE also got incorrect treatment as that flag is only treated special on the alloc side for non-coherent devices. Introduce a new