Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp8060456pxb; Fri, 19 Feb 2021 06:31:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzuyDATQRMTz7PWyEPN9RfVi4KjelXI5Bu1h/RApKNvvYHHZxvEeTyqwHi92d+6rUT/+DEI X-Received: by 2002:aa7:dd08:: with SMTP id i8mr9451183edv.1.1613745078443; Fri, 19 Feb 2021 06:31:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613745078; cv=none; d=google.com; s=arc-20160816; b=Pdb9xhPAlArBYagjJcGu+0UYTnZARk3B5SfCgWRAoAGkzicMTBCsrny6xzdOGDNjYN b0TGUwQNWmCG3DJx4roY2ZfKFrFXElsMuaIrSEw0wmhOmOkqmaepxHVPuYNzT0bN+eyV uw6waErgwQIesRG3dO3Y/k8PZq4gc70QsRQ21v/fhLw6R+5gvSAl0Vh/BVuuCkfdoyfc 8cOmWNKH04aFKC9MzyQW1R1qyrgq18xMCS3Hrmu/UxbjNz2ZRjTGN5XfbJT5pXJxDg/X fTa4zDhqoaxqclq2XKIhc+NPp5ipxSpBDDFIxGlVdwXxP5KE2gFTtqiqIMqSFeXiI1li 0qRw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=1OJCjYpu0WKYwrWXB0M7VMQlalIINkuei1N/8NZJJdU=; b=Z7z5wg6Rz4gdvFCvkUyoeodlz3gh4rqNeX50m6ZBGa93JW1OVVRihMo45Rg7FbW3U4 WDfngzWpDmX3iID/DZsFhaI4GvgPDC1yEgzzmQpjwQAU9mdWAwkKgPD2/9vuTTgXEqNc uLf4iBkXHDmNwScfE5ScnI1A71cw996mDZVcfDCT3lx2kwD7QoNKKcjNCVt64FQGqJ+b xEUM7BpyOzNgpu6QEHm7K0HCN46MZvqHE9HnReXKZEPiyVs4ojd6PKO01jDSuMh8Rfsi mmyHAVYMYxwmqIwGfd9WcLqx0pPfjWuV9Y8eqQ3+GfaUUMt7vTx6OYKoweNGR1Logm9k wfcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=ILw3QOLc; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=VwoBi0c+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si5795999edy.225.2021.02.19.06.30.53; Fri, 19 Feb 2021 06:31:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aj.id.au header.s=fm2 header.b=ILw3QOLc; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=VwoBi0c+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231137AbhBSO3u (ORCPT + 99 others); Fri, 19 Feb 2021 09:29:50 -0500 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:38549 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbhBSO1w (ORCPT ); Fri, 19 Feb 2021 09:27:52 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 9DAA65803A1; Fri, 19 Feb 2021 09:26:31 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Fri, 19 Feb 2021 09:26:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=1OJCjYpu0WKYw rWXB0M7VMQlalIINkuei1N/8NZJJdU=; b=ILw3QOLcmKLAvYHs9EbtycGvMzPzR /q2rjTYX9paeZDV5silvCqQRX/lOWrAJzrdfKM4b9RcXMbgDHLCiCXQE654TIRiX i+hP71ONgVzb9V6SMX7etanb5VTZDbJ+1fdNkHCPj5sx+Uliv2Q3HyZYE0cYZj6t u66IWv+IRhy7vISZbHQDUV5mTOVinbR992JNXRDeL3aaK/vXlkLbJdO44r5qy8aL /7lnNxygofyeRRa5/mUYsip/owUxtRo/YNhOkhI+y92WSmz1BjU667pypZrG4fUz YlUlNpc9k/Jxg1mSWyN7EVA/uxQH1/LcocnNnrP0zyf/+59uvc+z99tAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=1OJCjYpu0WKYwrWXB0M7VMQlalIINkuei1N/8NZJJdU=; b=VwoBi0c+ CusmZmbajJMRZZ7aE7EtowVXbYWISA4msoMn/mmO2UdVUfMIFlo8oD9dUVoEZ1Mm prR1nDf5vkArHnOUYwVU10F6oF70tG5H0c6P1v3nlazkXT6eK7dVjcM8wnTN9kS5 adWQkFFEAxqnOCW6rdcxbFVmrMNwljIreI8MzaIluY6lNq8I8e+CRC+HNwWzHlII MdfKvAgDglzzVmZ0cFD91FLuxpd+7t/3HfYY7HgMyLYCF2p3e3dr0DwklCHc/vIK mY7PFpcp429+g/w17YN8xtzj0CQMR0bhu89HOtayW0aof6ZxJSyuo1cplBBUtjie LZuNQjriYfpOtg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrjeeigdeigecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpeetnhgurhgvficulfgvfhhfvghrhicuoegrnhgurhgvfiesrghj rdhiugdrrghuqeenucggtffrrghtthgvrhhnpeejgfdvveehteekveeggeellefgleette ejffelffdvudduveeiffegteelvefhteenucfkphepudegrddvrdeluddrfeejnecuvehl uhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomheprghnughrvgifse grjhdrihgurdgruh X-ME-Proxy: Received: from localhost.localdomain (ppp14-2-91-37.adl-apt-pir-bras31.tpg.internode.on.net [14.2.91.37]) by mail.messagingengine.com (Postfix) with ESMTPA id 40C66240064; Fri, 19 Feb 2021 09:26:24 -0500 (EST) From: Andrew Jeffery To: openipmi-developer@lists.sourceforge.net, openbmc@lists.ozlabs.org, minyard@acm.org Cc: robh+dt@kernel.org, joel@jms.id.au, lee.jones@linaro.org, avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, linus.walleij@linaro.org, chiawei_wang@aspeedtech.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-gpio@vger.kernel.org Subject: [PATCH 07/19] ipmi: kcs_bmc: Make status update atomic Date: Sat, 20 Feb 2021 00:55:11 +1030 Message-Id: <20210219142523.3464540-8-andrew@aj.id.au> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210219142523.3464540-1-andrew@aj.id.au> References: <20210219142523.3464540-1-andrew@aj.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable more efficient implementation of read-modify-write sequences. Both device drivers for the KCS BMC stack use regmaps. The new callback allows us to exploit regmap_update_bits(). Signed-off-by: Andrew Jeffery --- drivers/char/ipmi/kcs_bmc.c | 7 +------ drivers/char/ipmi/kcs_bmc.h | 1 + drivers/char/ipmi/kcs_bmc_aspeed.c | 9 +++++++++ drivers/char/ipmi/kcs_bmc_npcm7xx.c | 10 ++++++++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c index f292e74bd4a5..58fb1a7bd50d 100644 --- a/drivers/char/ipmi/kcs_bmc.c +++ b/drivers/char/ipmi/kcs_bmc.c @@ -67,12 +67,7 @@ static inline void write_status(struct kcs_bmc *kcs_bmc, u8 data) static void update_status_bits(struct kcs_bmc *kcs_bmc, u8 mask, u8 val) { - u8 tmp = read_status(kcs_bmc); - - tmp &= ~mask; - tmp |= val & mask; - - write_status(kcs_bmc, tmp); + kcs_bmc->io_updateb(kcs_bmc, kcs_bmc->ioreg.str, mask, val); } static inline void set_state(struct kcs_bmc *kcs_bmc, u8 state) diff --git a/drivers/char/ipmi/kcs_bmc.h b/drivers/char/ipmi/kcs_bmc.h index eb9ea4ce78b8..970f53892f2d 100644 --- a/drivers/char/ipmi/kcs_bmc.h +++ b/drivers/char/ipmi/kcs_bmc.h @@ -76,6 +76,7 @@ struct kcs_bmc { struct kcs_ioreg ioreg; u8 (*io_inputb)(struct kcs_bmc *kcs_bmc, u32 reg); void (*io_outputb)(struct kcs_bmc *kcs_bmc, u32 reg, u8 b); + void (*io_updateb)(struct kcs_bmc *kcs_bmc, u32 reg, u8 mask, u8 val); enum kcs_phases phase; enum kcs_errors error; diff --git a/drivers/char/ipmi/kcs_bmc_aspeed.c b/drivers/char/ipmi/kcs_bmc_aspeed.c index 061f53676206..630cf095560e 100644 --- a/drivers/char/ipmi/kcs_bmc_aspeed.c +++ b/drivers/char/ipmi/kcs_bmc_aspeed.c @@ -90,6 +90,14 @@ static void aspeed_kcs_outb(struct kcs_bmc *kcs_bmc, u32 reg, u8 data) WARN(rc != 0, "regmap_write() failed: %d\n", rc); } +static void aspeed_kcs_updateb(struct kcs_bmc *kcs_bmc, u32 reg, u8 mask, u8 val) +{ + struct aspeed_kcs_bmc *priv = kcs_bmc_priv(kcs_bmc); + int rc; + + rc = regmap_update_bits(priv->map, reg, mask, val); + WARN(rc != 0, "regmap_update_bits() failed: %d\n", rc); +} /* * AST_usrGuide_KCS.pdf @@ -342,6 +350,7 @@ static int aspeed_kcs_probe(struct platform_device *pdev) kcs_bmc->ioreg = ast_kcs_bmc_ioregs[channel - 1]; kcs_bmc->io_inputb = aspeed_kcs_inb; kcs_bmc->io_outputb = aspeed_kcs_outb; + kcs_bmc->io_updateb = aspeed_kcs_updateb; addr = ops->get_io_address(pdev); if (addr < 0) diff --git a/drivers/char/ipmi/kcs_bmc_npcm7xx.c b/drivers/char/ipmi/kcs_bmc_npcm7xx.c index 722f7391fe1f..1f44aadec9e8 100644 --- a/drivers/char/ipmi/kcs_bmc_npcm7xx.c +++ b/drivers/char/ipmi/kcs_bmc_npcm7xx.c @@ -97,6 +97,15 @@ static void npcm7xx_kcs_outb(struct kcs_bmc *kcs_bmc, u32 reg, u8 data) WARN(rc != 0, "regmap_write() failed: %d\n", rc); } +static void npcm7xx_kcs_updateb(struct kcs_bmc *kcs_bmc, u32 reg, u8 mask, u8 data) +{ + struct npcm7xx_kcs_bmc *priv = kcs_bmc_priv(kcs_bmc); + int rc; + + rc = regmap_update_bits(priv->map, reg, mask, data); + WARN(rc != 0, "regmap_update_bits() failed: %d\n", rc); +} + static void npcm7xx_kcs_enable_channel(struct kcs_bmc *kcs_bmc, bool enable) { struct npcm7xx_kcs_bmc *priv = kcs_bmc_priv(kcs_bmc); @@ -163,6 +172,7 @@ static int npcm7xx_kcs_probe(struct platform_device *pdev) kcs_bmc->ioreg.str = priv->reg->sts; kcs_bmc->io_inputb = npcm7xx_kcs_inb; kcs_bmc->io_outputb = npcm7xx_kcs_outb; + kcs_bmc->io_updateb = npcm7xx_kcs_updateb; dev_set_drvdata(dev, kcs_bmc); -- 2.27.0