Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2117064rdf; Mon, 6 Nov 2023 05:20:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwleXMBJwzzPb/MwKXfoilAxG1bWjeqQeaOjNwt648BhesPdlVi032I/8FxUl1f1G/nriZ X-Received: by 2002:a05:6a21:3290:b0:184:16b7:df83 with SMTP id yt16-20020a056a21329000b0018416b7df83mr3897271pzb.45.1699276856360; Mon, 06 Nov 2023 05:20:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699276856; cv=none; d=google.com; s=arc-20160816; b=aOs1oS4bADopFqnddpXY+fWGVHKsWByuJB8fvo7uYN3P6QHXCsR0ON7YPblYdW9xKA k4yd0Er4EUIwKT00xO+sxU7jw2yoYjeEqmlPRQxls2rfU/IEXmxZ8l5te7CGnV6eE1/V mXBVmzgXlhzyTx4pBLh+hmSwbsxd9OqOwB2zd8u4aSkb8wz0ylGCxLFEyxCJ3SVe1jeK YJlBJ9ufTIJ1pPxFN0g4SklsRFMF4YmqFd7zAsJXmqIp1eVyz0mJfdctOtSEPbpaEgPn yft/OwS5B5VeOyjBgBxrJmkMKOU/NwH0ah8ouZEFzjiF7ZEW51YhLw3Qxmg+OuFQ/+Mc vQ1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:dkim-signature; bh=vZnDw/ozu0xnAeBgq4fKdy2/dlVUCQHSTJ3fl0mx/qQ=; fh=/hlOz4ovK3r102fmtpbmqLX/evtrn5sX7WNDjOwKo8w=; b=nfsDIxh+6Ny86UJTeaHyeA3ajkOrcqTJ9SYy995c7j1qylrdFLeELOUWZsWjLvZ8md Hj9EGcrIXoL6Uy6k+a6XkkMT7cobvG5gcjQiaunTSLdgOPDDde41HLRaioOcrUIfSukO qyL4TAoLMt8TTgSA7dNvtu2kkwwLoqB6Nxy6ibs6yMSIIu539bsfEXz/lbGiF8iwz8hh LwHxDjG3/JKkjaJo2z4tIQJKnTada/PG0ps7cQkEGEHLtJVmQR/lwCj1qMEFQmgCP08q RhoUFVG3TcwR6L3GP9Ah4VqbIj84334L12F2DqiEp113eVR4u45MIJtIG/bqQBX37kuc ZTVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MB8DxRON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id j15-20020a056a00174f00b006b9c3f8b912si8426398pfc.52.2023.11.06.05.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 05:20:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MB8DxRON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1B44480A8014; Mon, 6 Nov 2023 05:20:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232384AbjKFNUZ (ORCPT + 99 others); Mon, 6 Nov 2023 08:20:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232111AbjKFNUX (ORCPT ); Mon, 6 Nov 2023 08:20:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A57C94 for ; Mon, 6 Nov 2023 05:20:21 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A42CBC433C7; Mon, 6 Nov 2023 13:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699276821; bh=jzqcfpbOrk/5AJCHOBbHDhPfio1D8dMtQdDoPsbqqgs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=MB8DxRON0RWJ8uMv1cLkg2c3FsYAcjyhHlmsyx0oa9uZCNEGq9svpWruXhGbP/SqH +tBlw/LrH0Tm5LPdOnR341sG4mN4tMcI0ZIO5w1QLIVH0LxpEgcM2LxmthSrKMj639 37yKBL5mvo2xm4lOJDy2xw91ByBsX0Y7BMwZvHy9gTK5UfR4SQ+K7yTHMNKEtpzPvk 6wT79/vLfVfliTLUkEvyZ7fpKSYyw26MP2LMMz3ymUtYa+uZpH9Rg95JRhyqksXTMG O3msLKGydJBIoxNjDKKjvewaTEpPOtk8JTkfaARImymEooaSfhSWJWukcI2bruSzEC DbDAY9QZ67Nng== From: Pratyush Yadav To: Michael Walle Cc: Pratyush Yadav , AceLan Kao , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mika Westerberg , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] mtd: spi-nor: Improve reporting for software reset failures In-Reply-To: <8D87B330-8FA1-46BE-949E-5A8DFB8AACF3@walle.cc> (Michael Walle's message of "Thu, 26 Oct 2023 18:02:20 +0300") References: <20231026012017.518610-1-acelan.kao@canonical.com> <8D87B330-8FA1-46BE-949E-5A8DFB8AACF3@walle.cc> Date: Mon, 06 Nov 2023 14:20:18 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 05:20:48 -0800 (PST) On Thu, Oct 26 2023, Michael Walle wrote: > Am 26. Oktober 2023 16:39:54 OESZ schrieb Pratyush Yadav : >>On Thu, Oct 26 2023, AceLan Kao wrote: >> >>> From: "Chia-Lin Kao (AceLan)" >>> >>> When the software reset command isn't supported, we now report it >>> as an informational message(dev_info) instead of a warning(dev_warn). >>> This adjustment helps avoid unnecessary alarm and confusion regarding >>> software reset capabilities. >> >>I still think the soft reset command deserves a warn, and not an info. >>Because it _is_ a bad thing if you need to soft reset and are unable to >>do so. Your bootloader (or linux if you rmmod and modprobe again) might >>not be able to detect the flash mode and operate it properly. > > agreed.. but.. > >>I think we should just not unconditionally run this and instead only >>call it when the flash reset is not connected -- that is only call this >>under a check for SNOR_F_BROKEN_RESET, like we do for 4-byte addressing >>mode. > > .. keep in mind that this is a restriction of the flash controller. the Intel one seems to be the only affected one (for now) and it's doing a reset (according to mika) on its own. > > snor_broken_reset is a property of the flash. The documentation for the property says: broken-flash-reset: type: boolean description: Some flash devices utilize stateful addressing modes (e.g., for 32-bit addressing) which need to be managed carefully by a system. Because these sorts of flash don't have a standardized software reset command, and because some systems don't toggle the flash RESET# pin upon system reset (if the pin even exists at all), there are systems which cannot reboot properly if the flash is left in the "wrong" state. This boolean flag can be used on such systems, to denote the absence of a reliable reset mechanism. So it is more a property of the system as a whole perhaps. > > >>I don't have a strong opposition to this patch but I do think it is >>fixing the problem in the wrong place. > > if the flash controller doesn't let you issue a soft reset (or does so on its own), what's the fix? I think in those cases we could inquire the controller if it can do a soft reset (probably via spi_mem_supports_op()). If it can not do so _and_ the flash reset is broken, refuse to enter stateful modes like 8D-8D-8D or 4-byte addressing. We already do so for the broken reset thing in spi_nor_spimem_adjust_hwcaps(): /* * If the reset line is broken, we do not want to enter a stateful * mode. */ if (nor->flags & SNOR_F_BROKEN_RESET) *hwcaps &= ~(SNOR_HWCAPS_X_X_X | SNOR_HWCAPS_X_X_X_DTR); We should probably also add a spi_nor_spimem_can_soft_reset() (function doesn't exist as of now -- just using an example name) check here. Note: This restriction is placed only for X-X-X modes, and not 4-byte addressing mode, which is an inconsistency on SPI NOR's part. See below. Alternatively, if we are more willing to let users shoot themselves in the foot if they so wish, we can just throw a warning that you might not be able to recover, like we do in spi_nor_init(): /* * If the RESET# pin isn't hooked up properly, or the system * otherwise doesn't perform a reset command in the boot * sequence, it's impossible to 100% protect against unexpected * reboots (e.g., crashes). Warn the user (or hopefully, system * designer) that this is bad. */ WARN_ONCE(nor->flags & SNOR_F_BROKEN_RESET, "enabling reset hack; may not recover from unexpected reboots\n"); err = spi_nor_set_4byte_addr_mode(nor, true); In that case, we would only run spi_nor_soft_reset() if the reset is broken and let the user deal with the consequences if it fails. -- Regards, Pratyush Yadav