Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6092784imm; Mon, 23 Jul 2018 11:15:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2SRL0+jriAs0WFztjGMLeonYOi/jfPgZNWqmiHZ2tnKgD7oa2eho+JL5bP+ojrZkVhfL+ X-Received: by 2002:a17:902:3e3:: with SMTP id d90-v6mr13875251pld.12.1532369731752; Mon, 23 Jul 2018 11:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532369731; cv=none; d=google.com; s=arc-20160816; b=GGlrlCvcCFf6+QNmHFAQ10DmiGmCO4MpL8wZyboGDqgGVXDPriaDShdU+5cj1wWYPQ dWIAZxEoxKI5QeZ/FSGJTil4sSINkJSp+JQVxqTdusRZFZ8m2t6IlLDWWayt3qzCP9GH 3PikKpdmjmw1kQXQhPFhbL/BfwE3bJR8y9urSCjpEZO/1sPHBqVWC6T5kCW315xx8mTf PCdUhDi+Y2BjSKc1eug2wPMJrhRWYmzG1YvyfTbhfrYBMefEZsJn/1WTDNlMhUz331rK 18Em6l+EeNb5MzPugk2tM6skSNPZ6r1BX6z12ThtIqjQlN6ux69fktVIHEbthgSCCXVU q+AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=SWmWTlSHkFdqzXU/8y1HdYi9r7nfcKJn5ub7TzJFIFU=; b=V78bt0FNniy5Lpd3Na7CKPtRmfcCdbP7eCDoOIWSqYM2rrtFPtd6oRukjjZJkosEhD ezYjJ2T8fnWdrg4JIT5TZGWN+mjwHMMYq8Yv74apa2Q/ucenF70QneBrXpRERT79ZcrE 8kGbY4BFpg1stwGOXtgTr1ocMRHD2weL7VoeMBKzc47+dLUjTdZQm0pJlqkLrgr07yFi CT3yH5Xq+VIXNhTiCOPbJGbMQozVBcbi5qXKnaHY9wQyt3rL9gyryhlC2jIsD0CeZ2z5 mKeKUCHG8ioiYVVotXSCmKqJpfZLqDHG37TE/Ll7x71QWoNWGEqa9vIGDzy6oElqOHuJ qrKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XMH+Gpi5; 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 n1-v6si8259360plp.166.2018.07.23.11.15.17; Mon, 23 Jul 2018 11:15:31 -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=XMH+Gpi5; 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 S2388354AbeGWTQV (ORCPT + 99 others); Mon, 23 Jul 2018 15:16:21 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45380 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387873AbeGWTQV (ORCPT ); Mon, 23 Jul 2018 15:16:21 -0400 Received: by mail-pg1-f194.google.com with SMTP id f1-v6so933679pgq.12 for ; Mon, 23 Jul 2018 11:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=SWmWTlSHkFdqzXU/8y1HdYi9r7nfcKJn5ub7TzJFIFU=; b=XMH+Gpi5NyQBw1DwOHLx5XzRZ+tfEh/2mxm8Ll2v18kQ9ab7PDAJ1TpuKnB3iPHfiX MWHxIFNHy83CcRbXWKJvHQc9c/8expWFDapA2+HCaZgCtxEw2+dzQdfzkOESvdbQn1Bc Bp/Bd24oYbx0V+uMrSpmmFXLwysFZKNfp44WPfLrAsGNfiP5zziAKoapYl8tF7rSEA0J k3BGU8KBTI/2UqqJ3PTrxNPW7J/MMsjbJkiaA65hZ0rj1bWtoTxxSmjaOl3fZcFcgHhe SfNEp5Nq2vT7a7MmdsbKJzCb3HsMVZb627lkIXC5hWODUyHGmVZv8d8sMJwks/WstGaO 0b0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=SWmWTlSHkFdqzXU/8y1HdYi9r7nfcKJn5ub7TzJFIFU=; b=CWP3OzrTfEQOKKo91yhDAdhQXzfVMGz3ncPMpGtIi3qrld8e/ViqD1DqdbOoW76Cf/ ITwvOmQllCnRaLrlKzk3sVMctvyVZed6LkSLsfndx/CkXKhb2qaue5Ydjk1hAPLZ2z+8 Tb+ZCsfiuWS0XSyJQYk3TGaFUfHiGvbVxNkGA7E/wS4AVn2LtXmZSbLwo63G9As7jM8K l6zLjNKfEMm0U/hrhN1HiDYWNjlYmVSz/z7O94R5kyLbkWwv2Y8ohv01dIYY5O1TgWTm U103zq198P/NXzommaTZNnpUOER8amZPv14HvkEvXk95YHm1pBqRasPnSqXwXcYmhiJH w8iQ== X-Gm-Message-State: AOUpUlHoUyrHldQAbzVj2pqTrfPBypfPGZhEgcnocz9tISlksCuSEs0Q NU4RMQb49e4QM2RUf8HQHC4= X-Received: by 2002:a63:4e22:: with SMTP id c34-v6mr13242254pgb.6.1532369634749; Mon, 23 Jul 2018 11:13:54 -0700 (PDT) Received: from ban.mtv.corp.google.com ([2620:0:1000:1501:bc2f:3082:9938:5d41]) by smtp.gmail.com with ESMTPSA id t21-v6sm16882803pfi.73.2018.07.23.11.13.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 11:13:53 -0700 (PDT) Date: Mon, 23 Jul 2018 11:13:50 -0700 From: Brian Norris To: Zhiqiang Hou Cc: 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: <20180723181350.GA58212@ban.mtv.corp.google.com> References: <20171206025342.7266-1-Zhiqiang.Hou@nxp.com> <20171206025342.7266-3-Zhiqiang.Hou@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171206025342.7266-3-Zhiqiang.Hou@nxp.com> User-Agent: Mutt/1.10+33 (2f90ec28cf74) (2018-06-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, I noticed this got merged, but I wanted to put my 2 cents in here: 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. 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. 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. Brian > Signed-off-by: Hou Zhiqiang > --- > V3: > - Modified the commit to make this patch specific. > > drivers/mtd/devices/m25p80.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c > index dbe6a1de2bb8..a4e18f6aaa33 100644 > --- a/drivers/mtd/devices/m25p80.c > +++ b/drivers/mtd/devices/m25p80.c > @@ -307,10 +307,18 @@ static int m25p_remove(struct spi_device *spi) > { > struct m25p *flash = spi_get_drvdata(spi); > > + spi_nor_restore(&flash->spi_nor); > + > /* Clean up MTD stuff. */ > return mtd_device_unregister(&flash->spi_nor.mtd); > } > > +static void m25p_shutdown(struct spi_device *spi) > +{ > + struct m25p *flash = spi_get_drvdata(spi); > + > + spi_nor_restore(&flash->spi_nor); > +} > /* > * Do NOT add to this array without reading the following: > * > @@ -386,6 +394,7 @@ static struct spi_driver m25p80_driver = { > .id_table = m25p_ids, > .probe = m25p_probe, > .remove = m25p_remove, > + .shutdown = m25p_shutdown, > > /* REVISIT: many of these chips have deep power-down modes, which > * should clearly be entered on suspend() to minimize power use. > -- > 2.14.1 >