On Thu, Feb 20, 2020 at 05:21:35PM +0000, Robin Murphy wrote: >> @@ -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.