Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3584367ybi; Sun, 2 Jun 2019 18:26:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6gmLkjuSzn3LRawpJPPV3+uIQaD8lLKFYjOZhzcuL0xTXoL03LQSsyM+Oh1+N+sCjfmOR X-Received: by 2002:a17:90a:8982:: with SMTP id v2mr26015730pjn.138.1559525164951; Sun, 02 Jun 2019 18:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559525164; cv=none; d=google.com; s=arc-20160816; b=E9whsPz+cOxNf3hkDynHFP+hRCR+3DYVZh2SUiX65gGx76SmrHfBRzoBkvImqVtPUI mK4+2VUTWRjG3+mjNclYU7MaZmnXkg0kr5bl3OtFva98+8Vgqf5tIYH3ISnut9nVLy5Y 6+WX/tYHpHNwCFIOwHRQyExG1sNKGEA2DRgtAhBDVK+6Aqq7zHho1PVkAlKWtL0kD9Nb MKXIn+qT3uFB+2bgSHyebxLevuxYpwI0nMu2w+//IHB/6KpZKwmWgtFKYar+rmqHoVmN u+MmmC6c1vg7Mw96Cjr9hQSYZ4onP7PAqRwX+QeYiLJTg/OewCftvM1I5t1bXAXz80SL kNWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=aZBRW3PTOAn/fQdUBmLV3ACroGVCbJDBEcu57pBbIEM=; b=Zw9Q9xAC+W2pC0+6qypgoRT9XwnztuYTMo8T39uxF8DQUmBt3P32RL92KH1n1BBSN8 CBkcIHQRNWB8QV+BXjISmXQI5UduzcWiuPV7eOB3jx5faei359KuOL80IdbE2dCxx0NN hdpeDLro2Z5fIp7z0v/8u1yICWo5uoOMZ9TmbjzwJcmJ1884IMQ/F1HNCed+hU6yC9XS gpov9GJkcYBGMf1x++/vSLifUacH+2WikEUkT7pMOyt5yPRgKgmkGf63nvojkXb5GFZp AYFiaQ2UG+JwLHS+LPAWe0Aa6yi7ro1oQLreNTnHBGJTlJDypByafAT3cXUmdMEQsDAr 5rFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f63si19106709plf.224.2019.06.02.18.25.49; Sun, 02 Jun 2019 18:26:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727111AbfFCBYG (ORCPT + 99 others); Sun, 2 Jun 2019 21:24:06 -0400 Received: from mga17.intel.com ([192.55.52.151]:20792 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbfFCBYE (ORCPT ); Sun, 2 Jun 2019 21:24:04 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jun 2019 18:24:03 -0700 X-ExtLoop1: 1 Received: from allen-box.sh.intel.com ([10.239.159.136]) by FMSMGA003.fm.intel.com with ESMTP; 02 Jun 2019 18:24:00 -0700 From: Lu Baolu To: David Woodhouse , Joerg Roedel , Bjorn Helgaas , Christoph Hellwig Cc: ashok.raj@intel.com, jacob.jun.pan@intel.com, alan.cox@intel.com, kevin.tian@intel.com, mika.westerberg@linux.intel.com, Ingo Molnar , Greg Kroah-Hartman , pengfei.xu@intel.com, Konrad Rzeszutek Wilk , Marek Szyprowski , Robin Murphy , Jonathan Corbet , Boris Ostrovsky , Juergen Gross , Stefano Stabellini , Steven Rostedt , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Lu Baolu , Jacob Pan Subject: [PATCH v4 7/9] iommu/vt-d: Add trace events for domain map/unmap Date: Mon, 3 Jun 2019 09:16:18 +0800 Message-Id: <20190603011620.31999-8-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603011620.31999-1-baolu.lu@linux.intel.com> References: <20190603011620.31999-1-baolu.lu@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Jacob Pan Cc: Kevin Tian Signed-off-by: Mika Westerberg Signed-off-by: Lu Baolu --- drivers/iommu/Makefile | 1 + drivers/iommu/intel-trace.c | 14 +++ include/trace/events/intel_iommu.h | 132 +++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 drivers/iommu/intel-trace.c create mode 100644 include/trace/events/intel_iommu.h diff --git a/drivers/iommu/Makefile b/drivers/iommu/Makefile index 8c71a15e986b..8b5fb8051281 100644 --- a/drivers/iommu/Makefile +++ b/drivers/iommu/Makefile @@ -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 diff --git a/drivers/iommu/intel-trace.c b/drivers/iommu/intel-trace.c new file mode 100644 index 000000000000..bfb6a6e37a88 --- /dev/null +++ b/drivers/iommu/intel-trace.c @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Intel IOMMU trace support + * + * Copyright (C) 2019 Intel Corporation + * + * Author: Lu Baolu + */ + +#include +#include + +#define CREATE_TRACE_POINTS +#include diff --git a/include/trace/events/intel_iommu.h b/include/trace/events/intel_iommu.h new file mode 100644 index 000000000000..49ca57a90079 --- /dev/null +++ b/include/trace/events/intel_iommu.h @@ -0,0 +1,132 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Intel IOMMU trace support + * + * Copyright (C) 2019 Intel Corporation + * + * Author: Lu Baolu + */ +#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 +#include + +TRACE_EVENT(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), + + 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) +); + +TRACE_EVENT(bounce_unmap_single, + 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) +); + +TRACE_EVENT(bounce_map_sg, + TP_PROTO(struct device *dev, unsigned int i, unsigned int nelems, + dma_addr_t dev_addr, phys_addr_t phys_addr, size_t size), + + TP_ARGS(dev, i, nelems, dev_addr, phys_addr, size), + + TP_STRUCT__entry( + __string(dev_name, dev_name(dev)) + __field(unsigned int, i) + __field(unsigned int, last) + __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->i = i; + __entry->last = nelems - 1; + __entry->dev_addr = dev_addr; + __entry->phys_addr = phys_addr; + __entry->size = size; + ), + + TP_printk("dev=%s elem=%u/%u dev_addr=0x%llx phys_addr=0x%llx size=%zu", + __get_str(dev_name), __entry->i, __entry->last, + (unsigned long long)__entry->dev_addr, + (unsigned long long)__entry->phys_addr, + __entry->size) +); + +TRACE_EVENT(bounce_unmap_sg, + TP_PROTO(struct device *dev, unsigned int i, unsigned int nelems, + dma_addr_t dev_addr, phys_addr_t phys_addr, size_t size), + + TP_ARGS(dev, i, nelems, dev_addr, phys_addr, size), + + TP_STRUCT__entry( + __string(dev_name, dev_name(dev)) + __field(unsigned int, i) + __field(unsigned int, last) + __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->i = i; + __entry->last = nelems - 1; + __entry->dev_addr = dev_addr; + __entry->phys_addr = phys_addr; + __entry->size = size; + ), + + TP_printk("dev=%s elem=%u/%u dev_addr=0x%llx phys_addr=0x%llx size=%zu", + __get_str(dev_name), __entry->i, __entry->last, + (unsigned long long)__entry->dev_addr, + (unsigned long long)__entry->phys_addr, + __entry->size) +); +#endif /* _TRACE_INTEL_IOMMU_H */ + +/* This part must be outside protection */ +#include -- 2.17.1