mirror of
				https://git.openwrt.org/openwrt/openwrt.git
				synced 2025-10-31 23:05:48 +00:00 
			
		
		
		
	Continuous reading mode is broken for some spi controllers. There are two possible bug scenarios: 1) "continuous mode" flash and spi controller without dirmap support, but with restriction on transfer length in adjust_op_size() 2) "continuous mode" flash and spi controller with dirmap support for a single flash page In the first case, any read that exceeds the limit specified in adjust_op_size() will result in an EIO error. The limit may even be less than a size of a single flash page. In this case, any read will result in an error. In the second case, any read larger than flash page size will result in an EIO error or spinand driver spoofing (because the spi controller driver returns more bytes than were actually read). This patch series tries to fix continuous reading (spinand driver side). Unfortunately these fixes can't resolve "spinand driver spoofing" case. Spi controller drivers might need fixes as well. Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu> Link: https://github.com/openwrt/openwrt/pull/20295 Signed-off-by: Robert Marko <robimarko@gmail.com>
		
			
				
	
	
		
			35 lines
		
	
	
		
			808 B
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			808 B
		
	
	
	
		
			Diff
		
	
	
	
	
	
| --- a/drivers/mtd/nand/spi/core.c
 | |
| +++ b/drivers/mtd/nand/spi/core.c
 | |
| @@ -19,6 +19,7 @@
 | |
|  #include <linux/string.h>
 | |
|  #include <linux/spi/spi.h>
 | |
|  #include <linux/spi/spi-mem.h>
 | |
| +#include <linux/mtd/mtk_bmt.h>
 | |
|  
 | |
|  static int spinand_read_reg_op(struct spinand_device *spinand, u8 reg, u8 *val)
 | |
|  {
 | |
| @@ -1574,6 +1575,7 @@ static int spinand_probe(struct spi_mem
 | |
|  	if (ret)
 | |
|  		return ret;
 | |
|  
 | |
| +	mtk_bmt_attach(mtd);
 | |
|  	ret = mtd_device_register(mtd, NULL, 0);
 | |
|  	if (ret)
 | |
|  		goto err_spinand_cleanup;
 | |
| @@ -1581,6 +1583,7 @@ static int spinand_probe(struct spi_mem
 | |
|  	return 0;
 | |
|  
 | |
|  err_spinand_cleanup:
 | |
| +	mtk_bmt_detach(mtd);
 | |
|  	spinand_cleanup(spinand);
 | |
|  
 | |
|  	return ret;
 | |
| @@ -1599,6 +1602,7 @@ static int spinand_remove(struct spi_mem
 | |
|  	if (ret)
 | |
|  		return ret;
 | |
|  
 | |
| +	mtk_bmt_detach(mtd);
 | |
|  	spinand_cleanup(spinand);
 | |
|  
 | |
|  	return 0;
 |