From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.195.17 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796128744; b=WUhK/mdGAwRpl8c6OlZIdv9BLCIpmR3WeifmK9MKJjLt2L8X+je3E7Z25BQm2K7Z7SOz x7CNNe9ghYc3fpjsHOb2hPhXXRbL2/nvzsQEUAEfezvYh34l97r9CSyG/Jcnz+QTbQ+1J 7wV80AudUGw4MJQO/VPVCz1nWCdDnZw/mZUNX3wpEY3O3PjszvmZ2TeO7rZ6759YSmQJo ZBVnRkHVK/QlUMXt+qhQo3kPCl4CLeIA/OWesiZKdiOT3O8nPHkZEzlCYNYj6ZnvJde+f jxD5Y1Mzlqn9oVofnQodzum7KFXVy+S+3RXFxdWJHxwJaY5PNlfrNnv/ZARX+jsp8RA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796128744; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:Received:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:References:In-Reply-To:To:CC: X-Mailer:X-Developer-Signature:X-Developer-Key:X-EOPAttributedMessage: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=8VKl0ZiKEMygqoIJFz71rrlAAsolj9oF4d1Wc3uuGtE=; b=Ccrl319tZe3EOquM5DzE1QD8Rno80kWLzIMzartWR/eLmnS6zXSTwgluCW7VQmhnARfr Q4NuuCK0ASuzKnZSm+96VmTl0LOzMpngBQJlGQTWelezwEiGtAzFfgF+4A9HSUq68s156 lYS2t20jMhis1DO+D96zYglXHkIevcLhKtxyZLQVeo4slPHgC2XXfPv2rzURB3cWF+ppD pklQER4xGuhFu5SvsHtw0Hht+iacDDWpWogmOUxFQZgfmLddExQa3d0CJfod7kkLF8axu t5TCG4bpaYGnVml9SEZOP72O79M9jqmDE8EUTZH7PjxK3QqfDFckCt/EhU9MXi9v4Aw== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=HJznA228; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.195.17 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012017.outbound.protection.outlook.com [40.93.195.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91D62606A31A for ; Tue, 1 Dec 2026 12:39:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 91D62606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=HJznA228 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uiucbEKbQuqoHoxzEBnl0bB6btFRyKnHrfra2jV/2FTrgqwhcswWMY1ixcSlIqnNBkAQ0Y5oHnJMBtso+wTBE0Jdqhpd5xsxTah42UaC5MNJA33P2FgGKrYS5G1z9J8kAxckrjI+jZ7ATYf+piLWAXftNMv7F5nV4msPihFtUw/fujThZ7/Gsz6MYzFOfxEfSJ6Q0SHQFOZjntVgNZa3PjctcAWiPSXb3VHn9IVMbgslUxKwag/ySFUHJ2o/f9JhLayxoYF9cKsMPgecJ7ky+dz0Mk2NucMOcOUJcy/Y7CtqciqR88DbOL8NNJNE3WzYVd2M2xGnr20RSZTgD86xSQ== 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=8VKl0ZiKEMygqoIJFz71rrlAAsolj9oF4d1Wc3uuGtE=; b=OS53SbCr4FDzlEL84lSuWt1NKlT/UNyzn+qIxSygV+wUF57or5QRzyVcbUH5HQBG5Hs5Ve6UzAdoNuGz35lIuTZLSw5xdgs0VFyb+kU8vYzz5ijfSyWv713folPVnyrS8SumCn2ciECJcoANY0O2ml2GF73Dw3C4pyBG5YR7AYKlAOQF8l6CoqZX5rNqusfzJP54EqaF6LNWlpWlG9sdze6Ap1SY4TJcDEbZNcnRdk7PLe87eIy+3IMy+Lau2TjeS6TMZBeYz21PTU0wYcwrIwk3c97hLO5r5P7hRxoOcPIEgbdqwtWGFngwoHJFJiwKsqn6qxNJStgV/ee23rQLIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8VKl0ZiKEMygqoIJFz71rrlAAsolj9oF4d1Wc3uuGtE=; b=HJznA228AYzLnp/wyftRsZWEXlXVYVVuQPVepPuPnRm0KDqy4Pj8UMxqj9wSigBxKtsWC7ykL74gjUeo3+Z2GCCuCLSZ90hC8cPhBqSOvTz5RfrizOjQmaNoiasthLz5K6HYvjV9urmwPo7hFt22+2imBrJ1iFAp0CbBu/EOsCs= Received: from SJ0PR05CA0056.namprd05.prod.outlook.com (2603:10b6:a03:33f::31) by DM6PR12MB4188.namprd12.prod.outlook.com (2603:10b6:5:215::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Tue, 1 Dec 2026 12:38:57 +0000 Received: from SJ1PEPF00002318.namprd03.prod.outlook.com (2603:10b6:a03:33f:cafe::4f) by SJ0PR05CA0056.outlook.office365.com (2603:10b6:a03:33f::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 12:38:57 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by SJ1PEPF00002318.mail.protection.outlook.com (10.167.242.228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 12:38:56 +0000 Received: from satlexmb10.amd.com (10.181.42.219) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 06:38:48 -0600 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb10.amd.com (10.181.42.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 06:38:47 -0600 Received: from xhdlc220225.xilinx.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.57 via Frontend Transport; Tue, 1 Dec 2026 06:38:44 -0600 From: Srikanth Boyapally Date: Tue, 1 Dec 2026 18:08:25 +0530 Subject: [PATCH v2 2/2] mtd: spi-nor: Reset flash device on resume X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20261201-ospi_reset_v2-v2-2-ceb06548d531@amd.com> References: <20261201-ospi_reset_v2-v2-0-ceb06548d531@amd.com> In-Reply-To: <20261201-ospi_reset_v2-v2-0-ceb06548d531@amd.com> To: Pratyush Yadav , Michael Walle , Takahiro Kuwano , Miquel Raynal , Richard Weinberger , "Vignesh Raghavendra" CC: , , , , Srikanth Boyapally , Sai Krishna Potthuri X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796128717; l=2092; i=srikanth.boyapally@amd.com; s=20261106; h=from:subject:message-id; bh=sdDS4yoHhcJ+oDWqGrEMaSTvqwPo9Q8gmC2zNycGUvA=; b=H7fWLt5S0OIYCZCbQyTeg9WdmOTTQgY/zbBEcdCTrRaIm3qo6yKy014RRrCQUVj/Nr3pW+B3u pnZ6T+U0lVcBjszu8qBKrdfvCCKLvptMCBz//N6pBHYSBspCSZ6oUR+ X-Developer-Key: i=srikanth.boyapally@amd.com; a=ed25519; pk=VZiIwz5+m6FvZJ+3hzpXDQl0u531OPVeBcB2OVGeZVk= X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF00002318:EE_|DM6PR12MB4188:EE_ X-MS-Office365-Filtering-Correlation-Id: d847c07c-9bc1-4c2d-8c29-08df4fa810e9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|82310400026|376014|1800799024|36860700016|6133799003|22082099003|18002099003|10067099003|56012099006|11063799006|261026140227099003|261028144727099003|261102123227099003|261021121427099003|261022105027099003|261022075727099003|261009223027099003; X-Microsoft-Antispam-Message-Info: TlaR4VioIIXFZltlQwZQ5F+tgjotWUouLI5xn90s0ezIEdpX/krx/V5afGfYfsBFkiIolp2jW6hBG4Zkn+ovk7P8UtKE/PoxjTFwLlwpJI076pcGQ1C3Q38xTS6HG1gPPr1gZ8Mw8j5pAuRewl8ddP57NlnJVXBApFqeNWN2uNLW78RGz3sxPXtPtoyYl76GyowLaKG/H1Ftm4OgiLY/WEz4GKV6CgDfjVhXwqdAf33V2at+ypHPOinNd6aQyYgdTM5dG3nruR7o/myH4aXZ5tUKKPYy5kxdZQ/DrrKOvktYRHgV7uM9jTIl9A0Swpj5XCHJioU/EEWkPtoNu6ouiOV8S7JgMdVI06Vqndag0nV64vpAMzxSXu/TY7kj0kLj6Wd1hDslBDa6KwxJDjvHJBZO1PLtgfn54enBv2Njlz6OAEpA5cWCNctC71ASNh0l31jEHNWG3YSfsZTY7UdZsGslJP5GcDBtTPssNvNCJ+Ih8o3nUzJMVd/XAmkB3jP6j7PYh1cF7qK283439qsZr5f2FCmy9C/qXS4NOtNQwWDiMVIwPO8sbvMWqLZrrgbjbsMOsrIKZ5O0GD9qQ04v1lkxGcF1ICyfr9+pKl1leJlCoMdIVPIHaZeJI5EpOldXXIzlpTWucvxuJMxuEKzT6oNmLeUr96pg3kjXCAhiaz1VyWDWtEQxTbwbECdavrXHuqekxPy90yM9xWjJvizEjg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb08.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(23010399003)(82310400026)(376014)(1800799024)(36860700016)(6133799003)(22082099003)(18002099003)(10067099003)(56012099006)(11063799006)(261026140227099003)(261028144727099003)(261102123227099003)(261021121427099003)(261022105027099003)(261022075727099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xuchP/2M7WRmYa8347uXIZPP60lwvudWxDOcpbKEt1/fDybj/Edz3TRhd2PQUu10PgcTXI1WTtt5qE59czAMGfAIfErx7lIa8Tm/C34AkKTeiBIO+Ims4GRJODbFSSTM3BIcT0nra46HwAxJBhU512Zh4hrZVuciHGw+xUCrmBsr1Mxb67oWZkFB68pMDwW634YZrwRBMusKOTp1NU7h2dA5alARYncW80XS9bJkHZVE4rAFd9CeXnoz12tGtTLBduAA6f58i93pgkFXBnJThO5Q4r3vBhoSvaYw1JwqSeoVSIthwQkrC417SjJdWr6luNkD6G/WCv6y9o+LbOCcSzjMrbnZ8QSDRs0UP8XnGo+ZZC3Va7FJSEMydhxBUMBIfMlHKxtd/QhOQzkimQlL8lGw6fO11OTq/Ez96vPRSN8BgLME8Ws//kM4wJ8lIyeO X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 12:38:56.5986 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d847c07c-9bc1-4c2d-8c29-08df4fa810e9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF00002318.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4188 From: Sai Krishna Potthuri Reset the SPI NOR device before reinitializing it during resume. This ensures that the flash is brought back to a known state before spi_nor_init() restores the device configuration. The reset returns the flash to its power-on address mode, which is 3-byte addressing unless the non-volatile configuration says otherwise. Flashes such as multi-die Micron parts are put in 4-byte address mode at probe time, so re-enter that mode after the reset. Otherwise spi_nor_init() would use register accesses with a 4-byte address on a flash that expects 3 bytes. Signed-off-by: Sai Krishna Potthuri Signed-off-by: Srikanth Boyapally --- drivers/mtd/spi-nor/core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 0e0960bc6f63..0166f2b33246 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -45,6 +45,9 @@ #define SPI_NOR_SRST_SLEEP_MIN 200 #define SPI_NOR_SRST_SLEEP_MAX 400 +/* Perform a device reset */ +static void spi_nor_hw_reset(struct spi_nor *nor); + /** * spi_nor_get_cmd_ext() - Get the command opcode extension based on the * extension type. @@ -3188,6 +3191,24 @@ static void spi_nor_resume(struct mtd_info *mtd) struct device *dev = nor->dev; int ret; + /* + * Reset the flash to a known state before reinitializing it. The reset + * returns the flash to its power-on address mode, which is 3-byte + * addressing unless configured otherwise in non-volatile memory. + * Re-enter 4-byte address mode if it was in use, so that the flash + * matches the cached address mode used by spi_nor_init(). + */ + if (nor->reset) { + spi_nor_hw_reset(nor); + + if (nor->params->addr_mode_nbytes == 4) { + ret = spi_nor_set_4byte_addr_mode(nor, true); + if (ret) + dev_err(dev, "failed to enter 4-byte address mode: %d\n", + ret); + } + } + /* re-initialize the nor chip */ ret = spi_nor_init(nor); if (ret) -- 2.43.0