Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp282368pxm; Wed, 2 Mar 2022 15:21:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFRSv9CHVIVNr3gwa4etNK6mlDoSQUvxRz4BBh1tU4FmgS5ez2ViWGhK5nSG13aRceiv1o X-Received: by 2002:a63:1060:0:b0:374:6edc:7cfc with SMTP id 32-20020a631060000000b003746edc7cfcmr27766608pgq.500.1646263290279; Wed, 02 Mar 2022 15:21:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646263290; cv=none; d=google.com; s=arc-20160816; b=dSYCZbCFCr298THoI99YSbDP0LHBfdWmtowQ71GHa3LWoTv4MeTLziov+KwSioiyuX F4wfucRatEkRCcWk66N2OjhZjIdCeXxcS8kREqN8HD18OKEiCd7sICukH9NIwljfRwo2 a9Q/qKlZ3pvIudotPUoJCrqupJC5kWTZQ/xXtj6srNpJ3DTEMN3OeGqoPlraICeLnTBo p4sdNPUjA7R7R5APaHf41hRXPe0MnMg+0VjZgDVVYG6t5QayGd/m5aKDB6C3GK4vHtkV M8A2bIOoxY75qrTRZ2LMXuMvOR5oqnNx9XF5k8Q1ZAGK3/k/KdTviX6BLxu7hq9m3aV5 fWhA== 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=adTrpLZVJKnmmjxY3JrXYa+2AmXR5qdUoDqMVNFtUuU=; b=h5SEDjNpq4Yzse5viZkldhN05ZSnaotInzM+frNGPUTfBr8BKo+prUt1mL+emSrogY XB1gfitGGWnruFV1UwdHtgWrmtmQLLCOH1Y1dwe0NBKE6JSHMv7EE4udARPTzrVUGKRa 49cW6ybhMRFZjra5SSWhpohYg0AuSoRpuPrq/7gvrb7NwvwIEgse1NOARJOdkfyy6suQ q+t4Hc9AddB13wtKG7BaUTzkdgofIDD/xT87VNmZRtRzmnzm65T1hmJsyba0nnkABOPu YUEGi3XDfUrGi+r5kmRge1qmRrReXPDjBtQha+w0TU4plFML68OP0dGz4GZxQX5GXV/s 7PnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b="Jd/xtd1U"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bg27-20020a056a001f9b00b004f3ff3a3fb0si330854pfb.363.2022.03.02.15.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 15:21:30 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b="Jd/xtd1U"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5F3F0EC5E1; Wed, 2 Mar 2022 14:57:43 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237571AbiCAWgX (ORCPT + 99 others); Tue, 1 Mar 2022 17:36:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233241AbiCAWgW (ORCPT ); Tue, 1 Mar 2022 17:36:22 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D13893C726 for ; Tue, 1 Mar 2022 14:35:40 -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 6391922239; Tue, 1 Mar 2022 23:35:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1646174138; 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=adTrpLZVJKnmmjxY3JrXYa+2AmXR5qdUoDqMVNFtUuU=; b=Jd/xtd1UuNOXUmRqReeRrjXcjtBpUf0cjIXRcZ9xxbzk7rgcwYDjkIJm+52OqB+ndQnG2U FGvFxe+9AKaD9ozFksPkuxt+/0aiw8r37Bzq6fDsGONkDOewzp5pKo5nlKE73IbcGnjAU8 BkAJfAFzyRgW8q0NKB3P672++Zl2Fm0= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 01 Mar 2022 23:35:38 +0100 From: Michael Walle To: Tudor Ambarus Cc: p.yadav@ti.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, nicolas.ferre@microchip.com, stable@vger.kernel.org Subject: Re: [PATCH] mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is set In-Reply-To: <20220228163334.277730-1-tudor.ambarus@microchip.com> References: <20220228163334.277730-1-tudor.ambarus@microchip.com> User-Agent: Roundcube Webmail/1.4.12 Message-ID: X-Sender: michael@walle.cc X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2022-02-28 17:33, schrieb Tudor Ambarus: > Even if SPI_NOR_NO_ERASE was set, one could still send erase opcodes > to the flash. It is not recommended to send unsupported opcodes to > flashes. Fix the logic and do not set mtd->_erase when SPI_NOR_NO_ERASE > is specified. With this users will not be able to issue erase opcodes > to > flashes and instead they will recive an -ENOTSUPP error. But why is there an erase opcode and erase size set in the first place? spi_nor_select_erase() should probably return early if SPI_NOR_NO_ERASE is set. Not setting the erasesize would also return -ENOTSUPP. I prefer this one for a fixes patch, though. But spi_nor_select_erase() should also be fixed. Reviewed-by: Michael Walle > > Cc: stable@vger.kernel.org > Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR") > Signed-off-by: Tudor Ambarus > --- > drivers/mtd/spi-nor/core.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c > index 86a536c97c18..cd2d094ef837 100644 > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -2969,10 +2969,11 @@ static void spi_nor_set_mtd_info(struct spi_nor > *nor) > mtd->flags = MTD_CAP_NORFLASH; > if (nor->info->flags & SPI_NOR_NO_ERASE) > mtd->flags |= MTD_NO_ERASE; > + else > + mtd->_erase = spi_nor_erase; > mtd->writesize = nor->params->writesize; > mtd->writebufsize = nor->params->page_size; > mtd->size = nor->params->size; > - mtd->_erase = spi_nor_erase; > mtd->_read = spi_nor_read; > /* Might be already set by some SST flashes. */ > if (!mtd->_write)