From patchwork Sat May 20 10:49:02 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: 96753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp284257vqo; Sat, 20 May 2023 03:52:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/AEd5JNYWZsqDlnAu6RU6TBUWEGlgMrhmqut0ROocwyawkGG36LFAc1I0oXte7x9HC6WX X-Received: by 2002:a17:902:eacc:b0:1aa:f78d:97b7 with SMTP id p12-20020a170902eacc00b001aaf78d97b7mr5475922pld.46.1684579943237; Sat, 20 May 2023 03:52:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684579943; cv=none; d=google.com; s=arc-20160816; b=nqHcOpTcddpFtObuFsZP03nwZckzNtdNnkeFJHrVo9iiA5QXeua6RIQDxyT8kh0DoG y903C/f7ZX6SgA4L9EBvNp9Lmbj2UjZp3fT992xPqUH+QzscG6nh3OQVHlLjPGVmzUug eYhleRPXOuDlAOEunv+NVourieO41uXMlrdMPUqWUS/1y/hvK3g1RJtQgI+sBHnUEpEX d1DgPkLbpDJrfJe5dR632VkiJFpB7a8i2PdxQr1LrVsB5LgczofCkXFFLoOX0Gwjfj6V PFnz+/gtNvngG5sRCHGnc5z9uZ5smBww8UzLJjVxZ+1qoC+YQK9DMqwH0pKWVyY8Eogh 7wQg== 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=VEcx6R0vMTxhLaMxIyehMiLk4f4YLBPdXojbYXfq0QU=; b=Px3wRFjYfSUyCbE1GHPKtpZKpUqv17Nqnxok0FZktn4+3w5y8GHFGS0AWDQ05c4c3b we2aMiJx6SXBbM1suj8RlsFHnawCt4wjMoSvXNYv590hdCmGgYjY1qDCJu2Wg9AZaNcb zZGH7wc9D97yRGnxIZIzg9NNxk6EB+T757CEA8NY5mfVI6Qsqqcek5pxNb4VkCI414ih 7K80qrcpWtOovrCwPbP6RVFuQ+vhVLvtet2OVTvwblKZUwwdsQevGn95v/iSYAYMKE8U Xy0Lfl57jd1CP/8jpgC/5oeF7ASrF1SlOarerHVnCeB21fZsNDRH1WgwzJXcUBYjZJhm UYbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Nrk2CMMw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 g1-20020a1709026b4100b001a4ee6ec8d3si1203565plt.65.2023.05.20.03.52.08; Sat, 20 May 2023 03:52:23 -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=Nrk2CMMw; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S231593AbjETKtK (ORCPT + 99 others); Sat, 20 May 2023 06:49:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjETKtF (ORCPT ); Sat, 20 May 2023 06:49:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3566AE54; Sat, 20 May 2023 03:49:04 -0700 (PDT) Date: Sat, 20 May 2023 10:49:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684579742; 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=VEcx6R0vMTxhLaMxIyehMiLk4f4YLBPdXojbYXfq0QU=; b=Nrk2CMMwNGV5+iGXON1q75dYapEFejIW8Q+LEXt67DFV+lHRbG55Lp2JHZgG2wy1xhvX0Z kd2lCrQ/FPVO1uFlBK7AOK9gRCRNgCXKZfr/Gx/56eqgMShEvzVHiHw4HDDR06Cn0PtWRA vkPnxAqjFDUKYbKPi+etkekA0xPomySk91L/SWU74zp2sYhw+QxrMfG+hfwAJj/WrGIyVq PR8JOiiJGc3IeNFfl9f2Hm9lOvMz5KKf2JSxnpi4FKUK3rz/sHrbQ+qGE0msbgDDpinl8A Xlvx1DK+aUyA/NoSVIV4bGNExXP4iknAg+99EvMjede12WgzeFPsF6LLVG3/yg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684579742; 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=VEcx6R0vMTxhLaMxIyehMiLk4f4YLBPdXojbYXfq0QU=; b=ek3uP4UcF/SoyPSzt0DEz8O90yYXxCLWkM4lNTopS8zgszWp3l1NyC0n9k/LXikyFSKpkq kDCVslOku7izC6BQ== 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: <168457974238.404.5428671026952030867.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,URIBL_BLOCKED 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?1766410098520742425?= The following commit has been merged into the locking/core branch of tip: Commit-ID: d41f6f473d0f825678585fd1d782b4bdb9c3a528 Gitweb: https://git.kernel.org/tip/d41f6f473d0f825678585fd1d782b4bdb9c3a528 Author: Peter Zijlstra AuthorDate: Mon, 15 May 2023 09:57:05 +02:00 Committer: Peter Zijlstra CommitterDate: Fri, 19 May 2023 12:35:13 +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;