Skip to content

Commit 2577394

Browse files
committed
Merge tag 'dmaengine_topic_slave_id_removal_5.17' into next
Merge the tag dmaengine_topic_slave_id_removal_5.17 into next. This brings in the slave_id removal topic changes
2 parents d5aeba4 + 3c21964 commit 2577394

File tree

18 files changed

+117
-63
lines changed

18 files changed

+117
-63
lines changed

drivers/dma/mmp_pdma.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -727,12 +727,6 @@ static int mmp_pdma_config_write(struct dma_chan *dchan,
727727

728728
chan->dir = direction;
729729
chan->dev_addr = addr;
730-
/* FIXME: drivers should be ported over to use the filter
731-
* function. Once that's done, the following two lines can
732-
* be removed.
733-
*/
734-
if (cfg->slave_id)
735-
chan->drcmr = cfg->slave_id;
736730

737731
return 0;
738732
}

drivers/dma/pxa_dma.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -909,13 +909,6 @@ static void pxad_get_config(struct pxad_chan *chan,
909909
*dcmd |= PXA_DCMD_BURST16;
910910
else if (maxburst == 32)
911911
*dcmd |= PXA_DCMD_BURST32;
912-
913-
/* FIXME: drivers should be ported over to use the filter
914-
* function. Once that's done, the following two lines can
915-
* be removed.
916-
*/
917-
if (chan->cfg.slave_id)
918-
chan->drcmr = chan->cfg.slave_id;
919912
}
920913

921914
static struct dma_async_tx_descriptor *

drivers/dma/qcom/qcom_adm.c

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/device.h>
99
#include <linux/dmaengine.h>
1010
#include <linux/dma-mapping.h>
11+
#include <linux/dma/qcom_adm.h>
1112
#include <linux/init.h>
1213
#include <linux/interrupt.h>
1314
#include <linux/io.h>
@@ -140,6 +141,8 @@ struct adm_chan {
140141

141142
struct adm_async_desc *curr_txd;
142143
struct dma_slave_config slave;
144+
u32 crci;
145+
u32 mux;
143146
struct list_head node;
144147

145148
int error;
@@ -379,8 +382,8 @@ static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan,
379382
return ERR_PTR(-EINVAL);
380383
}
381384

382-
crci = achan->slave.slave_id & 0xf;
383-
if (!crci || achan->slave.slave_id > 0x1f) {
385+
crci = achan->crci & 0xf;
386+
if (!crci || achan->crci > 0x1f) {
384387
dev_err(adev->dev, "invalid crci value\n");
385388
return ERR_PTR(-EINVAL);
386389
}
@@ -403,9 +406,7 @@ static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan,
403406
if (!async_desc)
404407
return ERR_PTR(-ENOMEM);
405408

406-
if (crci)
407-
async_desc->mux = achan->slave.slave_id & ADM_CRCI_MUX_SEL ?
408-
ADM_CRCI_CTL_MUX_SEL : 0;
409+
async_desc->mux = achan->mux ? ADM_CRCI_CTL_MUX_SEL : 0;
409410
async_desc->crci = crci;
410411
async_desc->blk_size = blk_size;
411412
async_desc->dma_len = single_count * sizeof(struct adm_desc_hw_single) +
@@ -488,10 +489,13 @@ static int adm_terminate_all(struct dma_chan *chan)
488489
static int adm_slave_config(struct dma_chan *chan, struct dma_slave_config *cfg)
489490
{
490491
struct adm_chan *achan = to_adm_chan(chan);
492+
struct qcom_adm_peripheral_config *config = cfg->peripheral_config;
491493
unsigned long flag;
492494

493495
spin_lock_irqsave(&achan->vc.lock, flag);
494496
memcpy(&achan->slave, cfg, sizeof(struct dma_slave_config));
497+
if (cfg->peripheral_size == sizeof(config))
498+
achan->crci = config->crci;
495499
spin_unlock_irqrestore(&achan->vc.lock, flag);
496500

497501
return 0;
@@ -694,6 +698,45 @@ static void adm_channel_init(struct adm_device *adev, struct adm_chan *achan,
694698
achan->vc.desc_free = adm_dma_free_desc;
695699
}
696700

701+
/**
702+
* adm_dma_xlate
703+
* @dma_spec: pointer to DMA specifier as found in the device tree
704+
* @ofdma: pointer to DMA controller data
705+
*
706+
* This can use either 1-cell or 2-cell formats, the first cell
707+
* identifies the slave device, while the optional second cell
708+
* contains the crci value.
709+
*
710+
* Returns pointer to appropriate dma channel on success or NULL on error.
711+
*/
712+
static struct dma_chan *adm_dma_xlate(struct of_phandle_args *dma_spec,
713+
struct of_dma *ofdma)
714+
{
715+
struct dma_device *dev = ofdma->of_dma_data;
716+
struct dma_chan *chan, *candidate = NULL;
717+
struct adm_chan *achan;
718+
719+
if (!dev || dma_spec->args_count > 2)
720+
return NULL;
721+
722+
list_for_each_entry(chan, &dev->channels, device_node)
723+
if (chan->chan_id == dma_spec->args[0]) {
724+
candidate = chan;
725+
break;
726+
}
727+
728+
if (!candidate)
729+
return NULL;
730+
731+
achan = to_adm_chan(candidate);
732+
if (dma_spec->args_count == 2)
733+
achan->crci = dma_spec->args[1];
734+
else
735+
achan->crci = 0;
736+
737+
return dma_get_slave_channel(candidate);
738+
}
739+
697740
static int adm_dma_probe(struct platform_device *pdev)
698741
{
699742
struct adm_device *adev;
@@ -838,8 +881,7 @@ static int adm_dma_probe(struct platform_device *pdev)
838881
goto err_disable_clks;
839882
}
840883

841-
ret = of_dma_controller_register(pdev->dev.of_node,
842-
of_dma_xlate_by_chan_id,
884+
ret = of_dma_controller_register(pdev->dev.of_node, adm_dma_xlate,
843885
&adev->common);
844886
if (ret)
845887
goto err_unregister_dma;

drivers/dma/sh/shdma-base.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -786,14 +786,6 @@ static int shdma_config(struct dma_chan *chan,
786786
if (!config)
787787
return -EINVAL;
788788

789-
/*
790-
* overriding the slave_id through dma_slave_config is deprecated,
791-
* but possibly some out-of-tree drivers still do it.
792-
*/
793-
if (WARN_ON_ONCE(config->slave_id &&
794-
config->slave_id != schan->real_slave_id))
795-
schan->real_slave_id = config->slave_id;
796-
797789
/*
798790
* We could lock this, but you shouldn't be configuring the
799791
* channel, while using it...

drivers/dma/sprd-dma.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,6 @@ static int sprd_dma_fill_desc(struct dma_chan *chan,
795795
return dst_datawidth;
796796
}
797797

798-
if (slave_cfg->slave_id)
799-
schan->dev_id = slave_cfg->slave_id;
800-
801798
hw->cfg = SPRD_DMA_DONOT_WAIT_BDONE << SPRD_DMA_WAIT_BDONE_OFFSET;
802799

803800
/*

drivers/dma/tegra20-apb-dma.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,6 @@ static int tegra_dma_slave_config(struct dma_chan *dc,
343343
}
344344

345345
memcpy(&tdc->dma_sconfig, sconfig, sizeof(*sconfig));
346-
if (tdc->slave_id == TEGRA_APBDMA_SLAVE_ID_INVALID &&
347-
sconfig->device_fc) {
348-
if (sconfig->slave_id > TEGRA_APBDMA_CSR_REQ_SEL_MASK)
349-
return -EINVAL;
350-
tdc->slave_id = sconfig->slave_id;
351-
}
352346
tdc->config_init = true;
353347

354348
return 0;

drivers/dma/xilinx/xilinx_dpdma.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/clk.h>
1313
#include <linux/debugfs.h>
1414
#include <linux/delay.h>
15+
#include <linux/dma/xilinx_dpdma.h>
1516
#include <linux/dmaengine.h>
1617
#include <linux/dmapool.h>
1718
#include <linux/interrupt.h>
@@ -1273,6 +1274,7 @@ static int xilinx_dpdma_config(struct dma_chan *dchan,
12731274
struct dma_slave_config *config)
12741275
{
12751276
struct xilinx_dpdma_chan *chan = to_xilinx_chan(dchan);
1277+
struct xilinx_dpdma_peripheral_config *pconfig;
12761278
unsigned long flags;
12771279

12781280
/*
@@ -1282,15 +1284,18 @@ static int xilinx_dpdma_config(struct dma_chan *dchan,
12821284
* fixed both on the DPDMA side and on the DP controller side.
12831285
*/
12841286

1285-
spin_lock_irqsave(&chan->lock, flags);
1286-
12871287
/*
1288-
* Abuse the slave_id to indicate that the channel is part of a video
1289-
* group.
1288+
* Use the peripheral_config to indicate that the channel is part
1289+
* of a video group. This requires matching use of the custom
1290+
* structure in each driver.
12901291
*/
1291-
if (chan->id <= ZYNQMP_DPDMA_VIDEO2)
1292-
chan->video_group = config->slave_id != 0;
1292+
pconfig = config->peripheral_config;
1293+
if (WARN_ON(pconfig && config->peripheral_size != sizeof(*pconfig)))
1294+
return -EINVAL;
12931295

1296+
spin_lock_irqsave(&chan->lock, flags);
1297+
if (chan->id <= ZYNQMP_DPDMA_VIDEO2 && pconfig)
1298+
chan->video_group = pconfig->video_group;
12941299
spin_unlock_irqrestore(&chan->lock, flags);
12951300

12961301
return 0;

drivers/gpu/drm/xlnx/zynqmp_disp.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <linux/clk.h>
2626
#include <linux/delay.h>
27+
#include <linux/dma/xilinx_dpdma.h>
2728
#include <linux/dma-mapping.h>
2829
#include <linux/dmaengine.h>
2930
#include <linux/module.h>
@@ -1058,14 +1059,18 @@ static void zynqmp_disp_layer_set_format(struct zynqmp_disp_layer *layer,
10581059
zynqmp_disp_avbuf_set_format(layer->disp, layer, layer->disp_fmt);
10591060

10601061
/*
1061-
* Set slave_id for each DMA channel to indicate they're part of a
1062+
* Set pconfig for each DMA channel to indicate they're part of a
10621063
* video group.
10631064
*/
10641065
for (i = 0; i < info->num_planes; i++) {
10651066
struct zynqmp_disp_layer_dma *dma = &layer->dmas[i];
1067+
struct xilinx_dpdma_peripheral_config pconfig = {
1068+
.video_group = true,
1069+
};
10661070
struct dma_slave_config config = {
10671071
.direction = DMA_MEM_TO_DEV,
1068-
.slave_id = 1,
1072+
.peripheral_config = &pconfig,
1073+
.peripheral_size = sizeof(pconfig),
10691074
};
10701075

10711076
dmaengine_slave_config(dma->chan, &config);

drivers/mmc/host/bcm2835.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,14 +1293,12 @@ static int bcm2835_add_host(struct bcm2835_host *host)
12931293

12941294
host->dma_cfg_tx.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
12951295
host->dma_cfg_tx.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1296-
host->dma_cfg_tx.slave_id = 13; /* DREQ channel */
12971296
host->dma_cfg_tx.direction = DMA_MEM_TO_DEV;
12981297
host->dma_cfg_tx.src_addr = 0;
12991298
host->dma_cfg_tx.dst_addr = host->phys_addr + SDDATA;
13001299

13011300
host->dma_cfg_rx.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
13021301
host->dma_cfg_rx.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1303-
host->dma_cfg_rx.slave_id = 13; /* DREQ channel */
13041302
host->dma_cfg_rx.direction = DMA_DEV_TO_MEM;
13051303
host->dma_cfg_rx.src_addr = host->phys_addr + SDDATA;
13061304
host->dma_cfg_rx.dst_addr = 0;

drivers/mtd/nand/raw/qcom_nandc.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/clk.h>
77
#include <linux/slab.h>
88
#include <linux/bitops.h>
9+
#include <linux/dma/qcom_adm.h>
910
#include <linux/dma-mapping.h>
1011
#include <linux/dmaengine.h>
1112
#include <linux/module.h>
@@ -952,6 +953,7 @@ static int prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read,
952953
struct dma_async_tx_descriptor *dma_desc;
953954
struct scatterlist *sgl;
954955
struct dma_slave_config slave_conf;
956+
struct qcom_adm_peripheral_config periph_conf = {};
955957
enum dma_transfer_direction dir_eng;
956958
int ret;
957959

@@ -983,11 +985,19 @@ static int prep_adm_dma_desc(struct qcom_nand_controller *nandc, bool read,
983985
if (read) {
984986
slave_conf.src_maxburst = 16;
985987
slave_conf.src_addr = nandc->base_dma + reg_off;
986-
slave_conf.slave_id = nandc->data_crci;
988+
if (nandc->data_crci) {
989+
periph_conf.crci = nandc->data_crci;
990+
slave_conf.peripheral_config = &periph_conf;
991+
slave_conf.peripheral_size = sizeof(periph_conf);
992+
}
987993
} else {
988994
slave_conf.dst_maxburst = 16;
989995
slave_conf.dst_addr = nandc->base_dma + reg_off;
990-
slave_conf.slave_id = nandc->cmd_crci;
996+
if (nandc->cmd_crci) {
997+
periph_conf.crci = nandc->cmd_crci;
998+
slave_conf.peripheral_config = &periph_conf;
999+
slave_conf.peripheral_size = sizeof(periph_conf);
1000+
}
9911001
}
9921002

9931003
ret = dmaengine_slave_config(nandc->chan, &slave_conf);

0 commit comments

Comments
 (0)