Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6192391imm; Mon, 23 Jul 2018 13:11:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe/G9CjyWtPPGP50PdD8fzoepEmuC4rlsFQOwePl1RMVqtLMmYJqgrlZapogFeAP1pYdf00 X-Received: by 2002:a63:5964:: with SMTP id j36-v6mr13705725pgm.222.1532376679534; Mon, 23 Jul 2018 13:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532376679; cv=none; d=google.com; s=arc-20160816; b=HcwYmIY+ejd9CacddUYaDyeL6MAbM9HPWvvhdbQk7KBY3hoF9q87vuCr+kd3FReBj6 g5a/sdPItqMUV5ZyiI+imqy/xeefpOppORKr1VAIHEOlWs3/QP5u8PR+EdaSLUlDv+Y2 mcJRrHC5kfXKP4jirpUC1JW9Vh52bhMpcZaOQua0Xxx/PM2HWSArXRoV9AXpr/WrgRT7 ckoC2ht96tjOCiINBETuCdhuFdnHYXiNVLiE3reqx2I7qjLexlVs28zWaWS47qw7XXDq CtSx6m9arsU3qOla9gRC4GeR1/o9IxOqvC+m0+3wNmDbWwdkZftl4hdYp/+esv9XqBRv 1Wcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=x9WprEVm5RZfuBE6WOus+8to2o6lOGhX9/hpIgKF9gM=; b=JnDyIZh2w/8q2pjhsjAxuWh5fsLDwNN8/sqlBN0Agjsdwc4TD3cfgO/WO5YKuoSWJL B9HYr9Mfx3bO4/8R/LoVcxylCgtT95NTLdSJxwN9L0Ju2P0dlRxUkO+9viwFVWTJU/Hs NJlQuWbJ6Qusv88D+rO6S7fbPJcPtAPGvEq6I5JZx/yakiDMWJracmDCGFSew8+j4WLa Wz1FBw/bIcfbUuE81hQ2D4VFsXPS0w1P1pc9esmtzW69G7sCK2LK8ijK2QG8DXgJxax1 NFLl4S1Kq/T3iJX7SQ2q5bE2kZa5l/ONIHKJ8QWyqP/aFdXawwawMRGz0OVE9aU4Pz0S 8GPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 199-v6si10557329pfv.114.2018.07.23.13.11.04; Mon, 23 Jul 2018 13:11:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388109AbeGWVM5 (ORCPT + 99 others); Mon, 23 Jul 2018 17:12:57 -0400 Received: from mail.bootlin.com ([62.4.15.54]:36793 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728293AbeGWVM4 (ORCPT ); Mon, 23 Jul 2018 17:12:56 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 3A0C320737; Mon, 23 Jul 2018 22:10:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id E33CB203EC; Mon, 23 Jul 2018 22:10:05 +0200 (CEST) Date: Mon, 23 Jul 2018 22:10:02 +0200 From: Boris Brezillon To: Brian Norris Cc: Zhiqiang Hou , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org, boris.brezillon@free-electrons.com, marek.vasut@gmail.com, richard@nod.at, cyrille.pitchen@wedev4u.fr Subject: Re: [PATCHv3 2/2] mtd: m25p80: restore the status of SPI flash when exiting Message-ID: <20180723221002.736e0830@bbrezillon> In-Reply-To: <20180723181350.GA58212@ban.mtv.corp.google.com> References: <20171206025342.7266-1-Zhiqiang.Hou@nxp.com> <20171206025342.7266-3-Zhiqiang.Hou@nxp.com> <20180723181350.GA58212@ban.mtv.corp.google.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Brian, On Mon, 23 Jul 2018 11:13:50 -0700 Brian Norris wrote: > Hello, > > I noticed this got merged, but I wanted to put my 2 cents in here: I wish you had replied to this thread when it was posted (more than 6 months ago). Reverting the patch now implies making some people unhappy because they'll have to resort to their old out-of-tree hacks :-(. > > On Wed, Dec 06, 2017 at 10:53:42AM +0800, Zhiqiang Hou wrote: > > From: Hou Zhiqiang > > > > Restore the status to be compatible with legacy devices. > > Take Freescale eSPI boot for example, it copies (in 3 Byte > > addressing mode) the RCW and bootloader images from SPI flash > > without firing a reset signal previously, so the reboot command > > will fail without reseting the addressing mode of SPI flash. > > This patch implement .shutdown function to restore the status > > in reboot process, and add the same operation to the .remove > > function. > > We have previously rejected this patch multiple times, because the above > comment demonstrates a broken product. If we were to only support working HW parts, I fear Linux would not support a lot of HW (that's even more true when it comes to flashes :P). > You cannot guarantee that all > reboots will invoke the .shutdown() method -- what about crashes? What > about watchdog resets? IIUC, those will hit the same broken behavior, > and have unexepcted behavior in your bootloader. Yes, there are corner cases that are not addressed with this approach, but it still seems to improve things. Of course, that means the user should try to re-route all HW reset sources to SW ones (RESET input pin muxed to the GPIO controller, watchdog generating an interrupt instead of directly asserting the RESET output pin), which is not always possible, but even when it's not, isn't it better to have a setup that works fine 99% of the time instead of 50% of the time? > > I suppose one could argue for doing this in remove(), but AIUI you're > just papering over system bugs by introducing the shutdown() function > here. Thus, I'd prefer we drop the shutdown() method to avoid misleading > other users of this driver. I understand your point. But if the problem is about making sure people designing new boards get that right, why not complaining at probe time when things are wrong? I mean, spi_nor_restore() seems to only do something on very specific NORs (those on which a SW RESET does not resets the addressing mode). So, how about adding a flag that says "my board has the NOR HW RESET pin wired" (there would be a DT props to set that flag). Then you add a WARN_ON() when this flag is not set and a NOR chip impacted by this bug is detected. This way you make sure people are informed that they're doing something wrong, and for those who can't change their HW (because it's already widely deployed), you have a fix that improve things. Regards, Boris