Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba8d1c08 authored by Kyle Yan's avatar Kyle Yan Committed by Gerrit - the friendly Code Review server
Browse files

Merge "iommu/iommu-debug: Use more iterations while profiling" into msm-4.8

parents 561ac5cc 1c47bb50
Loading
Loading
Loading
Loading
+60 −41
Original line number Diff line number Diff line
@@ -455,6 +455,8 @@ static const char * const _size_to_string(unsigned long size)
	return "unknown size, please add to _size_to_string";
}

#define ITERS_PER_OP 100

static void iommu_debug_device_profiling(struct seq_file *s, struct device *dev,
					 bool secure)
{
@@ -496,13 +498,16 @@ static void iommu_debug_device_profiling(struct seq_file *s, struct device *dev,
		goto out_domain_free;
	}

	seq_printf(s, "(average over %d iterations)\n", ITERS_PER_OP);
	seq_printf(s, "%8s %15s %12s\n", "size", "iommu_map", "iommu_unmap");
	for (sz = sizes; *sz; ++sz) {
		unsigned long size = *sz;
		size_t unmapped;
		s64 map_elapsed_us, unmap_elapsed_us;
		u64 map_elapsed_us = 0, unmap_elapsed_us = 0;
		struct timespec tbefore, tafter, diff;
		int i;

		for (i = 0; i < ITERS_PER_OP; ++i) {
			getnstimeofday(&tbefore);
			if (iommu_map(domain, iova, paddr, size,
				      IOMMU_READ | IOMMU_WRITE)) {
@@ -511,18 +516,24 @@ static void iommu_debug_device_profiling(struct seq_file *s, struct device *dev,
			}
			getnstimeofday(&tafter);
			diff = timespec_sub(tafter, tbefore);
		map_elapsed_us = div_s64(timespec_to_ns(&diff), 1000);
			map_elapsed_us += div_s64(timespec_to_ns(&diff), 1000);

			getnstimeofday(&tbefore);
			unmapped = iommu_unmap(domain, iova, size);
			if (unmapped != size) {
			seq_printf(s, "Only unmapped %zx instead of %zx\n",
				seq_printf(s,
					   "Only unmapped %zx instead of %zx\n",
					   unmapped, size);
				continue;
			}
			getnstimeofday(&tafter);
			diff = timespec_sub(tafter, tbefore);
		unmap_elapsed_us = div_s64(timespec_to_ns(&diff), 1000);
			unmap_elapsed_us += div_s64(timespec_to_ns(&diff),
						    1000);
		}

		map_elapsed_us /= ITERS_PER_OP;
		unmap_elapsed_us /= ITERS_PER_OP;

		seq_printf(s, "%8s %12lld us %9lld us\n", _size_to_string(size),
			map_elapsed_us, unmap_elapsed_us);
@@ -533,10 +544,11 @@ static void iommu_debug_device_profiling(struct seq_file *s, struct device *dev,
	for (sz = sizes; *sz; ++sz) {
		unsigned long size = *sz;
		size_t unmapped;
		s64 map_elapsed_us, unmap_elapsed_us;
		u64 map_elapsed_us = 0, unmap_elapsed_us = 0;
		struct timespec tbefore, tafter, diff;
		struct sg_table table;
		unsigned long chunk_size = SZ_4K;
		int i;

		if (iommu_debug_build_phoney_sg_table(dev, &table, size,
						      chunk_size)) {
@@ -545,6 +557,7 @@ static void iommu_debug_device_profiling(struct seq_file *s, struct device *dev,
			goto out_detach;
		}

		for (i = 0; i < ITERS_PER_OP; ++i) {
			getnstimeofday(&tbefore);
			if (iommu_map_sg(domain, iova, table.sgl, table.nents,
					 IOMMU_READ | IOMMU_WRITE) != size) {
@@ -553,18 +566,24 @@ static void iommu_debug_device_profiling(struct seq_file *s, struct device *dev,
			}
			getnstimeofday(&tafter);
			diff = timespec_sub(tafter, tbefore);
		map_elapsed_us = div_s64(timespec_to_ns(&diff), 1000);
			map_elapsed_us += div_s64(timespec_to_ns(&diff), 1000);

			getnstimeofday(&tbefore);
			unmapped = iommu_unmap(domain, iova, size);
			if (unmapped != size) {
			seq_printf(s, "Only unmapped %zx instead of %zx\n",
				seq_printf(s,
					   "Only unmapped %zx instead of %zx\n",
					   unmapped, size);
				goto next;
			}
			getnstimeofday(&tafter);
			diff = timespec_sub(tafter, tbefore);
		unmap_elapsed_us = div_s64(timespec_to_ns(&diff), 1000);
			unmap_elapsed_us += div_s64(timespec_to_ns(&diff),
						    1000);
		}

		map_elapsed_us /= ITERS_PER_OP;
		unmap_elapsed_us /= ITERS_PER_OP;

		seq_printf(s, "%8s %12lld us %9lld us\n", _size_to_string(size),
			map_elapsed_us, unmap_elapsed_us);