2021-09-16 18:33:21

by Ville Baillie

[permalink] [raw]
Subject: [PATCH] spi: atmel: Fix PDC transfer setup bug

From 614bcf515cc8dbd1b7573a2fbf369fc84fca0501 Mon Sep 17 00:00:00 2001
From: Ville Baillie <[email protected]>
Date: Thu, 16 Sep 2021 14:16:46 +0000
Subject: [PATCH] spi: atmel: Fix PDC transfer setup bug

Commit d370f4b2808d ("spi: atmel: Switch to transfer_one transfer
method") refactored the code and changed a conditional causing
atmel_spi_dma_map_xfer to never be called in PDC mode. This causes the
driver to silently fail.

This patch changes the conditional to match the behaviour of the
previous commit before the refactor.

Signed-off-by: Ville Baillie <[email protected]>
---
drivers/spi/spi-atmel.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
index 788dcdf25f00..f00e9c9b426e 100644
--- a/drivers/spi/spi-atmel.c
+++ b/drivers/spi/spi-atmel.c
@@ -1301,7 +1301,7 @@ static int atmel_spi_one_transfer(struct spi_master *master,
* DMA map early, for performance (empties dcache ASAP) and
* better fault reporting.
*/
- if ((!master->cur_msg_mapped)
+ if ((!master->cur_msg->is_dma_mapped)
&& as->use_pdc) {
if (atmel_spi_dma_map_xfer(as, xfer) < 0)
return -ENOMEM;
--
2.17.1


2021-09-16 23:20:04

by Dan Sneddon

[permalink] [raw]
Subject: Re: [PATCH] spi: atmel: Fix PDC transfer setup bug

Hi Ville,

On 9/16/21 8:16 AM, Ville Baillie wrote:
> [Some people who received this message don't often get email from [email protected]. Learn why this is important at http://aka.ms/LearnAboutSenderIdentification.]
>
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> From 614bcf515cc8dbd1b7573a2fbf369fc84fca0501 Mon Sep 17 00:00:00 2001
> From: Ville Baillie <[email protected]>
> Date: Thu, 16 Sep 2021 14:16:46 +0000
> Subject: [PATCH] spi: atmel: Fix PDC transfer setup bug
>
> Commit d370f4b2808d ("spi: atmel: Switch to transfer_one transfer
> method") refactored the code and changed a conditional causing
> atmel_spi_dma_map_xfer to never be called in PDC mode. This causes the
> driver to silently fail.
>
> This patch changes the conditional to match the behaviour of the
> previous commit before the refactor.
>
> Signed-off-by: Ville Baillie <[email protected]>
> ---
> drivers/spi/spi-atmel.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c
> index 788dcdf25f00..f00e9c9b426e 100644
> --- a/drivers/spi/spi-atmel.c
> +++ b/drivers/spi/spi-atmel.c
> @@ -1301,7 +1301,7 @@ static int atmel_spi_one_transfer(struct spi_master *master,
> * DMA map early, for performance (empties dcache ASAP) and
> * better fault reporting.
> */
> - if ((!master->cur_msg_mapped)
> + if ((!master->cur_msg->is_dma_mapped)
> && as->use_pdc) {
> if (atmel_spi_dma_map_xfer(as, xfer) < 0)
> return -ENOMEM;
Looks like the same change should be made at the end of that same
function where the call to atmel_spi_dma_unmap_xfer is made.
> --
> 2.17.1
>

2021-09-17 13:02:44

by Ville Baillie

[permalink] [raw]
Subject: RE: [PATCH] spi: atmel: Fix PDC transfer setup bug

>Looks like the same change should be made at the end of that same function where the call to atmel_spi_dma_unmap_xfer is made.

Thanks Dan, I think you are correct. I will update the patch and send it out as V2.

Cheers
Ville