From nobody Fri Oct 3 23:12:13 2025 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11020080.outbound.protection.outlook.com [52.101.84.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC5EA156CA; Sat, 23 Aug 2025 00:16:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.84.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755908210; cv=fail; b=DKT3m5qcxTDp/ycEsXybSYpFRePQFmlxaQ4WSNIHc7dHQgsykkkP2F5rXypQEJqTge+xyBZgl7/Hc8meHa3qtThDtCh3WIDfJWm9j26b2cy+W3LOrxh2i/XdHEcCMMiLDvMFRLjwx9ngldpU/73uNjzCJjkBivMD7MPeGAc1YiA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755908210; c=relaxed/simple; bh=sTxm4XZXhMLHq0ZM+KYxR2WE1R+ia79q8kYaAWx/k0A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=CxXHkZZ5WdmzTIK2iQmMAbGIAyNu1XukU4itljZmW/sZkNbAdmxDnpc7u05uYON5QCWYX/bOdH1bLQzGuql9EIeALpfYRg2TPO0wchOdbBdtNLLCoG5Fz/GeSjdUi5LOF2DUyQ8vB2od2vcuG/mGCK727yMvpAcD/0t6lxTgpsM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iopsys.eu; spf=pass smtp.mailfrom=genexis.eu; dkim=pass (2048-bit key) header.d=iopsys.eu header.i=@iopsys.eu header.b=E38xapNG; arc=fail smtp.client-ip=52.101.84.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=iopsys.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=genexis.eu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=iopsys.eu header.i=@iopsys.eu header.b="E38xapNG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Fv+nFjEGxk9ws2eiUQf4opP4fsfLyE5K4GTJKSXzqD4rZHWhL7Ae+h4UkAMzZ/VnOMgQiV+/jIbaOvz/52r5WUeZsss6Om3BDo8jRBBFi3UiawNiMs9xVOQTM1CG0Jm5uaVgXGuYw7LUUOudmCLDlEcyMO7I8Q20vkhdlLsrVCeyZVSGZG+7hWGSSxTukKEU8EL8/DVTPe63NepvqQJ13/OtcH/s94dhmSEBHnoBIcvvhMwKtHT/KjZfI8VUiNCLixXz1v62xQ4lzfV3x4oqRzpXTlMPdowU7Y8KBR7jOylSA1IVvWi7Xwu2A2Q8kDx0y94ZfaRmikq5Co2naJQXwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c3c/TgdmkaaN9doSTnln4bmCmnSu+DX/UItnM4deJPs=; b=NNHCjSrRrsDWoxl5lzB6u/q91uQ/BJeaYS5FqUhmdULyWl4VnsJyjn+qsdCVxmz3NFkN63YiQjass12Ln6Ev6UIuEPIX0CEwSUpjQLtqijsn9Ge1N2tXuQ5ofJtNJ2PYSukpyo9upirUqCOV1PCDrUHIezQXwZ1zMqkDiUVWiKYZQTuDl/tf+P3K+7jvPIHpe2LIHvZHCH9Gsqe3u3020NGcYIbqW3dXkJHuWsjew3vvCdA+I522bg0lWM2omBidfxTDgbUCcRedXVFPjsmq/nleOK5qJUyXWyfJ/njBfr/qwCSCmp3PHWHmV2QqtlPIpPw/+xUOgSx06dXGIiWqPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=genexis.eu; dmarc=pass action=none header.from=iopsys.eu; dkim=pass header.d=iopsys.eu; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iopsys.eu; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c3c/TgdmkaaN9doSTnln4bmCmnSu+DX/UItnM4deJPs=; b=E38xapNGeRVM1fso0OOXbg2w5kl0DRY+GsXCoRMcpIEZIXBLdNGUhQGIiE9Cpk/9zg1FayUjcemni3+TBjXsE73WmxQjgAPL+C2OKGOEnPr3eWrqYFOZgQABLw59eniv3relAazBfB3RzqzY5R3wU3DF9u7Npa7HGHg+H7Hi9fDkq2Q4Qze2gdFUoEG83tWMnINxTdkK5V6OYJq+ezRXhDmRIlU8UxU/kZ/AfotnXotePrhUlZ6FAIjr2GoJgzOWzEpNxZ6RzZaSP3o3tgstsX3NEiYHudnfxvKUt/eW19zA46l1NaF2AOyzcoBkNPvrsyZ+YzQ7MQMKUI81k90kEA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=iopsys.eu; Received: from GV2PR08MB8121.eurprd08.prod.outlook.com (2603:10a6:150:7d::22) by PAXPR08MB6398.eurprd08.prod.outlook.com (2603:10a6:102:12d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9052.17; Sat, 23 Aug 2025 00:16:40 +0000 Received: from GV2PR08MB8121.eurprd08.prod.outlook.com ([fe80::4cd3:da80:2532:daa0]) by GV2PR08MB8121.eurprd08.prod.outlook.com ([fe80::4cd3:da80:2532:daa0%4]) with mapi id 15.20.9031.018; Sat, 23 Aug 2025 00:16:40 +0000 From: Mikhail Kshevetskiy To: Lorenzo Bianconi , Ray Liu , Mark Brown , Jyothi Kumar Seerapu , linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Mikhail Kshevetskiy Subject: [PATCH v4 07/13] spi: airoha: fix reading/writing of flashes with more than one plane per lun Date: Sat, 23 Aug 2025 03:16:19 +0300 Message-ID: <20250823001626.3641935-8-mikhail.kshevetskiy@iopsys.eu> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250823001626.3641935-1-mikhail.kshevetskiy@iopsys.eu> References: <20250823001626.3641935-1-mikhail.kshevetskiy@iopsys.eu> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: GVZP280CA0047.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:273::8) To GV2PR08MB8121.eurprd08.prod.outlook.com (2603:10a6:150:7d::22) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV2PR08MB8121:EE_|PAXPR08MB6398:EE_ X-MS-Office365-Filtering-Correlation-Id: 234bcef3-7971-400c-83ef-08dde1da551c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bio/XYC7KtQyE/ucte/vFQb3mTZLmknr/m03NcdnG24pIV+InU3hdM7TJPXr?= =?us-ascii?Q?gUanTBoLVZ9laJBarP7pNEL+Y+Cl0lJIlWRUvL5nyKNzXnCbWTA3SMtEVrge?= =?us-ascii?Q?pdRfaojQrvIxAvv/8SR84FG8c/DUPqhRPQ/D4biMkuS2ZvHue8nHLJ1EP9Et?= =?us-ascii?Q?+qVn0wikXx7UoENZmlXpEnD5yKKC4qP+TIE2j8eZEJmL0KZ/YGPbTNVJqQNT?= =?us-ascii?Q?MjyQCpdRTfqrD2WFvwI10zG5JNC9SVtA300UGepWCqTW86W0V7MG1innKSlu?= =?us-ascii?Q?lNGckYxk92K/wd6hPEsRR/ZmwlzFi88kEFyZHFx0g/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kLn5X6twJVqlFsWr0dW+SRq140daF/ytYPXacyQiNbhKm62?= =?us-ascii?Q?gVhBiAWHaBlHHLUost7cx22P/3s771Z/00IrDvnLN1qSz/lNNEovbMAyAEcf?= =?us-ascii?Q?Tkp3NDsY/dvUZ9mtRBfqdQjHP87mQfgeV+/h3p3NjfSoiAXIJYsfmMw+NCOe?= =?us-ascii?Q?elKU3PWl8XtiN/ZCBOndoaWqnkOtlT5y1YbpmMMpqiis9jPaBl+WI/gDZ/iZ?= =?us-ascii?Q?e3DmIf0pNpEGRYP137HmsPaXNrBwSVItANTsT6LrzcwKmpEX3PX26A=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV2PR08MB8121.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?8OOZaXBCZjVtFPlHtMjTcFcyVA+3Zt8hTtJRNb2tz0lgZCOC8/yH8P6CXpn8?= =?us-ascii?Q?Oh1SkcRgEgcLKj/3NXs8TamEF67YG1E0XplA+irQqGJiI+jQpSvO4tWH6Q7t?= =?us-ascii?Q?teorDv3lpOA84qUPqIV7u5p+cWfD29m9fKi/KBLHjKG+E94b6N7U9zXnvhDj?= =?us-ascii?Q?UW7fKq4p6kZ3VDs9CfQHZz23DQS1mw2Fb628Tl6A0ckGaPbEGRIsyVt4wbsb?= =?us-ascii?Q?65fsonmCMf8qGhIwa4noycuiJeD96QNu4ZNO613ISmPapBpyLJs9SH88i9eD?= =?us-ascii?Q?F4ucnyaSXLdA9tCkpkv2QCkdKlrsLNlhgOgUD+tYXiAvrjDbdsuS5+YBl1ne?= =?us-ascii?Q?OR3WDX2r7qXIB2HSD8x8sKXo/NOn0UP6dS9TYm4zTj/uijXi6ULT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Luf8ejkgraiQneVE5lpljzYotQj1Iur+nTMPm/QV+p5yP?= =?us-ascii?Q?QuYNohF4N94mUp4c20zZ2tHw+JVGikJFr2ljLuXlly0X+jXDq1yh+8PUs+N4?= =?us-ascii?Q?6db5i61atYh4WeR/yoTWrwaDxG/XA3LgkWEOPMX3aWJALaAzX8aFUppAAhiB?= =?us-ascii?Q?JsPFtPC6KP4G2lPvsbMzAXFMonPm7d7NLzszqIH8p4u8oXSl904ec/+TE60A?= =?us-ascii?Q?hiNTucBJjbwHaWBcSgE/5EFm2Fujq4c88qSkA/9KV85Z8g58vfLDWxLtvLkw?= =?us-ascii?Q?1xCFVlbG9qclUyKMzDuYKUtBtdCOa5ht3zzXfF81wSAbmPb1ZeHxYmAoMPKv?= =?us-ascii?Q?K9UopJQuELhZc9su12gTbTc=3D?= X-OriginatorOrg: iopsys.eu X-MS-Exchange-CrossTenant-Network-Message-Id: 234bcef3-7971-400c-83ef-08dde1da551c X-MS-Exchange-CrossTenant-AuthSource: GV2PR08MB8121.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2025 00:16:40.5175 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8d891be1-7bce-4216-9a99-bee9de02ba58 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IXY+eIeJXEOP9sk59uncweCFpskDFVgbzb3JauMLiqQPlPY2YWG2BRlSl8F2aLj37uPFmGuxcMyRpVu264Nt4i1QrYcSp3HVMBKmF+cxifk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6398 Content-Type: text/plain; charset="utf-8" Reading UBI on the flash with more than one plane per lun will lead to the following error: ubi0: default fastmap WL pool size: 50 ubi0: attaching mtd2 ubi0 error: ubi_add_to_av: two LEBs with same sequence number 403 eraseblock attaching information dump: ec 1 pnum 538 lnum 0 scrub 0 sqnum 403 Volume identifier header dump: magic 55424921 version 1 vol_type 1 copy_flag 0 compat 0 vol_id 1 lnum 0 data_size 0 used_ebs 0 data_pad 0 sqnum 403 hdr_crc c8418a31 Volume identifier header hexdump: 00000000: 55 42 49 21 01 01 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00= 00 00 00 00 00 00 00 00 00 00 UBI!............................ 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 93 00 00 00 00 00 00= 00 00 00 00 00 00 c8 41 8a 31 .............................A.1 ubi0 error: ubi_attach_mtd_dev: failed to attach mtd2, error -22 UBI error: cannot attach mtd2 UBI error: cannot initialize UBI, error -22 UBI init error 22 looking to spi_mem_no_dirmap_read() code we'll see: static ssize_t spi_mem_no_dirmap_read(struct spi_mem_dirmap_desc *desc, u64 offs, size_t len, void *buf) { struct spi_mem_op op =3D desc->info.op_tmpl; int ret; // --- see here --- op.addr.val =3D desc->info.offset + offs; //----------------- op.data.buf.in =3D buf; op.data.nbytes =3D len; ret =3D spi_mem_adjust_op_size(desc->mem, &op); if (ret) return ret; ret =3D spi_mem_exec_op(desc->mem, &op); if (ret) return ret; return op.data.nbytes; } The similar happens for spi_mem_no_dirmap_write(). Thus spi read address sh= ould take in the account the desc->info.offset. Signed-off-by: Mikhail Kshevetskiy --- drivers/spi/spi-airoha-snfi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c index 3431a9c84679..df2d3d717c00 100644 --- a/drivers/spi/spi-airoha-snfi.c +++ b/drivers/spi/spi-airoha-snfi.c @@ -727,8 +727,9 @@ static ssize_t airoha_snand_dirmap_read(struct spi_mem_= dirmap_desc *desc, if (err) goto error_dma_unmap; =20 - /* set read addr */ - err =3D regmap_write(as_ctrl->regmap_nfi, REG_SPI_NFI_RD_CTL3, 0x0); + /* set read addr: zero page offset + descriptor read offset */ + err =3D regmap_write(as_ctrl->regmap_nfi, REG_SPI_NFI_RD_CTL3, + desc->info.offset); if (err) goto error_dma_unmap; =20 @@ -872,7 +873,9 @@ static ssize_t airoha_snand_dirmap_write(struct spi_mem= _dirmap_desc *desc, if (err) goto error_dma_unmap; =20 - err =3D regmap_write(as_ctrl->regmap_nfi, REG_SPI_NFI_PG_CTL2, 0x0); + /* set write addr: zero page offset + descriptor write offset */ + err =3D regmap_write(as_ctrl->regmap_nfi, REG_SPI_NFI_PG_CTL2, + desc->info.offset); if (err) goto error_dma_unmap; =20 --=20 2.50.1