* [PATCH v2 0/2] spi: aspeed: Fix division by zero
@ 2022-06-22 9:42 Cédric Le Goater
2022-06-22 9:42 ` [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create() Cédric Le Goater
2022-06-22 9:42 ` [PATCH v2 2/2] spi: aspeed: Fix division by zero Cédric Le Goater
0 siblings, 2 replies; 5+ messages in thread
From: Cédric Le Goater @ 2022-06-22 9:42 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
Hello,
Here is a small series adding some debug and fixing a division by zero
on a board using normal speed reads.
Thanks,
C.
Cédric Le Goater (2):
spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create()
spi: aspeed: Fix division by zero
drivers/spi/spi-aspeed-smc.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--
2.35.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create()
2022-06-22 9:42 [PATCH v2 0/2] spi: aspeed: Fix division by zero Cédric Le Goater
@ 2022-06-22 9:42 ` Cédric Le Goater
2022-06-22 10:26 ` Andy Shevchenko
2022-06-22 10:34 ` Paul Menzel
2022-06-22 9:42 ` [PATCH v2 2/2] spi: aspeed: Fix division by zero Cédric Le Goater
1 sibling, 2 replies; 5+ messages in thread
From: Cédric Le Goater @ 2022-06-22 9:42 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
It helps to analyze the default setting of the control register.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
drivers/spi/spi-aspeed-smc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index 496f3e1e9079..ac64be289e59 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 */
--
2.35.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] spi: aspeed: Fix division by zero
2022-06-22 9:42 [PATCH v2 0/2] spi: aspeed: Fix division by zero Cédric Le Goater
2022-06-22 9:42 ` [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create() Cédric Le Goater
@ 2022-06-22 9:42 ` Cédric Le Goater
1 sibling, 0 replies; 5+ messages in thread
From: Cédric Le Goater @ 2022-06-22 9:42 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, 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 based on the AST2500 SoC
and using a MX25L51245GMI-08G SPI Flash.
Reported-by: Ian Woloschin <ian.woloschin@akamai.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Tested-by: Ian Woloschin <iwolosch@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 | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index ac64be289e59..3e891bf22470 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -582,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] 5+ messages in thread
* Re: [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create()
2022-06-22 9:42 ` [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create() Cédric Le Goater
@ 2022-06-22 10:26 ` Andy Shevchenko
2022-06-22 10:34 ` Paul Menzel
1 sibling, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-06-22 10:26 UTC (permalink / raw)
To: Cédric Le Goater
Cc: linux-spi, Mark Brown, Pratyush Yadav,
moderated list:ARM/ASPEED MACHINE SUPPORT, OpenBMC Maillist,
Joel Stanley, Andrew Jeffery, Chin-Ting Kuo,
linux-arm Mailing List, Linux Kernel Mailing List
On Wed, Jun 22, 2022 at 11:46 AM Cédric Le Goater <clg@kaod.org> wrote:
>
> It helps to analyze the default setting of the control register.
Replace "It" with a slightly more descriptive "what is it?".
Also make the subject aligned with the contents of the patch.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create()
2022-06-22 9:42 ` [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create() Cédric Le Goater
2022-06-22 10:26 ` Andy Shevchenko
@ 2022-06-22 10:34 ` Paul Menzel
1 sibling, 0 replies; 5+ messages in thread
From: Paul Menzel @ 2022-06-22 10:34 UTC (permalink / raw)
To: Cédric Le Goater
Cc: linux-spi, linux-aspeed, Andrew Jeffery, openbmc, linux-kernel,
Chin-Ting Kuo, Mark Brown, Joel Stanley, Pratyush Yadav,
linux-arm-kernel
Dear Cédric,
Am 22.06.22 um 11:42 schrieb Cédric Le Goater:
> It helps to analyze the default setting of the control register.
Maybe paste the new log line to the commit message.
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> drivers/spi/spi-aspeed-smc.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index 496f3e1e9079..ac64be289e59 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,
The commit message summary says `pr_debug()`.
> + "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 */
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
Kind regards,
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-06-22 10:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22 9:42 [PATCH v2 0/2] spi: aspeed: Fix division by zero Cédric Le Goater
2022-06-22 9:42 ` [PATCH v2 1/2] spi: aspeed: Add pr_debug in aspeed_spi_dirmap_create() Cédric Le Goater
2022-06-22 10:26 ` Andy Shevchenko
2022-06-22 10:34 ` Paul Menzel
2022-06-22 9:42 ` [PATCH v2 2/2] spi: aspeed: Fix division by zero Cédric Le Goater
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).