Skip to content

Commit bd89d69

Browse files
Desnes NunesChristoph Hellwig
authored andcommitted
dma-debug: add cacheline to user/kernel space dump messages
Having the cacheline also printed on the debug_dma_dump_mappings() and dump_show() is useful for debugging. Furthermore, this also standardizes the messages shown on both dump functions. Signed-off-by: Desnes Nunes <desnesn@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 479623f commit bd89d69

1 file changed

Lines changed: 64 additions & 58 deletions

File tree

kernel/dma/debug.c

Lines changed: 64 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -396,37 +396,6 @@ static unsigned long long phys_addr(struct dma_debug_entry *entry)
396396
return page_to_phys(pfn_to_page(entry->pfn)) + entry->offset;
397397
}
398398

399-
/*
400-
* Dump mapping entries for debugging purposes
401-
*/
402-
void debug_dma_dump_mappings(struct device *dev)
403-
{
404-
int idx;
405-
406-
for (idx = 0; idx < HASH_SIZE; idx++) {
407-
struct hash_bucket *bucket = &dma_entry_hash[idx];
408-
struct dma_debug_entry *entry;
409-
unsigned long flags;
410-
411-
spin_lock_irqsave(&bucket->lock, flags);
412-
413-
list_for_each_entry(entry, &bucket->list, list) {
414-
if (!dev || dev == entry->dev) {
415-
dev_info(entry->dev,
416-
"%s idx %d P=%Lx N=%lx D=%Lx L=%Lx %s %s\n",
417-
type2name[entry->type], idx,
418-
phys_addr(entry), entry->pfn,
419-
entry->dev_addr, entry->size,
420-
dir2name[entry->direction],
421-
maperr2str[entry->map_err_type]);
422-
}
423-
}
424-
425-
spin_unlock_irqrestore(&bucket->lock, flags);
426-
cond_resched();
427-
}
428-
}
429-
430399
/*
431400
* For each mapping (initial cacheline in the case of
432401
* dma_alloc_coherent/dma_map_page, initial cacheline in each page of a
@@ -547,6 +516,70 @@ static void active_cacheline_remove(struct dma_debug_entry *entry)
547516
spin_unlock_irqrestore(&radix_lock, flags);
548517
}
549518

519+
/*
520+
* Dump mappings entries on kernel space for debugging purposes
521+
*/
522+
void debug_dma_dump_mappings(struct device *dev)
523+
{
524+
int idx;
525+
phys_addr_t cln;
526+
527+
for (idx = 0; idx < HASH_SIZE; idx++) {
528+
struct hash_bucket *bucket = &dma_entry_hash[idx];
529+
struct dma_debug_entry *entry;
530+
unsigned long flags;
531+
532+
spin_lock_irqsave(&bucket->lock, flags);
533+
list_for_each_entry(entry, &bucket->list, list) {
534+
if (!dev || dev == entry->dev) {
535+
cln = to_cacheline_number(entry);
536+
dev_info(entry->dev,
537+
"%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
538+
type2name[entry->type], idx,
539+
phys_addr(entry), entry->pfn,
540+
entry->dev_addr, entry->size,
541+
cln, dir2name[entry->direction],
542+
maperr2str[entry->map_err_type]);
543+
}
544+
}
545+
spin_unlock_irqrestore(&bucket->lock, flags);
546+
547+
cond_resched();
548+
}
549+
}
550+
551+
/*
552+
* Dump mappings entries on user space via debugfs
553+
*/
554+
static int dump_show(struct seq_file *seq, void *v)
555+
{
556+
int idx;
557+
phys_addr_t cln;
558+
559+
for (idx = 0; idx < HASH_SIZE; idx++) {
560+
struct hash_bucket *bucket = &dma_entry_hash[idx];
561+
struct dma_debug_entry *entry;
562+
unsigned long flags;
563+
564+
spin_lock_irqsave(&bucket->lock, flags);
565+
list_for_each_entry(entry, &bucket->list, list) {
566+
cln = to_cacheline_number(entry);
567+
seq_printf(seq,
568+
"%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n",
569+
dev_driver_string(entry->dev),
570+
dev_name(entry->dev),
571+
type2name[entry->type], idx,
572+
phys_addr(entry), entry->pfn,
573+
entry->dev_addr, entry->size,
574+
cln, dir2name[entry->direction],
575+
maperr2str[entry->map_err_type]);
576+
}
577+
spin_unlock_irqrestore(&bucket->lock, flags);
578+
}
579+
return 0;
580+
}
581+
DEFINE_SHOW_ATTRIBUTE(dump);
582+
550583
/*
551584
* Wrapper function for adding an entry to the hash.
552585
* This function takes care of locking itself.
@@ -765,33 +798,6 @@ static const struct file_operations filter_fops = {
765798
.llseek = default_llseek,
766799
};
767800

768-
static int dump_show(struct seq_file *seq, void *v)
769-
{
770-
int idx;
771-
772-
for (idx = 0; idx < HASH_SIZE; idx++) {
773-
struct hash_bucket *bucket = &dma_entry_hash[idx];
774-
struct dma_debug_entry *entry;
775-
unsigned long flags;
776-
777-
spin_lock_irqsave(&bucket->lock, flags);
778-
list_for_each_entry(entry, &bucket->list, list) {
779-
seq_printf(seq,
780-
"%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx %s %s\n",
781-
dev_name(entry->dev),
782-
dev_driver_string(entry->dev),
783-
type2name[entry->type], idx,
784-
phys_addr(entry), entry->pfn,
785-
entry->dev_addr, entry->size,
786-
dir2name[entry->direction],
787-
maperr2str[entry->map_err_type]);
788-
}
789-
spin_unlock_irqrestore(&bucket->lock, flags);
790-
}
791-
return 0;
792-
}
793-
DEFINE_SHOW_ATTRIBUTE(dump);
794-
795801
static int __init dma_debug_fs_init(void)
796802
{
797803
struct dentry *dentry = debugfs_create_dir("dma-api", NULL);

0 commit comments

Comments
 (0)