Subject: linux-next: manual merge of the swiotlb tree with the dma-mapping tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 19 Aug 2021 11:13:12 +1000

Hi all,

Today's linux-next merge of the swiotlb tree got a conflict in:

  kernel/dma/direct.c

between commit:

  faf4ef823ac5 ("dma-direct: add support for dma_coherent_default_memory")

from the dma-mapping tree and commit:

  f4111e39a52a ("swiotlb: Add restricted DMA alloc/free support")

from the swiotlb tree.

I fixed it up (see below, though more may be needed) and can carry the
fix as necessary. This is now fixed as far as linux-next is concerned,
but any non trivial conflicts should be mentioned to your upstream
maintainer when your tree is submitted for merging.  You may also want
to consider cooperating with the maintainer of the conflicting tree to
minimise any particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc kernel/dma/direct.c
index 8dca4f97d12d,2de33e5d302b..000000000000
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@@ -155,15 -174,10 +174,16 @@@ void *dma_direct_alloc(struct device *d
  	}
  
  	if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED) &&
 -	    !IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) && !dev_is_dma_coherent(dev) &&
 +	    !IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
 +	    !IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) &&
- 	    !dev_is_dma_coherent(dev))
++	    !dev_is_dma_coherent(dev) &&
+ 	    !is_swiotlb_for_alloc(dev))
  		return arch_dma_alloc(dev, size, dma_handle, gfp, attrs);
  
 +	if (IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) &&
 +	    !dev_is_dma_coherent(dev))
 +		return dma_alloc_from_global_coherent(dev, size, dma_handle);
 +
  	/*
  	 * Remapping or decrypting memory may block. If either is required and
  	 * we can't block, allocate the memory from the atomic pools.
@@@ -259,9 -278,8 +284,10 @@@ void dma_direct_free(struct device *dev
  	}
  
  	if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_SET_UNCACHED) &&
 -	    !IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) && !dev_is_dma_coherent(dev) &&
 +	    !IS_ENABLED(CONFIG_DMA_DIRECT_REMAP) &&
 +	    !IS_ENABLED(CONFIG_DMA_GLOBAL_POOL) &&
- 	    !dev_is_dma_coherent(dev)) {
++	    !dev_is_dma_coherent(dev) &&
+ 	    !is_swiotlb_for_alloc(dev)) {
  		arch_dma_free(dev, size, cpu_addr, dma_addr, attrs);
  		return;
  	}