lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211206181745.kcro3sgwacrh22iw@ti.com>
Date:   Mon, 6 Dec 2021 23:47:47 +0530
From:   Pratyush Yadav <p.yadav@...com>
To:     Tudor Ambarus <tudor.ambarus@...rochip.com>
CC:     <Alexander.Stein@...group.com>, <michael@...le.cc>,
        <vigneshr@...com>, <linux-mtd@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE
 is set

On 06/11/21 09:56AM, Tudor Ambarus wrote:
> SPI_NOR_NO_ERASE is used either by F-RAMs, or MRAMs, or EEPROMs,
> neither of which supports SFDP, so once SPI_NOR_NO_ERASE is set,
> SFDP can not undo it. These type of flashes should be moved out of
> the SPI NOR core anyway, so don't complicate things and just skip
> the erase logic when SPI_NOR_NO_ERASE is set. Normally SPI NOR core
> should operate just on SNOR_F flags, but since SPI_NOR_NO_ERASE
> should be removed, don't bother with extra code.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@...rochip.com>
> ---
>  drivers/mtd/spi-nor/core.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index a1b5d5432f41..52c82d943499 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2680,6 +2680,9 @@ static void spi_nor_skip_sfdp_init_params(struct spi_nor *nor)
>  					SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR);
>  	}
>  
> +	if (info_flags & SPI_NOR_NO_ERASE)
> +		return;
> +
>  	/*
>  	 * Sector Erase settings. Sort Erase Types in ascending order, with the
>  	 * smallest erase size starting at BIT(0).
> @@ -3195,12 +3198,13 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)
>  		mtd->name = dev_name(dev);
>  	mtd->type = MTD_NORFLASH;
>  	mtd->flags = MTD_CAP_NORFLASH;
> -	if (nor->info->flags & SPI_NOR_NO_ERASE)
> +	if (nor->info->flags & SPI_NOR_NO_ERASE) {
> +		mtd->_erase = spi_nor_erase;

You only set mtd->_erase when SPI_NOR_NO_ERASE is set? That does not 
make any sense to me. It should be the opposite.

>  		mtd->flags |= MTD_NO_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)
> -- 
> 2.25.1
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ