From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422679AbcA1Tso (ORCPT ); Thu, 28 Jan 2016 14:48:44 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:32929 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967571AbcA1Tsj (ORCPT ); Thu, 28 Jan 2016 14:48:39 -0500 Date: Thu, 28 Jan 2016 11:48:36 -0800 From: Brian Norris To: Ezequiel Garcia Cc: "linux-mtd@lists.infradead.org" , =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= , Boris Brezillon , "linux-kernel@vger.kernel.org" , Bayi Cheng , Marek Vasut , Daniel Kurtz Subject: Re: [PATCH 4/8] mtd: spi-nor: disallow further writes to SR if WP# is low Message-ID: <20160128194836.GA63180@google.com> References: <1453960307-10181-1-git-send-email-computersforpeace@gmail.com> <1453960307-10181-5-git-send-email-computersforpeace@gmail.com> <20160128175905.GA33340@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2016 at 04:24:50PM -0300, Ezequiel Garcia wrote: > On 28 January 2016 at 14:59, Brian Norris wrote: > > So, maybe we want to clear SR_SRWD only when we unlock the *entire* > > flash? What do you think? I'll paste in the relevant datasheet details from w25q32fw, to make sure we're on the same page here, noting that 'SRP0' is our 'SR_SRWD', and we're not touching SRP1 (i.e., SRP1=0): "SRP1=0, SRP0=0, /WP=X: Software Protection /WP pin has no control. The Status register can be written to after a Write Enable instruction, WEL=1. [Factory Default] SRP1=0, SRP0=1, /WP=0: Hardware Protected When /WP pin is low the Status Register locked [sic] and cannot be written to. SRP1=0, SRP0=1, /WP=1: Hardware Unprotected When /WP pin is high the Status register is unlocked and can be written to after a Write Enable instruction, WEL=1." > How about this: > > 1) ioctl(MEMLOCK) the entire flash (SR_SRWD is set) > 2) ioctl(MEMUNLOCK) partially (SW_SRWD keeps set) > 3) ioctl(MEMLOCK) the entire flash again I might be confused; are you making a suggestion of a new behavior, or are you just trying to clarify my proposal? Because this sounds like it matches my proposal. > Not sure this use case make sense, I suppose it could make sense, if you (e.g.) have some intermediate steps toward determining the locked regions during factory programming. Maybe a process would start by doing #1 and #2, then decide conditionally whether to do #3. And only after the whole process is done does something assert /WP=0 (in my case, a factory process would tie /WP low). > but would (3) be allowed given > SW_SRWD is set? Yes, if /WP=1 (high). Brian