Skip to contentSkip to conversation

dmaengine: dma40: Add support to split up large elements

PATCH In review Per Forlin 4 participants 6 messages Dec 20, 2010 – Dec 22, 2010

Subsystems (4)
lore
Share & tools
lore

Per Forlin

author
#0 lore raw

PATCH 1/1 dmaengine: dma40: Add support to split up large elements

The maximum transfer size of the stedma40 is (64k-1) x data-width. If the transfer size of one element exceeds this limit the job is split up and sent as linked transfer.

---
 arch/arm/plat-nomadik/include/plat/ste_dma40.h |    8 +
 drivers/dma/ste_dma40.c                        |  191 +++++++++++++++----
 drivers/dma/ste_dma40_ll.c                     |  246 +++++++++++++++++-------
 drivers/dma/ste_dma40_ll.h                     |   36 ++--
 4 files changed, 351 insertions(+), 130 deletions(-)
arch/arm/plat-nomadik/include/plat/ste_dma40.h +8 -0
index 74b62f1..4d6dd4c 100644
@@ -13,6 +13,14 @@
 #include <linux/workqueue.h>
 #include <linux/interrupt.h>
 
+/*
+ * Maxium size for a single dma descriptor
+ * Size is limited to 16 bits.
+ * Size is in the units of addr-widths (1,2,4,8 bytes)
+ * Larger transfers will be split up to multiple linked desc
+ */
+#define STEDMA40_MAX_SEG_SIZE 0xFFFF
+
 /* dev types for memcpy */
 #define STEDMA40_DEV_DST_MEMORY (-1)
 #define	STEDMA40_DEV_SRC_MEMORY (-1)
drivers/dma/ste_dma40.c +152 -39

335 lines not on this page · raw message

drivers/dma/ste_dma40_ll.c +172 -74

333 lines not on this page · raw message

drivers/dma/ste_dma40_ll.h +19 -17
index 9e419b9..9cc4349 100644
@@ -292,18 +292,20 @@ int d40_phy_sg_to_lli(struct scatterlist *sg,
 		      struct d40_phy_lli *lli,
 		      dma_addr_t lli_phys,
 		      u32 reg_cfg,
-		      u32 data_width,
+		      u32 data_width1,
+		      u32 data_width2,
 		      int psize);
 
-int d40_phy_fill_lli(struct d40_phy_lli *lli,
-		     dma_addr_t data,
-		     u32 data_size,
-		     int psize,
-		     dma_addr_t next_lli,
-		     u32 reg_cfg,
-		     bool term_int,
-		     u32 data_width,
-		     bool is_device);
+struct d40_phy_lli *d40_phy_buf_to_lli(struct d40_phy_lli *lli,
+				       dma_addr_t data,
+				       u32 data_size,
+				       int psize,
+				       dma_addr_t next_lli,
+				       u32 reg_cfg,
+				       bool term_int,
+				       u32 data_width1,
+				       u32 data_width2,
+				       bool is_device);
 
 void d40_phy_lli_write(void __iomem *virtbase,
 		       u32 phy_chan_num,
@@ -312,12 +314,12 @@ void d40_phy_lli_write(void __iomem *virtbase,
 
 /* Logical channels */
 
-void d40_log_fill_lli(struct d40_log_lli *lli,
-		      dma_addr_t data,
-		      u32 data_size,
-		      u32 reg_cfg,
-		      u32 data_width,
-		      bool addr_inc);
+struct d40_log_lli *d40_log_buf_to_lli(struct d40_log_lli *lli_sg,
+				       dma_addr_t addr,
+				       int size,
+				       u32 lcsp13, /* src or dst*/
+				       u32 data_width1, u32 data_width2,
+				       bool addr_inc);
 
 int d40_log_sg_to_dev(struct scatterlist *sg,
 		      int sg_len,
@@ -332,7 +334,7 @@ int d40_log_sg_to_lli(struct scatterlist *sg,
 		      int sg_len,
 		      struct d40_log_lli *lli_sg,
 		      u32 lcsp13, /* src or dst*/
-		      u32 data_width);
+		      u32 data_width1, u32 data_width2);
 
 void d40_log_lli_lcpa_write(struct d40_log_lli_full *lcpa,
 			    struct d40_log_lli *lli_dst,
Signature · 1 line
1.6.3.3
Acked-by on v1 1/1
#1 lore raw

2010/12/20 Per Forlin <[email protected]>:

Quoted 5 lines

The maximum transfer size of the stedma40 is (64k-1) x data-width. If the transfer size of one element exceeds this limit the job is split up and sent as linked transfer.

I think this could actually go into 2.6.37 series: I consider it a bug fix since the transfer size limitation breaks the contract of the memcpy() API.

Yours,
Linus Walleij

#2 lore raw
Quoted 6 lines · Linus Walleij

2010/12/20 Per Forlin <[email protected]>:

Quoted 4 lines

The maximum transfer size of the stedma40 is (64k-1) x data-width. If the transfer size of one element exceeds this limit the job is split up and sent as linked transfer.

Quoted 8 lines
Quoted 1 line

I think this could actually go into 2.6.37 series: I consider it a bug fix since the transfer size limitation breaks the contract of the memcpy() API.

If that is the case then the temporary fix for 2.6.37 is along the lines of fixing up the clients to not submit such large requests. You mention the "memcpy api contract" can this be triggered outside of dmatest? The other memcpy clients NET_DMA and ASYNC_TX_DMA will never submit an operation larger than PAGE_SIZE.

"4 files changed, 351 insertions(+), 130 deletions(-)" is difficult to defend at this stage of the game, if a smaller "don't do that" patch will suffice for 2.6.37.

--
Dan

#3 lore raw

2010/12/21 Dan Williams <[email protected]>:

Quoted 2 lines

If that is the case then the temporary fix for 2.6.37 is along the lines of fixing up the clients to not submit such large requests.

They don't, currently. We actually had some debate about this internally, because the only driver submitting something >64K-1 was the MMCI driver (which is yet not in mainline) and yes, indeed the suggested solution was to amend the MMCI driver
for the time being.

I insisted on doing this fix anyway because I was under the impression that memcpy() is supposed to handle *any* size of request, is this the intention?

Since its semantics are not documented as far as I can see I was maybe misguided in assuming that any size of buffer should be possible to pass in... :-(

Quoted 3 lines

 You
mention the "memcpy api contract" can this be triggered outside of dmatest?

Nope. That and out-of-tree MMCI.

So for the next merge window it is, if the patch is semantically correct.

Yours,
Linus Walleij

#4 lore raw
Quoted 11 lines · Linus Walleij

2010/12/21 Dan Williams <[email protected]>:

Quoted 2 lines

If that is the case then the temporary fix for 2.6.37 is along the lines of fixing up the clients to not submit such large requests.

They don't, currently. We actually had some debate about this internally, because the only driver submitting something >64K-1 was the MMCI driver (which is yet not in mainline) and yes, indeed the suggested solution was to amend the MMCI driver
for the time being.

Quoted 3 lines

I insisted on doing this fix anyway because I was under the impression that memcpy() is supposed to handle *any* size of request, is this the intention?

Yes, the api does not enforce a limit if a driver cannot handle a given transaction size it can fail the prep. To be useful the driver at least needs to support PAGE_SIZE requests.

Quoted 3 lines

Since its semantics are not documented as far as I can see I was maybe misguided in assuming that any size of buffer should be possible to pass in... :-(

No, you made the right call. This is just a large change that I would have a hard time justifying at this stage of the release process, especially because mainline can't trigger it, even dmatest by default cannot trigger it. So I'll queue it up for the merge window.

If you want to send a patch that catches and reports this byte count in case some out of tree user submits a large request that would be an acceptable workaround for 37. >64K support is a new feature for 38.

--
Dan

#5 lore raw

2010/12/21 Dan Williams <[email protected]>:

Thanks for clearing out the misunderstandings...

Quoted 3 lines

If you want to send a patch that catches and reports this byte count in case some out of tree user submits a large request that would be an acceptable workaround for 37.  >64K support is a new feature for 38.

Nah noone else besides us would be using it right now and we have this under control. No-one should be harmed. It's fair enough if it goes into .38...

Yours,
Linus Walleij