Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6286876imm; Mon, 23 Jul 2018 15:07:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcphvCyYkhV/z+rDy/zP3wgLsS4JuNlkECRCGCApOgrn5TB/b9363ZciDa7iksSXTKw1Yvn X-Received: by 2002:a63:220d:: with SMTP id i13-v6mr14090826pgi.212.1532383675299; Mon, 23 Jul 2018 15:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532383675; cv=none; d=google.com; s=arc-20160816; b=TCSZUHBnhfEhEw/BoIldm61HpZFk7Jo13oKPFYSDj3I8d8YNNtAw1zA9eIlyD5gQxt TvM6bFX+fdZTfmkDiiEHDmTAlxHG2WEWOZT5udLA4hlvV1ZWoLNqYlR7OW8JPJOubAtP jdWuQ3qEXN8a25IxxhJp3Bf3elQ4z8CZ0aaqdaERHVOaGZHpidd0ymwNJmR+uBTxVwwc P6QsrCpJi6A15YEu6nl7Fa0tv7BSi85+eIXm4NjjeLGlDzedC9veu1caKA3kmSLCh/hj 5qaqMKTaS9pSbouhKWo4y1I7kUUANfJLuN9hU214a7WNHAFYaERIdaC+wNPe1HqXUMs3 QgfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=f9CwJybbmeWTDoE+D+UII72glveE4p8tyuFt4BymySs=; b=d9yyA56wlg5Jva0/cNGv+Opg5C8CLbx4PcANP5OIBMkZOf6kU6T5C2+kU0fSzl+onl UZgmfc+Pp196pk9Hv9VaRudAzu1wA9lnSLvm714VvbEKZ6PEISoFLtvlx2+xihxn7hHj GhtjzxM9F5Jo7Cf9WJPaZaUXAXDAvMj2Wgm2/qgGp3eWTd3qYT/YPeWhJrV5WIIUBN03 DAtFXTs4E5ua1C3wPmu+XvrbPrpGjIrgNvveP6r/yO1dH2Z31+VK+b5x7O1Udrzc1PyB Zg/fdseWsOAB3R9Y2eWMZ/KaTqv3eX34DU8RJwh/3rrSe1kKnzA8/fptPEis76/Fl7nb rU0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XQsUzt49; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 30-v6si8752692pgt.678.2018.07.23.15.07.39; Mon, 23 Jul 2018 15:07:55 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XQsUzt49; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388169AbeGWXKC (ORCPT + 99 others); Mon, 23 Jul 2018 19:10:02 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37454 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388052AbeGWXKC (ORCPT ); Mon, 23 Jul 2018 19:10:02 -0400 Received: by mail-wr1-f65.google.com with SMTP id q10-v6so2145534wrd.4 for ; Mon, 23 Jul 2018 15:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=f9CwJybbmeWTDoE+D+UII72glveE4p8tyuFt4BymySs=; b=XQsUzt49JrSp4vTZ5V/I5hAeOloUPs020Jq2aDnb5GCq005YYnmmv9XcS4T4vrIv79 hh6TAJZp/km2AxAmgIVhgV5ZJhJayaL8bGbN17jyBxVcOWWXY4BbYxiVJ1bcSgW03ynU ba4LQEGOeZ94ciqu/ziGRjIJOZGxlWLYOytdcJ44SZgy1zo+aIYEBaoSDxFBpkEdbBu/ gLppd9leJbQF5wG3s8tWXXTxLf/+asu5V6mEN+Q14loUVBjehkFjb6YA7U+PUFso0jri PUf5Jm10Yc+tpO+CGOxcqJyXb1SB7zl/Wbx7DvqI/wB9GhgxHqtY4touuw8Bh+u/L84z mvcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=f9CwJybbmeWTDoE+D+UII72glveE4p8tyuFt4BymySs=; b=oX+9mFTP5CIxNqHHl7ja95gBTsUI0ZXviUCGDf1x9M5p7v5vrgQPsrSznEg8U7h+fo j4QdhhaPtuKLYspGoMedj4rBNqjGIn9k4nABQWYBQdU+/iDEb8ADUAE1M0MIS8fuer2h HG9n9ZYmhPo1aYAo9xYndkbmh+0C2QOLH+9mpKpY+xF0qXK5U9g0xB7cmyWEq2oEp248 H30sjrfLSfuXFQVDU0lmJ69U0prkaUrdMBHi4+Hy9o3pLgXKCOji/mydprDRLCDmLSnt AZCmpLItMobUr64XaU0FTmMxM5nFjr0V6asze5ppdN1JmYbc4svLtGkRjFgGL5UJyJuj 2SSw== X-Gm-Message-State: AOUpUlFnEDGk9N+pAvkinVzhHKYlDq4Ekj6e0c6bYzT5jnG3pq5YrHOX 8oqKs4PDaTxOFJ8EeD+NKyRZK0p/RqboBVPa2fs= X-Received: by 2002:a5d:6401:: with SMTP id z1-v6mr9646844wru.64.1532383604483; Mon, 23 Jul 2018 15:06:44 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:7507:0:0:0:0:0 with HTTP; Mon, 23 Jul 2018 15:06:43 -0700 (PDT) In-Reply-To: <20180723221002.736e0830@bbrezillon> References: <20171206025342.7266-1-Zhiqiang.Hou@nxp.com> <20171206025342.7266-3-Zhiqiang.Hou@nxp.com> <20180723181350.GA58212@ban.mtv.corp.google.com> <20180723221002.736e0830@bbrezillon> From: Brian Norris Date: Mon, 23 Jul 2018 15:06:43 -0700 Message-ID: Subject: Re: [PATCHv3 2/2] mtd: m25p80: restore the status of SPI flash when exiting To: Boris Brezillon Cc: Zhiqiang Hou , linux-mtd@lists.infradead.org, Linux Kernel , David Woodhouse , Boris BREZILLON , Marek Vasut , Richard Weinberger , Cyrille Pitchen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Boris, On Mon, Jul 23, 2018 at 1:10 PM, Boris Brezillon wrote: > On Mon, 23 Jul 2018 11:13:50 -0700 > Brian Norris wrote: >> 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 :-(. I'd say I'm sorry for not following things closely these days, but I'm not really that sorry. There are plenty of other capable hands. And if y'all shoot yourselves in the foot, so be it. This patch isn't going to blow things up, but now that I did finally notice it (because it happened to show up in a list of backports I was looking at), I thought better late than never to remind you. For way of notification: Marek already noticed that we've started down a slippery slope months ago: https://lkml.org/lkml/2018/4/8/141 Re: [PATCH] mtd: spi-nor: clear Extended Address Reg on switch to 3-byte addressing. I'm not quite sure why that wasn't taken to its logical conclusion -- that the hack should be reverted. This problem has been noted many times already, and we've always stayed on the side of *avoiding* this hack. A few references from a search of my email: http://lists.infradead.org/pipermail/linux-mtd/2013-March/046343.html [PATCH 1/3] mtd: m25p80: utilize dedicated 4-byte addressing commands http://lists.infradead.org/pipermail/barebox/2014-September/020682.html [RFC] MTD m25p80 3-byte addressing and boot problem http://lists.infradead.org/pipermail/linux-mtd/2015-February/057683.html [PATCH 2/2] m25p80: if supported put chip to deep power down if not used >> 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 stopped allowing UBI to attach to MLC NAND recently, no? That sounds like almost the same boat -- you've probably killed quite a few shitty products, if they were to use mainline directly. Anyway, that's derailing the issue. Supporting broken hardware isn't something you try to do by applying the same hack to all systems. You normally try to apply your hack as narrowly as possible. You seem to imply that below. So maybe that's a solution to move forward with. But I'd personally be just as happy to see the patch reverted. >> 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, Is a system crash really a corner case? :D > 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? Perhaps, but not at the expense of future development. And realistically, no one is doing that if they have this hack. Most people won't even know that this hack is protecting them at all (so again, they won't try to mitigate the problem any further). >> 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). The point isn't that SW RESET doesn't reset the addressing mode -- it does on any flash I've seen. The point is that most systems are built around a stateless assumption in these flash. IIRC, there wasn't even a SW RESET command at all until these "huge" flash came around and stateful addressing modes came about. So boot ROMs and bootloaders would have to be updated to start figuring out when/how to do this SW RESET. And once two vendors start doing it differently (I'm not sure: have they done this already? I think so) it's no longer something a boot ROM will get right. The only way to get this stuff right is to have a hardware reset, or else to avoid all of the stateful modes in software. > 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. I'd kinda prefer the reverse. There really isn't a need to document anything for a working system (software usually can't control this RESET pin). The burden should be on the b0rked system to document where it needs unsound hacks to survive. > 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. Or even better: put this hack behind a DT flag, so that one has to admit that their board design is broken before it will even do anything. Proposal: "linux,badly-designed-flash-reset". But, I'd prefer just (partially?) reverting this, and let the authors submit something that works. We're not obligated to keep bad hacks in the kernel. Brian