Re: [PATCH 1/2] dma-mapping: support setting memory uncached in place
From: Christoph Hellwig <hch@lst.de>
Date: 2020-02-21 14:17:03
Also in:
linux-arch, linux-iommu, lkml
From: Christoph Hellwig <hch@lst.de>
Date: 2020-02-21 14:17:03
Also in:
linux-arch, linux-iommu, lkml
On Thu, Feb 20, 2020 at 05:21:35PM +0000, Robin Murphy wrote:
quoted
@@ -196,10 +192,15 @@ void *dma_direct_alloc_pages(struct device *dev, size_t size, memset(ret, 0, size); - if (IS_ENABLED(CONFIG_ARCH_HAS_UNCACHED_SEGMENT) && - dma_alloc_need_uncached(dev, attrs)) { + if (dma_alloc_need_uncached(dev, attrs)) { arch_dma_prep_coherent(page, size); - ret = uncached_kernel_address(ret); + + if (IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED)) { + if (!arch_dma_set_uncached(ret, size)) + goto out_free_pages; + } else if (IS_ENABLED(CONFIG_ARCH_HAS_UNCACHED_SEGMENT)) { + ret = uncached_kernel_address(ret);Hmm, would we actually need to keep ARCH_HAS_UNCACHED_SEGMENT? If arch_dma_set_uncached() returned void*/ERR_PTR instead, then it could work for both cases (with arch_dma_clear_uncached() being a no-op for segments).
Yes, I think so. I was a little worried about what to do with cached_kernel_address() in that scheme, but it turns out with the recent round of dma-direct cleanup that is actually entirely unused now. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel