From patchwork Fri Sep 13 21:07:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13804082 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CB1DFC6172 for ; Fri, 13 Sep 2024 21:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=h+zOvlVctybVKA0VSlSbXoHrQ20QfZEpI6GJ206EAqo=; b=gFrd1yngD+6rUxZ8S8GE0uttJa DFi67Lnb59gzlt7Nq/kftWselAPHqkny/vQbwqMctIQ8/qMUMJ9OWPTTo6KUNM5jtOqvqNK1Lii+H 77nEl+vQysWaFP7q3wqVyqh/XX4eSal4TioRN3GMeu0nptr1zecXRiuYRdAR7mwBV/79/9wnxGtwh BemQwZ350yPt5fEZ4O+QEr4TZ4ZRt52KbbNAdf72r3qw0IKILuXPZjG0sN28oBX7S9bdkzxexOOit Ynas4LKA+LPpXWdZUAQYDE2Rwp0CvM7JjCyAdv27NSXvi7tVeT2NEEPsQ+pvICNSJ0XvXHWxu8ALJ Vfdw+J1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1spDY3-0000000H8JT-293V; Fri, 13 Sep 2024 21:09:47 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1spDVz-0000000H8AY-1hrM for linux-arm-kernel@lists.infradead.org; Fri, 13 Sep 2024 21:07:40 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id BE8B1A4514C; Fri, 13 Sep 2024 21:07:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1BBDC4CEC0; Fri, 13 Sep 2024 21:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726261658; bh=YQLWHS/MsoePx6rxsH4eENXnN+TYWJB2F/5JkR3bs6M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rlo8Ga5zuHd5bgKxfDTXp6yl0pSgelwMH5wCi8zrbsmf+l/7MSIO75bGG399X+O09 xacjXexmd7zpAxG688IJKhCQFXoYe4irWMdBjMtiXHnKLPb7ZFAjprDS3uVH8Qka+z e4p/IR5/UL5vMknvDuGLiUIqg6Gho3Y2RXC/9DDO3jw47tJCvRB+ZZ/lMuU3r8k0lb n8BoiEp5UmnODQR7O0BX+4cUN1tbtr5P8lf+hgJ1H8oV7pffrLAIHot7ZBuH5Cet2K bTSlZI3m3x6YwQS5yhvCZL3mcdqQVJVRIUP0FpIR7mOzGxjGb8YdfaItFsiFHJWXgR dgmjnH6tcbWUA== From: Lorenzo Bianconi Date: Fri, 13 Sep 2024 23:07:13 +0200 Subject: [PATCH 1/4] spi: airoha: fix dirmap_{read,write} operations MIME-Version: 1.0 Message-Id: <20240913-airoha-spi-fixes-v1-1-de2e74ed4664@kernel.org> References: <20240913-airoha-spi-fixes-v1-0-de2e74ed4664@kernel.org> In-Reply-To: <20240913-airoha-spi-fixes-v1-0-de2e74ed4664@kernel.org> To: Lorenzo Bianconi , Ray Liu , Mark Brown , AngeloGioacchino Del Regno , Andy Shevchenko Cc: Christian Marangi , linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, upstream@airoha.com X-Mailer: b4 0.14.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240913_140739_544092_B3B47BBE X-CRM114-Status: GOOD ( 10.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org SPI_NFI_READ_FROM_CACHE_DONE bit must be written at the end of dirmap_read operation even if it is already set. In the same way, SPI_NFI_LOAD_TO_CACHE_DONE bit must be written at the end of dirmap_write operation even if it is already set. For this reason use regmap_write_bits() instead of regmap_set_bits(). This patch fixes mtd_pagetest kernel module test. Fixes: a403997c1201 ("spi: airoha: add SPI-NAND Flash controller driver") Tested-by: Christian Marangi Signed-off-by: Lorenzo Bianconi --- drivers/spi/spi-airoha-snfi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c index 9d97ec98881c..be3e4ac42153 100644 --- a/drivers/spi/spi-airoha-snfi.c +++ b/drivers/spi/spi-airoha-snfi.c @@ -739,8 +739,13 @@ static ssize_t airoha_snand_dirmap_read(struct spi_mem_dirmap_desc *desc, if (err) return err; - err = regmap_set_bits(as_ctrl->regmap_nfi, REG_SPI_NFI_SNF_STA_CTL1, - SPI_NFI_READ_FROM_CACHE_DONE); + /* + * SPI_NFI_READ_FROM_CACHE_DONE bit must be written at the end + * of dirmap_read operation even if it is already set. + */ + err = regmap_write_bits(as_ctrl->regmap_nfi, REG_SPI_NFI_SNF_STA_CTL1, + SPI_NFI_READ_FROM_CACHE_DONE, + SPI_NFI_READ_FROM_CACHE_DONE); if (err) return err; @@ -870,8 +875,13 @@ static ssize_t airoha_snand_dirmap_write(struct spi_mem_dirmap_desc *desc, if (err) return err; - err = regmap_set_bits(as_ctrl->regmap_nfi, REG_SPI_NFI_SNF_STA_CTL1, - SPI_NFI_LOAD_TO_CACHE_DONE); + /* + * SPI_NFI_LOAD_TO_CACHE_DONE bit must be written at the end + * of dirmap_write operation even if it is already set. + */ + err = regmap_write_bits(as_ctrl->regmap_nfi, REG_SPI_NFI_SNF_STA_CTL1, + SPI_NFI_LOAD_TO_CACHE_DONE, + SPI_NFI_LOAD_TO_CACHE_DONE); if (err) return err;