All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: aspeed: Fix division by zero
@ 2022-06-11 10:39 ` Cédric Le Goater
  0 siblings, 0 replies; 10+ messages in thread
From: Cédric Le Goater @ 2022-06-11 10:39 UTC (permalink / raw)
  To: linux-spi
  Cc: Mark Brown, Pratyush Yadav, linux-aspeed, openbmc, Joel Stanley,
	Andrew Jeffery, Chin-Ting Kuo, linux-arm-kernel, linux-kernel,
	Cédric Le Goater, Ian Woloschin

When using the normal read operation for data transfers, the dummy bus
width is zero. In that case, they are no dummy bytes to transfer and
setting the dummy field in the controller register becomes useless.

Issue was found on a custom "Bifrost" board with a AST2500 SoC and
using a MX25L51245GMI-08G SPI Flash.

Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 496f3e1e9079..3e891bf22470 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
 	u32 ctl_val;
 	int ret = 0;
 
+	dev_dbg(aspi->dev,
+		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
+		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
+		desc->info.offset, desc->info.offset + desc->info.length,
+		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
+		op->dummy.buswidth, op->data.buswidth,
+		op->addr.nbytes, op->dummy.nbytes);
+
 	chip->clk_freq = desc->mem->spi->max_speed_hz;
 
 	/* Only for reads */
@@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
 	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
 	ctl_val |= aspeed_spi_get_io_mode(op) |
 		op->cmd.opcode << CTRL_COMMAND_SHIFT |
-		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
 		CTRL_IO_MODE_READ;
 
+	if (op->dummy.nbytes)
+		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
+
 	/* Tune 4BYTE address mode */
 	if (op->addr.nbytes) {
 		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] spi: aspeed: Fix division by zero
@ 2022-06-11 10:39 ` Cédric Le Goater
  0 siblings, 0 replies; 10+ messages in thread
From: Cédric Le Goater @ 2022-06-11 10:39 UTC (permalink / raw)
  To: linux-spi
  Cc: linux-aspeed, Andrew Jeffery, openbmc, linux-kernel,
	Chin-Ting Kuo, Mark Brown, Joel Stanley, Ian Woloschin,
	Pratyush Yadav, linux-arm-kernel, Cédric Le Goater

When using the normal read operation for data transfers, the dummy bus
width is zero. In that case, they are no dummy bytes to transfer and
setting the dummy field in the controller register becomes useless.

Issue was found on a custom "Bifrost" board with a AST2500 SoC and
using a MX25L51245GMI-08G SPI Flash.

Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 496f3e1e9079..3e891bf22470 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
 	u32 ctl_val;
 	int ret = 0;
 
+	dev_dbg(aspi->dev,
+		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
+		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
+		desc->info.offset, desc->info.offset + desc->info.length,
+		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
+		op->dummy.buswidth, op->data.buswidth,
+		op->addr.nbytes, op->dummy.nbytes);
+
 	chip->clk_freq = desc->mem->spi->max_speed_hz;
 
 	/* Only for reads */
@@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
 	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
 	ctl_val |= aspeed_spi_get_io_mode(op) |
 		op->cmd.opcode << CTRL_COMMAND_SHIFT |
-		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
 		CTRL_IO_MODE_READ;
 
+	if (op->dummy.nbytes)
+		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
+
 	/* Tune 4BYTE address mode */
 	if (op->addr.nbytes) {
 		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] spi: aspeed: Fix division by zero
@ 2022-06-11 10:39 ` Cédric Le Goater
  0 siblings, 0 replies; 10+ messages in thread
From: Cédric Le Goater @ 2022-06-11 10:39 UTC (permalink / raw)
  To: linux-spi
  Cc: Mark Brown, Pratyush Yadav, linux-aspeed, openbmc, Joel Stanley,
	Andrew Jeffery, Chin-Ting Kuo, linux-arm-kernel, linux-kernel,
	Cédric Le Goater, Ian Woloschin

When using the normal read operation for data transfers, the dummy bus
width is zero. In that case, they are no dummy bytes to transfer and
setting the dummy field in the controller register becomes useless.

Issue was found on a custom "Bifrost" board with a AST2500 SoC and
using a MX25L51245GMI-08G SPI Flash.

Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 496f3e1e9079..3e891bf22470 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
 	u32 ctl_val;
 	int ret = 0;
 
+	dev_dbg(aspi->dev,
+		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
+		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
+		desc->info.offset, desc->info.offset + desc->info.length,
+		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
+		op->dummy.buswidth, op->data.buswidth,
+		op->addr.nbytes, op->dummy.nbytes);
+
 	chip->clk_freq = desc->mem->spi->max_speed_hz;
 
 	/* Only for reads */
@@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
 	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
 	ctl_val |= aspeed_spi_get_io_mode(op) |
 		op->cmd.opcode << CTRL_COMMAND_SHIFT |
-		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
 		CTRL_IO_MODE_READ;
 
+	if (op->dummy.nbytes)
+		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
+
 	/* Tune 4BYTE address mode */
 	if (op->addr.nbytes) {
 		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
-- 
2.35.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] spi: aspeed: Fix division by zero
  2022-06-11 10:39 ` Cédric Le Goater
  (?)
@ 2022-06-13  8:39   ` Pratyush Yadav
  -1 siblings, 0 replies; 10+ messages in thread
From: Pratyush Yadav @ 2022-06-13  8:39 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-spi, Mark Brown, linux-aspeed, openbmc, Joel Stanley,
	Andrew Jeffery, Chin-Ting Kuo, linux-arm-kernel, linux-kernel,
	Ian Woloschin

On 11/06/22 12:39PM, Cédric Le Goater wrote:
> When using the normal read operation for data transfers, the dummy bus
> width is zero. In that case, they are no dummy bytes to transfer and
> setting the dummy field in the controller register becomes useless.
> 
> Issue was found on a custom "Bifrost" board with a AST2500 SoC and
> using a MX25L51245GMI-08G SPI Flash.
> 
> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
> Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
> Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index 496f3e1e9079..3e891bf22470 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>  	u32 ctl_val;
>  	int ret = 0;
>  
> +	dev_dbg(aspi->dev,
> +		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
> +		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
> +		desc->info.offset, desc->info.offset + desc->info.length,
> +		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
> +		op->dummy.buswidth, op->data.buswidth,
> +		op->addr.nbytes, op->dummy.nbytes);
> +

Unrelated change. Please send as a separate patch.

>  	chip->clk_freq = desc->mem->spi->max_speed_hz;
>  
>  	/* Only for reads */
> @@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>  	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
>  	ctl_val |= aspeed_spi_get_io_mode(op) |
>  		op->cmd.opcode << CTRL_COMMAND_SHIFT |
> -		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
>  		CTRL_IO_MODE_READ;
>  
> +	if (op->dummy.nbytes)
> +		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
> +

LGTM. With the above fixed,

Reviewed-by: Pratyush Yadav <p.yadav@ti.com>

>  	/* Tune 4BYTE address mode */
>  	if (op->addr.nbytes) {
>  		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
> -- 
> 2.35.3
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] spi: aspeed: Fix division by zero
@ 2022-06-13  8:39   ` Pratyush Yadav
  0 siblings, 0 replies; 10+ messages in thread
From: Pratyush Yadav @ 2022-06-13  8:39 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-spi, Mark Brown, linux-aspeed, openbmc, Joel Stanley,
	Andrew Jeffery, Chin-Ting Kuo, linux-arm-kernel, linux-kernel,
	Ian Woloschin

On 11/06/22 12:39PM, Cédric Le Goater wrote:
> When using the normal read operation for data transfers, the dummy bus
> width is zero. In that case, they are no dummy bytes to transfer and
> setting the dummy field in the controller register becomes useless.
> 
> Issue was found on a custom "Bifrost" board with a AST2500 SoC and
> using a MX25L51245GMI-08G SPI Flash.
> 
> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
> Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
> Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index 496f3e1e9079..3e891bf22470 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>  	u32 ctl_val;
>  	int ret = 0;
>  
> +	dev_dbg(aspi->dev,
> +		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
> +		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
> +		desc->info.offset, desc->info.offset + desc->info.length,
> +		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
> +		op->dummy.buswidth, op->data.buswidth,
> +		op->addr.nbytes, op->dummy.nbytes);
> +

Unrelated change. Please send as a separate patch.

>  	chip->clk_freq = desc->mem->spi->max_speed_hz;
>  
>  	/* Only for reads */
> @@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>  	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
>  	ctl_val |= aspeed_spi_get_io_mode(op) |
>  		op->cmd.opcode << CTRL_COMMAND_SHIFT |
> -		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
>  		CTRL_IO_MODE_READ;
>  
> +	if (op->dummy.nbytes)
> +		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
> +

LGTM. With the above fixed,

Reviewed-by: Pratyush Yadav <p.yadav@ti.com>

>  	/* Tune 4BYTE address mode */
>  	if (op->addr.nbytes) {
>  		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
> -- 
> 2.35.3
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] spi: aspeed: Fix division by zero
@ 2022-06-13  8:39   ` Pratyush Yadav
  0 siblings, 0 replies; 10+ messages in thread
From: Pratyush Yadav @ 2022-06-13  8:39 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-aspeed, Andrew Jeffery, openbmc, linux-kernel, linux-spi,
	Mark Brown, Joel Stanley, Ian Woloschin, Chin-Ting Kuo,
	linux-arm-kernel

On 11/06/22 12:39PM, Cédric Le Goater wrote:
> When using the normal read operation for data transfers, the dummy bus
> width is zero. In that case, they are no dummy bytes to transfer and
> setting the dummy field in the controller register becomes useless.
> 
> Issue was found on a custom "Bifrost" board with a AST2500 SoC and
> using a MX25L51245GMI-08G SPI Flash.
> 
> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
> Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
> Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
>  drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index 496f3e1e9079..3e891bf22470 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>  	u32 ctl_val;
>  	int ret = 0;
>  
> +	dev_dbg(aspi->dev,
> +		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
> +		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
> +		desc->info.offset, desc->info.offset + desc->info.length,
> +		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
> +		op->dummy.buswidth, op->data.buswidth,
> +		op->addr.nbytes, op->dummy.nbytes);
> +

Unrelated change. Please send as a separate patch.

>  	chip->clk_freq = desc->mem->spi->max_speed_hz;
>  
>  	/* Only for reads */
> @@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>  	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
>  	ctl_val |= aspeed_spi_get_io_mode(op) |
>  		op->cmd.opcode << CTRL_COMMAND_SHIFT |
> -		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
>  		CTRL_IO_MODE_READ;
>  
> +	if (op->dummy.nbytes)
> +		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
> +

LGTM. With the above fixed,

Reviewed-by: Pratyush Yadav <p.yadav@ti.com>

>  	/* Tune 4BYTE address mode */
>  	if (op->addr.nbytes) {
>  		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
> -- 
> 2.35.3
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] spi: aspeed: Fix division by zero
  2022-06-13  8:39   ` Pratyush Yadav
  (?)
@ 2022-06-13  8:57     ` Cédric Le Goater
  -1 siblings, 0 replies; 10+ messages in thread
From: Cédric Le Goater @ 2022-06-13  8:57 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: linux-spi, Mark Brown, linux-aspeed, openbmc, Joel Stanley,
	Andrew Jeffery, Chin-Ting Kuo, linux-arm-kernel, linux-kernel,
	Ian Woloschin

On 6/13/22 10:39, Pratyush Yadav wrote:
> On 11/06/22 12:39PM, Cédric Le Goater wrote:
>> When using the normal read operation for data transfers, the dummy bus
>> width is zero. In that case, they are no dummy bytes to transfer and
>> setting the dummy field in the controller register becomes useless.
>>
>> Issue was found on a custom "Bifrost" board with a AST2500 SoC and
>> using a MX25L51245GMI-08G SPI Flash.
>>
>> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
>> Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
>> Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
>> index 496f3e1e9079..3e891bf22470 100644
>> --- a/drivers/spi/spi-aspeed-smc.c
>> +++ b/drivers/spi/spi-aspeed-smc.c
>> @@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>   	u32 ctl_val;
>>   	int ret = 0;
>>   
>> +	dev_dbg(aspi->dev,
>> +		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
>> +		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
>> +		desc->info.offset, desc->info.offset + desc->info.length,
>> +		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
>> +		op->dummy.buswidth, op->data.buswidth,
>> +		op->addr.nbytes, op->dummy.nbytes);
>> +
> 
> Unrelated change. Please send as a separate patch.

OK.
  
>>   	chip->clk_freq = desc->mem->spi->max_speed_hz;
>>   
>>   	/* Only for reads */
>> @@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>   	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
>>   	ctl_val |= aspeed_spi_get_io_mode(op) |
>>   		op->cmd.opcode << CTRL_COMMAND_SHIFT |
>> -		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
>>   		CTRL_IO_MODE_READ;
>>   
>> +	if (op->dummy.nbytes)
>> +		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
>> +
> 
> LGTM. With the above fixed,
>
> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>

Thanks,

C.

> 
>>   	/* Tune 4BYTE address mode */
>>   	if (op->addr.nbytes) {
>>   		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
>> -- 
>> 2.35.3
>>
> 


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] spi: aspeed: Fix division by zero
@ 2022-06-13  8:57     ` Cédric Le Goater
  0 siblings, 0 replies; 10+ messages in thread
From: Cédric Le Goater @ 2022-06-13  8:57 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: linux-spi, Mark Brown, linux-aspeed, openbmc, Joel Stanley,
	Andrew Jeffery, Chin-Ting Kuo, linux-arm-kernel, linux-kernel,
	Ian Woloschin

On 6/13/22 10:39, Pratyush Yadav wrote:
> On 11/06/22 12:39PM, Cédric Le Goater wrote:
>> When using the normal read operation for data transfers, the dummy bus
>> width is zero. In that case, they are no dummy bytes to transfer and
>> setting the dummy field in the controller register becomes useless.
>>
>> Issue was found on a custom "Bifrost" board with a AST2500 SoC and
>> using a MX25L51245GMI-08G SPI Flash.
>>
>> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
>> Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
>> Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
>> index 496f3e1e9079..3e891bf22470 100644
>> --- a/drivers/spi/spi-aspeed-smc.c
>> +++ b/drivers/spi/spi-aspeed-smc.c
>> @@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>   	u32 ctl_val;
>>   	int ret = 0;
>>   
>> +	dev_dbg(aspi->dev,
>> +		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
>> +		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
>> +		desc->info.offset, desc->info.offset + desc->info.length,
>> +		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
>> +		op->dummy.buswidth, op->data.buswidth,
>> +		op->addr.nbytes, op->dummy.nbytes);
>> +
> 
> Unrelated change. Please send as a separate patch.

OK.
  
>>   	chip->clk_freq = desc->mem->spi->max_speed_hz;
>>   
>>   	/* Only for reads */
>> @@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>   	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
>>   	ctl_val |= aspeed_spi_get_io_mode(op) |
>>   		op->cmd.opcode << CTRL_COMMAND_SHIFT |
>> -		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
>>   		CTRL_IO_MODE_READ;
>>   
>> +	if (op->dummy.nbytes)
>> +		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
>> +
> 
> LGTM. With the above fixed,
>
> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>

Thanks,

C.

> 
>>   	/* Tune 4BYTE address mode */
>>   	if (op->addr.nbytes) {
>>   		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
>> -- 
>> 2.35.3
>>
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] spi: aspeed: Fix division by zero
@ 2022-06-13  8:57     ` Cédric Le Goater
  0 siblings, 0 replies; 10+ messages in thread
From: Cédric Le Goater @ 2022-06-13  8:57 UTC (permalink / raw)
  To: Pratyush Yadav
  Cc: linux-aspeed, Andrew Jeffery, openbmc, linux-kernel, linux-spi,
	Mark Brown, Joel Stanley, Ian Woloschin, Chin-Ting Kuo,
	linux-arm-kernel

On 6/13/22 10:39, Pratyush Yadav wrote:
> On 11/06/22 12:39PM, Cédric Le Goater wrote:
>> When using the normal read operation for data transfers, the dummy bus
>> width is zero. In that case, they are no dummy bytes to transfer and
>> setting the dummy field in the controller register becomes useless.
>>
>> Issue was found on a custom "Bifrost" board with a AST2500 SoC and
>> using a MX25L51245GMI-08G SPI Flash.
>>
>> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
>> Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
>> Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>> ---
>>   drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
>>   1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
>> index 496f3e1e9079..3e891bf22470 100644
>> --- a/drivers/spi/spi-aspeed-smc.c
>> +++ b/drivers/spi/spi-aspeed-smc.c
>> @@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>   	u32 ctl_val;
>>   	int ret = 0;
>>   
>> +	dev_dbg(aspi->dev,
>> +		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
>> +		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
>> +		desc->info.offset, desc->info.offset + desc->info.length,
>> +		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
>> +		op->dummy.buswidth, op->data.buswidth,
>> +		op->addr.nbytes, op->dummy.nbytes);
>> +
> 
> Unrelated change. Please send as a separate patch.

OK.
  
>>   	chip->clk_freq = desc->mem->spi->max_speed_hz;
>>   
>>   	/* Only for reads */
>> @@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>   	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
>>   	ctl_val |= aspeed_spi_get_io_mode(op) |
>>   		op->cmd.opcode << CTRL_COMMAND_SHIFT |
>> -		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
>>   		CTRL_IO_MODE_READ;
>>   
>> +	if (op->dummy.nbytes)
>> +		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
>> +
> 
> LGTM. With the above fixed,
>
> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>

Thanks,

C.

> 
>>   	/* Tune 4BYTE address mode */
>>   	if (op->addr.nbytes) {
>>   		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
>> -- 
>> 2.35.3
>>
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] spi: aspeed: Fix division by zero
  2022-06-13  8:57     ` Cédric Le Goater
  (?)
  (?)
@ 2022-06-13 16:18     ` Woloschin, Ian
  -1 siblings, 0 replies; 10+ messages in thread
From: Woloschin, Ian @ 2022-06-13 16:18 UTC (permalink / raw)
  To: Cédric Le Goater
  Cc: linux-aspeed, Andrew Jeffery, openbmc, Chin-Ting Kuo,
	linux-kernel, linux-spi, Mark Brown, Joel Stanley, Woloschin,
	Ian, Pratyush Yadav, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 2676 bytes --]



> On Jun 13, 2022, at 4:57 AM, Cédric Le Goater <clg@kaod.org> wrote:
> 
> On 6/13/22 10:39, Pratyush Yadav wrote:
>> On 11/06/22 12:39PM, Cédric Le Goater wrote:
>>> When using the normal read operation for data transfers, the dummy bus
>>> width is zero. In that case, they are no dummy bytes to transfer and
>>> setting the dummy field in the controller register becomes useless.
>>> 
>>> Issue was found on a custom "Bifrost" board with a AST2500 SoC and
>>> using a MX25L51245GMI-08G SPI Flash.
>>> 
>>> Cc: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>
>>> Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
>>> Fixes: 54613fc6659b ("spi: aspeed: Add support for direct mapping")
>>> Signed-off-by: Cédric Le Goater <clg@kaod.org>
>>> ---
>>> drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
>>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>> 
>>> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
>>> index 496f3e1e9079..3e891bf22470 100644
>>> --- a/drivers/spi/spi-aspeed-smc.c
>>> +++ b/drivers/spi/spi-aspeed-smc.c
>>> @@ -558,6 +558,14 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>> 	u32 ctl_val;
>>> 	int ret = 0;
>>> +	dev_dbg(aspi->dev,
>>> +		"CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n",
>>> +		chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write",
>>> +		desc->info.offset, desc->info.offset + desc->info.length,
>>> +		op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth,
>>> +		op->dummy.buswidth, op->data.buswidth,
>>> +		op->addr.nbytes, op->dummy.nbytes);
>>> +
>> Unrelated change. Please send as a separate patch.
> 
> OK.
> 
>>> 	chip->clk_freq = desc->mem->spi->max_speed_hz;
>>> 	/* Only for reads */
>>> @@ -574,9 +582,11 @@ static int aspeed_spi_dirmap_create(struct spi_mem_dirmap_desc *desc)
>>> 	ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK;
>>> 	ctl_val |= aspeed_spi_get_io_mode(op) |
>>> 		op->cmd.opcode << CTRL_COMMAND_SHIFT |
>>> -		CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth) |
>>> 		CTRL_IO_MODE_READ;
>>> +	if (op->dummy.nbytes)
>>> +		ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth);
>>> +
>> LGTM. With the above fixed,
>> 
>> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
> 
> Thanks,
> 
> C.

I tested just the relevant change and it fixed my problem, allowing my board to boot.

Tested-by: Ian Woloschin <iwolosch@akamai.com <mailto:iwolosch@akamai.com>>

Thanks!

> 
>>> 	/* Tune 4BYTE address mode */
>>> 	if (op->addr.nbytes) {
>>> 		u32 addr_mode = readl(aspi->regs + CE_CTRL_REG);
>>> -- 
>>> 2.35.3


[-- Attachment #1.2: Type: text/html, Size: 12034 bytes --]

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 2998 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-06-16  2:44 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-11 10:39 [PATCH] spi: aspeed: Fix division by zero Cédric Le Goater
2022-06-11 10:39 ` Cédric Le Goater
2022-06-11 10:39 ` Cédric Le Goater
2022-06-13  8:39 ` Pratyush Yadav
2022-06-13  8:39   ` Pratyush Yadav
2022-06-13  8:39   ` Pratyush Yadav
2022-06-13  8:57   ` Cédric Le Goater
2022-06-13  8:57     ` Cédric Le Goater
2022-06-13  8:57     ` Cédric Le Goater
2022-06-13 16:18     ` Woloschin, Ian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.