]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
drm/vmwgfx: unwind spaghetti code in vmw_dma_select_mode
authorChristoph Hellwig <hch@lst.de>
Sat, 5 Jan 2019 08:01:08 +0000 (09:01 +0100)
committerThomas Hellstrom <thellstrom@vmware.com>
Tue, 29 Jan 2019 11:30:24 +0000 (12:30 +0100)
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>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

index 1456101e67a9c28fb31cc8d9f25ba2514ea2f4cf..3e2bcff34032ee0bd11625d0e715d7aa45ab7401 100644 (file)
@@ -566,39 +566,26 @@ 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;
-
        /* No TTM coherent page pool? FIXME: Ask TTM instead! */
         if (!(IS_ENABLED(CONFIG_SWIOTLB) || IS_ENABLED(CONFIG_INTEL_IOMMU)) &&
            (dev_priv->map_mode == vmw_dma_alloc_coherent))
                return -EINVAL;
 
        DRM_INFO("DMA map mode: %s\n", names[dev_priv->map_mode]);
-
        return 0;
 }