aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Jiang <dave.jiang@intel.com>2017-08-21 13:23:13 -0400
committerVinod Koul <vinod.koul@intel.com>2017-08-21 23:52:11 -0400
commitc678fa66341c7b82a57cfed0ba3656162e970f99 (patch)
tree1573dfbd3e1afb9ea57a8231183f836e51e12c43
parent61b5f54d8c1fafb97dace958a54cdd72b37138c3 (diff)
dmaengine: remove DMA_SG as it is dead code in kernel
There are no in kernel consumers for DMA_SG op. Removing operation, dead code, and test code in dmatest. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Cc: Gary Hook <gary.hook@amd.com> Cc: Ludovic Desroches <ludovic.desroches@microchip.com> Cc: Kedareswara rao Appana <appana.durga.rao@xilinx.com> Cc: Li Yang <leoyang.li@nxp.com> Cc: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--Documentation/dmaengine/provider.txt7
-rw-r--r--drivers/crypto/ccp/ccp-dmaengine.c23
-rw-r--r--drivers/dma/at_hdmac.c140
-rw-r--r--drivers/dma/dmaengine.c2
-rw-r--r--drivers/dma/dmatest.c36
-rw-r--r--drivers/dma/fsldma.c118
-rw-r--r--drivers/dma/mv_xor.c162
-rw-r--r--drivers/dma/nbpfaxi.c17
-rw-r--r--drivers/dma/ste_dma40.c18
-rw-r--r--drivers/dma/xgene-dma.c155
-rw-r--r--drivers/dma/xilinx/zynqmp_dma.c94
-rw-r--r--include/linux/dmaengine.h19
12 files changed, 5 insertions, 786 deletions
diff --git a/Documentation/dmaengine/provider.txt b/Documentation/dmaengine/provider.txt
index e33bc1c8ed2c..a75f52ff2e49 100644
--- a/Documentation/dmaengine/provider.txt
+++ b/Documentation/dmaengine/provider.txt
@@ -181,13 +181,6 @@ Currently, the types available are:
181 - Used by the client drivers to register a callback that will be 181 - Used by the client drivers to register a callback that will be
182 called on a regular basis through the DMA controller interrupt 182 called on a regular basis through the DMA controller interrupt
183 183
184 * DMA_SG
185 - The device supports memory to memory scatter-gather
186 transfers.
187 - Even though a plain memcpy can look like a particular case of a
188 scatter-gather transfer, with a single chunk to transfer, it's a
189 distinct transaction type in the mem2mem transfers case
190
191 * DMA_PRIVATE 184 * DMA_PRIVATE
192 - The devices only supports slave transfers, and as such isn't 185 - The devices only supports slave transfers, and as such isn't
193 available for async transfers. 186 available for async transfers.
diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
index e00be01fbf5a..3f7d54f4728c 100644
--- a/drivers/crypto/ccp/ccp-dmaengine.c
+++ b/drivers/crypto/ccp/ccp-dmaengine.c
@@ -502,27 +502,6 @@ static struct dma_async_tx_descriptor *ccp_prep_dma_memcpy(
502 return &desc->tx_desc; 502 return &desc->tx_desc;
503} 503}
504 504
505static struct dma_async_tx_descriptor *ccp_prep_dma_sg(
506 struct dma_chan *dma_chan, struct scatterlist *dst_sg,
507 unsigned int dst_nents, struct scatterlist *src_sg,
508 unsigned int src_nents, unsigned long flags)
509{
510 struct ccp_dma_chan *chan = container_of(dma_chan, struct ccp_dma_chan,
511 dma_chan);
512 struct ccp_dma_desc *desc;
513
514 dev_dbg(chan->ccp->dev,
515 "%s - src=%p, src_nents=%u dst=%p, dst_nents=%u, flags=%#lx\n",
516 __func__, src_sg, src_nents, dst_sg, dst_nents, flags);
517
518 desc = ccp_create_desc(dma_chan, dst_sg, dst_nents, src_sg, src_nents,
519 flags);
520 if (!desc)
521 return NULL;
522
523 return &desc->tx_desc;
524}
525
526static struct dma_async_tx_descriptor *ccp_prep_dma_interrupt( 505static struct dma_async_tx_descriptor *ccp_prep_dma_interrupt(
527 struct dma_chan *dma_chan, unsigned long flags) 506 struct dma_chan *dma_chan, unsigned long flags)
528{ 507{
@@ -704,7 +683,6 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
704 dma_dev->directions = DMA_MEM_TO_MEM; 683 dma_dev->directions = DMA_MEM_TO_MEM;
705 dma_dev->residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR; 684 dma_dev->residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
706 dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask); 685 dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask);
707 dma_cap_set(DMA_SG, dma_dev->cap_mask);
708 dma_cap_set(DMA_INTERRUPT, dma_dev->cap_mask); 686 dma_cap_set(DMA_INTERRUPT, dma_dev->cap_mask);
709 687
710 /* The DMA channels for this device can be set to public or private, 688 /* The DMA channels for this device can be set to public or private,
@@ -740,7 +718,6 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
740 718
741 dma_dev->device_free_chan_resources = ccp_free_chan_resources; 719 dma_dev->device_free_chan_resources = ccp_free_chan_resources;
742 dma_dev->device_prep_dma_memcpy = ccp_prep_dma_memcpy; 720 dma_dev->device_prep_dma_memcpy = ccp_prep_dma_memcpy;
743 dma_dev->device_prep_dma_sg = ccp_prep_dma_sg;
744 dma_dev->device_prep_dma_interrupt = ccp_prep_dma_interrupt; 721 dma_dev->device_prep_dma_interrupt = ccp_prep_dma_interrupt;
745 dma_dev->device_issue_pending = ccp_issue_pending; 722 dma_dev->device_issue_pending = ccp_issue_pending;
746 dma_dev->device_tx_status = ccp_tx_status; 723 dma_dev->device_tx_status = ccp_tx_status;
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 1baf3404a365..fbab271b3bf9 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -1203,138 +1203,6 @@ err:
1203} 1203}
1204 1204
1205/** 1205/**
1206 * atc_prep_dma_sg - prepare memory to memory scather-gather operation
1207 * @chan: the channel to prepare operation on
1208 * @dst_sg: destination scatterlist
1209 * @dst_nents: number of destination scatterlist entries
1210 * @src_sg: source scatterlist
1211 * @src_nents: number of source scatterlist entries
1212 * @flags: tx descriptor status flags
1213 */
1214static struct dma_async_tx_descriptor *
1215atc_prep_dma_sg(struct dma_chan *chan,
1216 struct scatterlist *dst_sg, unsigned int dst_nents,
1217 struct scatterlist *src_sg, unsigned int src_nents,
1218 unsigned long flags)
1219{
1220 struct at_dma_chan *atchan = to_at_dma_chan(chan);
1221 struct at_desc *desc = NULL;
1222 struct at_desc *first = NULL;
1223 struct at_desc *prev = NULL;
1224 unsigned int src_width;
1225 unsigned int dst_width;
1226 size_t xfer_count;
1227 u32 ctrla;
1228 u32 ctrlb;
1229 size_t dst_len = 0, src_len = 0;
1230 dma_addr_t dst = 0, src = 0;
1231 size_t len = 0, total_len = 0;
1232
1233 if (unlikely(dst_nents == 0 || src_nents == 0))
1234 return NULL;
1235
1236 if (unlikely(dst_sg == NULL || src_sg == NULL))
1237 return NULL;
1238
1239 ctrlb = ATC_DEFAULT_CTRLB | ATC_IEN
1240 | ATC_SRC_ADDR_MODE_INCR
1241 | ATC_DST_ADDR_MODE_INCR
1242 | ATC_FC_MEM2MEM;
1243
1244 /*
1245 * loop until there is either no more source or no more destination
1246 * scatterlist entry
1247 */
1248 while (true) {
1249
1250 /* prepare the next transfer */
1251 if (dst_len == 0) {
1252
1253 /* no more destination scatterlist entries */
1254 if (!dst_sg || !dst_nents)
1255 break;
1256
1257 dst = sg_dma_address(dst_sg);
1258 dst_len = sg_dma_len(dst_sg);
1259
1260 dst_sg = sg_next(dst_sg);
1261 dst_nents--;
1262 }
1263
1264 if (src_len == 0) {
1265
1266 /* no more source scatterlist entries */
1267 if (!src_sg || !src_nents)
1268 break;
1269
1270 src = sg_dma_address(src_sg);
1271 src_len = sg_dma_len(src_sg);
1272
1273 src_sg = sg_next(src_sg);
1274 src_nents--;
1275 }
1276
1277 len = min_t(size_t, src_len, dst_len);
1278 if (len == 0)
1279 continue;
1280
1281 /* take care for the alignment */
1282 src_width = dst_width = atc_get_xfer_width(src, dst, len);
1283
1284 ctrla = ATC_SRC_WIDTH(src_width) |
1285 ATC_DST_WIDTH(dst_width);
1286
1287 /*
1288 * The number of transfers to set up refer to the source width
1289 * that depends on the alignment.
1290 */
1291 xfer_count = len >> src_width;
1292 if (xfer_count > ATC_BTSIZE_MAX) {
1293 xfer_count = ATC_BTSIZE_MAX;
1294 len = ATC_BTSIZE_MAX << src_width;
1295 }
1296
1297 /* create the transfer */
1298 desc = atc_desc_get(atchan);
1299 if (!desc)
1300 goto err_desc_get;
1301
1302 desc->lli.saddr = src;
1303 desc->lli.daddr = dst;
1304 desc->lli.ctrla = ctrla | xfer_count;
1305 desc->lli.ctrlb = ctrlb;
1306
1307 desc->txd.cookie = 0;
1308 desc->len = len;
1309
1310 atc_desc_chain(&first, &prev, desc);
1311
1312 /* update the lengths and addresses for the next loop cycle */
1313 dst_len -= len;
1314 src_len -= len;
1315 dst += len;
1316 src += len;
1317
1318 total_len += len;
1319 }
1320
1321 /* First descriptor of the chain embedds additional information */
1322 first->txd.cookie = -EBUSY;
1323 first->total_len = total_len;
1324
1325 /* set end-of-link to the last link descriptor of list*/
1326 set_desc_eol(desc);
1327
1328 first->txd.flags = flags; /* client is in control of this ack */
1329
1330 return &first->txd;
1331
1332err_desc_get:
1333 atc_desc_put(atchan, first);
1334 return NULL;
1335}
1336
1337/**
1338 * atc_dma_cyclic_check_values 1206 * atc_dma_cyclic_check_values
1339 * Check for too big/unaligned periods and unaligned DMA buffer 1207 * Check for too big/unaligned periods and unaligned DMA buffer
1340 */ 1208 */
@@ -1933,14 +1801,12 @@ static int __init at_dma_probe(struct platform_device *pdev)
1933 1801
1934 /* setup platform data for each SoC */ 1802 /* setup platform data for each SoC */
1935 dma_cap_set(DMA_MEMCPY, at91sam9rl_config.cap_mask); 1803 dma_cap_set(DMA_MEMCPY, at91sam9rl_config.cap_mask);
1936 dma_cap_set(DMA_SG, at91sam9rl_config.cap_mask);
1937 dma_cap_set(DMA_INTERLEAVE, at91sam9g45_config.cap_mask); 1804 dma_cap_set(DMA_INTERLEAVE, at91sam9g45_config.cap_mask);
1938 dma_cap_set(DMA_MEMCPY, at91sam9g45_config.cap_mask); 1805 dma_cap_set(DMA_MEMCPY, at91sam9g45_config.cap_mask);
1939 dma_cap_set(DMA_MEMSET, at91sam9g45_config.cap_mask); 1806 dma_cap_set(DMA_MEMSET, at91sam9g45_config.cap_mask);
1940 dma_cap_set(DMA_MEMSET_SG, at91sam9g45_config.cap_mask); 1807 dma_cap_set(DMA_MEMSET_SG, at91sam9g45_config.cap_mask);
1941 dma_cap_set(DMA_PRIVATE, at91sam9g45_config.cap_mask); 1808 dma_cap_set(DMA_PRIVATE, at91sam9g45_config.cap_mask);
1942 dma_cap_set(DMA_SLAVE, at91sam9g45_config.cap_mask); 1809 dma_cap_set(DMA_SLAVE, at91sam9g45_config.cap_mask);
1943 dma_cap_set(DMA_SG, at91sam9g45_config.cap_mask);
1944 1810
1945 /* get DMA parameters from controller type */ 1811 /* get DMA parameters from controller type */
1946 plat_dat = at_dma_get_driver_data(pdev); 1812 plat_dat = at_dma_get_driver_data(pdev);
@@ -2078,16 +1944,12 @@ static int __init at_dma_probe(struct platform_device *pdev)
2078 atdma->dma_common.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; 1944 atdma->dma_common.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
2079 } 1945 }
2080 1946
2081 if (dma_has_cap(DMA_SG, atdma->dma_common.cap_mask))
2082 atdma->dma_common.device_prep_dma_sg = atc_prep_dma_sg;
2083
2084 dma_writel(atdma, EN, AT_DMA_ENABLE); 1947 dma_writel(atdma, EN, AT_DMA_ENABLE);
2085 1948
2086 dev_info(&pdev->dev, "Atmel AHB DMA Controller ( %s%s%s%s), %d channels\n", 1949 dev_info(&pdev->dev, "Atmel AHB DMA Controller ( %s%s%s), %d channels\n",
2087 dma_has_cap(DMA_MEMCPY, atdma->dma_common.cap_mask) ? "cpy " : "", 1950 dma_has_cap(DMA_MEMCPY, atdma->dma_common.cap_mask) ? "cpy " : "",
2088 dma_has_cap(DMA_MEMSET, atdma->dma_common.cap_mask) ? "set " : "", 1951 dma_has_cap(DMA_MEMSET, atdma->dma_common.cap_mask) ? "set " : "",
2089 dma_has_cap(DMA_SLAVE, atdma->dma_common.cap_mask) ? "slave " : "", 1952 dma_has_cap(DMA_SLAVE, atdma->dma_common.cap_mask) ? "slave " : "",
2090 dma_has_cap(DMA_SG, atdma->dma_common.cap_mask) ? "sg-cpy " : "",
2091 plat_dat->nr_channels); 1953 plat_dat->nr_channels);
2092 1954
2093 dma_async_device_register(&atdma->dma_common); 1955 dma_async_device_register(&atdma->dma_common);
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index d9118ec23025..428b1414263a 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -937,8 +937,6 @@ int dma_async_device_register(struct dma_device *device)
937 !device->device_prep_dma_memset); 937 !device->device_prep_dma_memset);
938 BUG_ON(dma_has_cap(DMA_INTERRUPT, device->cap_mask) && 938 BUG_ON(dma_has_cap(DMA_INTERRUPT, device->cap_mask) &&
939 !device->device_prep_dma_interrupt); 939 !device->device_prep_dma_interrupt);
940 BUG_ON(dma_has_cap(DMA_SG, device->cap_mask) &&
941 !device->device_prep_dma_sg);
942 BUG_ON(dma_has_cap(DMA_CYCLIC, device->cap_mask) && 940 BUG_ON(dma_has_cap(DMA_CYCLIC, device->cap_mask) &&
943 !device->device_prep_dma_cyclic); 941 !device->device_prep_dma_cyclic);
944 BUG_ON(dma_has_cap(DMA_INTERLEAVE, device->cap_mask) && 942 BUG_ON(dma_has_cap(DMA_INTERLEAVE, device->cap_mask) &&
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 35cb83b39192..34ff53290b03 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -52,15 +52,10 @@ module_param(iterations, uint, S_IRUGO | S_IWUSR);
52MODULE_PARM_DESC(iterations, 52MODULE_PARM_DESC(iterations,
53 "Iterations before stopping test (default: infinite)"); 53 "Iterations before stopping test (default: infinite)");
54 54
55static unsigned int sg_buffers = 1;
56module_param(sg_buffers, uint, S_IRUGO | S_IWUSR);
57MODULE_PARM_DESC(sg_buffers,
58 "Number of scatter gather buffers (default: 1)");
59
60static unsigned int dmatest; 55static unsigned int dmatest;
61module_param(dmatest, uint, S_IRUGO | S_IWUSR); 56module_param(dmatest, uint, S_IRUGO | S_IWUSR);
62MODULE_PARM_DESC(dmatest, 57MODULE_PARM_DESC(dmatest,
63 "dmatest 0-memcpy 1-slave_sg 2-memset (default: 0)"); 58 "dmatest 0-memcpy 1-memset (default: 0)");
64 59
65static unsigned int xor_sources = 3; 60static unsigned int xor_sources = 3;
66module_param(xor_sources, uint, S_IRUGO | S_IWUSR); 61module_param(xor_sources, uint, S_IRUGO | S_IWUSR);
@@ -471,9 +466,6 @@ static int dmatest_func(void *data)
471 align = dev->fill_align; 466 align = dev->fill_align;
472 src_cnt = dst_cnt = 1; 467 src_cnt = dst_cnt = 1;
473 is_memset = true; 468 is_memset = true;
474 } else if (thread->type == DMA_SG) {
475 align = dev->copy_align;
476 src_cnt = dst_cnt = sg_buffers;
477 } else if (thread->type == DMA_XOR) { 469 } else if (thread->type == DMA_XOR) {
478 /* force odd to ensure dst = src */ 470 /* force odd to ensure dst = src */
479 src_cnt = min_odd(params->xor_sources | 1, dev->max_xor); 471 src_cnt = min_odd(params->xor_sources | 1, dev->max_xor);
@@ -553,8 +545,6 @@ static int dmatest_func(void *data)
553 dma_addr_t srcs[src_cnt]; 545 dma_addr_t srcs[src_cnt];
554 dma_addr_t *dsts; 546 dma_addr_t *dsts;
555 unsigned int src_off, dst_off, len; 547 unsigned int src_off, dst_off, len;
556 struct scatterlist tx_sg[src_cnt];
557 struct scatterlist rx_sg[src_cnt];
558 548
559 total_tests++; 549 total_tests++;
560 550
@@ -650,15 +640,6 @@ static int dmatest_func(void *data)
650 um->bidi_cnt++; 640 um->bidi_cnt++;
651 } 641 }
652 642
653 sg_init_table(tx_sg, src_cnt);
654 sg_init_table(rx_sg, src_cnt);
655 for (i = 0; i < src_cnt; i++) {
656 sg_dma_address(&rx_sg[i]) = srcs[i];
657 sg_dma_address(&tx_sg[i]) = dsts[i] + dst_off;
658 sg_dma_len(&tx_sg[i]) = len;
659 sg_dma_len(&rx_sg[i]) = len;
660 }
661
662 if (thread->type == DMA_MEMCPY) 643 if (thread->type == DMA_MEMCPY)
663 tx = dev->device_prep_dma_memcpy(chan, 644 tx = dev->device_prep_dma_memcpy(chan,
664 dsts[0] + dst_off, 645 dsts[0] + dst_off,
@@ -668,9 +649,6 @@ static int dmatest_func(void *data)
668 dsts[0] + dst_off, 649 dsts[0] + dst_off,
669 *(thread->srcs[0] + src_off), 650 *(thread->srcs[0] + src_off),
670 len, flags); 651 len, flags);
671 else if (thread->type == DMA_SG)
672 tx = dev->device_prep_dma_sg(chan, tx_sg, src_cnt,
673 rx_sg, src_cnt, flags);
674 else if (thread->type == DMA_XOR) 652 else if (thread->type == DMA_XOR)
675 tx = dev->device_prep_dma_xor(chan, 653 tx = dev->device_prep_dma_xor(chan,
676 dsts[0] + dst_off, 654 dsts[0] + dst_off,
@@ -853,8 +831,6 @@ static int dmatest_add_threads(struct dmatest_info *info,
853 op = "copy"; 831 op = "copy";
854 else if (type == DMA_MEMSET) 832 else if (type == DMA_MEMSET)
855 op = "set"; 833 op = "set";
856 else if (type == DMA_SG)
857 op = "sg";
858 else if (type == DMA_XOR) 834 else if (type == DMA_XOR)
859 op = "xor"; 835 op = "xor";
860 else if (type == DMA_PQ) 836 else if (type == DMA_PQ)
@@ -916,15 +892,8 @@ static int dmatest_add_channel(struct dmatest_info *info,
916 } 892 }
917 893
918 if (dma_has_cap(DMA_MEMSET, dma_dev->cap_mask)) { 894 if (dma_has_cap(DMA_MEMSET, dma_dev->cap_mask)) {
919 if (dmatest == 2) {
920 cnt = dmatest_add_threads(info, dtc, DMA_MEMSET);
921 thread_count += cnt > 0 ? cnt : 0;
922 }
923 }
924
925 if (dma_has_cap(DMA_SG, dma_dev->cap_mask)) {
926 if (dmatest == 1) { 895 if (dmatest == 1) {
927 cnt = dmatest_add_threads(info, dtc, DMA_SG); 896 cnt = dmatest_add_threads(info, dtc, DMA_MEMSET);
928 thread_count += cnt > 0 ? cnt : 0; 897 thread_count += cnt > 0 ? cnt : 0;
929 } 898 }
930 } 899 }
@@ -1002,7 +971,6 @@ static void run_threaded_test(struct dmatest_info *info)
1002 request_channels(info, DMA_MEMCPY); 971 request_channels(info, DMA_MEMCPY);
1003 request_channels(info, DMA_MEMSET); 972 request_channels(info, DMA_MEMSET);
1004 request_channels(info, DMA_XOR); 973 request_channels(info, DMA_XOR);
1005 request_channels(info, DMA_SG);
1006 request_channels(info, DMA_PQ); 974 request_channels(info, DMA_PQ);
1007} 975}
1008 976
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 3b8b752ede2d..3eaece888e75 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -825,122 +825,6 @@ fail:
825 return NULL; 825 return NULL;
826} 826}
827 827
828static struct dma_async_tx_descriptor *fsl_dma_prep_sg(struct dma_chan *dchan,
829 struct scatterlist *dst_sg, unsigned int dst_nents,
830 struct scatterlist *src_sg, unsigned int src_nents,
831 unsigned long flags)
832{
833 struct fsl_desc_sw *first = NULL, *prev = NULL, *new = NULL;
834 struct fsldma_chan *chan = to_fsl_chan(dchan);
835 size_t dst_avail, src_avail;
836 dma_addr_t dst, src;
837 size_t len;
838
839 /* basic sanity checks */
840 if (dst_nents == 0 || src_nents == 0)
841 return NULL;
842
843 if (dst_sg == NULL || src_sg == NULL)
844 return NULL;
845
846 /*
847 * TODO: should we check that both scatterlists have the same
848 * TODO: number of bytes in total? Is that really an error?
849 */
850
851 /* get prepared for the loop */
852 dst_avail = sg_dma_len(dst_sg);
853 src_avail = sg_dma_len(src_sg);
854
855 /* run until we are out of scatterlist entries */
856 while (true) {
857
858 /* create the largest transaction possible */
859 len = min_t(size_t, src_avail, dst_avail);
860 len = min_t(size_t, len, FSL_DMA_BCR_MAX_CNT);
861 if (len == 0)
862 goto fetch;
863
864 dst = sg_dma_address(dst_sg) + sg_dma_len(dst_sg) - dst_avail;
865 src = sg_dma_address(src_sg) + sg_dma_len(src_sg) - src_avail;
866
867 /* allocate and populate the descriptor */
868 new = fsl_dma_alloc_descriptor(chan);
869 if (!new) {
870 chan_err(chan, "%s\n", msg_ld_oom);
871 goto fail;
872 }
873
874 set_desc_cnt(chan, &new->hw, len);
875 set_desc_src(chan, &new->hw, src);
876 set_desc_dst(chan, &new->hw, dst);
877
878 if (!first)
879 first = new;
880 else
881 set_desc_next(chan, &prev->hw, new->async_tx.phys);
882
883 new->async_tx.cookie = 0;
884 async_tx_ack(&new->async_tx);
885 prev = new;
886
887 /* Insert the link descriptor to the LD ring */
888 list_add_tail(&new->node, &first->tx_list);
889
890 /* update metadata */
891 dst_avail -= len;
892 src_avail -= len;
893
894fetch:
895 /* fetch the next dst scatterlist entry */
896 if (dst_avail == 0) {
897
898 /* no more entries: we're done */
899 if (dst_nents == 0)
900 break;
901
902 /* fetch the next entry: if there are no more: done */
903 dst_sg = sg_next(dst_sg);
904 if (dst_sg == NULL)
905 break;
906
907 dst_nents--;
908 dst_avail = sg_dma_len(dst_sg);
909 }
910
911 /* fetch the next src scatterlist entry */
912 if (src_avail == 0) {
913
914 /* no more entries: we're done */
915 if (src_nents == 0)
916 break;
917
918 /* fetch the next entry: if there are no more: done */
919 src_sg = sg_next(src_sg);
920 if (src_sg == NULL)
921 break;
922
923 src_nents--;
924 src_avail = sg_dma_len(src_sg);
925 }
926 }
927
928 new->async_tx.flags = flags; /* client is in control of this ack */
929 new->async_tx.cookie = -EBUSY;
930
931 /* Set End-of-link to the last link descriptor of new list */
932 set_ld_eol(chan, new);
933
934 return &first->async_tx;
935
936fail:
937 if (!first)
938 return NULL;
939
940 fsldma_free_desc_list_reverse(chan, &first->tx_list);
941 return NULL;
942}
943
944static int fsl_dma_device_terminate_all(struct dma_chan *dchan) 828static int fsl_dma_device_terminate_all(struct dma_chan *dchan)
945{ 829{
946 struct fsldma_chan *chan; 830 struct fsldma_chan *chan;
@@ -1357,12 +1241,10 @@ static int fsldma_of_probe(struct platform_device *op)
1357 fdev->irq = irq_of_parse_and_map(op->dev.of_node, 0); 1241 fdev->irq = irq_of_parse_and_map(op->dev.of_node, 0);
1358 1242
1359 dma_cap_set(DMA_MEMCPY, fdev->common.cap_mask); 1243 dma_cap_set(DMA_MEMCPY, fdev->common.cap_mask);
1360 dma_cap_set(DMA_SG, fdev->common.cap_mask);
1361 dma_cap_set(DMA_SLAVE, fdev->common.cap_mask); 1244 dma_cap_set(DMA_SLAVE, fdev->common.cap_mask);
1362 fdev->common.device_alloc_chan_resources = fsl_dma_alloc_chan_resources; 1245 fdev->common.device_alloc_chan_resources = fsl_dma_alloc_chan_resources;
1363 fdev->common.device_free_chan_resources = fsl_dma_free_chan_resources; 1246 fdev->common.device_free_chan_resources = fsl_dma_free_chan_resources;
1364 fdev->common.device_prep_dma_memcpy = fsl_dma_prep_memcpy; 1247 fdev->common.device_prep_dma_memcpy = fsl_dma_prep_memcpy;
1365 fdev->common.device_prep_dma_sg = fsl_dma_prep_sg;
1366 fdev->common.device_tx_status = fsl_tx_status; 1248 fdev->common.device_tx_status = fsl_tx_status;
1367 fdev->common.device_issue_pending = fsl_dma_memcpy_issue_pending; 1249 fdev->common.device_issue_pending = fsl_dma_memcpy_issue_pending;
1368 fdev->common.device_config = fsl_dma_device_config; 1250 fdev->common.device_config = fsl_dma_device_config;
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 25bc5b103aa2..1993889003fd 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -68,36 +68,6 @@ static void mv_desc_init(struct mv_xor_desc_slot *desc,
68 hw_desc->byte_count = byte_count; 68 hw_desc->byte_count = byte_count;
69} 69}
70 70
71/* Populate the descriptor */
72static void mv_xor_config_sg_ll_desc(struct mv_xor_desc_slot *desc,
73 dma_addr_t dma_src, dma_addr_t dma_dst,
74 u32 len, struct mv_xor_desc_slot *prev)
75{
76 struct mv_xor_desc *hw_desc = desc->hw_desc;
77
78 hw_desc->status = XOR_DESC_DMA_OWNED;
79 hw_desc->phy_next_desc = 0;
80 /* Configure for XOR with only one src address -> MEMCPY */
81 hw_desc->desc_command = XOR_DESC_OPERATION_XOR | (0x1 << 0);
82 hw_desc->phy_dest_addr = dma_dst;
83 hw_desc->phy_src_addr[0] = dma_src;
84 hw_desc->byte_count = len;
85
86 if (prev) {
87 struct mv_xor_desc *hw_prev = prev->hw_desc;
88
89 hw_prev->phy_next_desc = desc->async_tx.phys;
90 }
91}
92
93static void mv_xor_desc_config_eod(struct mv_xor_desc_slot *desc)
94{
95 struct mv_xor_desc *hw_desc = desc->hw_desc;
96
97 /* Enable end-of-descriptor interrupt */
98 hw_desc->desc_command |= XOR_DESC_EOD_INT_EN;
99}
100
101static void mv_desc_set_mode(struct mv_xor_desc_slot *desc) 71static void mv_desc_set_mode(struct mv_xor_desc_slot *desc)
102{ 72{
103 struct mv_xor_desc *hw_desc = desc->hw_desc; 73 struct mv_xor_desc *hw_desc = desc->hw_desc;
@@ -662,132 +632,6 @@ mv_xor_prep_dma_interrupt(struct dma_chan *chan, unsigned long flags)
662 return mv_xor_prep_dma_xor(chan, dest, &src, 1, len, flags); 632 return mv_xor_prep_dma_xor(chan, dest, &src, 1, len, flags);
663} 633}
664 634
665/**
666 * mv_xor_prep_dma_sg - prepare descriptors for a memory sg transaction
667 * @chan: DMA channel
668 * @dst_sg: Destination scatter list
669 * @dst_sg_len: Number of entries in destination scatter list
670 * @src_sg: Source scatter list
671 * @src_sg_len: Number of entries in source scatter list
672 * @flags: transfer ack flags
673 *
674 * Return: Async transaction descriptor on success and NULL on failure
675 */
676static struct dma_async_tx_descriptor *
677mv_xor_prep_dma_sg(struct dma_chan *chan, struct scatterlist *dst_sg,
678 unsigned int dst_sg_len, struct scatterlist *src_sg,
679 unsigned int src_sg_len, unsigned long flags)
680{
681 struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan);
682 struct mv_xor_desc_slot *new;
683 struct mv_xor_desc_slot *first = NULL;
684 struct mv_xor_desc_slot *prev = NULL;
685 size_t len, dst_avail, src_avail;
686 dma_addr_t dma_dst, dma_src;
687 int desc_cnt = 0;
688 int ret;
689
690 dev_dbg(mv_chan_to_devp(mv_chan),
691 "%s dst_sg_len: %d src_sg_len: %d flags: %ld\n",
692 __func__, dst_sg_len, src_sg_len, flags);
693
694 dst_avail = sg_dma_len(dst_sg);
695 src_avail = sg_dma_len(src_sg);
696
697 /* Run until we are out of scatterlist entries */
698 while (true) {
699 /* Allocate and populate the descriptor */
700 desc_cnt++;
701 new = mv_chan_alloc_slot(mv_chan);
702 if (!new) {
703 dev_err(mv_chan_to_devp(mv_chan),
704 "Out of descriptors (desc_cnt=%d)!\n",
705 desc_cnt);
706 goto err;
707 }
708
709 len = min_t(size_t, src_avail, dst_avail);
710 len = min_t(size_t, len, MV_XOR_MAX_BYTE_COUNT);
711 if (len == 0)
712 goto fetch;
713
714 if (len < MV_XOR_MIN_BYTE_COUNT) {
715 dev_err(mv_chan_to_devp(mv_chan),
716 "Transfer size of %zu too small!\n", len);
717 goto err;
718 }
719
720 dma_dst = sg_dma_address(dst_sg) + sg_dma_len(dst_sg) -
721 dst_avail;
722 dma_src = sg_dma_address(src_sg) + sg_dma_len(src_sg) -
723 src_avail;
724
725 /* Check if a new window needs to get added for 'dst' */
726 ret = mv_xor_add_io_win(mv_chan, dma_dst);
727 if (ret)
728 goto err;
729
730 /* Check if a new window needs to get added for 'src' */
731 ret = mv_xor_add_io_win(mv_chan, dma_src);
732 if (ret)
733 goto err;
734
735 /* Populate the descriptor */
736 mv_xor_config_sg_ll_desc(new, dma_src, dma_dst, len, prev);
737 prev = new;
738 dst_avail -= len;
739 src_avail -= len;
740
741 if (!first)
742 first = new;
743 else
744 list_move_tail(&new->node, &first->sg_tx_list);
745
746fetch:
747 /* Fetch the next dst scatterlist entry */
748 if (dst_avail == 0) {
749 if (dst_sg_len == 0)
750 break;
751
752 /* Fetch the next entry: if there are no more: done */
753 dst_sg = sg_next(dst_sg);
754 if (dst_sg == NULL)
755 break;
756
757 dst_sg_len--;
758 dst_avail = sg_dma_len(dst_sg);
759 }
760
761 /* Fetch the next src scatterlist entry */
762 if (src_avail == 0) {
763 if (src_sg_len == 0)
764 break;
765
766 /* Fetch the next entry: if there are no more: done */
767 src_sg = sg_next(src_sg);
768 if (src_sg == NULL)
769 break;
770
771 src_sg_len--;
772 src_avail = sg_dma_len(src_sg);
773 }
774 }
775
776 /* Set the EOD flag in the last descriptor */
777 mv_xor_desc_config_eod(new);
778 first->async_tx.flags = flags;
779
780 return &first->async_tx;
781
782err:
783 /* Cleanup: Move all descriptors back into the free list */
784 spin_lock_bh(&mv_chan->lock);
785 mv_desc_clean_slot(first, mv_chan);
786 spin_unlock_bh(&mv_chan->lock);
787
788 return NULL;
789}
790
791static void mv_xor_free_chan_resources(struct dma_chan *chan) 635static void mv_xor_free_chan_resources(struct dma_chan *chan)
792{ 636{
793 struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan); 637 struct mv_xor_chan *mv_chan = to_mv_xor_chan(chan);
@@ -1254,8 +1098,6 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
1254 dma_dev->device_prep_dma_interrupt = mv_xor_prep_dma_interrupt; 1098 dma_dev->device_prep_dma_interrupt = mv_xor_prep_dma_interrupt;
1255 if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask)) 1099 if (dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask))
1256 dma_dev->device_prep_dma_memcpy = mv_xor_prep_dma_memcpy; 1100 dma_dev->device_prep_dma_memcpy = mv_xor_prep_dma_memcpy;
1257 if (dma_has_cap(DMA_SG, dma_dev->cap_mask))
1258 dma_dev->device_prep_dma_sg = mv_xor_prep_dma_sg;
1259 if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) { 1101 if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
1260 dma_dev->max_xor = 8; 1102 dma_dev->max_xor = 8;
1261 dma_dev->device_prep_dma_xor = mv_xor_prep_dma_xor; 1103 dma_dev->device_prep_dma_xor = mv_xor_prep_dma_xor;
@@ -1305,11 +1147,10 @@ mv_xor_channel_add(struct mv_xor_device *xordev,
1305 goto err_free_irq; 1147 goto err_free_irq;
1306 } 1148 }
1307 1149
1308 dev_info(&pdev->dev, "Marvell XOR (%s): ( %s%s%s%s)\n", 1150 dev_info(&pdev->dev, "Marvell XOR (%s): ( %s%s%s)\n",
1309 mv_chan->op_in_desc ? "Descriptor Mode" : "Registers Mode", 1151 mv_chan->op_in_desc ? "Descriptor Mode" : "Registers Mode",
1310 dma_has_cap(DMA_XOR, dma_dev->cap_mask) ? "xor " : "", 1152 dma_has_cap(DMA_XOR, dma_dev->cap_mask) ? "xor " : "",
1311 dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask) ? "cpy " : "", 1153 dma_has_cap(DMA_MEMCPY, dma_dev->cap_mask) ? "cpy " : "",
1312 dma_has_cap(DMA_SG, dma_dev->cap_mask) ? "sg " : "",
1313 dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask) ? "intr " : ""); 1154 dma_has_cap(DMA_INTERRUPT, dma_dev->cap_mask) ? "intr " : "");
1314 1155
1315 dma_async_device_register(dma_dev); 1156 dma_async_device_register(dma_dev);
@@ -1552,7 +1393,6 @@ static int mv_xor_probe(struct platform_device *pdev)
1552 1393
1553 dma_cap_zero(cap_mask); 1394 dma_cap_zero(cap_mask);
1554 dma_cap_set(DMA_MEMCPY, cap_mask); 1395 dma_cap_set(DMA_MEMCPY, cap_mask);
1555 dma_cap_set(DMA_SG, cap_mask);
1556 dma_cap_set(DMA_XOR, cap_mask); 1396 dma_cap_set(DMA_XOR, cap_mask);
1557 dma_cap_set(DMA_INTERRUPT, cap_mask); 1397 dma_cap_set(DMA_INTERRUPT, cap_mask);
1558 1398
diff --git a/drivers/dma/nbpfaxi.c b/drivers/dma/nbpfaxi.c
index 3f45b9bdf201..d3f918a9ee76 100644
--- a/drivers/dma/nbpfaxi.c
+++ b/drivers/dma/nbpfaxi.c
@@ -1005,21 +1005,6 @@ static struct dma_async_tx_descriptor *nbpf_prep_memcpy(
1005 DMA_MEM_TO_MEM, flags); 1005 DMA_MEM_TO_MEM, flags);
1006} 1006}
1007 1007
1008static struct dma_async_tx_descriptor *nbpf_prep_memcpy_sg(
1009 struct dma_chan *dchan,
1010 struct scatterlist *dst_sg, unsigned int dst_nents,
1011 struct scatterlist *src_sg, unsigned int src_nents,
1012 unsigned long flags)
1013{
1014 struct nbpf_channel *chan = nbpf_to_chan(dchan);
1015
1016 if (dst_nents != src_nents)
1017 return NULL;
1018
1019 return nbpf_prep_sg(chan, src_sg, dst_sg, src_nents,
1020 DMA_MEM_TO_MEM, flags);
1021}
1022
1023static struct dma_async_tx_descriptor *nbpf_prep_slave_sg( 1008static struct dma_async_tx_descriptor *nbpf_prep_slave_sg(
1024 struct dma_chan *dchan, struct scatterlist *sgl, unsigned int sg_len, 1009 struct dma_chan *dchan, struct scatterlist *sgl, unsigned int sg_len,
1025 enum dma_transfer_direction direction, unsigned long flags, void *context) 1010 enum dma_transfer_direction direction, unsigned long flags, void *context)
@@ -1417,13 +1402,11 @@ static int nbpf_probe(struct platform_device *pdev)
1417 dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask); 1402 dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask);
1418 dma_cap_set(DMA_SLAVE, dma_dev->cap_mask); 1403 dma_cap_set(DMA_SLAVE, dma_dev->cap_mask);
1419 dma_cap_set(DMA_PRIVATE, dma_dev->cap_mask); 1404 dma_cap_set(DMA_PRIVATE, dma_dev->cap_mask);
1420 dma_cap_set(DMA_SG, dma_dev->cap_mask);
1421 1405
1422 /* Common and MEMCPY operations */ 1406 /* Common and MEMCPY operations */
1423 dma_dev->device_alloc_chan_resources 1407 dma_dev->device_alloc_chan_resources
1424 = nbpf_alloc_chan_resources; 1408 = nbpf_alloc_chan_resources;
1425 dma_dev->device_free_chan_resources = nbpf_free_chan_resources; 1409 dma_dev->device_free_chan_resources = nbpf_free_chan_resources;
1426 dma_dev->device_prep_dma_sg = nbpf_prep_memcpy_sg;
1427 dma_dev->device_prep_dma_memcpy = nbpf_prep_memcpy; 1410 dma_dev->device_prep_dma_memcpy = nbpf_prep_memcpy;
1428 dma_dev->device_tx_status = nbpf_tx_status; 1411 dma_dev->device_tx_status = nbpf_tx_status;
1429 dma_dev->device_issue_pending = nbpf_issue_pending; 1412 dma_dev->device_issue_pending = nbpf_issue_pending;
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index c3052fbfd092..97e1d8b00e22 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2485,19 +2485,6 @@ static struct dma_async_tx_descriptor *d40_prep_memcpy(struct dma_chan *chan,
2485} 2485}
2486 2486
2487static struct dma_async_tx_descriptor * 2487static struct dma_async_tx_descriptor *
2488d40_prep_memcpy_sg(struct dma_chan *chan,
2489 struct scatterlist *dst_sg, unsigned int dst_nents,
2490 struct scatterlist *src_sg, unsigned int src_nents,
2491 unsigned long dma_flags)
2492{
2493 if (dst_nents != src_nents)
2494 return NULL;
2495
2496 return d40_prep_sg(chan, src_sg, dst_sg, src_nents,
2497 DMA_MEM_TO_MEM, dma_flags);
2498}
2499
2500static struct dma_async_tx_descriptor *
2501d40_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, 2488d40_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
2502 unsigned int sg_len, enum dma_transfer_direction direction, 2489 unsigned int sg_len, enum dma_transfer_direction direction,
2503 unsigned long dma_flags, void *context) 2490 unsigned long dma_flags, void *context)
@@ -2821,9 +2808,6 @@ static void d40_ops_init(struct d40_base *base, struct dma_device *dev)
2821 dev->copy_align = DMAENGINE_ALIGN_4_BYTES; 2808 dev->copy_align = DMAENGINE_ALIGN_4_BYTES;
2822 } 2809 }
2823 2810
2824 if (dma_has_cap(DMA_SG, dev->cap_mask))
2825 dev->device_prep_dma_sg = d40_prep_memcpy_sg;
2826
2827 if (dma_has_cap(DMA_CYCLIC, dev->cap_mask)) 2811 if (dma_has_cap(DMA_CYCLIC, dev->cap_mask))
2828 dev->device_prep_dma_cyclic = dma40_prep_dma_cyclic; 2812 dev->device_prep_dma_cyclic = dma40_prep_dma_cyclic;
2829 2813
@@ -2865,7 +2849,6 @@ static int __init d40_dmaengine_init(struct d40_base *base,
2865 2849
2866 dma_cap_zero(base->dma_memcpy.cap_mask); 2850 dma_cap_zero(base->dma_memcpy.cap_mask);
2867 dma_cap_set(DMA_MEMCPY, base->dma_memcpy.cap_mask); 2851 dma_cap_set(DMA_MEMCPY, base->dma_memcpy.cap_mask);
2868 dma_cap_set(DMA_SG, base->dma_memcpy.cap_mask);
2869 2852
2870 d40_ops_init(base, &base->dma_memcpy); 2853 d40_ops_init(base, &base->dma_memcpy);
2871 2854
@@ -2883,7 +2866,6 @@ static int __init d40_dmaengine_init(struct d40_base *base,
2883 dma_cap_zero(base->dma_both.cap_mask); 2866 dma_cap_zero(base->dma_both.cap_mask);
2884 dma_cap_set(DMA_SLAVE, base->dma_both.cap_mask); 2867 dma_cap_set(DMA_SLAVE, base->dma_both.cap_mask);
2885 dma_cap_set(DMA_MEMCPY, base->dma_both.cap_mask); 2868 dma_cap_set(DMA_MEMCPY, base->dma_both.cap_mask);
2886 dma_cap_set(DMA_SG, base->dma_both.cap_mask);
2887 dma_cap_set(DMA_CYCLIC, base->dma_slave.cap_mask); 2869 dma_cap_set(DMA_CYCLIC, base->dma_slave.cap_mask);
2888 2870
2889 d40_ops_init(base, &base->dma_both); 2871 d40_ops_init(base, &base->dma_both);
diff --git a/drivers/dma/xgene-dma.c b/drivers/dma/xgene-dma.c
index 8b693b712d0f..8648d2394ab6 100644
--- a/drivers/dma/xgene-dma.c
+++ b/drivers/dma/xgene-dma.c
@@ -425,48 +425,6 @@ static void xgene_dma_init_desc(struct xgene_dma_desc_hw *desc,
425 XGENE_DMA_DESC_HOENQ_NUM_POS); 425 XGENE_DMA_DESC_HOENQ_NUM_POS);
426} 426}
427 427
428static void xgene_dma_prep_cpy_desc(struct xgene_dma_chan *chan,
429 struct xgene_dma_desc_sw *desc_sw,
430 dma_addr_t dst, dma_addr_t src,
431 size_t len)
432{
433 struct xgene_dma_desc_hw *desc1, *desc2;
434 int i;
435
436 /* Get 1st descriptor */
437 desc1 = &desc_sw->desc1;
438 xgene_dma_init_desc(desc1, chan->tx_ring.dst_ring_num);
439
440 /* Set destination address */
441 desc1->m2 |= cpu_to_le64(XGENE_DMA_DESC_DR_BIT);
442 desc1->m3 |= cpu_to_le64(dst);
443
444 /* Set 1st source address */
445 xgene_dma_set_src_buffer(&desc1->m1, &len, &src);
446
447 if (!len)
448 return;
449
450 /*
451 * We need to split this source buffer,
452 * and need to use 2nd descriptor
453 */
454 desc2 = &desc_sw->desc2;
455 desc1->m0 |= cpu_to_le64(XGENE_DMA_DESC_NV_BIT);
456
457 /* Set 2nd to 5th source address */
458 for (i = 0; i < 4 && len; i++)
459 xgene_dma_set_src_buffer(xgene_dma_lookup_ext8(desc2, i),
460 &len, &src);
461
462 /* Invalidate unused source address field */
463 for (; i < 4; i++)
464 xgene_dma_invalidate_buffer(xgene_dma_lookup_ext8(desc2, i));
465
466 /* Updated flag that we have prepared 64B descriptor */
467 desc_sw->flags |= XGENE_DMA_FLAG_64B_DESC;
468}
469
470static void xgene_dma_prep_xor_desc(struct xgene_dma_chan *chan, 428static void xgene_dma_prep_xor_desc(struct xgene_dma_chan *chan,
471 struct xgene_dma_desc_sw *desc_sw, 429 struct xgene_dma_desc_sw *desc_sw,
472 dma_addr_t *dst, dma_addr_t *src, 430 dma_addr_t *dst, dma_addr_t *src,
@@ -891,114 +849,6 @@ static void xgene_dma_free_chan_resources(struct dma_chan *dchan)
891 chan->desc_pool = NULL; 849 chan->desc_pool = NULL;
892} 850}
893 851
894static struct dma_async_tx_descriptor *xgene_dma_prep_sg(
895 struct dma_chan *dchan, struct scatterlist *dst_sg,
896 u32 dst_nents, struct scatterlist *src_sg,
897 u32 src_nents, unsigned long flags)
898{
899 struct xgene_dma_desc_sw *first = NULL, *new = NULL;
900 struct xgene_dma_chan *chan;
901 size_t dst_avail, src_avail;
902 dma_addr_t dst, src;
903 size_t len;
904
905 if (unlikely(!dchan))
906 return NULL;
907
908 if (unlikely(!dst_nents || !src_nents))
909 return NULL;
910
911 if (unlikely(!dst_sg || !src_sg))
912 return NULL;
913
914 chan = to_dma_chan(dchan);
915
916 /* Get prepared for the loop */
917 dst_avail = sg_dma_len(dst_sg);
918 src_avail = sg_dma_len(src_sg);
919 dst_nents--;
920 src_nents--;
921
922 /* Run until we are out of scatterlist entries */
923 while (true) {
924 /* Create the largest transaction possible */
925 len = min_t(size_t, src_avail, dst_avail);
926 len = min_t(size_t, len, XGENE_DMA_MAX_64B_DESC_BYTE_CNT);
927 if (len == 0)
928 goto fetch;
929
930 dst = sg_dma_address(dst_sg) + sg_dma_len(dst_sg) - dst_avail;
931 src = sg_dma_address(src_sg) + sg_dma_len(src_sg) - src_avail;
932
933 /* Allocate the link descriptor from DMA pool */
934 new = xgene_dma_alloc_descriptor(chan);
935 if (!new)
936 goto fail;
937
938 /* Prepare DMA descriptor */
939 xgene_dma_prep_cpy_desc(chan, new, dst, src, len);
940
941 if (!first)
942 first = new;
943
944 new->tx.cookie = 0;
945 async_tx_ack(&new->tx);
946
947 /* update metadata */
948 dst_avail -= len;
949 src_avail -= len;
950
951 /* Insert the link descriptor to the LD ring */
952 list_add_tail(&new->node, &first->tx_list);
953
954fetch:
955 /* fetch the next dst scatterlist entry */
956 if (dst_avail == 0) {
957 /* no more entries: we're done */
958 if (dst_nents == 0)
959 break;
960
961 /* fetch the next entry: if there are no more: done */
962 dst_sg = sg_next(dst_sg);
963 if (!dst_sg)
964 break;
965
966 dst_nents--;
967 dst_avail = sg_dma_len(dst_sg);
968 }
969
970 /* fetch the next src scatterlist entry */
971 if (src_avail == 0) {
972 /* no more entries: we're done */
973 if (src_nents == 0)
974 break;
975
976 /* fetch the next entry: if there are no more: done */
977 src_sg = sg_next(src_sg);
978 if (!src_sg)
979 break;
980
981 src_nents--;
982 src_avail = sg_dma_len(src_sg);
983 }
984 }
985
986 if (!new)
987 return NULL;
988
989 new->tx.flags = flags; /* client is in control of this ack */
990 new->tx.cookie = -EBUSY;
991 list_splice(&first->tx_list, &new->tx_list);
992
993 return &new->tx;
994fail:
995 if (!first)
996 return NULL;
997
998 xgene_dma_free_desc_list(chan, &first->tx_list);
999 return NULL;
1000}
1001
1002static struct dma_async_tx_descriptor *xgene_dma_prep_xor( 852static struct dma_async_tx_descriptor *xgene_dma_prep_xor(
1003 struct dma_chan *dchan, dma_addr_t dst, dma_addr_t *src, 853 struct dma_chan *dchan, dma_addr_t dst, dma_addr_t *src,
1004 u32 src_cnt, size_t len, unsigned long flags) 854 u32 src_cnt, size_t len, unsigned long flags)
@@ -1653,7 +1503,6 @@ static void xgene_dma_set_caps(struct xgene_dma_chan *chan,
1653 dma_cap_zero(dma_dev->cap_mask); 1503 dma_cap_zero(dma_dev->cap_mask);
1654 1504
1655 /* Set DMA device capability */ 1505 /* Set DMA device capability */
1656 dma_cap_set(DMA_SG, dma_dev->cap_mask);
1657 1506
1658 /* Basically here, the X-Gene SoC DMA engine channel 0 supports XOR 1507 /* Basically here, the X-Gene SoC DMA engine channel 0 supports XOR
1659 * and channel 1 supports XOR, PQ both. First thing here is we have 1508 * and channel 1 supports XOR, PQ both. First thing here is we have
@@ -1679,7 +1528,6 @@ static void xgene_dma_set_caps(struct xgene_dma_chan *chan,
1679 dma_dev->device_free_chan_resources = xgene_dma_free_chan_resources; 1528 dma_dev->device_free_chan_resources = xgene_dma_free_chan_resources;
1680 dma_dev->device_issue_pending = xgene_dma_issue_pending; 1529 dma_dev->device_issue_pending = xgene_dma_issue_pending;
1681 dma_dev->device_tx_status = xgene_dma_tx_status; 1530 dma_dev->device_tx_status = xgene_dma_tx_status;
1682 dma_dev->device_prep_dma_sg = xgene_dma_prep_sg;
1683 1531
1684 if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) { 1532 if (dma_has_cap(DMA_XOR, dma_dev->cap_mask)) {
1685 dma_dev->device_prep_dma_xor = xgene_dma_prep_xor; 1533 dma_dev->device_prep_dma_xor = xgene_dma_prep_xor;
@@ -1731,8 +1579,7 @@ static int xgene_dma_async_register(struct xgene_dma *pdma, int id)
1731 1579
1732 /* DMA capability info */ 1580 /* DMA capability info */
1733 dev_info(pdma->dev, 1581 dev_info(pdma->dev,
1734 "%s: CAPABILITY ( %s%s%s)\n", dma_chan_name(&chan->dma_chan), 1582 "%s: CAPABILITY ( %s%s)\n", dma_chan_name(&chan->dma_chan),
1735 dma_has_cap(DMA_SG, dma_dev->cap_mask) ? "SGCPY " : "",
1736 dma_has_cap(DMA_XOR, dma_dev->cap_mask) ? "XOR " : "", 1583 dma_has_cap(DMA_XOR, dma_dev->cap_mask) ? "XOR " : "",
1737 dma_has_cap(DMA_PQ, dma_dev->cap_mask) ? "PQ " : ""); 1584 dma_has_cap(DMA_PQ, dma_dev->cap_mask) ? "PQ " : "");
1738 1585
diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
index 47f64192d2fd..1ee1241ca797 100644
--- a/drivers/dma/xilinx/zynqmp_dma.c
+++ b/drivers/dma/xilinx/zynqmp_dma.c
@@ -830,98 +830,6 @@ static struct dma_async_tx_descriptor *zynqmp_dma_prep_memcpy(
830} 830}
831 831
832/** 832/**
833 * zynqmp_dma_prep_slave_sg - prepare descriptors for a memory sg transaction
834 * @dchan: DMA channel
835 * @dst_sg: Destination scatter list
836 * @dst_sg_len: Number of entries in destination scatter list
837 * @src_sg: Source scatter list
838 * @src_sg_len: Number of entries in source scatter list
839 * @flags: transfer ack flags
840 *
841 * Return: Async transaction descriptor on success and NULL on failure
842 */
843static struct dma_async_tx_descriptor *zynqmp_dma_prep_sg(
844 struct dma_chan *dchan, struct scatterlist *dst_sg,
845 unsigned int dst_sg_len, struct scatterlist *src_sg,
846 unsigned int src_sg_len, unsigned long flags)
847{
848 struct zynqmp_dma_desc_sw *new, *first = NULL;
849 struct zynqmp_dma_chan *chan = to_chan(dchan);
850 void *desc = NULL, *prev = NULL;
851 size_t len, dst_avail, src_avail;
852 dma_addr_t dma_dst, dma_src;
853 u32 desc_cnt = 0, i;
854 struct scatterlist *sg;
855
856 for_each_sg(src_sg, sg, src_sg_len, i)
857 desc_cnt += DIV_ROUND_UP(sg_dma_len(sg),
858 ZYNQMP_DMA_MAX_TRANS_LEN);
859
860 spin_lock_bh(&chan->lock);
861 if (desc_cnt > chan->desc_free_cnt) {
862 spin_unlock_bh(&chan->lock);
863 dev_dbg(chan->dev, "chan %p descs are not available\n", chan);
864 return NULL;
865 }
866 chan->desc_free_cnt = chan->desc_free_cnt - desc_cnt;
867 spin_unlock_bh(&chan->lock);
868
869 dst_avail = sg_dma_len(dst_sg);
870 src_avail = sg_dma_len(src_sg);
871
872 /* Run until we are out of scatterlist entries */
873 while (true) {
874 /* Allocate and populate the descriptor */
875 new = zynqmp_dma_get_descriptor(chan);
876 desc = (struct zynqmp_dma_desc_ll *)new->src_v;
877 len = min_t(size_t, src_avail, dst_avail);
878 len = min_t(size_t, len, ZYNQMP_DMA_MAX_TRANS_LEN);
879 if (len == 0)
880 goto fetch;
881 dma_dst = sg_dma_address(dst_sg) + sg_dma_len(dst_sg) -
882 dst_avail;
883 dma_src = sg_dma_address(src_sg) + sg_dma_len(src_sg) -
884 src_avail;
885
886 zynqmp_dma_config_sg_ll_desc(chan, desc, dma_src, dma_dst,
887 len, prev);
888 prev = desc;
889 dst_avail -= len;
890 src_avail -= len;
891
892 if (!first)
893 first = new;
894 else
895 list_add_tail(&new->node, &first->tx_list);
896fetch:
897 /* Fetch the next dst scatterlist entry */
898 if (dst_avail == 0) {
899 if (dst_sg_len == 0)
900 break;
901 dst_sg = sg_next(dst_sg);
902 if (dst_sg == NULL)
903 break;
904 dst_sg_len--;
905 dst_avail = sg_dma_len(dst_sg);
906 }
907 /* Fetch the next src scatterlist entry */
908 if (src_avail == 0) {
909 if (src_sg_len == 0)
910 break;
911 src_sg = sg_next(src_sg);
912 if (src_sg == NULL)
913 break;
914 src_sg_len--;
915 src_avail = sg_dma_len(src_sg);
916 }
917 }
918
919 zynqmp_dma_desc_config_eod(chan, desc);
920 first->async_tx.flags = flags;
921 return &first->async_tx;
922}
923
924/**
925 * zynqmp_dma_chan_remove - Channel remove function 833 * zynqmp_dma_chan_remove - Channel remove function
926 * @chan: ZynqMP DMA channel pointer 834 * @chan: ZynqMP DMA channel pointer
927 */ 835 */
@@ -1064,11 +972,9 @@ static int zynqmp_dma_probe(struct platform_device *pdev)
1064 INIT_LIST_HEAD(&zdev->common.channels); 972 INIT_LIST_HEAD(&zdev->common.channels);
1065 973
1066 dma_set_mask(&pdev->dev, DMA_BIT_MASK(44)); 974 dma_set_mask(&pdev->dev, DMA_BIT_MASK(44));
1067 dma_cap_set(DMA_SG, zdev->common.cap_mask);
1068 dma_cap_set(DMA_MEMCPY, zdev->common.cap_mask); 975 dma_cap_set(DMA_MEMCPY, zdev->common.cap_mask);
1069 976
1070 p = &zdev->common; 977 p = &zdev->common;
1071 p->device_prep_dma_sg = zynqmp_dma_prep_sg;
1072 p->device_prep_dma_memcpy = zynqmp_dma_prep_memcpy; 978 p->device_prep_dma_memcpy = zynqmp_dma_prep_memcpy;
1073 p->device_terminate_all = zynqmp_dma_device_terminate_all; 979 p->device_terminate_all = zynqmp_dma_device_terminate_all;
1074 p->device_issue_pending = zynqmp_dma_issue_pending; 980 p->device_issue_pending = zynqmp_dma_issue_pending;
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 533680860865..64fbd380c430 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -68,7 +68,6 @@ enum dma_transaction_type {
68 DMA_MEMSET, 68 DMA_MEMSET,
69 DMA_MEMSET_SG, 69 DMA_MEMSET_SG,
70 DMA_INTERRUPT, 70 DMA_INTERRUPT,
71 DMA_SG,
72 DMA_PRIVATE, 71 DMA_PRIVATE,
73 DMA_ASYNC_TX, 72 DMA_ASYNC_TX,
74 DMA_SLAVE, 73 DMA_SLAVE,
@@ -771,11 +770,6 @@ struct dma_device {
771 unsigned int nents, int value, unsigned long flags); 770 unsigned int nents, int value, unsigned long flags);
772 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)( 771 struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)(
773 struct dma_chan *chan, unsigned long flags); 772 struct dma_chan *chan, unsigned long flags);
774 struct dma_async_tx_descriptor *(*device_prep_dma_sg)(
775 struct dma_chan *chan,
776 struct scatterlist *dst_sg, unsigned int dst_nents,
777 struct scatterlist *src_sg, unsigned int src_nents,
778 unsigned long flags);
779 773
780 struct dma_async_tx_descriptor *(*device_prep_slave_sg)( 774 struct dma_async_tx_descriptor *(*device_prep_slave_sg)(
781 struct dma_chan *chan, struct scatterlist *sgl, 775 struct dma_chan *chan, struct scatterlist *sgl,
@@ -905,19 +899,6 @@ static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_memcpy(
905 len, flags); 899 len, flags);
906} 900}
907 901
908static inline struct dma_async_tx_descriptor *dmaengine_prep_dma_sg(
909 struct dma_chan *chan,
910 struct scatterlist *dst_sg, unsigned int dst_nents,
911 struct scatterlist *src_sg, unsigned int src_nents,
912 unsigned long flags)
913{
914 if (!chan || !chan->device || !chan->device->device_prep_dma_sg)
915 return NULL;
916
917 return chan->device->device_prep_dma_sg(chan, dst_sg, dst_nents,
918 src_sg, src_nents, flags);
919}
920
921/** 902/**
922 * dmaengine_terminate_all() - Terminate all active DMA transfers 903 * dmaengine_terminate_all() - Terminate all active DMA transfers
923 * @chan: The channel for which to terminate the transfers 904 * @chan: The channel for which to terminate the transfers