hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/include/linux/dmar.h
....@@ -1,18 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (c) 2006, Intel Corporation.
3
- *
4
- * This program is free software; you can redistribute it and/or modify it
5
- * under the terms and conditions of the GNU General Public License,
6
- * version 2, as published by the Free Software Foundation.
7
- *
8
- * This program is distributed in the hope it will be useful, but WITHOUT
9
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11
- * more details.
12
- *
13
- * You should have received a copy of the GNU General Public License along with
14
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
- * Place - Suite 330, Boston, MA 02111-1307 USA.
164 *
175 * Copyright (C) Ashok Raj <ashok.raj@intel.com>
186 * Copyright (C) Shaohua Li <shaohua.li@intel.com>
....@@ -39,6 +27,7 @@
3927 /* DMAR Flags */
4028 #define DMAR_INTR_REMAP 0x1
4129 #define DMAR_X2APIC_OPT_OUT 0x2
30
+#define DMAR_PLATFORM_OPT_IN 0x4
4231
4332 struct intel_iommu;
4433
....@@ -59,6 +48,7 @@
5948 u16 segment; /* PCI domain */
6049 u8 ignored:1; /* ignore drhd */
6150 u8 include_all:1;
51
+ u8 gfx_dedicated:1; /* graphic dedicated */
6252 struct intel_iommu *iommu;
6353 };
6454
....@@ -80,19 +70,23 @@
8070 extern struct rw_semaphore dmar_global_lock;
8171 extern struct list_head dmar_drhd_units;
8272
83
-#define for_each_drhd_unit(drhd) \
84
- list_for_each_entry_rcu(drhd, &dmar_drhd_units, list)
73
+#define for_each_drhd_unit(drhd) \
74
+ list_for_each_entry_rcu(drhd, &dmar_drhd_units, list, \
75
+ dmar_rcu_check())
8576
8677 #define for_each_active_drhd_unit(drhd) \
87
- list_for_each_entry_rcu(drhd, &dmar_drhd_units, list) \
78
+ list_for_each_entry_rcu(drhd, &dmar_drhd_units, list, \
79
+ dmar_rcu_check()) \
8880 if (drhd->ignored) {} else
8981
9082 #define for_each_active_iommu(i, drhd) \
91
- list_for_each_entry_rcu(drhd, &dmar_drhd_units, list) \
83
+ list_for_each_entry_rcu(drhd, &dmar_drhd_units, list, \
84
+ dmar_rcu_check()) \
9285 if (i=drhd->iommu, drhd->ignored) {} else
9386
9487 #define for_each_iommu(i, drhd) \
95
- list_for_each_entry_rcu(drhd, &dmar_drhd_units, list) \
88
+ list_for_each_entry_rcu(drhd, &dmar_drhd_units, list, \
89
+ dmar_rcu_check()) \
9690 if (i=drhd->iommu, 0) {} else
9791
9892 static inline bool dmar_rcu_check(void)
....@@ -103,12 +97,14 @@
10397
10498 #define dmar_rcu_dereference(p) rcu_dereference_check((p), dmar_rcu_check())
10599
106
-#define for_each_dev_scope(a, c, p, d) \
107
- for ((p) = 0; ((d) = (p) < (c) ? dmar_rcu_dereference((a)[(p)].dev) : \
108
- NULL, (p) < (c)); (p)++)
100
+#define for_each_dev_scope(devs, cnt, i, tmp) \
101
+ for ((i) = 0; ((tmp) = (i) < (cnt) ? \
102
+ dmar_rcu_dereference((devs)[(i)].dev) : NULL, (i) < (cnt)); \
103
+ (i)++)
109104
110
-#define for_each_active_dev_scope(a, c, p, d) \
111
- for_each_dev_scope((a), (c), (p), (d)) if (!(d)) { continue; } else
105
+#define for_each_active_dev_scope(devs, cnt, i, tmp) \
106
+ for_each_dev_scope((devs), (cnt), (i), (tmp)) \
107
+ if (!(tmp)) { continue; } else
112108
113109 extern int dmar_table_init(void);
114110 extern int dmar_dev_scope_init(void);
....@@ -138,6 +134,7 @@
138134 #ifdef CONFIG_INTEL_IOMMU
139135 extern int iommu_detected, no_iommu;
140136 extern int intel_iommu_init(void);
137
+extern void intel_iommu_shutdown(void);
141138 extern int dmar_parse_one_rmrr(struct acpi_dmar_header *header, void *arg);
142139 extern int dmar_parse_one_atsr(struct acpi_dmar_header *header, void *arg);
143140 extern int dmar_check_one_atsr(struct acpi_dmar_header *hdr, void *arg);
....@@ -146,6 +143,7 @@
146143 extern int dmar_iommu_notify_scope_dev(struct dmar_pci_notify_info *info);
147144 #else /* !CONFIG_INTEL_IOMMU: */
148145 static inline int intel_iommu_init(void) { return -ENODEV; }
146
+static inline void intel_iommu_shutdown(void) { }
149147
150148 #define dmar_parse_one_rmrr dmar_res_noop
151149 #define dmar_parse_one_atsr dmar_res_noop
....@@ -170,6 +168,8 @@
170168 { return 0; }
171169 #endif /* CONFIG_IRQ_REMAP */
172170
171
+extern bool dmar_platform_optin(void);
172
+
173173 #else /* CONFIG_DMAR_TABLE */
174174
175175 static inline int dmar_device_add(void *handle)
....@@ -182,6 +182,11 @@
182182 return 0;
183183 }
184184
185
+static inline bool dmar_platform_optin(void)
186
+{
187
+ return false;
188
+}
189
+
185190 #endif /* CONFIG_DMAR_TABLE */
186191
187192 struct irte {