From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00749606A32C for ; Thu, 3 Dec 2026 21:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.u-boot-project.org header.i=@lists.u-boot-project.org header.a=rsa-sha256 header.s=default header.b=PnHIa+aJ; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=dH5YzuQT Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 93E1940D45; Thu, 3 Dec 2026 21:39:05 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id A7j9Tng_vQAP; Thu, 3 Dec 2026 21:39:05 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp4.osuosl.org D1BA2407D8 Authentication-Results: smtp4.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1796333945; b=p0aeLlJE/q/rIDZuTNPuCzgosgg61277wFXhESiaJh+N4H0wLdqRtfkjHpcDIFpSQO5R JW80AzwD2b0p83TAsqfMll4FMd6DcGpE2JLpw2PXjDuovn+QLZYYXS+duvxBk9GhGwjYE 4Nb6eMAkjupJ9hwtarQ1XaNIF8/M8g4ZBaADegmowERvqPsnnGPqoHR3+SXRtDYm2Fkro RZ/XS7v7WuyJ/YNI28WGohEawtw88iuv/EH4i1K1gEkjw4lcqFq8ST9MMlWnDd3v9z9XV mfIVFvQdqZ2iRDDk02Mb1DrzF09wI+7v/w92N877EfefpD3sIzwbrp8Sb+55vRhcxvg== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1796333945; h=X-Comment:DKIM-Signature:X-Original-To:Delivered-To:Received: Received:X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level: X-Spam-Status:Received:ARC-Filter:Received-SPF:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-Mailman-Approved-At:X-BeenThere:X-Mailman-Version:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:Errors-To; bh=0nMx9HyI2aFer/5RNLPwuLSPNgTOWnoUTisasJuTJ9Y=; b=Fw4EiPM4vZg+LeEsj/lLQhoazoNON+G8jbMPePQSV+eevDyf2e/mBp8UAkNdLWRXOd9+ EHJDoHQPL0Kmmmhg7EM8L47YbWm1ZFpEQhQ7f+jZHho38j+sOg6OzLN5vxFj4M+KVteS9 gyd/qzMEO0dYgmTZXkldD4o96mr0hKDGI0osG+JScjbuiw5nDjXXlVSj20aLJR7dJUNwm cKYfzsTx8Ix6V8AsHsp0NkmGYujV9y1Njl2S3t6GBu4/YmfKGOwPL8eXD7NLKQoHQZ99A YrAp0pm/7lX2lwwOFwhBMy5ZJE1s5wKFnPkAdeKmzfB7pdITeiO+KHCRz0RGG3j9EEQ== ARC-Authentication-Results: i=1; smtp4.osuosl.org; arc=none smtp.remote-ip=140.211.166.142 X-Comment: SPF check N/A for local connections - client-ip=140.211.166.142; helo=lists1.osuosl.org; envelope-from=u-boot-bounces@lists.u-boot-project.org; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.u-boot-project.org; s=default; t=1796333945; bh=0nMx9HyI2aFer/5RNLPwuLSPNgTOWnoUTisasJuTJ9Y=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=PnHIa+aJjQlpWBjLBzxJ3XzDKKBkCPa+w7yJLMpAZivX+LeSzWu0Ff7Ce3Vx7HKwx dBDvARAMH0CtjtLD05+9k3Uo6L6pkz6UPW6UZtaZ5P91ZDwd9kB5+gAXrrv92b2i6B nOECBTOUYhfV8lSiaB8epBY7tWou/6c8sXzreTP4/reEidCKAFZPuI6ipU97Vk+bVQ Yare8tu84qVBuTnXC7ulCWp7uU7yLZSO/dSylIZ22V4fEd54iTPgmw4TVKjVRtHzW2 1JhRJS28GFvIv6syLZbc15nXiaTwQIviz7xqzJL5cIEP0Aw3IvoHrbH66EgJ6dfBSn 4qdsM+7RHMfOw== Received: from lists1.osuosl.org (lists1.osuosl.org [140.211.166.142]) by smtp4.osuosl.org (Postfix) with ESMTP id D1BA2407D8; Thu, 3 Dec 2026 21:39:04 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists1.osuosl.org (Postfix) with ESMTP id EAF1636A for ; Thu, 3 Dec 2026 20:17:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D1421400E4 for ; Thu, 3 Dec 2026 20:17:21 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id gU9NH5a8p0-5 for ; Thu, 3 Dec 2026 20:17:21 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.2 smtp2.osuosl.org 0F332400BA Authentication-Results: smtp2.osuosl.org; arc=none smtp.remote-ip="2607:f8b0:4864:20::229" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::229; helo=mail-oi1-x229.google.com; envelope-from=oss.patchbox@gmail.com; receiver= Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=dH5YzuQT Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by smtp2.osuosl.org (Postfix) with ESMTPS id 0F332400BA for ; Thu, 3 Dec 2026 20:17:20 +0000 (UTC) Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-4af81963f35so177366b6e.0 for ; Thu, 03 Dec 2026 12:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796329039; x=1796933839; darn=lists.u-boot-project.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=0nMx9HyI2aFer/5RNLPwuLSPNgTOWnoUTisasJuTJ9Y=; b=dH5YzuQTNuwhBAvbfawzSij0hohJqsYAVCK013fQPjzfvF2z/hs626aBdR255eRgoT Al7k/PLAkRM7+BsYgwY2qM62IQh7ZPQVrueuPd2hhpWYfrcRjA8whgYK7umjlfULsmGV 0L5V9Tu5BL7rXpS57QNJf7dsnxPxlp8YLxpSB34z9qpRohjNCwD3UdfoJtIcGYzRVCv8 3YNk3Ug4+tenxwlHM9iPdyvRkfUOcOUfigZySsigG/1eh4ablGY5XRPruNRq2RYHxrI7 xc8ata9fczQUOhN8D9z4LxsdQicqAG7QNNiQbzgkKNOiztt+VhvcrdGMSEtaMrRQGMcX VzTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796329039; x=1796933839; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0nMx9HyI2aFer/5RNLPwuLSPNgTOWnoUTisasJuTJ9Y=; b=TgJIa5oQbI5OgqcqGq66HAO6YPv8f+9n+eWfC1SobGUvbpuT3KtVz82CK8LmzRIF5W X5ejNIx+Wm8nRcdd+WjapikmBknZ4oNcJ6PlpUcjOs1A6i734A49Tl2XdIqzjOjNI9CG 4MfBbNDcys19Fknh1hVbD0l9wNmRkC0gXt1ioOSd+oSK6cT1sLxCkTL3uC7lvP9K4MxO T5gTdNVwQqTLoVDBQMwHfzVV7xZIUFYjadGuEg5SDN52j/8cdeeurHaK9TPomyd0UYxN M2NkRV1USg2oHKyffnUyJr2/O2PvJbeHxRpvXXVdDtUj1UlkxKPNYETSsAtLc4gubrHe Ks1w== X-Forwarded-Encrypted: i=1; AL+hErFUkv7INqqd4c5ceewbUpVwe8CVhoHvHqKrbzqI0Sp6lpJB710AkS+sKa261QQJDTEoc857x3g=@lists.u-boot-project.org X-Gm-Message-State: APuU4Z9viZV2QdXQC++8wkYrkqydBTIKqGVR0rzbTOyKcsumsAFjSNZ/ rActDyCZvdhxxLmESM3p31z4sR62DglJWPnySyHFZ2atyErHKZoQYZPy X-Gm-Gg: AZFdTZf8QkA22wMASDR5e3CWOaluCZMCJlBQUTd31zurP7Ki5A3vKENQ1aQYwUPdIsQ vC3+54OwnNLY2vEAMD5sx5ZzeDI03sC5JVc0zrZGpHsr8U4f9XyK23gsvovnY2AqEggTd2HR2SR 26b454N3IReAH0+K3CQwDQVTHbJGk/KTZBPKLSAXV/XuZtxQrP16cvkgD6Wxi2f887VEjbVldyp jIAeTSFxhpps4UWbJYextS/5GmTghYgRFp07+kBzPFR6E6aQjPh5q4W1xAM8x5kZ1Erntp6Gn3D VKYq8O+S5gK0/86dT2Iseh1FQjHddBEMJwSrhOb4ZrBZe2s8LJ1Q/tSH2Xb13SNX3502rOq391w r7OU5XuSTKu8q4v4yD79sWLD0eIJ2MELSzjOXTfgVk9X/aKcMWEeXls69QLLszvqrEZLrea/jvn NUh7kBR15Z2GOc+qeJleDv9PcrMBZrHJYtNuOzJLf4gw054qEz/LaFddYNwjXt7rZyBI6HDoIFw jL7l4jyO0XVKhXSRD/R6ERTqsoAPby1hkFxQdauZvBBW0NEIA49EcTXELW8IpRJGMuXrJU9nFGo q7ZurvbzbZExi2OICdk0vtG5O5AJ6+eA16CSSFn/agFaUFYJN3pGdVYZni4Cst3ax4U+lAsSEg8 CxWORwNXMZMfc4ilmGmMzFlCHQZVsu3CJgJQ2JV1wGhsaDeRL8rGHAgK2rqlWhizY2Sl0kORZGv Z7z4+nvBm7Oq1u X-Received: by 2002:a05:6808:1694:b0:57f:daa:9b68 with SMTP id 5614622812f47-57f0daa9e2fmr2628987b6e.15.1796329039496; Thu, 03 Dec 2026 12:17:19 -0800 (PST) Received: from tempest-testimage-cc-centos9-stream-server-1191361818 (chi-dyn-129-114-108-164.tacc.chameleoncloud.org. [129.114.108.164]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57a35c5ac5dsm35058122b6e.15.2026.12.03.12.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 12:17:17 -0800 (PST) From: Yuho Choi To: Vignesh R Cc: Takahiro Kuwano , Tom Rini , Ashok Reddy Soma , Abbarapu Venkatesh Yadav , u-boot@lists.u-boot-project.org, Yuho Choi Subject: [PATCH] mtd: spi-nor: Return the error when write_bar() fails to wait for ready Date: Thu, 3 Dec 2026 20:17:06 +0000 Message-ID: <20261203201714.2129394-2-oss.patchbox@gmail.com> X-Mailer: git-send-email 2.56.1 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 03 Dec 2026 21:39:03 +0000 X-BeenThere: u-boot@lists.u-boot-project.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: U-Boot discussion List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 write_bar() returns 1 when waiting for the flash to become ready fails, but its callers only treat negative values as errors. The read, write or erase then goes on without switching the bank and uses the same offset in the previously selected 16 MiB bank: a read returns data from the wrong bank as a success, and a write or erase changes the wrong bank. Return the error from spi_nor_wait_till_ready() instead. Fixes: c480ec2c45b2 ("mtd: spi-nor: Add parallel and stacked memories support in read_bar and write_bar") Signed-off-by: Yuho Choi --- An LLM helped write this patch and the reproduction test, and run the test. Tested on sandbox (origin/main d1caced3a43) with SPI_FLASH_BAR=y. The sandbox SPI flash emulator was changed locally, not in this patch, to emulate a 32 MiB w25q256 with an extended address register and to fail one status register read on request, so the wait at the start of write_bar() fails. Bank 0 was filled with 0xaa and bank 1 with 0x55. Before: sf read 0x10000 0x1000000 0x100 -> "Read: OK", but the data is 0xaa sf erase 0x1000000 0x1000 -> "Erased: OK", but offset 0x0 reads back 0xff afterwards and 0x1000000 still reads 0x55 After: both commands fail with -EIO and the flash is unchanged. ut dm spi_flash and ut dm spi_flash_func pass before and after. drivers/mtd/spi/spi-nor-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 7bc889c9629..57640908765 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -966,8 +966,9 @@ static int write_bar(struct spi_nor *nor, u32 offset) struct mtd_info *mtd = &nor->mtd; /* Wait until previous write command is finished */ - if (spi_nor_wait_till_ready(nor)) - return 1; + ret = spi_nor_wait_till_ready(nor); + if (ret) + return ret; if (nor->flags & (SNOR_F_HAS_PARALLEL | SNOR_F_HAS_STACKED) && mtd->size <= SZ_32M) base-commit: d1caced3a435607435cb7969e34499051a4ac1e6 -- 2.56.1