Merge tag 'locking-core-2023-06-27' of git://git.kernel.org/pub/scm/linux/kernel...
[platform/kernel/linux-rpi.git] / drivers / iommu / amd / iommu.c
index e8a2e59..9ea4096 100644 (file)
@@ -3023,10 +3023,10 @@ out:
 static int modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index,
                          struct irte_ga *irte, struct amd_ir_data *data)
 {
-       bool ret;
        struct irq_remap_table *table;
-       unsigned long flags;
        struct irte_ga *entry;
+       unsigned long flags;
+       u128 old;
 
        table = get_irq_table(iommu, devid);
        if (!table)
@@ -3037,16 +3037,14 @@ static int modify_irte_ga(struct amd_iommu *iommu, u16 devid, int index,
        entry = (struct irte_ga *)table->table;
        entry = &entry[index];
 
-       ret = cmpxchg_double(&entry->lo.val, &entry->hi.val,
-                            entry->lo.val, entry->hi.val,
-                            irte->lo.val, irte->hi.val);
        /*
         * We use cmpxchg16 to atomically update the 128-bit IRTE,
         * and it cannot be updated by the hardware or other processors
         * behind us, so the return value of cmpxchg16 should be the
         * same as the old value.
         */
-       WARN_ON(!ret);
+       old = entry->irte;
+       WARN_ON(!try_cmpxchg128(&entry->irte, &old, irte->irte));
 
        if (data)
                data->ref = entry;