Skip to content

Commit 05f9467

Browse files
Christoph Hellwigthomashvmw
authored andcommitted
drm/vmwgfx: unwind spaghetti code in vmw_dma_select_mode
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>
1 parent 2b3cd62 commit 05f9467

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -566,39 +566,26 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv)
566566
[vmw_dma_map_populate] = "Keeping DMA mappings.",
567567
[vmw_dma_map_bind] = "Giving up DMA mappings early."};
568568

569-
if (intel_iommu_enabled) {
569+
if (vmw_force_coherent)
570+
dev_priv->map_mode = vmw_dma_alloc_coherent;
571+
else if (intel_iommu_enabled)
570572
dev_priv->map_mode = vmw_dma_map_populate;
571-
goto out_fixup;
572-
}
573-
574-
if (!(vmw_force_iommu || vmw_force_coherent)) {
573+
else if (!vmw_force_iommu)
575574
dev_priv->map_mode = vmw_dma_phys;
576-
DRM_INFO("DMA map mode: %s\n", names[dev_priv->map_mode]);
577-
return 0;
578-
}
579-
580-
#ifdef CONFIG_SWIOTLB
581-
if (swiotlb_nr_tbl())
575+
else if (IS_ENABLED(CONFIG_SWIOTLB) && swiotlb_nr_tbl())
582576
dev_priv->map_mode = vmw_dma_alloc_coherent;
583577
else
584-
#endif
585578
dev_priv->map_mode = vmw_dma_map_populate;
586579

587-
out_fixup:
588-
if (dev_priv->map_mode == vmw_dma_map_populate &&
589-
vmw_restrict_iommu)
580+
if (dev_priv->map_mode == vmw_dma_map_populate && vmw_restrict_iommu)
590581
dev_priv->map_mode = vmw_dma_map_bind;
591582

592-
if (vmw_force_coherent)
593-
dev_priv->map_mode = vmw_dma_alloc_coherent;
594-
595583
/* No TTM coherent page pool? FIXME: Ask TTM instead! */
596584
if (!(IS_ENABLED(CONFIG_SWIOTLB) || IS_ENABLED(CONFIG_INTEL_IOMMU)) &&
597585
(dev_priv->map_mode == vmw_dma_alloc_coherent))
598586
return -EINVAL;
599587

600588
DRM_INFO("DMA map mode: %s\n", names[dev_priv->map_mode]);
601-
602589
return 0;
603590
}
604591

0 commit comments

Comments
 (0)