Skip to content

Commit 503101a

Browse files
author
CKI KWF Bot
committed
Merge: dmaengine: fsl-edma: update to v6.17 and enable driver
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1455 ## Summary of Changes Update fsl-edma driver to v6.17 as part of NXP S32G enablement work. See [VROOM-32805](https://issues.redhat.com/browse/VROOM-32805) for details. Depends: !1483 ## Testing This MR requires a non-standard setup to test. See [RHEL-115725](https://issues.redhat.com/browse/RHEL-115725) for how to boot into a console (uses a temporary Buildroot userspace since the hardware is currently being brought up). Once booted into a Linux console, I probed the `fsl-edma` module then tested with `dmatest`: ```console # modprobe fsl-edma # lsmod Module Size Used by Tainted: G fsl_edma 61440 0 virt_dma 16384 1 fsl_edma # modprobe dmatest iterations=1000 timeout=30000 run=1 ``` The `dmesg` logs from the module should resemble the following, with "0 failures" on every test summary line: ``` [ 874.648740] dmatest: No channels configured, continue with any [ 874.648990] dmatest: Added 1 threads using dma0chan0 [ 874.649104] dmatest: Added 1 threads using dma0chan1 <snip> [ 874.656470] dmatest: Started 1 threads using dma0chan0 [ 874.656485] dmatest: Started 1 threads using dma0chan1 <snip> [ 874.680380] dmatest: dma0chan27-copy: summary 10 tests, 0 failures 570.67 iops 5079 KB/s (0) [ 874.680633] dmatest: dma0chan13-copy: summary 10 tests, 0 failures 536.59 iops 3219 KB/s (0) <snip> ``` I did notice that the driver spewed warnings on removal; this is documented in [VROOM-33316](https://issues.redhat.com/browse/VROOM-33316). Based on my investigation, I don't believe the warnings are severe enough to block this MR, especially considering the board is still in early bringup. See the [investigation notes](https://issues.redhat.com/browse/VROOM-33316?focusedId=28159605&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-28159605) for details. ## Approved Development Ticket(s) JIRA: https://issues.redhat.com/browse/RHEL-115725 Related ARK enablement MR: https://gitlab.com/cki-project/kernel-ark/-/merge_requests/4170 Signed-off-by: Jared Kangas <jkangas@redhat.com> Approved-by: Eder Zulian <ezulian@redhat.com> Approved-by: Eric Chanudet <echanude@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 246b119 + 5d37f33 commit 503101a

File tree

5 files changed

+383
-42
lines changed

5 files changed

+383
-42
lines changed

Documentation/devicetree/bindings/dma/fsl,edma.yaml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,33 @@ properties:
2626
- fsl,imx93-edma3
2727
- fsl,imx93-edma4
2828
- fsl,imx95-edma5
29+
- nxp,s32g2-edma
30+
- items:
31+
- enum:
32+
- fsl,imx94-edma3
33+
- const: fsl,imx93-edma3
34+
- items:
35+
- enum:
36+
- fsl,imx94-edma5
37+
- const: fsl,imx95-edma5
2938
- items:
3039
- const: fsl,ls1028a-edma
3140
- const: fsl,vf610-edma
41+
- items:
42+
- const: nxp,s32g3-edma
43+
- const: nxp,s32g2-edma
3244

3345
reg:
3446
minItems: 1
3547
maxItems: 3
3648

3749
interrupts:
3850
minItems: 1
39-
maxItems: 64
51+
maxItems: 65
4052

4153
interrupt-names:
4254
minItems: 1
43-
maxItems: 64
55+
maxItems: 65
4456

4557
"#dma-cells":
4658
description: |
@@ -221,6 +233,36 @@ allOf:
221233
properties:
222234
power-domains: false
223235

236+
- if:
237+
properties:
238+
compatible:
239+
contains:
240+
const: nxp,s32g2-edma
241+
then:
242+
properties:
243+
clocks:
244+
minItems: 2
245+
maxItems: 2
246+
clock-names:
247+
items:
248+
- const: dmamux0
249+
- const: dmamux1
250+
interrupts:
251+
minItems: 3
252+
maxItems: 3
253+
interrupt-names:
254+
items:
255+
- const: tx-0-15
256+
- const: tx-16-31
257+
- const: err
258+
reg:
259+
minItems: 3
260+
maxItems: 3
261+
"#dma-cells":
262+
const: 2
263+
dma-channels:
264+
const: 32
265+
224266
unevaluatedProperties: false
225267

226268
examples:

drivers/dma/fsl-edma-common.c

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void fsl_edma3_enable_request(struct fsl_edma_chan *fsl_chan)
9595
}
9696

9797
val = edma_readl_chreg(fsl_chan, ch_csr);
98-
val |= EDMA_V3_CH_CSR_ERQ;
98+
val |= EDMA_V3_CH_CSR_ERQ | EDMA_V3_CH_CSR_EEI;
9999
edma_writel_chreg(fsl_chan, val, ch_csr);
100100
}
101101

@@ -480,8 +480,8 @@ void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan,
480480
bool disable_req, bool enable_sg)
481481
{
482482
struct dma_slave_config *cfg = &fsl_chan->cfg;
483+
u32 burst = 0;
483484
u16 csr = 0;
484-
u32 burst;
485485

486486
/*
487487
* eDMA hardware SGs require the TCDs to be stored in little
@@ -496,16 +496,30 @@ void fsl_edma_fill_tcd(struct fsl_edma_chan *fsl_chan,
496496

497497
fsl_edma_set_tcd_to_le(fsl_chan, tcd, soff, soff);
498498

499-
if (fsl_chan->is_multi_fifo) {
500-
/* set mloff to support multiple fifo */
501-
burst = cfg->direction == DMA_DEV_TO_MEM ?
502-
cfg->src_maxburst : cfg->dst_maxburst;
503-
nbytes |= EDMA_V3_TCD_NBYTES_MLOFF(-(burst * 4));
504-
/* enable DMLOE/SMLOE */
505-
if (cfg->direction == DMA_MEM_TO_DEV) {
499+
/* If we expect to have either multi_fifo or a port window size,
500+
* we will use minor loop offset, meaning bits 29-10 will be used for
501+
* address offset, while bits 9-0 will be used to tell DMA how much
502+
* data to read from addr.
503+
* If we don't have either of those, will use a major loop reading from addr
504+
* nbytes (29bits).
505+
*/
506+
if (cfg->direction == DMA_MEM_TO_DEV) {
507+
if (fsl_chan->is_multi_fifo)
508+
burst = cfg->dst_maxburst * 4;
509+
if (cfg->dst_port_window_size)
510+
burst = cfg->dst_port_window_size * cfg->dst_addr_width;
511+
if (burst) {
512+
nbytes |= EDMA_V3_TCD_NBYTES_MLOFF(-burst);
506513
nbytes |= EDMA_V3_TCD_NBYTES_DMLOE;
507514
nbytes &= ~EDMA_V3_TCD_NBYTES_SMLOE;
508-
} else {
515+
}
516+
} else {
517+
if (fsl_chan->is_multi_fifo)
518+
burst = cfg->src_maxburst * 4;
519+
if (cfg->src_port_window_size)
520+
burst = cfg->src_port_window_size * cfg->src_addr_width;
521+
if (burst) {
522+
nbytes |= EDMA_V3_TCD_NBYTES_MLOFF(-burst);
509523
nbytes |= EDMA_V3_TCD_NBYTES_SMLOE;
510524
nbytes &= ~EDMA_V3_TCD_NBYTES_DMLOE;
511525
}
@@ -623,11 +637,15 @@ struct dma_async_tx_descriptor *fsl_edma_prep_dma_cyclic(
623637
dst_addr = fsl_chan->dma_dev_addr;
624638
soff = fsl_chan->cfg.dst_addr_width;
625639
doff = fsl_chan->is_multi_fifo ? 4 : 0;
640+
if (fsl_chan->cfg.dst_port_window_size)
641+
doff = fsl_chan->cfg.dst_addr_width;
626642
} else if (direction == DMA_DEV_TO_MEM) {
627643
src_addr = fsl_chan->dma_dev_addr;
628644
dst_addr = dma_buf_next;
629645
soff = fsl_chan->is_multi_fifo ? 4 : 0;
630646
doff = fsl_chan->cfg.src_addr_width;
647+
if (fsl_chan->cfg.src_port_window_size)
648+
soff = fsl_chan->cfg.src_addr_width;
631649
} else {
632650
/* DMA_DEV_TO_DEV */
633651
src_addr = fsl_chan->cfg.src_addr;
@@ -803,7 +821,7 @@ void fsl_edma_issue_pending(struct dma_chan *chan)
803821
int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
804822
{
805823
struct fsl_edma_chan *fsl_chan = to_fsl_edma_chan(chan);
806-
int ret;
824+
int ret = 0;
807825

808826
if (fsl_edma_drvflags(fsl_chan) & FSL_EDMA_DRV_HAS_CHCLK)
809827
clk_prepare_enable(fsl_chan->clk);
@@ -813,17 +831,29 @@ int fsl_edma_alloc_chan_resources(struct dma_chan *chan)
813831
sizeof(struct fsl_edma_hw_tcd64) : sizeof(struct fsl_edma_hw_tcd),
814832
32, 0);
815833

816-
if (fsl_chan->txirq) {
834+
if (fsl_chan->txirq)
817835
ret = request_irq(fsl_chan->txirq, fsl_chan->irq_handler, IRQF_SHARED,
818836
fsl_chan->chan_name, fsl_chan);
819837

820-
if (ret) {
821-
dma_pool_destroy(fsl_chan->tcd_pool);
822-
return ret;
823-
}
824-
}
838+
if (ret)
839+
goto err_txirq;
840+
841+
if (fsl_chan->errirq > 0)
842+
ret = request_irq(fsl_chan->errirq, fsl_chan->errirq_handler, IRQF_SHARED,
843+
fsl_chan->errirq_name, fsl_chan);
844+
845+
if (ret)
846+
goto err_errirq;
825847

826848
return 0;
849+
850+
err_errirq:
851+
if (fsl_chan->txirq)
852+
free_irq(fsl_chan->txirq, fsl_chan);
853+
err_txirq:
854+
dma_pool_destroy(fsl_chan->tcd_pool);
855+
856+
return ret;
827857
}
828858

829859
void fsl_edma_free_chan_resources(struct dma_chan *chan)
@@ -844,6 +874,8 @@ void fsl_edma_free_chan_resources(struct dma_chan *chan)
844874

845875
if (fsl_chan->txirq)
846876
free_irq(fsl_chan->txirq, fsl_chan);
877+
if (fsl_chan->errirq)
878+
free_irq(fsl_chan->errirq, fsl_chan);
847879

848880
vchan_dma_desc_free_list(&fsl_chan->vchan, &head);
849881
dma_pool_destroy(fsl_chan->tcd_pool);

drivers/dma/fsl-edma-common.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@
6868
#define EDMA_V3_CH_CSR_EEI BIT(2)
6969
#define EDMA_V3_CH_CSR_DONE BIT(30)
7070
#define EDMA_V3_CH_CSR_ACTIVE BIT(31)
71+
#define EDMA_V3_CH_ES_ERR BIT(31)
72+
#define EDMA_V3_MP_ES_VLD BIT(31)
73+
74+
#define EDMA_V3_CH_ERR_DBE BIT(0)
75+
#define EDMA_V3_CH_ERR_SBE BIT(1)
76+
#define EDMA_V3_CH_ERR_SGE BIT(2)
77+
#define EDMA_V3_CH_ERR_NCE BIT(3)
78+
#define EDMA_V3_CH_ERR_DOE BIT(4)
79+
#define EDMA_V3_CH_ERR_DAE BIT(5)
80+
#define EDMA_V3_CH_ERR_SOE BIT(6)
81+
#define EDMA_V3_CH_ERR_SAE BIT(7)
82+
#define EDMA_V3_CH_ERR_ECX BIT(8)
83+
#define EDMA_V3_CH_ERR_UCE BIT(9)
84+
#define EDMA_V3_CH_ERR BIT(31)
7185

7286
enum fsl_edma_pm_state {
7387
RUNNING = 0,
@@ -160,18 +174,22 @@ struct fsl_edma_chan {
160174
u32 dma_dev_size;
161175
enum dma_data_direction dma_dir;
162176
char chan_name[32];
177+
char errirq_name[36];
163178
void __iomem *tcd;
164179
void __iomem *mux_addr;
165180
u32 real_count;
166181
struct work_struct issue_worker;
167182
struct platform_device *pdev;
168183
struct device *pd_dev;
184+
struct device_link *pd_dev_link;
169185
u32 srcid;
170186
struct clk *clk;
171187
int priority;
172188
int hw_chanid;
173189
int txirq;
190+
int errirq;
174191
irqreturn_t (*irq_handler)(int irq, void *dev_id);
192+
irqreturn_t (*errirq_handler)(int irq, void *dev_id);
175193
bool is_rxchan;
176194
bool is_remote;
177195
bool is_multi_fifo;
@@ -205,6 +223,9 @@ struct fsl_edma_desc {
205223
/* Need clean CHn_CSR DONE before enable TCD's MAJORELINK */
206224
#define FSL_EDMA_DRV_CLEAR_DONE_E_LINK BIT(14)
207225
#define FSL_EDMA_DRV_TCD64 BIT(15)
226+
/* All channel ERR IRQ share one IRQ line */
227+
#define FSL_EDMA_DRV_ERRIRQ_SHARE BIT(16)
228+
208229

209230
#define FSL_EDMA_DRV_EDMA3 (FSL_EDMA_DRV_SPLIT_REG | \
210231
FSL_EDMA_DRV_BUS_8BYTE | \
@@ -240,6 +261,7 @@ struct fsl_edma_engine {
240261
const struct fsl_edma_drvdata *drvdata;
241262
u32 n_chans;
242263
int txirq;
264+
int txirq_16_31;
243265
int errirq;
244266
bool big_endian;
245267
struct edma_regs regs;

0 commit comments

Comments
 (0)