Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp625034pxb; Wed, 20 Jan 2021 16:26:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzc3DijZeCvI3bttIrp4u2PcPfAbVyz5x0WEsPUQa2alT71YIQf7RCHluXjm+LNk3Rs4D2K X-Received: by 2002:a17:906:4348:: with SMTP id z8mr7648630ejm.371.1611188803510; Wed, 20 Jan 2021 16:26:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611188803; cv=none; d=google.com; s=arc-20160816; b=yIXIfoFglobPow2HHBFus/levLbKOhcHqq8/TDP3+aQt/b0IKpTE35mHHJtBLFlLWV mkKxENDfgz0z9Ud1/scMq9b7G6HaqQ22bg6LdtyWKUxEvZOifz4e/ZPtGHruYJgfCpPG jVVBaAwLOe/uXnKQd/AhR7Pu+onDIR0WdewVT7jvbsqFURJB2EgEO5YOVzodvXoZqAVd ZDl9T/rB8e0La6HF3R8REND1EXR/tgsobKys1MGImTk+BLTWI5XOclASYDzsK5HYPLHn S+kBDhvwgWpcbx8tPoueNiVIzzxubMwBd1xJee16YopvQ2uB5U7h94wWP5H/djoE41Sq upyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=mUzrNzLNRcIreZmsLWq69k96pnmltY8SD1QI1C8Xvtc=; b=ivYYee63hKW3/kAq7FDNW2hfuo0qu4Zbvjbm21CH2xEZUqwdkZfCHHiGSnvfa8BK04 YNumD6kbRBrtFquDHQ0sXmx8FhX5/Oy9BThWOyE61njFOK9jfSo4IS36Z3GjTLraDIK4 0MVfNJmzhZ1IGl4D46sxlIcnVgGFXCAbiA58eFtJrmEZQjoxbhbhgvfjOhkTDQpwvN0W 7J6SHSVVllYo9F9/1xsNovuFAn+M2MmIF2G+Q95YXTeqG0MGPXQMTIEhSUrkzID4RnLB A1Qw9F99VVcIziFVy751Hl4YF79TT8cf7P0KhcoA03z/Lj95egHiUEgWFwHEwT7G/ph/ xe1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=L5pQvWqh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si383308edv.392.2021.01.20.16.26.20; Wed, 20 Jan 2021 16:26:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=L5pQvWqh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726694AbhATRG5 (ORCPT + 99 others); Wed, 20 Jan 2021 12:06:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391054AbhATPuD (ORCPT ); Wed, 20 Jan 2021 10:50:03 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28D0EC0613CF for ; Wed, 20 Jan 2021 07:49:23 -0800 (PST) Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 2A3D022727; Wed, 20 Jan 2021 16:49:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1611157761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mUzrNzLNRcIreZmsLWq69k96pnmltY8SD1QI1C8Xvtc=; b=L5pQvWqhEA+gLO4h7w/qbBgpTvDHeGlyG6fzjNFNthQiS4SuUVhd987+sn7ePNgqYGZM4y jI7Cco9UbSUoHU1Jg7ygI/FOs3VSTIpAj2WiVGZbAgerBBFYTFLcJnPU25j1m9UweQYQ5K Nchsvs9cGuSTWwUZJwoFXYl2wSaiclo= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Wed, 20 Jan 2021 16:49:21 +0100 From: Michael Walle To: Tudor.Ambarus@microchip.com Cc: vigneshr@ti.com, p.yadav@ti.com, miquel.raynal@bootlin.com, richard@nod.at, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Kavyasree.Kotagiri@microchip.com Subject: Re: [PATCH v2 2/2] mtd: spi-nor: sst: Add support for Global Unlock on sst26vf In-Reply-To: <8a0e7885-4b9e-be62-eb46-1af74c65afa8@microchip.com> References: <20210120131914.277363-1-tudor.ambarus@microchip.com> <20210120131914.277363-2-tudor.ambarus@microchip.com> <447aca9c61a45b05f7869b9747e2c301@walle.cc> <8a0e7885-4b9e-be62-eb46-1af74c65afa8@microchip.com> User-Agent: Roundcube Webmail/1.4.10 Message-ID: X-Sender: michael@walle.cc Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2021-01-20 16:39, schrieb Tudor.Ambarus@microchip.com: > On 1/20/21 5:02 PM, Michael Walle wrote: >> EXTERNAL EMAIL: Do not click links or open attachments unless you know >> the content is safe >> >> Am 2021-01-20 15:52, schrieb Tudor.Ambarus@microchip.com: >>> On 1/20/21 4:05 PM, Michael Walle wrote: >>>>> diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c >>>>> index 00e48da0744a..d6e1396abb96 100644 >>>>> --- a/drivers/mtd/spi-nor/sst.c >>>>> +++ b/drivers/mtd/spi-nor/sst.c >>>>> @@ -8,6 +8,39 @@ >>>>> >>>>>  #include "core.h" >>>>> >>>>> +static int sst26vf_lock(struct spi_nor *nor, loff_t ofs, uint64_t >>>>> len) >>>>> +{ >>>>> +     return -EOPNOTSUPP; >>>>> +} >>>>> + >>>>> +static int sst26vf_unlock(struct spi_nor *nor, loff_t ofs, >>>>> uint64_t >>>>> len) >>>>> +{ >>>>> +     if (ofs == 0 && len == nor->params->size) >>>>> +             return spi_nor_global_block_unlock(nor); >>>> >>>> >>>> Some blocks might not be unlocked because they are permanently >>>> locked. Does it make sense to read BPNV of the control register >>>> and add a debug message here? >>> >>> It would, yes. If any block is permanently locked in the unlock_all >>> case, >>> I'll just print a dbg message and return -EINVAL. Sounds good? >> >> spi_nor_sr_unlock(), atmel_at25fs_unlock() and >> atmel_global_unprotect() >> will return -EIO in case the SR wasn't writable. > > You mean in the spi_nor_write_sr_and_check() calls. -EIO is fine > there if what we wrote is different than what we read back, it would > indicate an IO error. > > GBULK command clears all the write-protection bits in the Block > Protection register, except for those bits that have been permanently > locked down. So even if we have few blocks permanently locked, i.e. > CR.BPNV == 1, the GBULK can clear the protection for the remaining > blocks. So not really an IO error, but rather an -EINVAL, because > the user asks to unlock more than we can. Doesn't EINVAL indicate wrong parameters, but does nothing? In this case, unlock would be partially successful. In any case, my point was that depending on the underlying locking ops, either -EIO or -EINVAL is returned if spi_nor_unlock() fails for the same reason, that is unlock() wasn't possible because of some sort of hardware write protection. And IMHO it should return the same errno (whatever the correct errno is in this case). -michael