From nobody Thu Apr 2 15:35:51 2026 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71D433CEB8C for ; Wed, 11 Mar 2026 10:31:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773225085; cv=none; b=r4KxjfF0WJpALPf5VJE3hPZV2aspIoFWllqxKaiK2Soc+TCYKmi5QJN1L8NfICEIj/dLp2V0OIUwHVol9YssHpbwQn3VqEROeNn9PtTXeHf5/9/FIPVQbs31inyMV2/rARPFUZxgEzh3aZpaX6iRYz2rHHDPxd15bgiXhZmghpY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773225085; c=relaxed/simple; bh=kPoRVNxNpO3Z50WxHXMMyqAvSb7QbpFQJukqGhW/z/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lzy7mC0tUSsJbGKT2M3mRnbtcnWJgZ4I3enhtsttzbFYT5M8bMymJQKz3Zvq5WNSMk/9wBQxhW02OEgbLKQfOkr2qQjjcuaJMnODvuwRgNzWOepXV4fG4dQEy6Pf8TPM5A/qqypeB5EeZdBwXIaMs2Ch/KC+qbe2KJbG0jHbn10= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=boAL0uv8; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="boAL0uv8" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-824b05d2786so10638012b3a.2 for ; Wed, 11 Mar 2026 03:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773225084; x=1773829884; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=68kFT9M+v1YFr8fLxiUdg7OyCK95BGAep7GJPhPQZJ0=; b=boAL0uv8SImXFMa/i5N5ON7QmtBzqz60ocH16rgrE01H7d947Chhzzo89axedinyzX R8FjAh9pxeTN/pkD87I495kK2kmslyIlrsuz7epCm52mRofHvr5rJU+mUEZT4nvJbbu3 dcXX1inZ1RU3nEs1HxFEkvO7VNEpOVrzQJqv5Sm4XxnMV0HyVELLmjbWs5l08KwO4ZQ0 hoJxEnz3kYT/sA5vCoQwnDti3XiLxOWMPf7nzcp/1kRwi8hnzG8rh4zQa9PcTWa2q1dv VuoZeOIJT+BBPksNTJk26r8YFQNZvUSe7GqIvxJa9HV23yx3CnKEt+NkCUPxXEx7lx9o UeCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773225084; x=1773829884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=68kFT9M+v1YFr8fLxiUdg7OyCK95BGAep7GJPhPQZJ0=; b=S4td6HnBY3r9AavDPfTYP5QRPpjxptcGI7/Cqd6yIQw0suiiOpZnuu6nso2P33lBP+ yyWJl3bpwD+ZJJ7EtE23lDY3RAdQWbQLMalTh7hjVCwwc+oFQvL9uEVJ+6fDLqoQy4DQ wG3eJWmUzpzGeMjVJnThvic1WHE0zUdQRlwQYhgRFJofRB/srJMdtVWRU86phdeeRANp 0Xl00SQ5PF5j5rXuJYPd1+dzslhlIseTqVy2ZoEvQjI12lEa8jDKhinxjrTWH1vxvnbB am6MZNps9LSmjB8BnD9HcsFGapNOrJf+aajoiTtai9F0XTFrmB/5ZUcKRWpBDyFCURRi vOnw== X-Gm-Message-State: AOJu0Yz2bY36ETgcrKmiob5flwuMfGZsHaVS76tvjNGlefQLEcL+Occo 2M1ZYr3aulOkfm27cDOIXvBF5ovWaYKUnjy0pFhCwxk4OaaMnisV3YlUFWzjAG1V X-Gm-Gg: ATEYQzyoKQ2Y5f622XjCz62VZNg2ZpDKYYlfegOB/sRyIJ7LK5jJCzkp468ElglapM8 u8vJrHZWHo/g7XQrotupEfns+w2gWkx2LquO8qj9L4m3NVikd7sI8s871m0+gmDmqDo7/WPsVH7 ByNokuJbUenaVDGkWz6CzzvPYudHYEU/18g3PrbN1yLFEPDTQyLNrIKAl2RGa5OFrwbU3+sWOJ1 bKBo4qqYlJ5CisuTWa8MAGC4h70H3pnI87+zollzbLRHoZhUSsz+e2oF0ssrZe56vi4rHci24RH vFfiH2tnrVyG4qwyXi5hKeuvCAb3C2uNiN/Jw6ozucNnxG8EBUkO/99p1z7F9AZ6Y4zqnH2Dc2k bcxF1Znm/0PRykrcU7ht4puoSH/blibJZgItZwG76RXTHb6VzroQ1XPoiglVU8JUZ8EM4WOMhNd A773fTMVO7PsK5OA59/8cDjgtkA77HQDOtnHJOx+bQ X-Received: by 2002:a05:6a00:2b88:b0:829:924c:3482 with SMTP id d2e1a72fcca58-829f7148a9emr1655467b3a.53.1773225083833; Wed, 11 Mar 2026 03:31:23 -0700 (PDT) Received: from 1f3ae71dd79f ([115.245.213.202]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-829f6eebf57sm2052558b3a.38.2026.03.11.03.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 03:31:23 -0700 (PDT) From: Sanjaikumar V S To: mwalle@kernel.org Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, miquel.raynal@bootlin.com, pratyush@kernel.org, richard@nod.at, sanjaikumar.vs@dicortech.com, sanjaikumarvs@gmail.com, stable@vger.kernel.org, tudor.ambarus@linaro.org, vigneshr@ti.com Subject: [PATCH v4 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence Date: Wed, 11 Mar 2026 10:30:56 +0000 Message-ID: <20260311103057.29-2-sanjaikumarvs@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260311103057.29-1-sanjaikumarvs@gmail.com> References: <20260311103057.29-1-sanjaikumarvs@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Sanjaikumar V S When writing to SST flash starting at an odd address, a single byte is first programmed using the byte program (BP) command. After this operation completes, the flash hardware automatically clears the Write Enable Latch (WEL) bit. If an AAI (Auto Address Increment) word program sequence follows, it requires WEL to be set. Without re-enabling writes, the AAI sequence fails. Add spi_nor_write_enable() after the odd-address byte program when more data needs to be written. Use a local boolean for clarity. Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR") Cc: stable@vger.kernel.org Signed-off-by: Sanjaikumar V S Acked-by: Pratyush Yadav Reviewed-by: Hendrik Donner Tested-by: Hendrik Donner --- drivers/mtd/spi-nor/sst.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c index 175211fe6a5e..db02c14ba16f 100644 --- a/drivers/mtd/spi-nor/sst.c +++ b/drivers/mtd/spi-nor/sst.c @@ -203,6 +203,8 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t t= o, size_t len, =20 /* Start write from odd address. */ if (to % 2) { + bool needs_write_enable =3D (len > 1); + /* write one byte. */ ret =3D sst_nor_write_data(nor, to, 1, buf); if (ret < 0) @@ -210,6 +212,17 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t = to, size_t len, =20 to++; actual++; + + /* + * Byte program clears the write enable latch. If more + * data needs to be written using the AAI sequence, + * re-enable writes. + */ + if (needs_write_enable) { + ret =3D spi_nor_write_enable(nor); + if (ret) + goto out; + } } =20 /* Write out most of the data here. */ --=20 2.43.0