Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2857892rwb; Mon, 15 Aug 2022 12:43:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR47U5WM/VYxVmY8pX95Gu28PzBafYV0coJr/N52xB1Y43wQd3/4hQtt0snFzkYJbEjXzUkU X-Received: by 2002:a17:902:7c90:b0:172:5f2a:9e3a with SMTP id y16-20020a1709027c9000b001725f2a9e3amr11219767pll.1.1660592628556; Mon, 15 Aug 2022 12:43:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660592628; cv=none; d=google.com; s=arc-20160816; b=Dfr3elIYGwr1QgFihuqZOaZHlKJDzN9WolUXKH+Hpb9R9JMWfwSsrMnRKkCdD7igfy kbHlfTPo+2QaBUHFcCq40OgAqQqpAKXw9jGsQMEDYHFaU732ASGJl0WftJpY8VzAqWzE MXCLr31D4sd3I5x7yd4kcVQlITEJueyzX+ku3p2pnHln2o8sUMqVkNKCbTd8fElYsSzy Atn3LlzD6Jld3NMcKzM1f7GyNuejKYY9qvWN+SAySnkzEsfoWUqMFznzR1gMShWpl5xy EaHDYNlf/VhXnXCAVFaDEY5MBzSXDVT4hGqEcVkfAybRzWxXYeKX1ix5nxZ46mGa4c+z kKhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+0xxTc9VtxYc7YvA92BzDLTOc1kL3AtjTwv+zcrG5tI=; b=W1nmL5HDZ3FQK4NyjfYYXAv1NZI7TOwSKsTOHrLOk+TWsmIR+MUhdlpzqJlmtuo+b4 c99XvPsv3u9U0wwFsoe9dXYPllmE6xerxSHtn+OYBOtJpp+X88L8R3MH/lzrHhATAA/i B9GIZwcQ2TKB+aw49+bhT05rA+6gXxmoEBKg2qjdgx9n1n1QjGcueQ/YM63mml7tyPag 1KGHc8o2AhVYfPnO+O3f7RfgYE/XikUu9YRss7QsXMB7Hi6m0+xYj85RtY+8Q2gvaAwN unBcVTEJUV7AgDQ4F1ZHg4ulHw/F2v11x/fpV/BO/LoVIzl8/Vui+3RWMNGAQtJWBGaL BFOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tPXasR58; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y14-20020a17090aca8e00b001f3185e3a9asi13324747pjt.112.2022.08.15.12.43.37; Mon, 15 Aug 2022 12:43:48 -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=@linuxfoundation.org header.s=korg header.b=tPXasR58; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344211AbiHOTm6 (ORCPT + 99 others); Mon, 15 Aug 2022 15:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343991AbiHOTiU (ORCPT ); Mon, 15 Aug 2022 15:38:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87A993ED72; Mon, 15 Aug 2022 11:46:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2579F611DB; Mon, 15 Aug 2022 18:46:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25AB4C433C1; Mon, 15 Aug 2022 18:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589192; bh=DQqfjIPCusGfeXhHiEnPPDYHHL0EQoPeHiJRj6wvgJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tPXasR58sE+90u2/LePNj/asSGZhDi0had+c5Qg0HK/CyPQm/eErq6YAgBzB7/9S+ C4c0tIiM+MtUbl/lHWBchxRO2ErSOm475ciUg+n4R5yNnyo6ghnjN3grjJCDiKfMi6 n9lGXrziD6PC4HdURmaKGQTslyIaqOvsuvaKNFDI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiko Carstens , Alexander Gordeev , Vasily Gorbik , Sasha Levin Subject: [PATCH 5.15 642/779] s390/smp: cleanup control register update routines Date: Mon, 15 Aug 2022 20:04:46 +0200 Message-Id: <20220815180404.804207438@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Alexander Gordeev [ Upstream commit 9097fc793f74ef9c677f8c4aed0c24f6f07f0133 ] Get rid of duplicate code and redundant data. Reviewed-by: Heiko Carstens Signed-off-by: Alexander Gordeev Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/include/asm/ctl_reg.h | 16 ++++++++++----- arch/s390/kernel/smp.c | 36 +++++++++++---------------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/arch/s390/include/asm/ctl_reg.h b/arch/s390/include/asm/ctl_reg.h index 04dc65f8901d..80b93c06a2bb 100644 --- a/arch/s390/include/asm/ctl_reg.h +++ b/arch/s390/include/asm/ctl_reg.h @@ -72,8 +72,17 @@ static __always_inline void __ctl_clear_bit(unsigned int cr, unsigned int bit) __ctl_load(reg, cr, cr); } -void smp_ctl_set_bit(int cr, int bit); -void smp_ctl_clear_bit(int cr, int bit); +void smp_ctl_set_clear_bit(int cr, int bit, bool set); + +static inline void ctl_set_bit(int cr, int bit) +{ + smp_ctl_set_clear_bit(cr, bit, true); +} + +static inline void ctl_clear_bit(int cr, int bit) +{ + smp_ctl_set_clear_bit(cr, bit, false); +} union ctlreg0 { unsigned long val; @@ -128,8 +137,5 @@ union ctlreg15 { }; }; -#define ctl_set_bit(cr, bit) smp_ctl_set_bit(cr, bit) -#define ctl_clear_bit(cr, bit) smp_ctl_clear_bit(cr, bit) - #endif /* __ASSEMBLY__ */ #endif /* __ASM_CTL_REG_H */ diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index 982b72ca677c..7bbcb5b8d3f6 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c @@ -579,39 +579,27 @@ static void smp_ctl_bit_callback(void *info) } static DEFINE_SPINLOCK(ctl_lock); -static unsigned long ctlreg; -/* - * Set a bit in a control register of all cpus - */ -void smp_ctl_set_bit(int cr, int bit) +void smp_ctl_set_clear_bit(int cr, int bit, bool set) { - struct ec_creg_mask_parms parms = { 1UL << bit, -1UL, cr }; - - spin_lock(&ctl_lock); - memcpy_absolute(&ctlreg, &S390_lowcore.cregs_save_area[cr], sizeof(ctlreg)); - __set_bit(bit, &ctlreg); - memcpy_absolute(&S390_lowcore.cregs_save_area[cr], &ctlreg, sizeof(ctlreg)); - spin_unlock(&ctl_lock); - on_each_cpu(smp_ctl_bit_callback, &parms, 1); -} -EXPORT_SYMBOL(smp_ctl_set_bit); - -/* - * Clear a bit in a control register of all cpus - */ -void smp_ctl_clear_bit(int cr, int bit) -{ - struct ec_creg_mask_parms parms = { 0, ~(1UL << bit), cr }; + struct ec_creg_mask_parms parms = { .cr = cr, }; + u64 ctlreg; + if (set) { + parms.orval = 1UL << bit; + parms.andval = -1UL; + } else { + parms.orval = 0; + parms.andval = ~(1UL << bit); + } spin_lock(&ctl_lock); memcpy_absolute(&ctlreg, &S390_lowcore.cregs_save_area[cr], sizeof(ctlreg)); - __clear_bit(bit, &ctlreg); + ctlreg = (ctlreg & parms.andval) | parms.orval; memcpy_absolute(&S390_lowcore.cregs_save_area[cr], &ctlreg, sizeof(ctlreg)); spin_unlock(&ctl_lock); on_each_cpu(smp_ctl_bit_callback, &parms, 1); } -EXPORT_SYMBOL(smp_ctl_clear_bit); +EXPORT_SYMBOL(smp_ctl_set_clear_bit); #ifdef CONFIG_CRASH_DUMP -- 2.35.1