Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4160151ybl; Mon, 26 Aug 2019 06:26:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWya6jd5aksZIDT2GR38d2eWotNOx8WIbxMQsPQBkWfrwTFuHTKw8vidScw6n0/UMAc32x X-Received: by 2002:a17:902:8d82:: with SMTP id v2mr17576222plo.24.1566826006793; Mon, 26 Aug 2019 06:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566826006; cv=none; d=google.com; s=arc-20160816; b=J4mFBmxqhce3t/WNjzb1/F0JsyeOZO2Tf5n2TR3+4QA82iFpxBKAkED7JZnnqyEwvV cDvTe1UO9SZX3Sh/t0EO928wgHXdvAVSdmLsa1CHupPTD80J4AfNp0M9SielKQho9Qs/ 8pkuSHMn2PSnwTR6zvQGxYnm/ll3TvA/HEArt779TnvP0+iIvcZ1NjlT4UPC4to+Rzth JCdyx7vOjdrUNpNhfJlvx2CfGV9r9tOolHnFI2LAgv8X4Wu2kHyrs4S8Xy9Lhnce9rqH gUoafznp62c1lLEgiu6U/KI4Mb1PdAwXe3Wjw38SOQ8MnXBPWwaB30p3X2jcl7RnYN6o g52g== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=B4GfwmoWXoHyv4NJqIc8DXBOBAAPEEKqjZx53OgjuOc=; b=WFf8Fp1PpnRjwxflhu5AaJGsXCKtUkJbbmZu7RknBwtNQW+RI6xvrGbCkO5MpkbMJw 9X7ltcw4IAzF4+eMk+hiTNhAy4OHCQSaBG4Rl/Bz9zvSraLnvT+AgcyzkdtBhzXxn6HS LbX/bm/M52Y1r9dSPzIwACxQJubBueg31AWrHHvic0qtoHXhTnXqt8b5YCL9RohXmYGC tK4mRrNMPnvOnH8WAWdXGkPRpf00FnP8fpvyCFo1cpD7aSrYl8l3sw23nqMjtWyzLZao GHvzuWaWIIVl2+MgqZVhKUJs6eMtFGiozG3+aU9sMYNjc94PXurQeELk2hx4wphMTdCm 2+Rw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o33si9070990pgb.381.2019.08.26.06.26.31; Mon, 26 Aug 2019 06:26:46 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732059AbfHZMt0 (ORCPT + 99 others); Mon, 26 Aug 2019 08:49:26 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:46780 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbfHZMt0 (ORCPT ); Mon, 26 Aug 2019 08:49:26 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 6BD6A28A1B7; Mon, 26 Aug 2019 13:49:24 +0100 (BST) Date: Mon, 26 Aug 2019 14:49:21 +0200 From: Boris Brezillon To: Cc: , , , , , Subject: Re: [RESEND RFC PATCH v3 20/20] mtd: spi-nor: Rework the disabling of block write protection Message-ID: <20190826144921.70ee27c5@collabora.com> In-Reply-To: <20190826120821.16351-21-tudor.ambarus@microchip.com> References: <20190826120821.16351-1-tudor.ambarus@microchip.com> <20190826120821.16351-21-tudor.ambarus@microchip.com> Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-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 On Mon, 26 Aug 2019 12:09:09 +0000 wrote: > From: Tudor Ambarus > > spi_nor_unlock() unlocks blocks of memory or the entire flash memory > array, if requested. clear_sr_bp() unlocks the entire flash memory > array at boot time. This calls for some unification, clear_sr_bp() is > just an optimization for the case when the unlock request covers the > entire flash size. > > Merge the clear_sr_bp() and stm_lock/unlock logic and introduce > spi_nor_unlock_all(), which makes an unlock request that covers the > entire flash size. > > Get rid of the MFR handling and implement specific manufacturer > default_init() fixup hooks. > > Move write_sr_cr() to avoid to add a forward declaration. Prefix > new function with 'spi_nor_'. > > Note that this changes a bit the logic for the SNOR_MFR_ATMEL and > SNOR_MFR_INTEL cases. Before this patch, the Atmel and Intel chips > did not set the locking ops, but unlocked the entire flash at boot > time, while now they are setting the locking ops to stm_locking_ops. > This should work, since the the disable of the block protection at the > boot time used the same Status Register bits to unlock the flash, as > in the stm_locking_ops case. > > In future, we should probably add new hooks to > 'struct spi_nor_flash_parameter' to describe how to interact with the > Status and Configuration Registers in the form of: > nor->params.ops->read_sr > nor->params.ops->write_sr > nor->params.ops->read_cr > nor->params.ops->write_sr > We can retrieve this info starting with JESD216 revB, by checking the > 15th DWORD of Basic Flash Parameter Table, or with later revisions of > the standard, by parsing the "Status, Control and Configuration Register > Map for SPI Memory Devices". > > Suggested-by: Boris Brezillon > Signed-off-by: Tudor Ambarus Reviewed-by: Boris Brezillon Though I'd recommend waiting a bit before applying that one. As discussed privately, we might have problems when ->quad_enable is set to spansion_read_cr_quad_enable or spansion_no_read_cr_quad_enable.