From nobody Wed Apr 1 12:31:59 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 4BA9539BFFB for ; Tue, 31 Mar 2026 09:50:46 +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=1774950647; cv=none; b=OFYaqsrn3cMNYKj1axGzsWc0yvNFuBCbnT/2mOjLKUz9VdcBkde9dvRBU7gODL0GWISBDWNPP+Od6ZCyfnWq1GVYgP8zbazjX3Kz1PbhfakuWKhMliYNqVJ6QaufBZBBrcka/EmV0CNYzZk1kg5Dyq7b65U5aFGeci70BsZRDVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774950647; c=relaxed/simple; bh=cNSpa42mZKBpO6X9VxDXfS83F3gls16Ut2Hgfy/5fhA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kJ+EhUHOBl0cb9uzrxkj9xMcqq3hhUwjwcB7f6PEGuQf+ap0fS2/9zMzhmbhNx5SbmtZgEpWwJjA6Uy/qOb4ObxkN/U82I9FXL/wMFOoQcUU93C/WvZEJwgxG0wTb/0OoqGXTKerJ881gRABHPM5BOkiDvuHntSaY1/7MevQ0ms= 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=FA7R6kC0; 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="FA7R6kC0" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-82cd70febc7so564663b3a.2 for ; Tue, 31 Mar 2026 02:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774950645; x=1775555445; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GU/F2QI9q8EVNVojnX0CtcCJf9ZvbWREtW+2yWmBDUg=; b=FA7R6kC0DsA+hL/8E/9a7DUwlHK7CSsQtw/A0OJFuC/x46PXN10QO9js+M48GKvWNo sfNmEcpd7yA6l3462C7kUI1+k1C6qFn4dNRJtL8Pwzv/tvUe9aEcNsSBO3f1vgSipah5 z17KNGZ0G9slkrsHaShgnF8nvS+wwSLy1HdMDH2K32t/9YFTbd4dv48/S8s/2f5osFLD 3Zzjy1OVlipMfqPDpxUqMze+R4EbABJ1Wsp5WUV70kpvi4ttOvBsvXi80rphR9Cnw3qh D9WaewGIatoouzbliRUaRPnnc0+6a8D4SG+2ImonMBtqU7VgFEV2wpZuwBDOEP/x/mbG 5Ltw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774950645; x=1775555445; 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; bh=GU/F2QI9q8EVNVojnX0CtcCJf9ZvbWREtW+2yWmBDUg=; b=B6sKSIfTWyz0wtec3Z6jNfSmEeHn4zruXLprTA+3OynjwQitRIebZkAACkO9+1QYX0 PZ2iOUvtitB265PMb/B2WN36mrT/sI69z1L5W4Yq87ZFI9vmmFWx/MX8Wm4QMVt859OE 9Rxc6vcjEMd58j3vpUKe8Y1qggBDiirLWzeswTY6/+eqUSzS88H2fpHjJmAy1yhn9sG8 iYclX3mOy1SJhzNHjY68g9Akf1m6uZ2cLoIVdZMCY6dvgsKx4W8+YpKyDBlZPfIc3VH9 ED7cjIJUhz+kZc8GdYLnJco3rPWWe747VMzFhOJcrhCP+KwKlbiw53YnvEzq0FKFxINA 5CIw== X-Forwarded-Encrypted: i=1; AJvYcCVZGPEDG+7B8mrRBGYMe4ME+8Fxum2pqumlaqSLAlTUoVphoqinm30MfbvdSXHFPLIf3cmFIatQiPB0LOU=@vger.kernel.org X-Gm-Message-State: AOJu0YzEEi0DVV1OhIJNixbCNa7moh29Y3s6CKzbFlQ1p1655ayuXOxU 8OEOnWoC4KdhjoDSwhsJTULk4kL36ICwT1KvJi0lQaYKWZTo10SGX+WU X-Gm-Gg: ATEYQzw9YONMzpHe+WdUpZNp1yMmTfX1a+M9TDZqn9Eciuopof1PO4FONX8dm5SxEtU 5Ppq282Y6cgmeNJDlOpDp89UviC1zyI1OeKBaNWT0eM6iareg8US+oY3D/+G7Lb/yGDcH+xpcLe 534sj3T/Q/L5ycJyZcBXbMjE3kQn3uPfeOmdTO72Zfz6g7SGDmVSPANVEMC93LhnmPoZB8xRzxd GrVlVwSVoiHa5gzuMW2GQiY61mv2g+CG/ZQTC3xkCTLQPLTc9NfgHu8sKHTSbEx0PqpYgj0yvl5 811QHDGldDbStt1rVX/G8LacSQsIwCVU9vmCmXJBNMaxjklgUOplb5xcNbP7s/yRQlLiQ+MOPk1 QKDTTA0GGz+gxz91WfmQednFMAgullgxn9/TUzjImHsNuZqNv/j76jNgrQeW0gYZzDCzvStXpZN 5LgcEwHKOrSO+wyPaA/ZHsBVA8TopkrhzW7UphgjHiMQ== X-Received: by 2002:a05:6a00:4c9c:b0:82a:7f6b:3fa1 with SMTP id d2e1a72fcca58-82c95ed4602mr15144187b3a.33.1774950645507; Tue, 31 Mar 2026 02:50:45 -0700 (PDT) Received: from f7eceb44c2db ([115.245.213.202]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82ca85fc6e9sm11279771b3a.46.2026.03.31.02.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2026 02:50:44 -0700 (PDT) From: Sanjaikumar V S To: mwalle@kernel.org, pratyush@kernel.org Cc: hd@os-cillation.de, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, miquel.raynal@bootlin.com, richard@nod.at, sanjaikumar.vs@dicortech.com, sanjaikumarvs@gmail.com, stable@vger.kernel.org, tudor.ambarus@linaro.org, vigneshr@ti.com Subject: [PATCH v5] mtd: spi-nor: Fix SST AAI write mode opcode handling Date: Tue, 31 Mar 2026 09:50:26 +0000 Message-ID: <20260331095026.38-1-sanjaikumarvs@gmail.com> X-Mailer: git-send-email 2.52.0 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 lacks direct mapping support, the fallback path in spi_nor_spimem_write_data() uses nor->write_proto based operation template. However, this template uses the standard page program opcode set during probe, not the AAI opcode required for SST flash. Additionally, controllers that do support direct mapping will also use the wrong opcode since the dirmap template is created at probe time with the standard page program opcode. Fix this by: 1. Checking the nodirmap flag in spi_nor_spimem_write_data() to ensure the code falls through to spi_nor_spimem_exec_op() path which builds the operation at runtime with the correct program_opcode. 2. Setting nodirmap=3Dtrue for SST AAI devices in sst_nor_late_init() to disable dirmap and force the runtime opcode path. This only affects SST devices with SST_WRITE flag. Other SST devices that use standard page program can still benefit from dirmap. Fixes: df5c21002cf4 ("mtd: spi-nor: use spi-mem dirmap API") Cc: stable@vger.kernel.org Signed-off-by: Sanjaikumar V S --- Changes since v4: - Disable dirmap for SST AAI devices in sst_nor_late_init() to fix the case when controller supports direct mapping (Pratyush) - Updated commit message and subject to reflect the broader fix Note: Patch 1/2 from v4 series is already in spi-nor/next. I don't have hardware to test the new sst.c change. Hendrik, could you please verify this on your SST25VF032B setup? drivers/mtd/spi-nor/core.c | 2 +- drivers/mtd/spi-nor/sst.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index e6c1fda61f57..2e4b167cab57 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 { diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c index db02c14ba16f..cd2f04830a6b 100644 --- a/drivers/mtd/spi-nor/sst.c +++ b/drivers/mtd/spi-nor/sst.c @@ -267,8 +267,16 @@ static int sst_nor_write(struct mtd_info *mtd, loff_t = to, size_t len, =20 static int sst_nor_late_init(struct spi_nor *nor) { - if (nor->info->mfr_flags & SST_WRITE) + if (nor->info->mfr_flags & SST_WRITE) { nor->mtd._write =3D sst_nor_write; + /* + * AAI mode requires dynamic opcode changes (BP vs AAI_WP). + * Disable dirmap to ensure spi_nor_spimem_exec_op() uses + * the runtime opcode instead of the dirmap template. + */ + if (nor->dirmap.wdesc) + nor->dirmap.wdesc->nodirmap =3D true; + } =20 return 0; } --=20 2.43.0