Skip to content

Commit b81b78d

Browse files
committed
Merge tag 'dma-mapping-6.12-2024-09-29' of git://git.infradead.org/users/hch/dma-mapping
Pull dma-mapping fix from Christoph Hellwig: - handle chained SGLs in the new tracing code (Christoph Hellwig) * tag 'dma-mapping-6.12-2024-09-29' of git://git.infradead.org/users/hch/dma-mapping: dma-mapping: fix DMA API tracing for chained scatterlists
2 parents 3ed7df0 + bfc4a24 commit b81b78d

File tree

1 file changed

+19
-18
lines changed
  • include/trace/events

1 file changed

+19
-18
lines changed

include/trace/events/dma.h

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ TRACE_EVENT(dma_free,
176176
);
177177

178178
TRACE_EVENT(dma_map_sg,
179-
TP_PROTO(struct device *dev, struct scatterlist *sg, int nents,
179+
TP_PROTO(struct device *dev, struct scatterlist *sgl, int nents,
180180
int ents, enum dma_data_direction dir, unsigned long attrs),
181-
TP_ARGS(dev, sg, nents, ents, dir, attrs),
181+
TP_ARGS(dev, sgl, nents, ents, dir, attrs),
182182

183183
TP_STRUCT__entry(
184184
__string(device, dev_name(dev))
@@ -190,17 +190,17 @@ TRACE_EVENT(dma_map_sg,
190190
),
191191

192192
TP_fast_assign(
193+
struct scatterlist *sg;
193194
int i;
194195

195196
__assign_str(device);
196-
for (i = 0; i < nents; i++)
197-
((u64 *)__get_dynamic_array(phys_addrs))[i] =
198-
sg_phys(sg + i);
199-
for (i = 0; i < ents; i++) {
197+
for_each_sg(sgl, sg, nents, i)
198+
((u64 *)__get_dynamic_array(phys_addrs))[i] = sg_phys(sg);
199+
for_each_sg(sgl, sg, ents, i) {
200200
((u64 *)__get_dynamic_array(dma_addrs))[i] =
201-
sg_dma_address(sg + i);
201+
sg_dma_address(sg);
202202
((unsigned int *)__get_dynamic_array(lengths))[i] =
203-
sg_dma_len(sg + i);
203+
sg_dma_len(sg);
204204
}
205205
__entry->dir = dir;
206206
__entry->attrs = attrs;
@@ -222,9 +222,9 @@ TRACE_EVENT(dma_map_sg,
222222
);
223223

224224
TRACE_EVENT(dma_unmap_sg,
225-
TP_PROTO(struct device *dev, struct scatterlist *sg, int nents,
225+
TP_PROTO(struct device *dev, struct scatterlist *sgl, int nents,
226226
enum dma_data_direction dir, unsigned long attrs),
227-
TP_ARGS(dev, sg, nents, dir, attrs),
227+
TP_ARGS(dev, sgl, nents, dir, attrs),
228228

229229
TP_STRUCT__entry(
230230
__string(device, dev_name(dev))
@@ -234,12 +234,12 @@ TRACE_EVENT(dma_unmap_sg,
234234
),
235235

236236
TP_fast_assign(
237+
struct scatterlist *sg;
237238
int i;
238239

239240
__assign_str(device);
240-
for (i = 0; i < nents; i++)
241-
((u64 *)__get_dynamic_array(addrs))[i] =
242-
sg_phys(sg + i);
241+
for_each_sg(sgl, sg, nents, i)
242+
((u64 *)__get_dynamic_array(addrs))[i] = sg_phys(sg);
243243
__entry->dir = dir;
244244
__entry->attrs = attrs;
245245
),
@@ -290,9 +290,9 @@ DEFINE_EVENT(dma_sync_single, dma_sync_single_for_device,
290290
TP_ARGS(dev, dma_addr, size, dir));
291291

292292
DECLARE_EVENT_CLASS(dma_sync_sg,
293-
TP_PROTO(struct device *dev, struct scatterlist *sg, int nents,
293+
TP_PROTO(struct device *dev, struct scatterlist *sgl, int nents,
294294
enum dma_data_direction dir),
295-
TP_ARGS(dev, sg, nents, dir),
295+
TP_ARGS(dev, sgl, nents, dir),
296296

297297
TP_STRUCT__entry(
298298
__string(device, dev_name(dev))
@@ -302,14 +302,15 @@ DECLARE_EVENT_CLASS(dma_sync_sg,
302302
),
303303

304304
TP_fast_assign(
305+
struct scatterlist *sg;
305306
int i;
306307

307308
__assign_str(device);
308-
for (i = 0; i < nents; i++) {
309+
for_each_sg(sgl, sg, nents, i) {
309310
((u64 *)__get_dynamic_array(dma_addrs))[i] =
310-
sg_dma_address(sg + i);
311+
sg_dma_address(sg);
311312
((unsigned int *)__get_dynamic_array(lengths))[i] =
312-
sg_dma_len(sg + i);
313+
sg_dma_len(sg);
313314
}
314315
__entry->dir = dir;
315316
),

0 commit comments

Comments
 (0)