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

Commit 129a6739 authored by Liam Mark's avatar Liam Mark
Browse files

iommu: Expand ftrace events



Identify the domain associated with each map or unmap event for
convienence. Additionally, add a map_sg() event.

Change-Id: I9ddf241ffa6cf519f6abece7b0820640f5ce1975
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent ea1cded2
Loading
Loading
Loading
Loading
+21 −2
Original line number Original line Diff line number Diff line
@@ -598,6 +598,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev)
	if (ret)
	if (ret)
		goto err_put_group;
		goto err_put_group;



	/* Notify any listeners about change to group. */
	/* Notify any listeners about change to group. */
	blocking_notifier_call_chain(&group->notifier,
	blocking_notifier_call_chain(&group->notifier,
				     IOMMU_GROUP_NOTIFY_ADD_DEVICE, dev);
				     IOMMU_GROUP_NOTIFY_ADD_DEVICE, dev);
@@ -1267,6 +1268,7 @@ static struct iommu_domain *__iommu_domain_alloc(struct bus_type *bus,
	/* Assume all sizes by default; the driver may override this later */
	/* Assume all sizes by default; the driver may override this later */
	domain->pgsize_bitmap  = bus->iommu_ops->pgsize_bitmap;
	domain->pgsize_bitmap  = bus->iommu_ops->pgsize_bitmap;
	domain->is_debug_domain = false;
	domain->is_debug_domain = false;
	memset(domain->name, 0, IOMMU_DOMAIN_NAME_LEN);


	return domain;
	return domain;
}
}
@@ -1299,6 +1301,11 @@ static int __iommu_attach_device(struct iommu_domain *domain,
	if (!ret) {
	if (!ret) {
		trace_attach_device_to_domain(dev);
		trace_attach_device_to_domain(dev);
		iommu_debug_attach_device(domain, dev);
		iommu_debug_attach_device(domain, dev);

		if (!strnlen(domain->name, IOMMU_DOMAIN_NAME_LEN)) {
			strlcpy(domain->name, dev_name(dev),
				IOMMU_DOMAIN_NAME_LEN);
		}
	}
	}
	return ret;
	return ret;
}
}
@@ -1588,7 +1595,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
	if (ret)
	if (ret)
		iommu_unmap(domain, orig_iova, orig_size - size);
		iommu_unmap(domain, orig_iova, orig_size - size);
	else
	else
		trace_map(orig_iova, orig_paddr, orig_size);
		trace_map(domain, orig_iova, orig_paddr, orig_size, prot);


	return ret;
	return ret;
}
}
@@ -1650,7 +1657,7 @@ static size_t __iommu_unmap(struct iommu_domain *domain,
	if (sync && ops->iotlb_sync)
	if (sync && ops->iotlb_sync)
		ops->iotlb_sync(domain);
		ops->iotlb_sync(domain);


	trace_unmap(orig_iova, size, unmapped);
	trace_unmap(domain, orig_iova, size, unmapped);
	return unmapped;
	return unmapped;
}
}


@@ -1668,6 +1675,18 @@ size_t iommu_unmap_fast(struct iommu_domain *domain,
}
}
EXPORT_SYMBOL_GPL(iommu_unmap_fast);
EXPORT_SYMBOL_GPL(iommu_unmap_fast);


size_t iommu_map_sg(struct iommu_domain *domain,
				  unsigned long iova, struct scatterlist *sg,
				  unsigned int nents, int prot)
{
	size_t mapped;

	mapped = domain->ops->map_sg(domain, iova, sg, nents, prot);
	trace_map_sg(domain, iova, mapped, prot);
	return mapped;
}
EXPORT_SYMBOL(iommu_map_sg);

size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
			 struct scatterlist *sg, unsigned int nents, int prot)
			 struct scatterlist *sg, unsigned int nents, int prot)
{
{
+6 −7
Original line number Original line Diff line number Diff line
@@ -101,6 +101,8 @@ struct iommu_pgtbl_info {
#define IOMMU_DOMAIN_DMA	(__IOMMU_DOMAIN_PAGING |	\
#define IOMMU_DOMAIN_DMA	(__IOMMU_DOMAIN_PAGING |	\
				 __IOMMU_DOMAIN_DMA_API)
				 __IOMMU_DOMAIN_DMA_API)



#define IOMMU_DOMAIN_NAME_LEN 32
struct iommu_domain {
struct iommu_domain {
	unsigned type;
	unsigned type;
	const struct iommu_ops *ops;
	const struct iommu_ops *ops;
@@ -110,6 +112,7 @@ struct iommu_domain {
	struct iommu_domain_geometry geometry;
	struct iommu_domain_geometry geometry;
	void *iova_cookie;
	void *iova_cookie;
	bool is_debug_domain;
	bool is_debug_domain;
	char name[IOMMU_DOMAIN_NAME_LEN];
};
};


enum iommu_cap {
enum iommu_cap {
@@ -363,6 +366,9 @@ extern size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova,
			  size_t size);
			  size_t size);
extern size_t iommu_unmap_fast(struct iommu_domain *domain,
extern size_t iommu_unmap_fast(struct iommu_domain *domain,
			       unsigned long iova, size_t size);
			       unsigned long iova, size_t size);
extern size_t iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
				struct scatterlist *sg, unsigned int nents,
				int prot);
extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
extern size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
				struct scatterlist *sg,unsigned int nents,
				struct scatterlist *sg,unsigned int nents,
				int prot);
				int prot);
@@ -445,13 +451,6 @@ static inline void iommu_tlb_sync(struct iommu_domain *domain)
		domain->ops->iotlb_sync(domain);
		domain->ops->iotlb_sync(domain);
}
}


static inline size_t iommu_map_sg(struct iommu_domain *domain,
				  unsigned long iova, struct scatterlist *sg,
				  unsigned int nents, int prot)
{
	return domain->ops->map_sg(domain, iova, sg, nents, prot);
}

extern void iommu_trigger_fault(struct iommu_domain *domain,
extern void iommu_trigger_fault(struct iommu_domain *domain,
				unsigned long flags);
				unsigned long flags);


+47 −8
Original line number Original line Diff line number Diff line
@@ -12,8 +12,10 @@
#define _TRACE_IOMMU_H
#define _TRACE_IOMMU_H


#include <linux/tracepoint.h>
#include <linux/tracepoint.h>
#include <linux/iommu.h>


struct device;
struct device;
struct iommu_domain;


DECLARE_EVENT_CLASS(iommu_group_event,
DECLARE_EVENT_CLASS(iommu_group_event,


@@ -85,47 +87,84 @@ DEFINE_EVENT(iommu_device_event, detach_device_from_domain,


TRACE_EVENT(map,
TRACE_EVENT(map,


	TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size),
	TP_PROTO(struct iommu_domain *domain, unsigned long iova,
		 phys_addr_t paddr, size_t size, int prot),


	TP_ARGS(iova, paddr, size),
	TP_ARGS(domain, iova, paddr, size, prot),


	TP_STRUCT__entry(
	TP_STRUCT__entry(
		__string(name, domain->name)
		__field(u64, iova)
		__field(u64, iova)
		__field(u64, paddr)
		__field(u64, paddr)
		__field(size_t, size)
		__field(size_t, size)
		__field(int, prot)
	),
	),


	TP_fast_assign(
	TP_fast_assign(
		__assign_str(name, domain->name);
		__entry->iova = iova;
		__entry->iova = iova;
		__entry->paddr = paddr;
		__entry->paddr = paddr;
		__entry->size = size;
		__entry->size = size;
		__entry->prot = prot;
	),
	),


	TP_printk("IOMMU: iova=0x%016llx paddr=0x%016llx size=%zu",
	TP_printk("IOMMU:%s iova=0x%016llx paddr=0x%016llx size=0x%zx prot=0x%x",
			__entry->iova, __entry->paddr, __entry->size
			__get_str(name), __entry->iova, __entry->paddr,
			__entry->size, __entry->prot
	)
	)
);
);


TRACE_EVENT(unmap,
TRACE_EVENT(unmap,


	TP_PROTO(unsigned long iova, size_t size, size_t unmapped_size),
	TP_PROTO(struct iommu_domain *domain, unsigned long iova, size_t size,
			size_t unmapped_size),


	TP_ARGS(iova, size, unmapped_size),
	TP_ARGS(domain, iova, size, unmapped_size),


	TP_STRUCT__entry(
	TP_STRUCT__entry(
		__string(name, domain->name)
		__field(u64, iova)
		__field(u64, iova)
		__field(size_t, size)
		__field(size_t, size)
		__field(size_t, unmapped_size)
		__field(size_t, unmapped_size)
	),
	),


	TP_fast_assign(
	TP_fast_assign(
		__assign_str(name, domain->name);
		__entry->iova = iova;
		__entry->iova = iova;
		__entry->size = size;
		__entry->size = size;
		__entry->unmapped_size = unmapped_size;
		__entry->unmapped_size = unmapped_size;
	),
	),


	TP_printk("IOMMU: iova=0x%016llx size=%zu unmapped_size=%zu",
	TP_printk("IOMMU:%s iova=0x%016llx size=0x%zx unmapped_size=0x%zx",
			__entry->iova, __entry->size, __entry->unmapped_size
			__get_str(name), __entry->iova, __entry->size,
			__entry->unmapped_size
	)
);

TRACE_EVENT(map_sg,

	TP_PROTO(struct iommu_domain *domain, unsigned long iova, size_t size,
		int prot),

	TP_ARGS(domain, iova, size, prot),

	TP_STRUCT__entry(
		__string(name, domain->name)
		__field(u64, iova)
		__field(size_t, size)
		__field(int, prot)
	),

	TP_fast_assign(
		__assign_str(name, domain->name);
		__entry->iova = iova;
		__entry->size = size;
		__entry->prot = prot;
	),

	TP_printk("IOMMU:%s iova=0x%016llx size=0x%zx prot=0x%x",
			__get_str(name), __entry->iova, __entry->size,
			__entry->prot
	)
	)
);
);