Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86,amd_iommu: Replace cmpxchg_double()

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Vasant Hegde <vasant.hegde@amd.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20230531132323.788955257@infradead.org

+11 -8
+7 -2
drivers/iommu/amd/amd_iommu_types.h
··· 986 986 }; 987 987 988 988 struct irte_ga { 989 - union irte_ga_lo lo; 990 - union irte_ga_hi hi; 989 + union { 990 + struct { 991 + union irte_ga_lo lo; 992 + union irte_ga_hi hi; 993 + }; 994 + u128 irte; 995 + }; 991 996 }; 992 997 993 998 struct irq_2_irte {
+4 -6
drivers/iommu/amd/iommu.c
··· 3003 3003 static int modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index, 3004 3004 struct irte_ga *irte, struct amd_ir_data *data) 3005 3005 { 3006 - bool ret; 3007 3006 struct irq_remap_table *table; 3008 - unsigned long flags; 3009 3007 struct irte_ga *entry; 3008 + unsigned long flags; 3009 + u128 old; 3010 3010 3011 3011 table = get_irq_table(iommu, devid); 3012 3012 if (!table) ··· 3017 3017 entry = (struct irte_ga *)table->table; 3018 3018 entry = &entry[index]; 3019 3019 3020 - ret = cmpxchg_double(&entry->lo.val, &entry->hi.val, 3021 - entry->lo.val, entry->hi.val, 3022 - irte->lo.val, irte->hi.val); 3023 3020 /* 3024 3021 * We use cmpxchg16 to atomically update the 128-bit IRTE, 3025 3022 * and it cannot be updated by the hardware or other processors 3026 3023 * behind us, so the return value of cmpxchg16 should be the 3027 3024 * same as the old value. 3028 3025 */ 3029 - WARN_ON(!ret); 3026 + old = entry->irte; 3027 + WARN_ON(!try_cmpxchg128(&entry->irte, &old, irte->irte)); 3030 3028 3031 3029 if (data) 3032 3030 data->ref = entry;