diff options
Diffstat (limited to 'drivers/parisc/ccio-dma.c')
-rw-r--r-- | drivers/parisc/ccio-dma.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c index b30e38f3a50d..dcc1e9958d2f 100644 --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c | |||
@@ -66,15 +66,8 @@ | |||
66 | #undef DEBUG_CCIO_RUN_SG | 66 | #undef DEBUG_CCIO_RUN_SG |
67 | 67 | ||
68 | #ifdef CONFIG_PROC_FS | 68 | #ifdef CONFIG_PROC_FS |
69 | /* | 69 | /* depends on proc fs support. But costs CPU performance. */ |
70 | * CCIO_SEARCH_TIME can help measure how fast the bitmap search is. | 70 | #undef CCIO_COLLECT_STATS |
71 | * impacts performance though - ditch it if you don't use it. | ||
72 | */ | ||
73 | #define CCIO_SEARCH_TIME | ||
74 | #undef CCIO_MAP_STATS | ||
75 | #else | ||
76 | #undef CCIO_SEARCH_TIME | ||
77 | #undef CCIO_MAP_STATS | ||
78 | #endif | 71 | #endif |
79 | 72 | ||
80 | #include <linux/proc_fs.h> | 73 | #include <linux/proc_fs.h> |
@@ -239,12 +232,10 @@ struct ioc { | |||
239 | u32 res_size; /* size of resource map in bytes */ | 232 | u32 res_size; /* size of resource map in bytes */ |
240 | spinlock_t res_lock; | 233 | spinlock_t res_lock; |
241 | 234 | ||
242 | #ifdef CCIO_SEARCH_TIME | 235 | #ifdef CCIO_COLLECT_STATS |
243 | #define CCIO_SEARCH_SAMPLE 0x100 | 236 | #define CCIO_SEARCH_SAMPLE 0x100 |
244 | unsigned long avg_search[CCIO_SEARCH_SAMPLE]; | 237 | unsigned long avg_search[CCIO_SEARCH_SAMPLE]; |
245 | unsigned long avg_idx; /* current index into avg_search */ | 238 | unsigned long avg_idx; /* current index into avg_search */ |
246 | #endif | ||
247 | #ifdef CCIO_MAP_STATS | ||
248 | unsigned long used_pages; | 239 | unsigned long used_pages; |
249 | unsigned long msingle_calls; | 240 | unsigned long msingle_calls; |
250 | unsigned long msingle_pages; | 241 | unsigned long msingle_pages; |
@@ -351,7 +342,7 @@ ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size) | |||
351 | unsigned int pages_needed = size >> IOVP_SHIFT; | 342 | unsigned int pages_needed = size >> IOVP_SHIFT; |
352 | unsigned int res_idx; | 343 | unsigned int res_idx; |
353 | unsigned long boundary_size; | 344 | unsigned long boundary_size; |
354 | #ifdef CCIO_SEARCH_TIME | 345 | #ifdef CCIO_COLLECT_STATS |
355 | unsigned long cr_start = mfctl(16); | 346 | unsigned long cr_start = mfctl(16); |
356 | #endif | 347 | #endif |
357 | 348 | ||
@@ -406,7 +397,7 @@ resource_found: | |||
406 | DBG_RES("%s() res_idx %d res_hint: %d\n", | 397 | DBG_RES("%s() res_idx %d res_hint: %d\n", |
407 | __func__, res_idx, ioc->res_hint); | 398 | __func__, res_idx, ioc->res_hint); |
408 | 399 | ||
409 | #ifdef CCIO_SEARCH_TIME | 400 | #ifdef CCIO_COLLECT_STATS |
410 | { | 401 | { |
411 | unsigned long cr_end = mfctl(16); | 402 | unsigned long cr_end = mfctl(16); |
412 | unsigned long tmp = cr_end - cr_start; | 403 | unsigned long tmp = cr_end - cr_start; |
@@ -416,7 +407,7 @@ resource_found: | |||
416 | ioc->avg_search[ioc->avg_idx++] = cr_start; | 407 | ioc->avg_search[ioc->avg_idx++] = cr_start; |
417 | ioc->avg_idx &= CCIO_SEARCH_SAMPLE - 1; | 408 | ioc->avg_idx &= CCIO_SEARCH_SAMPLE - 1; |
418 | #endif | 409 | #endif |
419 | #ifdef CCIO_MAP_STATS | 410 | #ifdef CCIO_COLLECT_STATS |
420 | ioc->used_pages += pages_needed; | 411 | ioc->used_pages += pages_needed; |
421 | #endif | 412 | #endif |
422 | /* | 413 | /* |
@@ -452,7 +443,7 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped) | |||
452 | DBG_RES("%s(): res_idx: %d pages_mapped %d\n", | 443 | DBG_RES("%s(): res_idx: %d pages_mapped %d\n", |
453 | __func__, res_idx, pages_mapped); | 444 | __func__, res_idx, pages_mapped); |
454 | 445 | ||
455 | #ifdef CCIO_MAP_STATS | 446 | #ifdef CCIO_COLLECT_STATS |
456 | ioc->used_pages -= pages_mapped; | 447 | ioc->used_pages -= pages_mapped; |
457 | #endif | 448 | #endif |
458 | 449 | ||
@@ -764,7 +755,7 @@ ccio_map_single(struct device *dev, void *addr, size_t size, | |||
764 | size = ALIGN(size + offset, IOVP_SIZE); | 755 | size = ALIGN(size + offset, IOVP_SIZE); |
765 | spin_lock_irqsave(&ioc->res_lock, flags); | 756 | spin_lock_irqsave(&ioc->res_lock, flags); |
766 | 757 | ||
767 | #ifdef CCIO_MAP_STATS | 758 | #ifdef CCIO_COLLECT_STATS |
768 | ioc->msingle_calls++; | 759 | ioc->msingle_calls++; |
769 | ioc->msingle_pages += size >> IOVP_SHIFT; | 760 | ioc->msingle_pages += size >> IOVP_SHIFT; |
770 | #endif | 761 | #endif |
@@ -828,7 +819,7 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size, | |||
828 | 819 | ||
829 | spin_lock_irqsave(&ioc->res_lock, flags); | 820 | spin_lock_irqsave(&ioc->res_lock, flags); |
830 | 821 | ||
831 | #ifdef CCIO_MAP_STATS | 822 | #ifdef CCIO_COLLECT_STATS |
832 | ioc->usingle_calls++; | 823 | ioc->usingle_calls++; |
833 | ioc->usingle_pages += size >> IOVP_SHIFT; | 824 | ioc->usingle_pages += size >> IOVP_SHIFT; |
834 | #endif | 825 | #endif |
@@ -894,7 +885,7 @@ ccio_free_consistent(struct device *dev, size_t size, void *cpu_addr, | |||
894 | */ | 885 | */ |
895 | #define PIDE_FLAG 0x80000000UL | 886 | #define PIDE_FLAG 0x80000000UL |
896 | 887 | ||
897 | #ifdef CCIO_MAP_STATS | 888 | #ifdef CCIO_COLLECT_STATS |
898 | #define IOMMU_MAP_STATS | 889 | #define IOMMU_MAP_STATS |
899 | #endif | 890 | #endif |
900 | #include "iommu-helpers.h" | 891 | #include "iommu-helpers.h" |
@@ -938,7 +929,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents, | |||
938 | 929 | ||
939 | spin_lock_irqsave(&ioc->res_lock, flags); | 930 | spin_lock_irqsave(&ioc->res_lock, flags); |
940 | 931 | ||
941 | #ifdef CCIO_MAP_STATS | 932 | #ifdef CCIO_COLLECT_STATS |
942 | ioc->msg_calls++; | 933 | ioc->msg_calls++; |
943 | #endif | 934 | #endif |
944 | 935 | ||
@@ -997,13 +988,13 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents, | |||
997 | DBG_RUN_SG("%s() START %d entries, %08lx,%x\n", | 988 | DBG_RUN_SG("%s() START %d entries, %08lx,%x\n", |
998 | __func__, nents, sg_virt_addr(sglist), sglist->length); | 989 | __func__, nents, sg_virt_addr(sglist), sglist->length); |
999 | 990 | ||
1000 | #ifdef CCIO_MAP_STATS | 991 | #ifdef CCIO_COLLECT_STATS |
1001 | ioc->usg_calls++; | 992 | ioc->usg_calls++; |
1002 | #endif | 993 | #endif |
1003 | 994 | ||
1004 | while(sg_dma_len(sglist) && nents--) { | 995 | while(sg_dma_len(sglist) && nents--) { |
1005 | 996 | ||
1006 | #ifdef CCIO_MAP_STATS | 997 | #ifdef CCIO_COLLECT_STATS |
1007 | ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT; | 998 | ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT; |
1008 | #endif | 999 | #endif |
1009 | ccio_unmap_single(dev, sg_dma_address(sglist), | 1000 | ccio_unmap_single(dev, sg_dma_address(sglist), |
@@ -1048,7 +1039,7 @@ static int ccio_proc_info(struct seq_file *m, void *p) | |||
1048 | len += seq_printf(m, "IO PDIR size : %d bytes (%d entries)\n", | 1039 | len += seq_printf(m, "IO PDIR size : %d bytes (%d entries)\n", |
1049 | total_pages * 8, total_pages); | 1040 | total_pages * 8, total_pages); |
1050 | 1041 | ||
1051 | #ifdef CCIO_MAP_STATS | 1042 | #ifdef CCIO_COLLECT_STATS |
1052 | len += seq_printf(m, "IO PDIR entries : %ld free %ld used (%d%%)\n", | 1043 | len += seq_printf(m, "IO PDIR entries : %ld free %ld used (%d%%)\n", |
1053 | total_pages - ioc->used_pages, ioc->used_pages, | 1044 | total_pages - ioc->used_pages, ioc->used_pages, |
1054 | (int)(ioc->used_pages * 100 / total_pages)); | 1045 | (int)(ioc->used_pages * 100 / total_pages)); |
@@ -1057,7 +1048,7 @@ static int ccio_proc_info(struct seq_file *m, void *p) | |||
1057 | len += seq_printf(m, "Resource bitmap : %d bytes (%d pages)\n", | 1048 | len += seq_printf(m, "Resource bitmap : %d bytes (%d pages)\n", |
1058 | ioc->res_size, total_pages); | 1049 | ioc->res_size, total_pages); |
1059 | 1050 | ||
1060 | #ifdef CCIO_SEARCH_TIME | 1051 | #ifdef CCIO_COLLECT_STATS |
1061 | min = max = ioc->avg_search[0]; | 1052 | min = max = ioc->avg_search[0]; |
1062 | for(j = 0; j < CCIO_SEARCH_SAMPLE; ++j) { | 1053 | for(j = 0; j < CCIO_SEARCH_SAMPLE; ++j) { |
1063 | avg += ioc->avg_search[j]; | 1054 | avg += ioc->avg_search[j]; |
@@ -1070,7 +1061,7 @@ static int ccio_proc_info(struct seq_file *m, void *p) | |||
1070 | len += seq_printf(m, " Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n", | 1061 | len += seq_printf(m, " Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n", |
1071 | min, avg, max); | 1062 | min, avg, max); |
1072 | #endif | 1063 | #endif |
1073 | #ifdef CCIO_MAP_STATS | 1064 | #ifdef CCIO_COLLECT_STATS |
1074 | len += seq_printf(m, "pci_map_single(): %8ld calls %8ld pages (avg %d/1000)\n", | 1065 | len += seq_printf(m, "pci_map_single(): %8ld calls %8ld pages (avg %d/1000)\n", |
1075 | ioc->msingle_calls, ioc->msingle_pages, | 1066 | ioc->msingle_calls, ioc->msingle_pages, |
1076 | (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls)); | 1067 | (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls)); |
@@ -1088,7 +1079,7 @@ static int ccio_proc_info(struct seq_file *m, void *p) | |||
1088 | len += seq_printf(m, "pci_unmap_sg() : %8ld calls %8ld pages (avg %d/1000)\n\n\n", | 1079 | len += seq_printf(m, "pci_unmap_sg() : %8ld calls %8ld pages (avg %d/1000)\n\n\n", |
1089 | ioc->usg_calls, ioc->usg_pages, | 1080 | ioc->usg_calls, ioc->usg_pages, |
1090 | (int)((ioc->usg_pages * 1000)/ioc->usg_calls)); | 1081 | (int)((ioc->usg_pages * 1000)/ioc->usg_calls)); |
1091 | #endif /* CCIO_MAP_STATS */ | 1082 | #endif /* CCIO_COLLECT_STATS */ |
1092 | 1083 | ||
1093 | ioc = ioc->next; | 1084 | ioc = ioc->next; |
1094 | } | 1085 | } |