diff mbox series

[4/4] drm/vmwgfx: unwind spaghetti code in vmw_dma_select_mode

Message ID 20190105080108.14837-5-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/4] drm/vmwgfx: remove CONFIG_X86 ifdefs | expand

Commit Message

Christoph Hellwig Jan. 5, 2019, 8:01 a.m. UTC
Just use a simple if/else chain to select the DMA mode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

Comments

Thomas Hellstrom Jan. 8, 2019, 10:56 a.m. UTC | #1
On Sat, 2019-01-05 at 09:01 +0100, Christoph Hellwig wrote:
> Just use a simple if/else chain to select the DMA mode.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>


> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 25 ++++++-------------------
>  1 file changed, 6 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index c2060f6cc9e8..86387735a90b 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -566,34 +566,21 @@ static int vmw_dma_select_mode(struct
> vmw_private *dev_priv)
>  		[vmw_dma_map_populate] = "Keeping DMA mappings.",
>  		[vmw_dma_map_bind] = "Giving up DMA mappings early."};
>  
> -	if (intel_iommu_enabled) {
> +	if (vmw_force_coherent)
> +		dev_priv->map_mode = vmw_dma_alloc_coherent;
> +	else if (intel_iommu_enabled)
>  		dev_priv->map_mode = vmw_dma_map_populate;
> -		goto out_fixup;
> -	}
> -
> -	if (!(vmw_force_iommu || vmw_force_coherent)) {
> +	else if (!vmw_force_iommu)
>  		dev_priv->map_mode = vmw_dma_phys;
> -		DRM_INFO("DMA map mode: %s\n", names[dev_priv-
> >map_mode]);
> -		return 0;
> -	}
> -
> -#ifdef CONFIG_SWIOTLB
> -	if (swiotlb_nr_tbl())
> +	else if (IS_ENABLED(CONFIG_SWIOTLB) && swiotlb_nr_tbl())
>  		dev_priv->map_mode = vmw_dma_alloc_coherent;
>  	else
> -#endif
>  		dev_priv->map_mode = vmw_dma_map_populate;
>  
> -out_fixup:
> -	if (dev_priv->map_mode == vmw_dma_map_populate &&
> -	    vmw_restrict_iommu)
> +	if (dev_priv->map_mode == vmw_dma_map_populate &&
> vmw_restrict_iommu)
>  		dev_priv->map_mode = vmw_dma_map_bind;
>  
> -	if (vmw_force_coherent)
> -		dev_priv->map_mode = vmw_dma_alloc_coherent;
> -
>  	DRM_INFO("DMA map mode: %s\n", names[dev_priv->map_mode]);
> -
>  	return 0;
>  }
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index c2060f6cc9e8..86387735a90b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -566,34 +566,21 @@  static int vmw_dma_select_mode(struct vmw_private *dev_priv)
 		[vmw_dma_map_populate] = "Keeping DMA mappings.",
 		[vmw_dma_map_bind] = "Giving up DMA mappings early."};
 
-	if (intel_iommu_enabled) {
+	if (vmw_force_coherent)
+		dev_priv->map_mode = vmw_dma_alloc_coherent;
+	else if (intel_iommu_enabled)
 		dev_priv->map_mode = vmw_dma_map_populate;
-		goto out_fixup;
-	}
-
-	if (!(vmw_force_iommu || vmw_force_coherent)) {
+	else if (!vmw_force_iommu)
 		dev_priv->map_mode = vmw_dma_phys;
-		DRM_INFO("DMA map mode: %s\n", names[dev_priv->map_mode]);
-		return 0;
-	}
-
-#ifdef CONFIG_SWIOTLB
-	if (swiotlb_nr_tbl())
+	else if (IS_ENABLED(CONFIG_SWIOTLB) && swiotlb_nr_tbl())
 		dev_priv->map_mode = vmw_dma_alloc_coherent;
 	else
-#endif
 		dev_priv->map_mode = vmw_dma_map_populate;
 
-out_fixup:
-	if (dev_priv->map_mode == vmw_dma_map_populate &&
-	    vmw_restrict_iommu)
+	if (dev_priv->map_mode == vmw_dma_map_populate && vmw_restrict_iommu)
 		dev_priv->map_mode = vmw_dma_map_bind;
 
-	if (vmw_force_coherent)
-		dev_priv->map_mode = vmw_dma_alloc_coherent;
-
 	DRM_INFO("DMA map mode: %s\n", names[dev_priv->map_mode]);
-
 	return 0;
 }