From nobody Fri Apr 17 06:13:01 2026 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 77E5D34EF0C for ; Mon, 23 Feb 2026 10:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771841869; cv=none; b=C8aqNbhk25gTUrYrZRjHvsJieBtAg0bv3kxBvGahEbXfQNIn+8wCH1NPGCQLgnKewhlHY14pZurvprXjSoRfR+23Sf6mnz7CX2kgAtQPR+aHuo8Sj5XGpX55PGO+3SeDm+X2i+MC01yjyId9kvYtawBrhYur89XEUW5rvISvJVg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771841869; c=relaxed/simple; bh=kPoRVNxNpO3Z50WxHXMMyqAvSb7QbpFQJukqGhW/z/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bnjLAIGet7D0jlj+Bmr0RxTkAYYMxDRunrhOvtAF3vCcNn+vXSF4oCySl1bFX1Z7Nx3sPsM/U+ju61Wo5rAbVq6QY4jF1CApuLEYrTViJnRuZwInKm3g+NGeQyiti25Ogmiyf8ihKpmYZQ2QHiRwxLoDTIJGDfRs/ckfUnV0hxA= 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=FZ4NRp74; arc=none smtp.client-ip=209.85.215.176 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="FZ4NRp74" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-c6e2355739dso1410337a12.2 for ; Mon, 23 Feb 2026 02:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771841868; x=1772446668; 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=FZ4NRp74IAvPu8rwJR61Zyz7ImSvEqWC1Y2//oSxQMiCiMmR3Wgl67PA/aqkki7SDj rgV2Fxrm1mhQgmbwPGND6P4lzglHuey/NAxCvahNFZnH4aHnl+KM1auziRe7/yrGHekF MgxICmGZvzmR3ymZoVuHDWZ59wnqvIucqe3B5ZDNSLuXuCfsFO5WiPCZ5athgem+n8BT mhzTwfbFYvOBCEiBlYdqekd3X2PPtG8E/CaCbpriwkuIj++IiF6hmQttoBz/AuRAlawj YAJfuMWBqou6B0zv6uJb6WI1Tndxunw8T5r2SYHbJhibTdPpjj/0Z5ZdfKdNtzDHMxPa kTDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771841868; x=1772446668; 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=LE1f3zr4D92LXgr6Y8uH/V/iDo37/MwJUf2iQY86yB7GxMDR095b4i6CeigWCy5Nb2 Uxy/DyCOEOYIM+lzAxST6c3zdNK2zNFj8HSpXDLmHGRf1rgX6vFFPZJmS32XAtJlY6+6 UqmSuNwMi0iGjOTx7vvSy55ufeBGynQyTfG+7zrMx4xVJ7AwWkildm+6zBfX02GuDGRh T9qk85xHlpEDizYB7ns6BmRnKi11o8VSEMX3cCEasgee04opL2NH4iD5m/v/QvA7+OpS AcuHOX6gjPbcuGrIor8gjuLcIKcFyJbOZucgRC0b/VBoABRD2sUvu7wBGSS8WnlBTQeY oSGw== X-Gm-Message-State: AOJu0YwtDek9A/Y3IwtkGN7f/RZxM5/zvY2uai1cfGVmW+NZ40cHv5Gi ZfbIQSUJGEFz1xrfsEALOu6M3sXcoJVRPMiwbcfDnpr5l3obS23Ghsf1 X-Gm-Gg: ATEYQzxQlczkV7e4Oar71Nl3yoJvBSDurvz/8p5CQp6spLXBQzi2/GMCc2osHoMn0Qq Maz/X4uDCvHdqJ6x0Wair+sU02ngmYusPaW6FeV6j08//MvS1rJQsZUw29CVGka/JxSbzfqYWzO R4noBdn9a4BBoZu7tNewlAWS9S2SAkQB2gCtze+7Om1DzuxnPFytLOF2bqoqe7X7DUbb2M1Cwud lcoq3hTSGr/WZeD5w+s68TQrpwoE95W8RUPAreGafFuL2GKq1/1706saNJIL14LVIr/wCgjAh3p FWkdOljsKYt7dFYUYc1tsKI461XkgftozWveDcdn/v3sIJIC2Uw/uEyE7dR1UWtFBIyaIbpj8gj m7sAWqdx7ozwIC0qS1BxkEhrp3/YkrK/tn/Vl21CPKY5yDOBKVPMSgTzJB/PhDbcUVaK/GOqLiY bIpLp/o3E3S0gHQMvf/1nSALdnB17HysePWFzFzdef X-Received: by 2002:a17:903:2c05:b0:2a7:d5c0:c661 with SMTP id d9443c01a7336-2ad7443a1c0mr70941425ad.15.1771841867797; Mon, 23 Feb 2026 02:17:47 -0800 (PST) Received: from c6dfb3cc7c9a ([115.245.213.202]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ad74e3425dsm66574795ad.16.2026.02.23.02.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 02:17:47 -0800 (PST) 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, sanjaikumarvs@gmail.com, sanjaikumar.vs@dicortech.com, tudor.ambarus@linaro.org, stable@vger.kernel.org, vigneshr@ti.com Subject: [PATCH v3 1/2] mtd: spi-nor: sst: Fix write enable before AAI sequence Date: Mon, 23 Feb 2026 10:17:17 +0000 Message-ID: <20260223101718.89-2-sanjaikumarvs@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260223101718.89-1-sanjaikumarvs@gmail.com> References: <20260220094236.28-1-sanjaikumarvs@gmail.com> <20260223101718.89-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 --- 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 From nobody Fri Apr 17 06:13:01 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 BC879356A24 for ; Mon, 23 Feb 2026 10:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771841878; cv=none; b=mVSUrgqx7hmVknWmYoWmtVFJ7UuaSK5tzWEI9Tw4p90aUYAjee6yWHeLwYek68KyUfy5+O/b7FYrcBGKzylf38QCYLmVtfSCR2SLlSZbyg9TjYrDix6V2HMV94NYUFwH/U7RapNFYuH1TwrJLCUeZA12lqiThyKgviTz7HvFcO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771841878; c=relaxed/simple; bh=JDc/qo7rkUOcZGNhJ0Wl/HeJIKj7/AleosrYhzqya/c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XVxP0YwOG4dIlMNTnX0VnASunEYT4Lh7aSg4RzCYDop/vq8lI1hio101nI6cc8/GlvieCjppRviM9jNvpe7duz+0VbXYTksmw5u0MiajdRjlYLUxzDJiiMLmNQ5mQ213gvD2lfuqukcBq2eWNAIhUurHId0Zejt/gueQBd/eYgg= 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=LfAPOLYH; arc=none smtp.client-ip=209.85.214.172 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="LfAPOLYH" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2aaed195901so19540075ad.0 for ; Mon, 23 Feb 2026 02:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771841876; x=1772446676; 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=ZxR8y+DDVU/sD2lLySC6/WbxsSmg5U6pRubVnyPkrSo=; b=LfAPOLYH6/CYmyGD7y4Gx0nzk6YR60hu8x8bNhN9eHhmgHw8AKeWeSjbFYxfNGOF7y PSLRHi7NwZMGQNxMuzaeUQ3Bk5CtRIl9J/R2KUPpuksndQKe1+67t+jG16kpqYNnUYcM Vx+Mvx2zPXp7xSkGWtL121S0fuVWFkpWVJF5RBvVXbncaTyTV6EJreHK5eQpkChjKJjO E15Y7c41PukhNxqe4QThS9lsby/UeqSWovmDilGFYmJ+jhD3/n6asTMFJn8k5URXiBS4 AMRMDX+2i8GocCiuRHrP54kNAz3UKQxG/OZK1GVSDj6hBuZFaY5prAxGvpAQZS77Kd5X /lUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771841876; x=1772446676; 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=ZxR8y+DDVU/sD2lLySC6/WbxsSmg5U6pRubVnyPkrSo=; b=Vu8HsGny9fQHmIs0Ln8X5Pk5rpbYCk65vAg4dPmu2zSfAfgN/l/RVASOc0n7pCUOxG OiE58syIHicgFsINrvzCMBlWj8ph+e/Vf0wF8V91QnySWgJBjUHrY+wbkXkLogS2Y9Zl a2Xp80wsmZOOgQCglNFc6dQiOwwcN7K3oDfBc7VeHVguBLGVIURP5j5ylbDUknWcTHBu b19hoC9ZsQ8VG1e8zdbSyeNaEC1nePRqC1/N36qVYMy55Aymk/Iv0eUvDBPM3v8nPifE UMN0Jk6/4xf5aeK6gCYEAouScOH3x5fiXj6P0oCPGeQAQ6i6E2Kf4mlgo2sc8X1ikcPo D7QA== X-Gm-Message-State: AOJu0Yy9jWTfl9uFimY69jP6qHl+3KvP/U4Bj4GOYWMD+/+gN79l4yws QinlQqGWcuyWXDBuE81fS2sEravo2oOUL3pkJNf2pUzqKK6lBk00UB/n X-Gm-Gg: ATEYQzxcpFFV/BLiKWr8JHC1lZylt1xU80IhiaherXd2fUii4M6puLGdx72gxg2ze6w UPG+gy70rQHNpEGvc25hj3VTc3A8iJ45rlRWAAo5sTkIrRhMN37NDjdA07EZQxuKo34eBdOAzfG xKy4Z631DaU6G0iFXG8PjNCPo2n5/eA4pnw1E0j2213Rhni744HgOXTsbpuaDVfcmoqWkJ/saDD tNTHAc5OEoSdc25/+2hZbwnwUFu8+jsvf9LIYg6wRsfJgXntO/mrbKZp4shTFD/UIJrDl9SfUNJ 17yGHIlvTfgK76ohypfscuAoYmyVQH37j1halP4vAmVKwkpQio4U5ggI8rq3gpdcUx8l4JnG9nn hKOj+jD4Fd1OvfpfohSSYGvXT93zv+e//GgThzK5fcJcRP/JqWjpunYJo11yXJwvYoatRJJ9nf9 hZ9/ueD2k9hrJBgyyPyRtopCP/GSVSzQ== X-Received: by 2002:a17:902:d4d2:b0:2a7:c2d5:bcd7 with SMTP id d9443c01a7336-2ad74464b22mr67997785ad.20.1771841876019; Mon, 23 Feb 2026 02:17:56 -0800 (PST) Received: from c6dfb3cc7c9a ([115.245.213.202]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ad74e3425dsm66574795ad.16.2026.02.23.02.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 02:17:55 -0800 (PST) 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, sanjaikumarvs@gmail.com, sanjaikumar.vs@dicortech.com, tudor.ambarus@linaro.org, stable@vger.kernel.org, vigneshr@ti.com Subject: [PATCH v3 2/2] mtd: spi-nor: core: Fix AAI mode when dirmap is not available Date: Mon, 23 Feb 2026 10:17:18 +0000 Message-ID: <20260223101718.89-3-sanjaikumarvs@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260223101718.89-1-sanjaikumarvs@gmail.com> References: <20260220094236.28-1-sanjaikumarvs@gmail.com> <20260223101718.89-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 the SPI controller does not support direct mapping (nodirmap=3Dtrue), spi_nor_spimem_write_data() calls spi_mem_dirmap_write() which falls back to spi_mem_no_dirmap_write(). This fallback uses the operation template created at probe time with the standard page program opcode. For SST flashes using AAI mode, this fails because the template cannot handle the dynamic opcode and address byte changes required by AAI. Fix by checking nodirmap and using spi_nor_spimem_exec_op() directly, which uses the runtime-built operation with correct AAI configuration. Cc: stable@vger.kernel.org Signed-off-by: Sanjaikumar V S --- drivers/mtd/spi-nor/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index d3f8a78efd3b..7caeb508d628 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -281,7 +281,7 @@ static ssize_t spi_nor_spimem_write_data(struct spi_nor= *nor, loff_t to, if (spi_nor_spimem_bounce(nor, &op)) memcpy(nor->bouncebuf, buf, op.data.nbytes); =20 - if (nor->dirmap.wdesc) { + if (nor->dirmap.wdesc && !nor->dirmap.wdesc->nodirmap) { nbytes =3D spi_mem_dirmap_write(nor->dirmap.wdesc, op.addr.val, op.data.nbytes, op.data.buf.out); } else { --=20 2.43.0