xref: /linux/drivers/gpu/drm/i915/i915_utils.c (revision ca220141fa8ebae09765a242076b2b77338106b0)
1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright © 2019 Intel Corporation
4  */
5 
6 #include <linux/device.h>
7 
8 #include <drm/drm_drv.h>
9 #include <drm/drm_print.h>
10 
11 #include "i915_drv.h"
12 #include "i915_reg.h"
13 #include "i915_utils.h"
14 
15 void add_taint_for_CI(struct drm_i915_private *i915, unsigned int taint)
16 {
17 	drm_notice(&i915->drm, "CI tainted: %#x by %pS\n",
18 		   taint, __builtin_return_address(0));
19 
20 	__add_taint_for_CI(taint);
21 }
22 
23 bool i915_vtd_active(struct drm_i915_private *i915)
24 {
25 	if (device_iommu_mapped(i915->drm.dev))
26 		return true;
27 
28 	/* Running as a guest, we assume the host is enforcing VT'd */
29 	return i915_run_as_guest();
30 }
31 
32 bool i915_direct_stolen_access(struct drm_i915_private *i915)
33 {
34 	/*
35 	 * Wa_22018444074
36 	 *
37 	 * Access via BAR can hang MTL, go directly to GSM/DSM,
38 	 * except for VM guests which won't have access to it.
39 	 *
40 	 * Normally this would not work but on MTL the system firmware
41 	 * should have relaxed the access permissions sufficiently.
42 	 * 0x138914==0x1 indicates that the firmware has done its job.
43 	 */
44 	return IS_METEORLAKE(i915) && !i915_run_as_guest() &&
45 		intel_uncore_read(&i915->uncore, MTL_PCODE_STOLEN_ACCESS) == STOLEN_ACCESS_ALLOWED;
46 }
47