Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp525067pxb; Wed, 27 Jan 2021 13:54:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKoyAf6HTRnIniRbe5rf77agIIWAuMPsh8/Tcz6VUwLJGpMTFTwSZAjbwRum/8LF6qUSTr X-Received: by 2002:a50:fd19:: with SMTP id i25mr10950481eds.386.1611784458021; Wed, 27 Jan 2021 13:54:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611784458; cv=none; d=google.com; s=arc-20160816; b=BX4YAcjn2LtB1f2N87htl/5U3bGkkvPVNCu1z5AGY0Qo6D4BSj1mwUzu6F9N5Q0iTg +lNOlPIGoGuZPXW5QK7w8Nv28JVOAvuJb+MMd2H8fGDTUo9ibm4bV0C6MY4y49L+410b ROwsWi5aj0Iq+kTHEkhkVlNUkYlZgMJitgkx2O+cNrpEZetedDap0qM66Sps6MCTyUQK 5LkgXF7BgTettDW4FkdAG7+2QrWqLxxqYve1f2IIGwMYp7yk0/H15fDwRH2UdzJS0y7f OZxNeSwZfB3IrFL6WGM/AhAEtFh2CG9PFmI0Pb7PT+puLArCOJJKyiBpeheuDRBpf4Ou LwbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=A97+0pRF4waUh0u/KngVuNfeIBap+BkcrQ/Ysu5laUM=; b=SKkCEQist98tKXEQebeAeD5sTH5WtyiC4hG4a01sn5r2VLyZw9RCdmF3A6TACbGjrg x9ghwf07POKk61qP+GmNNhGivr05IdmR7AJBWi8hyt+rs1t1meSLRfH+2EbY7aGhvk8C oQRjzrpJiJ9+2cVwgVRUAFW1G25ViF2B4GwjJ4MYC96jz7wiippfWxOPIOxIiOSNtY29 LhExnYhy2na7ftWPCx/FsxUkPqsucseD7wUAc6r74tvbWWHqAFc4Lv+DJRF1AC1hNDbM kfh7QYCRYirMuqFqBTtdJP4aqHSgG03GlSUJc209mMLLtr+cUIvEiuKhS4I85zNXECy6 LShA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si1785626edc.60.2021.01.27.13.53.51; Wed, 27 Jan 2021 13:54:18 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235593AbhA0Jv0 (ORCPT + 99 others); Wed, 27 Jan 2021 04:51:26 -0500 Received: from foss.arm.com ([217.140.110.172]:32952 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232573AbhA0I7I (ORCPT ); Wed, 27 Jan 2021 03:59:08 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 888D514BF; Wed, 27 Jan 2021 00:55:49 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.91.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DECB13F66B; Wed, 27 Jan 2021 00:55:46 -0800 (PST) From: Anshuman Khandual To: linux-arm-kernel@lists.infradead.org, coresight@lists.linaro.org Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, mike.leach@linaro.org, lcherian@marvell.com, linux-kernel@vger.kernel.org, Anshuman Khandual Subject: [PATCH V3 08/14] coresight: core: Add support for dedicated percpu sinks Date: Wed, 27 Jan 2021 14:25:32 +0530 Message-Id: <1611737738-1493-9-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1611737738-1493-1-git-send-email-anshuman.khandual@arm.com> References: <1611737738-1493-1-git-send-email-anshuman.khandual@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for dedicated sinks that are bound to individual CPUs. (e.g, TRBE). To allow quicker access to the sink for a given CPU bound source, keep a percpu array of the sink devices. Also, add support for building a path to the CPU local sink from the ETM. This adds a new percpu sink type CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM. This new sink type is exclusively available and can only work with percpu source type device CORESIGHT_DEV_SUBTYPE_SOURCE_PERCPU_PROC. This defines a percpu structure that accommodates a single coresight_device which can be used to store an initialized instance from a sink driver. As these sinks are exclusively linked and dependent on corresponding percpu sources devices, they should also be the default sink device during a perf session. Outwards device connections are scanned while establishing paths between a source and a sink device. But such connections are not present for certain percpu source and sink devices which are exclusively linked and dependent. Build the path directly and skip connection scanning for such devices. Cc: Mathieu Poirier Cc: Mike Leach Cc: Suzuki K Poulose Signed-off-by: Anshuman Khandual --- Changes in V3: - Updated coresight_find_default_sink() drivers/hwtracing/coresight/coresight-core.c | 16 ++++++++++++++-- include/linux/coresight.h | 12 ++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 0062c89..4795e28 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -23,6 +23,7 @@ #include "coresight-priv.h" static DEFINE_MUTEX(coresight_mutex); +DEFINE_PER_CPU(struct coresight_device *, csdev_sink); /** * struct coresight_node - elements of a path, from source to sink @@ -784,6 +785,13 @@ static int _coresight_build_path(struct coresight_device *csdev, if (csdev == sink) goto out; + if (coresight_is_percpu_source(csdev) && coresight_is_percpu_sink(sink) && + sink == per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev))) { + _coresight_build_path(sink, sink, path); + found = true; + goto out; + } + /* Not a sink - recursively explore each port found on this element */ for (i = 0; i < csdev->pdata->nr_outport; i++) { struct coresight_device *child_dev; @@ -999,8 +1007,12 @@ coresight_find_default_sink(struct coresight_device *csdev) int depth = 0; /* look for a default sink if we have not found for this device */ - if (!csdev->def_sink) - csdev->def_sink = coresight_find_sink(csdev, &depth); + if (!csdev->def_sink) { + if (coresight_is_percpu_source(csdev)) + csdev->def_sink = per_cpu(csdev_sink, source_ops(csdev)->cpu_id(csdev)); + if (!csdev->def_sink) + csdev->def_sink = coresight_find_sink(csdev, &depth); + } return csdev->def_sink; } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 976ec26..bc3a5ca 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -50,6 +50,7 @@ enum coresight_dev_subtype_sink { CORESIGHT_DEV_SUBTYPE_SINK_PORT, CORESIGHT_DEV_SUBTYPE_SINK_BUFFER, CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM, + CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM, }; enum coresight_dev_subtype_link { @@ -428,6 +429,17 @@ static inline void csdev_access_write64(struct csdev_access *csa, u64 val, u32 o csa->write(val, offset, false, true); } +static inline bool coresight_is_percpu_source(struct coresight_device *csdev) +{ + return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SOURCE) && + csdev->subtype.source_subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_PROC; +} + +static inline bool coresight_is_percpu_sink(struct coresight_device *csdev) +{ + return csdev && (csdev->type == CORESIGHT_DEV_TYPE_SINK) && + csdev->subtype.sink_subtype == CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM; +} #else /* !CONFIG_64BIT */ static inline u64 csdev_access_relaxed_read64(struct csdev_access *csa, -- 2.7.4