Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp448026pxb; Tue, 9 Feb 2021 04:39:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJw55F/4xAqXjE1lFDyRlH4bWE82NZDu1R6XhGVelECq6UhDp+CaxCkq12qODJvKKSNsHbBL X-Received: by 2002:a17:906:c455:: with SMTP id ck21mr22737520ejb.354.1612874385095; Tue, 09 Feb 2021 04:39:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612874385; cv=none; d=google.com; s=arc-20160816; b=cSSPSajrqr2ferY9sbzVwi438st9VorBfqF2M3IYfxc1YMsSHNEtA/uTbJyRhJktxG +EUGCAp2JttPqtvLo255XacHjFqecYztzdv5PRB/6evevCx9gMI6+Nw2+VomD8Yqk7LB ILpSr+TFCrM990YvOTj7DWUTtH5kE/QpLuRBUbGXGqNuTNbRQlEEM0W2lYH5Mtq0BFiX wzeTCiaNPNN2LVHrsgmtQdgQzHQnzRaGN2OKgXKFPLSjHuTf3P7O//FFDSWIe+lyVvvM 5QEMq+bz51FzmVUk1kN2Hp6QnVo7wIpmtAtgCqMQQaOkHkiH8JfGKsrKxXhGTDGrsklt LTIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dmarc-filter:sender :dkim-signature; bh=XA1/wY6qzZKfm1+w+nC9ectbnZF3AqmFvZoAzmlwiLM=; b=bsfG96t5NpV4b68nivZB4iHEeM9hdOLskS7ZYfM5NVz+M70UXitMs9S7zPEs+09g+Y qF6E3ejPe3iRC4Bp1OWaE2cPhZo2028N/mzRFchBaPzJhZXNn9Vln50aIiKMrNc4EOZM BcpcHi18i2RFJf635RU/bsAMRC65X/tIHnet5jpmho8StuD0SrXuuh+TwldFHapqGNxr Hmv0fNvHd6uK+imMHrliwJb/kG8qQnaggGZibHlA7Bx5udX7F1A5kJersNqBJSCnB1Fe 8qFvo2wSWyppUl7XXZLuCGtFo3gSqatlgKQC5Kud/Dmh5gPZmdsjIdSFeKmABckh51aA JQtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=SSYjiiyU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr1si13415082ejc.438.2021.02.09.04.39.20; Tue, 09 Feb 2021 04:39:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=SSYjiiyU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230050AbhBIMhb (ORCPT + 99 others); Tue, 9 Feb 2021 07:37:31 -0500 Received: from mail29.static.mailgun.info ([104.130.122.29]:60265 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230054AbhBIMh3 (ORCPT ); Tue, 9 Feb 2021 07:37:29 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1612874223; h=Content-Transfer-Encoding: MIME-Version: Message-Id: Date: Subject: Cc: To: From: Sender; bh=XA1/wY6qzZKfm1+w+nC9ectbnZF3AqmFvZoAzmlwiLM=; b=SSYjiiyU3K407xp2tGanf5p++FyF4xGbvVneDRf2hyPziK53RYTjlMYM/1AggBRy2pdVYg0u EHOzUPQaFtjjDZ1PMDOGJ/8AJRzBIfLn2QOLVpinHLVlxpt360WEHqI8HcVaOlYpWP+dSZzX SKeRtm0pJlIJVQfLH2uclSQyhXI= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-east-1.postgun.com with SMTP id 602281d381f6c45dce7a9504 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 09 Feb 2021 12:36:35 GMT Sender: saiprakash.ranjan=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id D018FC43462; Tue, 9 Feb 2021 12:36:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from blr-ubuntu-253.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: saiprakash.ranjan) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4CD79C433C6; Tue, 9 Feb 2021 12:36:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4CD79C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=saiprakash.ranjan@codeaurora.org From: Sai Prakash Ranjan To: Will Deacon , Robin Murphy , Joerg Roedel Cc: iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Sai Prakash Ranjan Subject: [PATCH] iommu: Add device name to iommu map/unmap trace events Date: Tue, 9 Feb 2021 18:06:20 +0530 Message-Id: <20210209123620.19993-1-saiprakash.ranjan@codeaurora.org> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org IOMMU map/unmap traces become hard to decode i.e., it becomes hard to associate the map/unmap events with the particular device from the iova/paddr/size parameters alone when there are multiple devices attached. So it is useful to add the device name to iommu trace events which can be used to filter out map/unmap traces for a particular device when we are debugging iommu faults such as context faults where we are interested with the map/unmap traces for a specific device. Before: map: IOMMU: iova=0x0000000ffff36000 paddr=0x00000001164d8000 size=4096 unmap: IOMMU: iova=0x0000000ffff36000 size=4096 unmapped_size=4096 After: map: IOMMU: dev=1d84000.ufshc iova=0x0000000fffa88000 paddr=0x00000001063db000 size=4096 unmap: IOMMU: dev=1d84000.ufshc iova=0x0000000fffa88000 size=4096 unmapped_size=4096 Signed-off-by: Sai Prakash Ranjan --- drivers/iommu/iommu.c | 8 +++++--- include/linux/iommu.h | 1 + include/trace/events/iommu.h | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index d0b0a15dba84..37081b745f38 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1947,8 +1947,10 @@ static int __iommu_attach_device(struct iommu_domain *domain, return -ENODEV; ret = domain->ops->attach_dev(domain, dev); - if (!ret) + if (!ret) { trace_attach_device_to_domain(dev); + strscpy(domain->dev_name, dev_name(dev), sizeof(domain->dev_name)); + } return ret; } @@ -2440,7 +2442,7 @@ static int __iommu_map(struct iommu_domain *domain, unsigned long iova, if (ret) iommu_unmap(domain, orig_iova, orig_size - size); else - trace_map(orig_iova, orig_paddr, orig_size); + trace_map(orig_iova, orig_paddr, orig_size, domain->dev_name); return ret; } @@ -2523,7 +2525,7 @@ static size_t __iommu_unmap(struct iommu_domain *domain, unmapped += unmapped_page; } - trace_unmap(orig_iova, size, unmapped); + trace_unmap(orig_iova, size, unmapped, domain->dev_name); return unmapped; } diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 5e7fe519430a..6064187d9bb6 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -87,6 +87,7 @@ struct iommu_domain { void *handler_token; struct iommu_domain_geometry geometry; void *iova_cookie; + char dev_name[32]; }; enum iommu_cap { diff --git a/include/trace/events/iommu.h b/include/trace/events/iommu.h index 72b4582322ff..44e48fb8b677 100644 --- a/include/trace/events/iommu.h +++ b/include/trace/events/iommu.h @@ -85,47 +85,51 @@ DEFINE_EVENT(iommu_device_event, detach_device_from_domain, TRACE_EVENT(map, - TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size), + TP_PROTO(unsigned long iova, phys_addr_t paddr, size_t size, const char *dev_name), - TP_ARGS(iova, paddr, size), + TP_ARGS(iova, paddr, size, dev_name), TP_STRUCT__entry( __field(u64, iova) __field(u64, paddr) __field(size_t, size) + __string(dev_name, dev_name) ), TP_fast_assign( __entry->iova = iova; __entry->paddr = paddr; __entry->size = size; + __assign_str(dev_name, dev_name); ), - TP_printk("IOMMU: iova=0x%016llx paddr=0x%016llx size=%zu", - __entry->iova, __entry->paddr, __entry->size + TP_printk("IOMMU: dev=%s iova=0x%016llx paddr=0x%016llx size=%zu", + __get_str(dev_name), __entry->iova, __entry->paddr, __entry->size ) ); TRACE_EVENT(unmap, - TP_PROTO(unsigned long iova, size_t size, size_t unmapped_size), + TP_PROTO(unsigned long iova, size_t size, size_t unmapped_size, const char *dev_name), - TP_ARGS(iova, size, unmapped_size), + TP_ARGS(iova, size, unmapped_size, dev_name), TP_STRUCT__entry( __field(u64, iova) __field(size_t, size) __field(size_t, unmapped_size) + __string(dev_name, dev_name) ), TP_fast_assign( __entry->iova = iova; __entry->size = size; __entry->unmapped_size = unmapped_size; + __assign_str(dev_name, dev_name); ), - TP_printk("IOMMU: iova=0x%016llx size=%zu unmapped_size=%zu", - __entry->iova, __entry->size, __entry->unmapped_size + TP_printk("IOMMU: dev=%s iova=0x%016llx size=%zu unmapped_size=%zu", + __get_str(dev_name), __entry->iova, __entry->size, __entry->unmapped_size ) ); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation