@@ -565,7 +565,15 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv)
[vmw_dma_map_populate] = "Caching DMA mappings.",
[vmw_dma_map_bind] = "Giving up DMA mappings early."};
- if (vmw_force_coherent)
+ /*
+ * dma_max_mapping_size() != SIZE_MAX means something is going
+ * on in the dma layer that the dma_map_bind or dma_map_populate modes
+ * are not working well with, or haven't been tested with.
+ * This typically happens when the SWIOTLB is active. Fall back to
+ * coherent memory in those cases.
+ */
+ if (dma_max_mapping_size(dev_priv->dev->dev) != SIZE_MAX ||
+ vmw_force_coherent)
dev_priv->map_mode = vmw_dma_alloc_coherent;
else if (vmw_restrict_iommu)
dev_priv->map_mode = vmw_dma_map_bind;
@@ -668,10 +676,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
dev_priv->capabilities2 = vmw_read(dev_priv, SVGA_REG_CAP2);
}
-
- ret = vmw_dma_select_mode(dev_priv);
- if (unlikely(ret != 0)) {
- DRM_INFO("Restricting capabilities due to IOMMU setup.\n");
+ if (vmw_dma_masks(dev_priv) || vmw_dma_select_mode(dev_priv)) {
+ DRM_WARN("Refusing DMA due to lack of DMA support.");
refuse_dma = true;
}
@@ -740,10 +746,6 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
if (dev_priv->capabilities & SVGA_CAP_CAP2_REGISTER)
vmw_print_capabilities2(dev_priv->capabilities2);
- ret = vmw_dma_masks(dev_priv);
- if (unlikely(ret != 0))
- goto out_err0;
-
dma_set_max_seg_size(dev->dev, min_t(unsigned int, U32_MAX & PAGE_MASK,
SCATTERLIST_MAX_SEGMENT));