Skip to content

Commit 42cb6e0

Browse files
committed
Merge branch 'topic/tegra' into for-linus
2 parents a74e795 + 863326a commit 42cb6e0

File tree

3 files changed

+92
-19
lines changed

3 files changed

+92
-19
lines changed

drivers/dma/tegra20-apb-dma.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838

3939
#include "dmaengine.h"
4040

41+
#define CREATE_TRACE_POINTS
42+
#include <trace/events/tegra_apb_dma.h>
43+
4144
#define TEGRA_APBDMA_GENERAL 0x0
4245
#define TEGRA_APBDMA_GENERAL_ENABLE BIT(31)
4346

@@ -146,7 +149,7 @@ struct tegra_dma_channel_regs {
146149
};
147150

148151
/*
149-
* tegra_dma_sg_req: Dma request details to configure hardware. This
152+
* tegra_dma_sg_req: DMA request details to configure hardware. This
150153
* contains the details for one transfer to configure DMA hw.
151154
* The client's request for data transfer can be broken into multiple
152155
* sub-transfer as per requester details and hw support.
@@ -155,7 +158,7 @@ struct tegra_dma_channel_regs {
155158
*/
156159
struct tegra_dma_sg_req {
157160
struct tegra_dma_channel_regs ch_regs;
158-
int req_len;
161+
unsigned int req_len;
159162
bool configured;
160163
bool last_sg;
161164
struct list_head node;
@@ -169,8 +172,8 @@ struct tegra_dma_sg_req {
169172
*/
170173
struct tegra_dma_desc {
171174
struct dma_async_tx_descriptor txd;
172-
int bytes_requested;
173-
int bytes_transferred;
175+
unsigned int bytes_requested;
176+
unsigned int bytes_transferred;
174177
enum dma_status dma_status;
175178
struct list_head node;
176179
struct list_head tx_list;
@@ -186,7 +189,7 @@ typedef void (*dma_isr_handler)(struct tegra_dma_channel *tdc,
186189
/* tegra_dma_channel: Channel specific information */
187190
struct tegra_dma_channel {
188191
struct dma_chan dma_chan;
189-
char name[30];
192+
char name[12];
190193
bool config_init;
191194
int id;
192195
int irq;
@@ -574,7 +577,7 @@ static bool handle_continuous_head_request(struct tegra_dma_channel *tdc,
574577
struct tegra_dma_sg_req *hsgreq = NULL;
575578

576579
if (list_empty(&tdc->pending_sg_req)) {
577-
dev_err(tdc2dev(tdc), "Dma is running without req\n");
580+
dev_err(tdc2dev(tdc), "DMA is running without req\n");
578581
tegra_dma_stop(tdc);
579582
return false;
580583
}
@@ -587,7 +590,7 @@ static bool handle_continuous_head_request(struct tegra_dma_channel *tdc,
587590
hsgreq = list_first_entry(&tdc->pending_sg_req, typeof(*hsgreq), node);
588591
if (!hsgreq->configured) {
589592
tegra_dma_stop(tdc);
590-
dev_err(tdc2dev(tdc), "Error in dma transfer, aborting dma\n");
593+
dev_err(tdc2dev(tdc), "Error in DMA transfer, aborting DMA\n");
591594
tegra_dma_abort_all(tdc);
592595
return false;
593596
}
@@ -636,7 +639,10 @@ static void handle_cont_sngl_cycle_dma_done(struct tegra_dma_channel *tdc,
636639

637640
sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), node);
638641
dma_desc = sgreq->dma_desc;
639-
dma_desc->bytes_transferred += sgreq->req_len;
642+
/* if we dma for long enough the transfer count will wrap */
643+
dma_desc->bytes_transferred =
644+
(dma_desc->bytes_transferred + sgreq->req_len) %
645+
dma_desc->bytes_requested;
640646

641647
/* Callback need to be call */
642648
if (!dma_desc->cb_count)
@@ -669,6 +675,8 @@ static void tegra_dma_tasklet(unsigned long data)
669675
dmaengine_desc_get_callback(&dma_desc->txd, &cb);
670676
cb_count = dma_desc->cb_count;
671677
dma_desc->cb_count = 0;
678+
trace_tegra_dma_complete_cb(&tdc->dma_chan, cb_count,
679+
cb.callback);
672680
spin_unlock_irqrestore(&tdc->lock, flags);
673681
while (cb_count--)
674682
dmaengine_desc_callback_invoke(&cb, NULL);
@@ -685,6 +693,7 @@ static irqreturn_t tegra_dma_isr(int irq, void *dev_id)
685693

686694
spin_lock_irqsave(&tdc->lock, flags);
687695

696+
trace_tegra_dma_isr(&tdc->dma_chan, irq);
688697
status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
689698
if (status & TEGRA_APBDMA_STATUS_ISE_EOC) {
690699
tdc_write(tdc, TEGRA_APBDMA_CHAN_STATUS, status);
@@ -843,6 +852,7 @@ static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
843852
dma_set_residue(txstate, residual);
844853
}
845854

855+
trace_tegra_dma_tx_status(&tdc->dma_chan, cookie, txstate);
846856
spin_unlock_irqrestore(&tdc->lock, flags);
847857
return ret;
848858
}
@@ -919,7 +929,7 @@ static int get_transfer_param(struct tegra_dma_channel *tdc,
919929
return 0;
920930

921931
default:
922-
dev_err(tdc2dev(tdc), "Dma direction is not supported\n");
932+
dev_err(tdc2dev(tdc), "DMA direction is not supported\n");
923933
return -EINVAL;
924934
}
925935
return -EINVAL;
@@ -952,7 +962,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg(
952962
enum dma_slave_buswidth slave_bw;
953963

954964
if (!tdc->config_init) {
955-
dev_err(tdc2dev(tdc), "dma channel is not configured\n");
965+
dev_err(tdc2dev(tdc), "DMA channel is not configured\n");
956966
return NULL;
957967
}
958968
if (sg_len < 1) {
@@ -985,7 +995,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg(
985995

986996
dma_desc = tegra_dma_desc_get(tdc);
987997
if (!dma_desc) {
988-
dev_err(tdc2dev(tdc), "Dma descriptors not available\n");
998+
dev_err(tdc2dev(tdc), "DMA descriptors not available\n");
989999
return NULL;
9901000
}
9911001
INIT_LIST_HEAD(&dma_desc->tx_list);
@@ -1005,14 +1015,14 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg(
10051015
if ((len & 3) || (mem & 3) ||
10061016
(len > tdc->tdma->chip_data->max_dma_count)) {
10071017
dev_err(tdc2dev(tdc),
1008-
"Dma length/memory address is not supported\n");
1018+
"DMA length/memory address is not supported\n");
10091019
tegra_dma_desc_put(tdc, dma_desc);
10101020
return NULL;
10111021
}
10121022

10131023
sg_req = tegra_dma_sg_req_get(tdc);
10141024
if (!sg_req) {
1015-
dev_err(tdc2dev(tdc), "Dma sg-req not available\n");
1025+
dev_err(tdc2dev(tdc), "DMA sg-req not available\n");
10161026
tegra_dma_desc_put(tdc, dma_desc);
10171027
return NULL;
10181028
}
@@ -1087,7 +1097,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic(
10871097
* terminating the DMA.
10881098
*/
10891099
if (tdc->busy) {
1090-
dev_err(tdc2dev(tdc), "Request not allowed when dma running\n");
1100+
dev_err(tdc2dev(tdc), "Request not allowed when DMA running\n");
10911101
return NULL;
10921102
}
10931103

@@ -1144,7 +1154,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic(
11441154
while (remain_len) {
11451155
sg_req = tegra_dma_sg_req_get(tdc);
11461156
if (!sg_req) {
1147-
dev_err(tdc2dev(tdc), "Dma sg-req not available\n");
1157+
dev_err(tdc2dev(tdc), "DMA sg-req not available\n");
11481158
tegra_dma_desc_put(tdc, dma_desc);
11491159
return NULL;
11501160
}
@@ -1319,8 +1329,9 @@ static int tegra_dma_probe(struct platform_device *pdev)
13191329
return -ENODEV;
13201330
}
13211331

1322-
tdma = devm_kzalloc(&pdev->dev, sizeof(*tdma) + cdata->nr_channels *
1323-
sizeof(struct tegra_dma_channel), GFP_KERNEL);
1332+
tdma = devm_kzalloc(&pdev->dev,
1333+
struct_size(tdma, channels, cdata->nr_channels),
1334+
GFP_KERNEL);
13241335
if (!tdma)
13251336
return -ENOMEM;
13261337

drivers/dma/tegra210-adma.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,9 @@ static int tegra_adma_probe(struct platform_device *pdev)
678678
return -ENODEV;
679679
}
680680

681-
tdma = devm_kzalloc(&pdev->dev, sizeof(*tdma) + cdata->nr_channels *
682-
sizeof(struct tegra_adma_chan), GFP_KERNEL);
681+
tdma = devm_kzalloc(&pdev->dev,
682+
struct_size(tdma, channels, cdata->nr_channels),
683+
GFP_KERNEL);
683684
if (!tdma)
684685
return -ENOMEM;
685686

include/trace/events/tegra_apb_dma.h

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#if !defined(_TRACE_TEGRA_APB_DMA_H) || defined(TRACE_HEADER_MULTI_READ)
2+
#define _TRACE_TEGRA_APM_DMA_H
3+
4+
#include <linux/tracepoint.h>
5+
#include <linux/dmaengine.h>
6+
7+
#undef TRACE_SYSTEM
8+
#define TRACE_SYSTEM tegra_apb_dma
9+
10+
TRACE_EVENT(tegra_dma_tx_status,
11+
TP_PROTO(struct dma_chan *dc, dma_cookie_t cookie, struct dma_tx_state *state),
12+
TP_ARGS(dc, cookie, state),
13+
TP_STRUCT__entry(
14+
__string(chan, dev_name(&dc->dev->device))
15+
__field(dma_cookie_t, cookie)
16+
__field(__u32, residue)
17+
),
18+
TP_fast_assign(
19+
__assign_str(chan, dev_name(&dc->dev->device));
20+
__entry->cookie = cookie;
21+
__entry->residue = state ? state->residue : (u32)-1;
22+
),
23+
TP_printk("channel %s: dma cookie %d, residue %u",
24+
__get_str(chan), __entry->cookie, __entry->residue)
25+
);
26+
27+
TRACE_EVENT(tegra_dma_complete_cb,
28+
TP_PROTO(struct dma_chan *dc, int count, void *ptr),
29+
TP_ARGS(dc, count, ptr),
30+
TP_STRUCT__entry(
31+
__string(chan, dev_name(&dc->dev->device))
32+
__field(int, count)
33+
__field(void *, ptr)
34+
),
35+
TP_fast_assign(
36+
__assign_str(chan, dev_name(&dc->dev->device));
37+
__entry->count = count;
38+
__entry->ptr = ptr;
39+
),
40+
TP_printk("channel %s: done %d, ptr %p",
41+
__get_str(chan), __entry->count, __entry->ptr)
42+
);
43+
44+
TRACE_EVENT(tegra_dma_isr,
45+
TP_PROTO(struct dma_chan *dc, int irq),
46+
TP_ARGS(dc, irq),
47+
TP_STRUCT__entry(
48+
__string(chan, dev_name(&dc->dev->device))
49+
__field(int, irq)
50+
),
51+
TP_fast_assign(
52+
__assign_str(chan, dev_name(&dc->dev->device));
53+
__entry->irq = irq;
54+
),
55+
TP_printk("%s: irq %d\n", __get_str(chan), __entry->irq)
56+
);
57+
58+
#endif /* _TRACE_TEGRADMA_H */
59+
60+
/* This part must be outside protection */
61+
#include <trace/define_trace.h>

0 commit comments

Comments
 (0)