From patchwork Fri Oct 27 03:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 831032 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yNTBm213vz9t30 for ; Fri, 27 Oct 2017 14:00:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751399AbdJ0DAO (ORCPT ); Thu, 26 Oct 2017 23:00:14 -0400 Received: from ozlabs.ru ([107.173.13.209]:51116 "EHLO ozlabs.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751263AbdJ0DAO (ORCPT ); Thu, 26 Oct 2017 23:00:14 -0400 Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 611FB3A60125; Thu, 26 Oct 2017 22:59:05 -0400 (EDT) From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Cc: Alexey Kardashevskiy , Alex Williamson , David Gibson , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH kernel] vfio/spapr: Add trace points for map/unmap Date: Fri, 27 Oct 2017 14:00:08 +1100 Message-Id: <20171027030008.17200-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org This adds trace_map/trace_unmap tracepoints to spapr driver. Type1 already uses these via the IOMMU API (iommu_map/__iommu_unmap). Signed-off-by: Alexey Kardashevskiy --- Example: qemu-system-ppc-8655 [096] 724.662740: unmap: IOMMU: iova=0x000000003ffff000 size=4096 unmapped_size=4096 qemu-system-ppc-8656 [104] 724.970912: map: IOMMU: iova=0x0800000000000000 paddr=0x00007ffef7ff0000 size=65536 --- drivers/vfio/vfio_iommu_spapr_tce.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index 63112c36ab2d..4531486c77c6 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -502,17 +503,19 @@ static int tce_iommu_clear(struct tce_container *container, struct iommu_table *tbl, unsigned long entry, unsigned long pages) { - unsigned long oldhpa; + unsigned long oldhpa, unmapped, firstentry = entry, totalpages = pages; long ret; enum dma_data_direction direction; - for ( ; pages; --pages, ++entry) { + for (unmapped = 0; pages; --pages, ++entry) { direction = DMA_NONE; oldhpa = 0; ret = iommu_tce_xchg(tbl, entry, &oldhpa, &direction); if (ret) continue; + ++unmapped; + if (direction == DMA_NONE) continue; @@ -523,6 +526,9 @@ static int tce_iommu_clear(struct tce_container *container, tce_iommu_unuse_page(container, oldhpa); } + trace_unmap(firstentry << tbl->it_page_shift, + totalpages << tbl->it_page_shift, + unmapped << tbl->it_page_shift); return 0; } @@ -965,6 +971,8 @@ static long tce_iommu_ioctl(void *iommu_data, direction); iommu_flush_tce(tbl); + if (!ret) + trace_map(param.iova, param.vaddr, param.size); return ret; }