History

x86,intel_iommu: Replace cmpxchg_double()

Peter Zijlstra committed 3 years ago

Commit b1fe7f21 parent 0a0a6802 files · +68 −65Browse files

Unified · Split

2 files
  1. drivers/iommu/intel/irq_remapping.c +2 −6
  2. include/linux/dmar.h +66 −59
drivers/iommu/intel/irq_remapping.c+2−6
@@ -175,18 +175,14 @@ static int modify_irte(struct irq_2_iommu *irq_iommu, · 174 unmodified lines
175175 irte = &iommu->ir_table->base[index];
176176
177177 if ((irte->pst == 1) || (irte_modified->pst == 1)) {
178− bool ret;
179−
180− ret = cmpxchg_double(&irte->low, &irte->high,
181− irte->low, irte->high,
182− irte_modified->low, irte_modified->high);
183178 /*
184179 * We use cmpxchg16 to atomically update the 128-bit IRTE,
185180 * and it cannot be updated by the hardware or other processors
186181 * behind us, so the return value of cmpxchg16 should be the
187182 * same as the old value.
188183 */
189− WARN_ON(!ret);
184+ u128 old = irte->irte;
185+ WARN_ON(!try_cmpxchg128(&irte->irte, &old, irte_modified->irte));
190186 } else {
191187 WRITE_ONCE(irte->low, irte_modified->low);
192188 WRITE_ONCE(irte->high, irte_modified->high);
include/linux/dmar.h+66−59
@@ -202,67 +202,74 @@ static inline void detect_intel_iommu(void) · 201 unmodified lines
202202
203203 struct irte {
204204 union {
205− /* Shared between remapped and posted mode*/
206205 struct {
207− __u64 present : 1, /* 0 */
208− fpd : 1, /* 1 */
209− __res0 : 6, /* 2 - 6 */
210− avail : 4, /* 8 - 11 */
211− __res1 : 3, /* 12 - 14 */
212− pst : 1, /* 15 */
213− vector : 8, /* 16 - 23 */
214− __res2 : 40; /* 24 - 63 */
206+ union {
207+ /* Shared between remapped and posted mode*/
208+ struct {
209+ __u64 present : 1, /* 0 */
210+ fpd : 1, /* 1 */
211+ __res0 : 6, /* 2 - 6 */
212+ avail : 4, /* 8 - 11 */
213+ __res1 : 3, /* 12 - 14 */
214+ pst : 1, /* 15 */
215+ vector : 8, /* 16 - 23 */
216+ __res2 : 40; /* 24 - 63 */
217+ };
218+
219+ /* Remapped mode */
220+ struct {
221+ __u64 r_present : 1, /* 0 */
222+ r_fpd : 1, /* 1 */
223+ dst_mode : 1, /* 2 */
224+ redir_hint : 1, /* 3 */
225+ trigger_mode : 1, /* 4 */
226+ dlvry_mode : 3, /* 5 - 7 */
227+ r_avail : 4, /* 8 - 11 */
228+ r_res0 : 4, /* 12 - 15 */
229+ r_vector : 8, /* 16 - 23 */
230+ r_res1 : 8, /* 24 - 31 */
231+ dest_id : 32; /* 32 - 63 */
232+ };
233+
234+ /* Posted mode */
235+ struct {
236+ __u64 p_present : 1, /* 0 */
237+ p_fpd : 1, /* 1 */
238+ p_res0 : 6, /* 2 - 7 */
239+ p_avail : 4, /* 8 - 11 */
240+ p_res1 : 2, /* 12 - 13 */
241+ p_urgent : 1, /* 14 */
242+ p_pst : 1, /* 15 */
243+ p_vector : 8, /* 16 - 23 */
244+ p_res2 : 14, /* 24 - 37 */
245+ pda_l : 26; /* 38 - 63 */
246+ };
247+ __u64 low;
248+ };
249+
250+ union {
251+ /* Shared between remapped and posted mode*/
252+ struct {
253+ __u64 sid : 16, /* 64 - 79 */
254+ sq : 2, /* 80 - 81 */
255+ svt : 2, /* 82 - 83 */
256+ __res3 : 44; /* 84 - 127 */
257+ };
258+
259+ /* Posted mode*/
260+ struct {
261+ __u64 p_sid : 16, /* 64 - 79 */
262+ p_sq : 2, /* 80 - 81 */
263+ p_svt : 2, /* 82 - 83 */
264+ p_res3 : 12, /* 84 - 95 */
265+ pda_h : 32; /* 96 - 127 */
266+ };
267+ __u64 high;
268+ };
215269 };
216−
217− /* Remapped mode */
218− struct {
219− __u64 r_present : 1, /* 0 */
220− r_fpd : 1, /* 1 */
221− dst_mode : 1, /* 2 */
222− redir_hint : 1, /* 3 */
223− trigger_mode : 1, /* 4 */
224− dlvry_mode : 3, /* 5 - 7 */
225− r_avail : 4, /* 8 - 11 */
226− r_res0 : 4, /* 12 - 15 */
227− r_vector : 8, /* 16 - 23 */
228− r_res1 : 8, /* 24 - 31 */
229− dest_id : 32; /* 32 - 63 */
230− };
231−
232− /* Posted mode */
233− struct {
234− __u64 p_present : 1, /* 0 */
235− p_fpd : 1, /* 1 */
236− p_res0 : 6, /* 2 - 7 */
237− p_avail : 4, /* 8 - 11 */
238− p_res1 : 2, /* 12 - 13 */
239− p_urgent : 1, /* 14 */
240− p_pst : 1, /* 15 */
241− p_vector : 8, /* 16 - 23 */
242− p_res2 : 14, /* 24 - 37 */
243− pda_l : 26; /* 38 - 63 */
244− };
245− __u64 low;
246− };
247−
248− union {
249− /* Shared between remapped and posted mode*/
250− struct {
251− __u64 sid : 16, /* 64 - 79 */
252− sq : 2, /* 80 - 81 */
253− svt : 2, /* 82 - 83 */
254− __res3 : 44; /* 84 - 127 */
255− };
256−
257− /* Posted mode*/
258− struct {
259− __u64 p_sid : 16, /* 64 - 79 */
260− p_sq : 2, /* 80 - 81 */
261− p_svt : 2, /* 82 - 83 */
262− p_res3 : 12, /* 84 - 95 */
263− pda_h : 32; /* 96 - 127 */
264− };
265− __u64 high;
270+#ifdef CONFIG_IRQ_REMAP
271+ __u128 irte;
272+#endif
266273 };
267274 };
268275

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t