With both integrated and discrete Intel GPUs in a system, the current global check of intel_iommu_gfx_mapped, as done from intel_vtd_active() may not be completely accurate. In this patch we add i915 parameter to intel_vtd_active() in order to prepare it for multiple GPUs and we also change the check away from Intel specific intel_iommu_gfx_mapped (global exported by the Intel IOMMU driver) to probing the presence of IOMMU on a specific device using device_iommu_mapped(). This will return true both for IOMMU pass-through and address translation modes which matches the current behaviour. If in the future we wanted to distinguish between these two modes we could either use iommu_get_domain_for_dev() and check for __IOMMU_DOMAIN_PAGING bit indicating address translation, or ask for a new API to be exported from the IOMMU core code. v2: * Check for dmar translation specifically, not just iommu domain. (Baolu) v3: * Go back to plain "any domain" check for now, rewrite commit message. v4: * Use device_iommu_mapped. (Robin, Baolu) Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Lu Baolu <baolu.lu@linux.intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Cc: Robin Murphy <robin.murphy@arm.com> Acked-by: Robin Murphy <robin.murphy@arm.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20211126141424.493753-1-tvrtko.ursulin@linux.intel.com
60 lines
1.3 KiB
C
60 lines
1.3 KiB
C
/*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
* Copyright © 2017 Intel Corporation
|
|
*/
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/mount.h>
|
|
|
|
#include "i915_drv.h"
|
|
#include "i915_gemfs.h"
|
|
|
|
int i915_gemfs_init(struct drm_i915_private *i915)
|
|
{
|
|
char huge_opt[] = "huge=within_size"; /* r/w */
|
|
struct file_system_type *type;
|
|
struct vfsmount *gemfs;
|
|
char *opts;
|
|
|
|
type = get_fs_type("tmpfs");
|
|
if (!type)
|
|
return -ENODEV;
|
|
|
|
/*
|
|
* By creating our own shmemfs mountpoint, we can pass in
|
|
* mount flags that better match our usecase.
|
|
*
|
|
* One example, although it is probably better with a per-file
|
|
* control, is selecting huge page allocations ("huge=within_size").
|
|
* However, we only do so to offset the overhead of iommu lookups
|
|
* due to bandwidth issues (slow reads) on Broadwell+.
|
|
*/
|
|
|
|
opts = NULL;
|
|
if (intel_vtd_active(i915)) {
|
|
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) {
|
|
opts = huge_opt;
|
|
drm_info(&i915->drm,
|
|
"Transparent Hugepage mode '%s'\n",
|
|
opts);
|
|
} else {
|
|
drm_notice(&i915->drm,
|
|
"Transparent Hugepage support is recommended for optimal performance when IOMMU is enabled!\n");
|
|
}
|
|
}
|
|
|
|
gemfs = vfs_kern_mount(type, SB_KERNMOUNT, type->name, opts);
|
|
if (IS_ERR(gemfs))
|
|
return PTR_ERR(gemfs);
|
|
|
|
i915->mm.gemfs = gemfs;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void i915_gemfs_fini(struct drm_i915_private *i915)
|
|
{
|
|
kern_unmount(i915->mm.gemfs);
|
|
}
|