forked from luck/tmp_suning_uos_patched
iommu/vt-d: Add trace events for device dma map/unmap
This adds trace support for the Intel IOMMU driver. It also declares some events which could be used to trace the events when an IOVA is being mapped or unmapped in a domain. Cc: Ashok Raj <ashok.raj@intel.com> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Cc: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Joerg Roedel <jroedel@suse.de>
This commit is contained in:
parent
c5a5dc4cbb
commit
3b53034c26
|
@ -17,6 +17,7 @@ obj-$(CONFIG_ARM_SMMU) += arm-smmu.o
|
|||
obj-$(CONFIG_ARM_SMMU_V3) += arm-smmu-v3.o
|
||||
obj-$(CONFIG_DMAR_TABLE) += dmar.o
|
||||
obj-$(CONFIG_INTEL_IOMMU) += intel-iommu.o intel-pasid.o
|
||||
obj-$(CONFIG_INTEL_IOMMU) += intel-trace.o
|
||||
obj-$(CONFIG_INTEL_IOMMU_DEBUGFS) += intel-iommu-debugfs.o
|
||||
obj-$(CONFIG_INTEL_IOMMU_SVM) += intel-svm.o
|
||||
obj-$(CONFIG_IPMMU_VMSA) += ipmmu-vmsa.o
|
||||
|
|
|
@ -3512,6 +3512,9 @@ static dma_addr_t __intel_map_single(struct device *dev, phys_addr_t paddr,
|
|||
|
||||
start_paddr = (phys_addr_t)iova_pfn << PAGE_SHIFT;
|
||||
start_paddr += paddr & ~PAGE_MASK;
|
||||
|
||||
trace_map_single(dev, start_paddr, paddr, size << VTD_PAGE_SHIFT);
|
||||
|
||||
return start_paddr;
|
||||
|
||||
error:
|
||||
|
@ -3567,10 +3570,7 @@ static void intel_unmap(struct device *dev, dma_addr_t dev_addr, size_t size)
|
|||
if (dev_is_pci(dev))
|
||||
pdev = to_pci_dev(dev);
|
||||
|
||||
dev_dbg(dev, "Device unmapping: pfn %lx-%lx\n", start_pfn, last_pfn);
|
||||
|
||||
freelist = domain_unmap(domain, start_pfn, last_pfn);
|
||||
|
||||
if (intel_iommu_strict || (pdev && pdev->untrusted) ||
|
||||
!has_iova_flush_queue(&domain->iovad)) {
|
||||
iommu_flush_iotlb_psi(iommu, domain, start_pfn,
|
||||
|
@ -3586,6 +3586,8 @@ static void intel_unmap(struct device *dev, dma_addr_t dev_addr, size_t size)
|
|||
* cpu used up by the iotlb flush operation...
|
||||
*/
|
||||
}
|
||||
|
||||
trace_unmap_single(dev, dev_addr, size);
|
||||
}
|
||||
|
||||
static void intel_unmap_page(struct device *dev, dma_addr_t dev_addr,
|
||||
|
@ -3676,6 +3678,8 @@ static void intel_unmap_sg(struct device *dev, struct scatterlist *sglist,
|
|||
}
|
||||
|
||||
intel_unmap(dev, startaddr, nrpages << VTD_PAGE_SHIFT);
|
||||
|
||||
trace_unmap_sg(dev, startaddr, nrpages << VTD_PAGE_SHIFT);
|
||||
}
|
||||
|
||||
static int intel_map_sg(struct device *dev, struct scatterlist *sglist, int nelems,
|
||||
|
@ -3732,6 +3736,9 @@ static int intel_map_sg(struct device *dev, struct scatterlist *sglist, int nele
|
|||
return 0;
|
||||
}
|
||||
|
||||
trace_map_sg(dev, iova_pfn << PAGE_SHIFT,
|
||||
sg_phys(sglist), size << VTD_PAGE_SHIFT);
|
||||
|
||||
return nelems;
|
||||
}
|
||||
|
||||
|
|
14
drivers/iommu/intel-trace.c
Normal file
14
drivers/iommu/intel-trace.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Intel IOMMU trace support
|
||||
*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* Author: Lu Baolu <baolu.lu@linux.intel.com>
|
||||
*/
|
||||
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#define CREATE_TRACE_POINTS
|
||||
#include <trace/events/intel_iommu.h>
|
106
include/trace/events/intel_iommu.h
Normal file
106
include/trace/events/intel_iommu.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/*
|
||||
* Intel IOMMU trace support
|
||||
*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
*
|
||||
* Author: Lu Baolu <baolu.lu@linux.intel.com>
|
||||
*/
|
||||
#ifdef CONFIG_INTEL_IOMMU
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM intel_iommu
|
||||
|
||||
#if !defined(_TRACE_INTEL_IOMMU_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_INTEL_IOMMU_H
|
||||
|
||||
#include <linux/tracepoint.h>
|
||||
#include <linux/intel-iommu.h>
|
||||
|
||||
DECLARE_EVENT_CLASS(dma_map,
|
||||
TP_PROTO(struct device *dev, dma_addr_t dev_addr, phys_addr_t phys_addr,
|
||||
size_t size),
|
||||
|
||||
TP_ARGS(dev, dev_addr, phys_addr, size),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__string(dev_name, dev_name(dev))
|
||||
__field(dma_addr_t, dev_addr)
|
||||
__field(phys_addr_t, phys_addr)
|
||||
__field(size_t, size)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__assign_str(dev_name, dev_name(dev));
|
||||
__entry->dev_addr = dev_addr;
|
||||
__entry->phys_addr = phys_addr;
|
||||
__entry->size = size;
|
||||
),
|
||||
|
||||
TP_printk("dev=%s dev_addr=0x%llx phys_addr=0x%llx size=%zu",
|
||||
__get_str(dev_name),
|
||||
(unsigned long long)__entry->dev_addr,
|
||||
(unsigned long long)__entry->phys_addr,
|
||||
__entry->size)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dma_map, map_single,
|
||||
TP_PROTO(struct device *dev, dma_addr_t dev_addr, phys_addr_t phys_addr,
|
||||
size_t size),
|
||||
TP_ARGS(dev, dev_addr, phys_addr, size)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dma_map, map_sg,
|
||||
TP_PROTO(struct device *dev, dma_addr_t dev_addr, phys_addr_t phys_addr,
|
||||
size_t size),
|
||||
TP_ARGS(dev, dev_addr, phys_addr, size)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dma_map, bounce_map_single,
|
||||
TP_PROTO(struct device *dev, dma_addr_t dev_addr, phys_addr_t phys_addr,
|
||||
size_t size),
|
||||
TP_ARGS(dev, dev_addr, phys_addr, size)
|
||||
);
|
||||
|
||||
DECLARE_EVENT_CLASS(dma_unmap,
|
||||
TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size),
|
||||
|
||||
TP_ARGS(dev, dev_addr, size),
|
||||
|
||||
TP_STRUCT__entry(
|
||||
__string(dev_name, dev_name(dev))
|
||||
__field(dma_addr_t, dev_addr)
|
||||
__field(size_t, size)
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__assign_str(dev_name, dev_name(dev));
|
||||
__entry->dev_addr = dev_addr;
|
||||
__entry->size = size;
|
||||
),
|
||||
|
||||
TP_printk("dev=%s dev_addr=0x%llx size=%zu",
|
||||
__get_str(dev_name),
|
||||
(unsigned long long)__entry->dev_addr,
|
||||
__entry->size)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dma_unmap, unmap_single,
|
||||
TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size),
|
||||
TP_ARGS(dev, dev_addr, size)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dma_unmap, unmap_sg,
|
||||
TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size),
|
||||
TP_ARGS(dev, dev_addr, size)
|
||||
);
|
||||
|
||||
DEFINE_EVENT(dma_unmap, bounce_unmap_single,
|
||||
TP_PROTO(struct device *dev, dma_addr_t dev_addr, size_t size),
|
||||
TP_ARGS(dev, dev_addr, size)
|
||||
);
|
||||
|
||||
#endif /* _TRACE_INTEL_IOMMU_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
#endif /* CONFIG_INTEL_IOMMU */
|
Loading…
Reference in New Issue
Block a user