Skip to content

Commit 9ddac73

Browse files
committed
drm/vmwgfx: Improve on IOMMU detection
instead of relying on intel_iommu_enabled, use the fact that the dma_map_ops::map_page != dma_direct_map_page. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Deepak Rawat <drawat@vmware.com>
1 parent 4cbfa1e commit 9ddac73

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
**************************************************************************/
2727
#include <linux/module.h>
2828
#include <linux/console.h>
29+
#include <linux/dma-mapping.h>
2930

3031
#include <drm/drmP.h>
3132
#include "vmwgfx_drv.h"
@@ -34,7 +35,6 @@
3435
#include <drm/ttm/ttm_placement.h>
3536
#include <drm/ttm/ttm_bo_driver.h>
3637
#include <drm/ttm/ttm_module.h>
37-
#include <linux/intel-iommu.h>
3838

3939
#define VMWGFX_DRIVER_DESC "Linux drm driver for VMware graphics devices"
4040
#define VMWGFX_CHIP_SVGAII 0
@@ -545,6 +545,21 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv)
545545
dev_priv->initial_height = height;
546546
}
547547

548+
/**
549+
* vmw_assume_iommu - Figure out whether coherent dma-remapping might be
550+
* taking place.
551+
* @dev: Pointer to the struct drm_device.
552+
*
553+
* Return: true if iommu present, false otherwise.
554+
*/
555+
static bool vmw_assume_iommu(struct drm_device *dev)
556+
{
557+
const struct dma_map_ops *ops = get_dma_ops(dev->dev);
558+
559+
return !dma_is_direct(ops) && ops &&
560+
ops->map_page != dma_direct_map_page;
561+
}
562+
548563
/**
549564
* vmw_dma_select_mode - Determine how DMA mappings should be set up for this
550565
* system.
@@ -568,7 +583,7 @@ static int vmw_dma_select_mode(struct vmw_private *dev_priv)
568583

569584
if (vmw_force_coherent)
570585
dev_priv->map_mode = vmw_dma_alloc_coherent;
571-
else if (intel_iommu_enabled)
586+
else if (vmw_assume_iommu(dev_priv->dev))
572587
dev_priv->map_mode = vmw_dma_map_populate;
573588
else if (!vmw_force_iommu)
574589
dev_priv->map_mode = vmw_dma_phys;

0 commit comments

Comments
 (0)