From patchwork Mon Jun 5 07:42:50 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: 103160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2513825vqr; Mon, 5 Jun 2023 00:45:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7kNSWJeQRAfIH4mSd0MwfRk2EnQEaqVBpQNk8vVkTmceUienQQikpT6cE0eb/tqLJwJXuL X-Received: by 2002:a17:902:d488:b0:1af:e4d5:703c with SMTP id c8-20020a170902d48800b001afe4d5703cmr2799712plg.61.1685951134909; Mon, 05 Jun 2023 00:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685951134; cv=none; d=google.com; s=arc-20160816; b=qqbQWNB5OqCElfGBFLPB/4sAzyqMh8Y/znigybmy47h3L2cvf0kTVaVKJtQnZkLesk k+oGWXgysUxBww3ZjQKpCWEAKh9e8DaPAjmAjnfeQLYjv8W9XMK2AP3i8hEaQuN6CWZP Iq2CWxpHvMz/LIy0APFMnDQA0kmkAulMigv2UWm/SgIMePzhotnZfcrkEaiYRkLOtbu5 t1YRMk1kNsDuyOWj3/l9aXEHqH1Ca0iIXz+YfuutsDRAlf00SGZs+i3ETys0u5pMs4fN 9WtJi7eg9VMUi2/cvlxmpwXofmceS+RGJstFbOu9g4i8UmpFZvFkbdmuQQIFPXUtqQui h0/w== 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=q7PdDgM6w1ufVrBg+pEhGG43hhM2mIg7TeX3hTEv1iE=; b=pNgvVJ+NZdjGkXPO/qOKSJVPJv+LD1b03QE+TO3bN/922IYHGo+ktgkpS3mzpQpPnq bVoAuXQ42/KxMVnRa0TEh+UbtoV1Yd/SzHBz75gJKZnV+g/TyMsh7N/8iXclCZ9aIO8n XXJ303jzhNY5yrGXQ08R8Re1mW8xtJKQWx1ehnam2sruNKJMGpU6OLIehDYe3lgdXsLU WBdpmAa0/nSNHZELXcpS2lMX5MsUnm2CQGIaUqRFgJ6bXIquGVhXOC866m6HUbCrJLU4 VgBqIBXIRCNiSp9hdqYjVnLl22hwbmYOWwLk84W4Qvj2N/GF4lIeAkqT5H1EVS6vHXUj 2xUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dnYOLynH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=mqJ1G+S8; 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 e2-20020a170902b78200b001ae7c646551si5011743pls.392.2023.06.05.00.45.22; Mon, 05 Jun 2023 00:45:34 -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=dnYOLynH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=mqJ1G+S8; 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 S231162AbjFEHnA (ORCPT + 99 others); Mon, 5 Jun 2023 03:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbjFEHmx (ORCPT ); Mon, 5 Jun 2023 03:42:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33832AD; Mon, 5 Jun 2023 00:42:52 -0700 (PDT) Date: Mon, 05 Jun 2023 07:42:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685950970; 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=q7PdDgM6w1ufVrBg+pEhGG43hhM2mIg7TeX3hTEv1iE=; b=dnYOLynH+ccQSoqIQs1FfRFJrlM/iz0zR5Ui9IFFAl5RdJ7NginDa0NUi79K2DG8ShW6Nl CapGle0C2HNfm43p9T8hiLAssdrKLVJXhGrOCiAoyuGVoBGNa6PRsorQg0YiWnqvXZYYB3 A/1Z2+7KCoQlNFLk2lOc9jIyC5Msa1fQcS2j/7rz0vQT13oXDnd+6WxnusiMjL68tO/HEq bB8l/tGEnlC6J9clEeRR3QxESnm5DCWOd7hBqy2p2l5iIMIZMyQydjz8KIXAV+hzO2OluJ 4sv8d2+CDyK/EP8Ot2lTn/6X+st+n5cB+x7dSNf6LONEqZrtSE1PFn3pYsXUyQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685950970; 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=q7PdDgM6w1ufVrBg+pEhGG43hhM2mIg7TeX3hTEv1iE=; b=mqJ1G+S8O8iWoj7q4RnD627S4271Tl2GxYr2QNhGw0rKJYD/Q0kvQwwmiiNF/ulP9qXmrA KAyC8L5H9gthczBw== 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 , Mark Rutland , Vasant Hegde , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230531132323.788955257@infradead.org> References: <20230531132323.788955257@infradead.org> MIME-Version: 1.0 Message-ID: <168595097042.404.1105917513854333768.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?1767417301087883853?= X-GMAIL-MSGID: =?utf-8?q?1767847897135356620?= The following commit has been merged into the locking/core branch of tip: Commit-ID: 0a0a6800b02489c1288f963ad290b6a4876a2cc8 Gitweb: https://git.kernel.org/tip/0a0a6800b02489c1288f963ad290b6a4876a2cc8 Author: Peter Zijlstra AuthorDate: Wed, 31 May 2023 15:08:41 +02:00 Committer: Peter Zijlstra CommitterDate: Mon, 05 Jun 2023 09:36:38 +02:00 x86,amd_iommu: Replace cmpxchg_double() Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Arnd Bergmann Reviewed-by: Mark Rutland Tested-by: Vasant Hegde Tested-by: Mark Rutland Link: https://lore.kernel.org/r/20230531132323.788955257@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;