Skip to contentSkip to conversation

spi-atmel.c: fix DMA for bits_per_word > 8

PATCH New David Mosberger 3 participants 4 messages Oct 12, 2015 – Oct 19, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi-atmel.c: fix DMA for bits_per_word > 8

I need the patch below to make DMA work in spi-atmel.c when bits_per_word > 8.

--david

Signature · 1 line
eGauge Systems LLC, http://egauge.net/, 1.877-EGAUGE1, fax 720.545.9768
drivers/spi/spi-atmel.c +0 -0
index 04e48e5..7bb361a 100644
@@ -711,6 +711,7 @@ static void atmel_spi_next_xfer_pio(struct

spi_master *master,
* Submit next transfer for DMA.
*/
static int atmel_spi_next_xfer_dma_submit(struct spi_master *master,
+ struct spi_message *msg,
struct spi_transfer *xfer,
u32 *plen)
{
@@ -721,7 +722,7 @@ static int atmel_spi_next_xfer_dma_submit(struct spi_master *master,
struct dma_async_tx_descriptor *txdesc;
struct dma_slave_config slave_config;
dma_cookie_t cookie;
- u32 len = *plen;
+ u32 len = *plen, bpw;

  dev_vdbg(master->dev.parent, "atmel_spi_next_xfer_dma_submit\n");

@@ -758,7 +759,11 @@ static int atmel_spi_next_xfer_dma_submit(struct spi_master *master,

  *plen = len;

- if (atmel_spi_dma_slave_config(as, &slave_config, 8))
+ bpw = xfer->bits_per_word;
+ if (!bpw)
+ bpw = msg->spi->bits_per_word;
+
+ if (atmel_spi_dma_slave_config(as, &slave_config, bpw)) goto err_exit;

/* Send both scatterlists */
@@ -1316,8 +1321,8 @@ static int atmel_spi_one_transfer(struct spi_master *master,
atmel_spi_pdc_next_xfer(master, msg, xfer);
} else if (atmel_spi_use_dma(as, xfer)) {
len = as->current_remaining_bytes;
- ret = atmel_spi_next_xfer_dma_submit(master,
- xfer, &len);
+ ret = atmel_spi_next_xfer_dma_submit(master, msg,
+ xfer, &len);
if (ret) {
dev_err(&spi->dev,
"unable to use DMA, fallback to PIO\n");

#1 lore raw

PATCH 1/1 spi-atmel.c: fix DMA for bits_per_word > 8

David,

It seems that your email client is doing funny things with the source code whitespace. Anyway, I can deal with this and re-format your patch:
no problem. For later patches I advice you to use "git format-patch" command.

Still, see comments below...

Le 13/10/2015 00:32, David Mosberger a ?crit :

Quoted 1 line

I need the patch below to make DMA work in spi-atmel.c when bits_per_word > 8.

A little bit more explanation would be good.

Quoted 1 line

--david

I would need your "Signed-off-by:" tag.

Quoted 27 lines
Signature · 1 line
eGauge Systems LLC, http://egauge.net/, 1.877-EGAUGE1, fax 720.545.9768
drivers/spi/spi-atmel.c +1 -0
index 04e48e5..7bb361a 100644
@@ -711,6 +711,7 @@ static void atmel_spi_next_xfer_pio(struct
 spi_master *master,
  * Submit next transfer for DMA.
  */
 static int atmel_spi_next_xfer_dma_submit(struct spi_master *master,
+  struct spi_message *msg,
  struct spi_transfer *xfer,
  u32 *plen)

{

drivers/spi/spi-atmel.c +1 -1
@@ -721,7 +722,7 @@ static int atmel_spi_next_xfer_dma_submit(struct
 spi_master *master,
  struct dma_async_tx_descriptor *txdesc;
  struct dma_slave_config slave_config;
  dma_cookie_t cookie;
- u32 len = *plen;
+ u32 len = *plen, bpw;
 
  dev_vdbg(master->dev.parent, "atmel_spi_next_xfer_dma_submit\n");

drivers/spi/spi-atmel.c static int atmel_spi_next_xfer_dma_submit(struct · line 764

Quoted 7 lines
drivers/spi/spi-atmel.c +2 -1
@@ -758,7 +759,11 @@ static int atmel_spi_next_xfer_dma_submit(struct
 spi_master *master,
 
  *plen = len;
 
- if (atmel_spi_dma_slave_config(as, &slave_config, 8))
+ bpw = xfer->bits_per_word;
+ if (!bpw)

I assume that xfer->bits_per_word must be filled with the proper value. So why do you need this test and de additional assignment below? Does it come from a bad experience with the "xfer->bits_per_word" value being empty?

drivers/spi/spi-atmel.c static int atmel_spi_next_xfer_dma_submit(struct · line 767

Quoted 3 lines
drivers/spi/spi-atmel.c +3 -0
+ bpw = msg->spi->bits_per_word;
+
+ if (atmel_spi_dma_slave_config(as, &slave_config, bpw))

I may have called bpw variable as "bits" like elsewhere in this driver:
it's a detail though.

Quoted 14 lines
drivers/spi/spi-atmel.c +0 -0
  goto err_exit;
 

/* Send both scatterlists */

drivers/spi/spi-atmel.c +2 -2
@@ -1316,8 +1321,8 @@ static int atmel_spi_one_transfer(struct
 spi_master *master,
  atmel_spi_pdc_next_xfer(master, msg, xfer);
  } else if (atmel_spi_use_dma(as, xfer)) {
  len = as->current_remaining_bytes;
- ret = atmel_spi_next_xfer_dma_submit(master,
- xfer, &len);
+ ret = atmel_spi_next_xfer_dma_submit(master, msg,
+     xfer, &len);
  if (ret) {
  dev_err(&spi->dev,
Quoted 1 line

"unable to use DMA, fallback to PIO\n");

Ok, the patch seems reasonable. So, can you please answer my main question and give me the permission to add your "Signed-off-by:" tag or re-send me a more standard patch...

Thanks a lot for your work on this driver David.
Best regards,

Signature · 1 line
Nicolas Ferre
maintainer
#2 lore raw

PATCH 1/1 spi-atmel.c: fix DMA for bits_per_word > 8

Quoted 7 lines · Nicolas Ferre
Quoted 6 lines

- xfer, &len);
+ ret = atmel_spi_next_xfer_dma_submit(master, msg,
+ xfer, &len);
if (ret) {
dev_err(&spi->dev,
"unable to use DMA, fallback to PIO\n");

Quoted 5 lines

Ok, the patch seems reasonable. So, can you please answer my main question and give me the permission to add your "Signed-off-by:" tag or re-send me a more standard patch...

Thanks a lot for your work on this driver David.

Please also remember to CC subsysetm maintainers on patches...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151019/e603fa80/attachment.sig>

#3 lore raw

PATCH 1/1 spi-atmel.c: fix DMA for bits_per_word > 8

In reply to Nicolas Ferre

Nicolas,

Thanks for your comments.

On Mon, Oct 19, 2015 at 10:01 AM, Nicolas Ferre <[email protected]> wrote:
David,

Quoted 4 lines

It seems that your email client is doing funny things with the source code whitespace. Anyway, I can deal with this and re-format your patch:
no problem. For later patches I advice you to use "git format-patch" command.

Yeah, I should finally give up any hope that Gmail will get fixed to not mangle tabs etc...

Quoted 7 lines

- if (atmel_spi_dma_slave_config(as, &slave_config, 8))
+ bpw = xfer->bits_per_word;
+ if (!bpw)

I assume that xfer->bits_per_word must be filled with the proper value. So why do you need this test and de additional assignment below? Does it come from a bad experience with the "xfer->bits_per_word" value being empty?

Sorry, that was a mistake. I forgot that spi.c:__spi_validate() takes care of setting the transfer's bits_per_word if it's not non-zero already.

Quoted 3 lines

Ok, the patch seems reasonable. So, can you please answer my main question and give me the permission to add your "Signed-off-by:" tag or re-send me a more standard patch...

I just sent an updated patch.

Quoted 1 line

Thanks a lot for your work on this driver David.

Oh, you're welcome!

--david

Quoted 88 lines · Nicolas Ferre

David,

It seems that your email client is doing funny things with the source code whitespace. Anyway, I can deal with this and re-format your patch:
no problem. For later patches I advice you to use "git format-patch" command.

Still, see comments below...

Le 13/10/2015 00:32, David Mosberger a ?crit :

Quoted 1 line

I need the patch below to make DMA work in spi-atmel.c when bits_per_word > 8.

A little bit more explanation would be good.

Quoted 1 line

--david

I would need your "Signed-off-by:" tag.

Quoted 27 lines

--
eGauge Systems LLC, http://egauge.net/, 1.877-EGAUGE1, fax 720.545.9768

drivers/spi/spi-atmel.c +1 -0
index 04e48e5..7bb361a 100644
@@ -711,6 +711,7 @@ static void atmel_spi_next_xfer_pio(struct
 spi_master *master,
  * Submit next transfer for DMA.
  */
 static int atmel_spi_next_xfer_dma_submit(struct spi_master *master,
+  struct spi_message *msg,
  struct spi_transfer *xfer,
  u32 *plen)

{

drivers/spi/spi-atmel.c +1 -1
@@ -721,7 +722,7 @@ static int atmel_spi_next_xfer_dma_submit(struct
 spi_master *master,
  struct dma_async_tx_descriptor *txdesc;
  struct dma_slave_config slave_config;
  dma_cookie_t cookie;
- u32 len = *plen;
+ u32 len = *plen, bpw;
 
  dev_vdbg(master->dev.parent, "atmel_spi_next_xfer_dma_submit\n");

drivers/spi/spi-atmel.c static int atmel_spi_next_xfer_dma_submit(struct · line 764

Quoted 7 lines
drivers/spi/spi-atmel.c +2 -1
@@ -758,7 +759,11 @@ static int atmel_spi_next_xfer_dma_submit(struct
 spi_master *master,
 
  *plen = len;
 
- if (atmel_spi_dma_slave_config(as, &slave_config, 8))
+ bpw = xfer->bits_per_word;
+ if (!bpw)

I assume that xfer->bits_per_word must be filled with the proper value. So why do you need this test and de additional assignment below? Does it come from a bad experience with the "xfer->bits_per_word" value being empty?

drivers/spi/spi-atmel.c static int atmel_spi_next_xfer_dma_submit(struct · line 767

Quoted 3 lines
drivers/spi/spi-atmel.c +3 -0
+ bpw = msg->spi->bits_per_word;
+
+ if (atmel_spi_dma_slave_config(as, &slave_config, bpw))

I may have called bpw variable as "bits" like elsewhere in this driver:
it's a detail though.

Quoted 14 lines
drivers/spi/spi-atmel.c +0 -0
  goto err_exit;
 

/* Send both scatterlists */

drivers/spi/spi-atmel.c +2 -2
@@ -1316,8 +1321,8 @@ static int atmel_spi_one_transfer(struct
 spi_master *master,
  atmel_spi_pdc_next_xfer(master, msg, xfer);
  } else if (atmel_spi_use_dma(as, xfer)) {
  len = as->current_remaining_bytes;
- ret = atmel_spi_next_xfer_dma_submit(master,
- xfer, &len);
+ ret = atmel_spi_next_xfer_dma_submit(master, msg,
+     xfer, &len);
  if (ret) {
  dev_err(&spi->dev,
Quoted 1 line

"unable to use DMA, fallback to PIO\n");

Ok, the patch seems reasonable. So, can you please answer my main question and give me the permission to add your "Signed-off-by:" tag or re-send me a more standard patch...

Thanks a lot for your work on this driver David.
Best regards,
--
Nicolas Ferre

Signature · 1 line
eGauge Systems LLC, http://egauge.net/, 1.877-EGAUGE1, fax 720.545.9768