From patchwork Mon May 22 10:27:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 97246 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1345769vqo; Mon, 22 May 2023 03:35:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MEf6YuhJozD8nFZ6YKrSXOPV/EvrNjfF5JT76m/mu4bh/rOp7poPQyDXL0N0bFRj1Fz5Y X-Received: by 2002:a17:902:db07:b0:1ab:28ec:bf10 with SMTP id m7-20020a170902db0700b001ab28ecbf10mr13117816plx.51.1684751738150; Mon, 22 May 2023 03:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684751738; cv=none; d=google.com; s=arc-20160816; b=mnmYditpkpaVuWDcSqJPlV2RFC5QZFbh5hOK+xAqoBR0iRzjdhSqoBs+Kx8SHsGBdO 7A7Vxdx9nXAgPjaT+w4uZ3swhXcWm8aeW8BUBW/9dXju+C5ymtOpgcvbPcLMPAgdqkpt b5YvvITCw9DWS6pfIlAvukNMCneDaS0k5Tt+SDsGRo1UjTNUk0FrjwBjV7kvtt0yFRdE e9USZpwRJDp1la7gIYcY387C+Wkhf4Ev5czF2rfo6fXp1+lQtlrIsz962HtKeBIjV7RE ZzI88bwBNHyrdfHQDWLwnluO1RGw8P58c3GVG100E7EfD58bW47Xtx0wMTfAGPyIVg1S Qfcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=R3WTvXkYlPq6nWh192gzxgoVw4kAZ8FG0/Dvn8oavV4=; b=hQEGxyqdXgGF+RGPPdg4n95M5qVioOfv/+XJ5TDz8/lRPpAa1FIxjsq3o956CKPiqI r/m9jQhapdX+BENy9mdYe6mSrBMiPIixeCQo2ZMt/7WtOrBcccbj+Z5jALuSdKEQRYNy 8uop2Lt7SneOeUO0zI9rp3Xt3nH2UjK6yae0iAWkPu+xvZx/Efvpq/tC2OEFHlcS8lcl 4iZpxrJSOVg0B5QSxmzeXDerLpqmHfo1muDu1SlD0Fkl6Fo5yEzavhYWrH8/bZZkiyG0 YY2g41wJilCQXNOfq/kJzntiPwMrR3/qCjZqKMKGJ7bWAAeHHTHBcMpj3a+ghZ0tlkSE GTLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=y9xEExOC; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l12-20020a170902d34c00b001a686b1dc64si4508633plk.412.2023.05.22.03.35.26; Mon, 22 May 2023 03:35:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=y9xEExOC; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232880AbjEVK14 (ORCPT + 99 others); Mon, 22 May 2023 06:27:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232848AbjEVK1b (ORCPT ); Mon, 22 May 2023 06:27:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0890188; Mon, 22 May 2023 03:27:28 -0700 (PDT) Date: Mon, 22 May 2023 10:27:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684751247; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R3WTvXkYlPq6nWh192gzxgoVw4kAZ8FG0/Dvn8oavV4=; b=y9xEExOCP4djmA9SGETmAE5rLVXLjU4u4uQQvwrNt0l97srD1GA0bH+0+PlLuv4qeEeyXq g0QeE6BqferrOvzMC7cVsPVHyePL+8utpGbl9cBJrTnMg5603vfjFdn/VUE7hyvn7iKXXf Jde2CPMWa8y/FRCOQ69zQg0jKg+nNO7/eqWuS+9jXEYc+8615fslSNwjRe7tjNvMUt+9Ul 7wSyojhT0Gi0BQwYXuTGrJxlOaRBlLJhNwyLztGR9uQ+BMjO7bbYmo3iA9OBwqh/ACnfcG 7ShsIXs504fM2aU87dEFhPfkWryey3nCwGCalXGQgF7Fc6cat8YabfLrbFjomA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684751247; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R3WTvXkYlPq6nWh192gzxgoVw4kAZ8FG0/Dvn8oavV4=; b=OqoCm4ixzw8AUBWDtobzmduwkbJHFzonEx16Plf69YUmu5nDOUyJy1YkwfgEHYxixoQ1rK DqzZMvcUKi4vdhCg== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] x86,amd_iommu: Replace cmpxchg_double() Cc: "Peter Zijlstra (Intel)" , Arnd Bergmann , Vasant Hegde , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230515080554.315901115@infradead.org> References: <20230515080554.315901115@infradead.org> MIME-Version: 1.0 Message-ID: <168475124693.404.16075587226894097261.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765946826258426075?= X-GMAIL-MSGID: =?utf-8?q?1766590238405934739?= The following commit has been merged into the locking/core branch of tip: Commit-ID: b9ae9266b1965ad162c10af5c3d83571408dc3c3 Gitweb: https://git.kernel.org/tip/b9ae9266b1965ad162c10af5c3d83571408dc3c3 Author: Peter Zijlstra AuthorDate: Mon, 15 May 2023 09:57:05 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 22 May 2023 10:49:50 +02:00 x86,amd_iommu: Replace cmpxchg_double() Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Arnd Bergmann Tested-by: Vasant Hegde Link: https://lore.kernel.org/r/20230515080554.315901115@infradead.org --- drivers/iommu/amd/amd_iommu_types.h | 9 +++++++-- drivers/iommu/amd/iommu.c | 10 ++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h index 2ddbda3..ab8aa8f 100644 --- a/drivers/iommu/amd/amd_iommu_types.h +++ b/drivers/iommu/amd/amd_iommu_types.h @@ -986,8 +986,13 @@ union irte_ga_hi { }; struct irte_ga { - union irte_ga_lo lo; - union irte_ga_hi hi; + union { + struct { + union irte_ga_lo lo; + union irte_ga_hi hi; + }; + u128 irte; + }; }; struct irq_2_irte { diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 4a31464..1e9f85e 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3003,10 +3003,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) @@ -3017,16 +3017,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;