From patchwork Fri Jan 31 16:36:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13955576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C89EBC0218F for ; Fri, 31 Jan 2025 16:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=G7MomK86+ouS/G5oAALpKpnv8TVzemPi9Q2kt64Ct2c=; b=HRAqd0IsL4qiiaryxVaHclLRBP K16Pi1UXrSyuC7dhlH6tKzFr8OO1a6ArZk/8IGLICNnm4xZUpWdBAAYrX/brOkveaNVtw3qbfTZtO qzmb622OZZ1ZQeDyoXflPcSBRn4bu+yRYLI23KV+B/ZB1UD80fX4i3+6+kKvrScEqsw5KtB6qNrPk Ge8OpgD0bL9ZMLDIQ+/eSIFr7cZAIlRK5ZIdB32IOLRww90QsmTTFLjmfMt1xwXXnU2y0JVfMGStd Fu6jLnMnJ7Ovxr6o+ic7HFw3Ko3r2VdB4tqu+834+zZRWi1bA4UyOQ9sFd7uOXwiqw44JqtkoYVVx kar22Mew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdu8W-0000000B1qU-2Pgm; Fri, 31 Jan 2025 16:44:56 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tdu0z-0000000B0HV-092s for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 16:37:10 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-43675b1155bso25447445e9.2 for ; Fri, 31 Jan 2025 08:37:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738341427; x=1738946227; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=G7MomK86+ouS/G5oAALpKpnv8TVzemPi9Q2kt64Ct2c=; b=m+4dCg53uThwU937co/C2+rwskdjwhZMC/q8hoXqNOVJOK/J1qxrUAfNH8icJUV2zy huacEl8q0fIpKfaCeRZKVvsyJ62F8/RUT4HNt45XnbOKgCfSXNlHGkVAOI9DPmHz6GXF kRLszr0e6xoIrqfF7hOue0AAz+K5+fxw/uVPNVThhYUmimEQvN0/Q3Y09Y+u6wRFn97F p8+WsxdBEcbsAar4XtpfNlo87UHNlbcIcE/Kj4kxGZ5wB/236B0oZpV41IjP+46SfzQy bVdBX2dYb9Kw5URDPIRN+2GwJkUwWUmPEI56IVpskq6YKIY1tTSDe1H547VwDEnoiGH1 bavA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738341427; x=1738946227; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=G7MomK86+ouS/G5oAALpKpnv8TVzemPi9Q2kt64Ct2c=; b=Xkae69yDThh3EmytP+YKvZxzdkffxgJNQ1mRYw0kkKKUAxVzy5ZM/rAuaMfbuLv/G6 uooEUw04ufM+Ec0d45B2XTjoy+VVeImGDByj/gEZQbGCSMBoLEVXDfQONRkndPjtA1fM I35Z/C5yDAWplgSQukX1fqqkYWn5G8HwXksDoutyStK312o7LthbzsVvAGRZkIbWE9HD WOfOq28WeBoUV5lotuaFiG8Zq8eOzRZOZc4eTmhUjhASaZPcyCTXNLtYPjQQpkPza4U+ REu/BrJUgNz28h0K4D65jz4L2QB7bHV07qADSgsFWo09oy16nFUOwKnmDyKf2WXQJWQM 3zvg== X-Forwarded-Encrypted: i=1; AJvYcCXOD3al4NC470Ofy5ht/+ZMnAnf988T7sOLtJAVDSxVX97hcQFWvb2xXl2h6uuMwcyqonP5laYQ9ziP3wcH7lPo@lists.infradead.org X-Gm-Message-State: AOJu0YxTg1OAm4zXXnTGW2psKjABUWKY8S67zZqKIepzWzFOsVKZVw1C uIAAUMK0IzsO8XfRZX3dhvmiAc6ye16Sp6nmIMFuPHw6UGTwt3Zyw8viqAdxL54= X-Gm-Gg: ASbGncvh2/zzlIheMLP3crkZaELkkVOAPtnTA/NyUC+OlHRPb5wbIFP5gLihodF6+LR 3mkGLY/lkhqXZHvgxGWfv5Z4jJFIWw/T6PCyos+Zj7NrcHJZJJwC0soqNY8CdHbusH16v/AN9LX H66XflRzzBoo+trq5PrfZwEoI5SriHeNjZwR6m01ocO6cGhC7PWco8A0oBXxPzr43sCOgg+PiTR plDhEljHdh254bvBq0eJ11RVE2QRygzxsHPzQfGoADN33/h8fnPIKeyWA8I5mHtcXTFlpRMHeDJ jDPggImulYheF/I= X-Google-Smtp-Source: AGHT+IFW6UUx3VFvrhhQA0UKfWXPE61O1AfZdbHWQgh9U8vY75F7edI1Un+IGYs+RKA8bLLCI9gYtQ== X-Received: by 2002:a7b:c347:0:b0:436:6460:e680 with SMTP id 5b1f17b1804b1-438dc3cc9e6mr118298935e9.16.1738341427298; Fri, 31 Jan 2025 08:37:07 -0800 (PST) Received: from pop-os.. ([145.224.90.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c5c1e8f53sm4975118f8f.100.2025.01.31.08.36.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 08:36:53 -0800 (PST) From: James Clark To: quic_jiegan@quicinc.com Cc: quic_tingweiz@quicinc.com, quic_jinlmao@quicinc.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, suzuki.poulose@arm.com, mike.leach@linaro.org, alexander.shishkin@linux.intel.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andersson@kernel.org, konradybcio@kernel.org, James Clark Subject: [PATCH 1/3] coresight: Don't save handle in path Date: Fri, 31 Jan 2025 16:36:13 +0000 Message-Id: <20250131163617.1730505-2-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250131163617.1730505-1-james.clark@linaro.org> References: <20250131163617.1730505-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250131_083709_075523_3009E42F X-CRM114-Status: GOOD ( 18.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-core.c | 10 +++++----- drivers/hwtracing/coresight/coresight-dummy.c | 2 +- drivers/hwtracing/coresight/coresight-etb10.c | 8 +++----- drivers/hwtracing/coresight/coresight-etm-perf.c | 3 +-- drivers/hwtracing/coresight/coresight-priv.h | 4 ++-- drivers/hwtracing/coresight/coresight-sysfs.c | 2 +- drivers/hwtracing/coresight/coresight-tmc-etf.c | 9 ++++----- drivers/hwtracing/coresight/coresight-tmc-etr.c | 13 +++++-------- drivers/hwtracing/coresight/coresight-tmc.h | 2 +- drivers/hwtracing/coresight/coresight-tpiu.c | 2 +- drivers/hwtracing/coresight/coresight-trbe.c | 4 +--- drivers/hwtracing/coresight/ultrasoc-smb.c | 8 +++----- include/linux/coresight.h | 2 +- 13 files changed, 29 insertions(+), 40 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 11d5d5320b1a..253ef02fde12 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -272,9 +272,9 @@ void coresight_add_helper(struct coresight_device *csdev, EXPORT_SYMBOL_GPL(coresight_add_helper); static int coresight_enable_sink(struct coresight_device *csdev, - enum cs_mode mode, void *data) + enum cs_mode mode, struct perf_output_handle *handle) { - return sink_ops(csdev)->enable(csdev, mode, data); + return sink_ops(csdev)->enable(csdev, mode, handle); } static void coresight_disable_sink(struct coresight_device *csdev) @@ -448,7 +448,8 @@ static int coresight_enable_helpers(struct coresight_device *csdev, return 0; } -int coresight_enable_path(struct coresight_path *cs_path, enum cs_mode mode) +int coresight_enable_path(struct coresight_path *cs_path, enum cs_mode mode, + struct perf_output_handle *handle) { int ret = 0; u32 type; @@ -479,7 +480,7 @@ int coresight_enable_path(struct coresight_path *cs_path, enum cs_mode mode) switch (type) { case CORESIGHT_DEV_TYPE_SINK: - ret = coresight_enable_sink(csdev, mode, cs_path); + ret = coresight_enable_sink(csdev, mode, handle); /* * Sink is the first component turned on. If we * failed to enable the sink, there are no components @@ -807,7 +808,6 @@ void coresight_release_path(struct coresight_path *cs_path) kfree(nd); } - cs_path->handle = NULL; kfree(cs_path->path); kfree(cs_path); } diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c index dfcf24e9c49a..6f86d33efef4 100644 --- a/drivers/hwtracing/coresight/coresight-dummy.c +++ b/drivers/hwtracing/coresight/coresight-dummy.c @@ -54,7 +54,7 @@ static int dummy_source_trace_id(struct coresight_device *csdev, enum cs_mode mo } static int dummy_sink_enable(struct coresight_device *csdev, enum cs_mode mode, - void *data) + struct perf_output_handle *handle) { dev_dbg(csdev->dev.parent, "Dummy sink enabled\n"); diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 05430d8931d1..e373b0f590bf 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -167,14 +167,12 @@ static int etb_enable_sysfs(struct coresight_device *csdev) return ret; } -static int etb_enable_perf(struct coresight_device *csdev, void *data) +static int etb_enable_perf(struct coresight_device *csdev, struct perf_output_handle *handle) { int ret = 0; pid_t pid; unsigned long flags; struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - struct coresight_path *cs_path = (struct coresight_path *)data; - struct perf_output_handle *handle = cs_path->handle; struct cs_buffers *buf = etm_perf_sink_config(handle); spin_lock_irqsave(&drvdata->spinlock, flags); @@ -225,7 +223,7 @@ static int etb_enable_perf(struct coresight_device *csdev, void *data) } static int etb_enable(struct coresight_device *csdev, enum cs_mode mode, - void *data) + struct perf_output_handle *handle) { int ret; @@ -234,7 +232,7 @@ static int etb_enable(struct coresight_device *csdev, enum cs_mode mode, ret = etb_enable_sysfs(csdev); break; case CS_MODE_PERF: - ret = etb_enable_perf(csdev, data); + ret = etb_enable_perf(csdev, handle); break; default: ret = -EINVAL; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index b6765abb0a26..0fad9968c2c0 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -501,9 +501,8 @@ static void etm_event_start(struct perf_event *event, int flags) if (WARN_ON_ONCE(!sink)) goto fail_end_stop; - cs_path->handle = handle; /* Nothing will happen without a path */ - if (coresight_enable_path(cs_path, CS_MODE_PERF)) + if (coresight_enable_path(cs_path, CS_MODE_PERF, handle)) goto fail_end_stop; /* Finally enable the tracer */ diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 8e02a222b9f8..7bd43304f461 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -112,7 +112,6 @@ struct cs_buffers { * @trace_id: trace_id of the whole path. */ struct coresight_path { - struct perf_output_handle *handle; struct list_head *path; u8 trace_id; }; @@ -142,7 +141,8 @@ static inline void CS_UNLOCK(void __iomem *addr) } void coresight_disable_path(struct coresight_path *cs_path); -int coresight_enable_path(struct coresight_path *cs_path, enum cs_mode mode); +int coresight_enable_path(struct coresight_path *cs_path, enum cs_mode mode, + struct perf_output_handle *handle); struct coresight_device *coresight_get_sink(struct list_head *path); struct coresight_device *coresight_get_sink_by_id(u32 id); struct coresight_device * diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c index 04e76cc1bfdf..f9a6b838726c 100644 --- a/drivers/hwtracing/coresight/coresight-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-sysfs.c @@ -209,7 +209,7 @@ int coresight_enable_sysfs(struct coresight_device *csdev) goto out; } - ret = coresight_enable_path(cs_path, CS_MODE_SYSFS); + ret = coresight_enable_path(cs_path, CS_MODE_SYSFS, NULL); if (ret) goto err_path; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index e6b07f917556..fdf1c2511d67 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -244,14 +244,13 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev) return ret; } -static int tmc_enable_etf_sink_perf(struct coresight_device *csdev, void *data) +static int tmc_enable_etf_sink_perf(struct coresight_device *csdev, + struct perf_output_handle *handle) { int ret = 0; pid_t pid; unsigned long flags; struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - struct coresight_path *cs_path= (struct coresight_path *)data; - struct perf_output_handle *handle = cs_path->handle; struct cs_buffers *buf = etm_perf_sink_config(handle); spin_lock_irqsave(&drvdata->spinlock, flags); @@ -303,7 +302,7 @@ static int tmc_enable_etf_sink_perf(struct coresight_device *csdev, void *data) } static int tmc_enable_etf_sink(struct coresight_device *csdev, - enum cs_mode mode, void *data) + enum cs_mode mode, struct perf_output_handle *handle) { int ret; @@ -312,7 +311,7 @@ static int tmc_enable_etf_sink(struct coresight_device *csdev, ret = tmc_enable_etf_sink_sysfs(csdev); break; case CS_MODE_PERF: - ret = tmc_enable_etf_sink_perf(csdev, data); + ret = tmc_enable_etf_sink_perf(csdev, handle); break; /* We shouldn't be here */ default: diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index 82a872882e24..2d0bd06bab2a 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1252,10 +1252,8 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev) } struct etr_buf *tmc_etr_get_buffer(struct coresight_device *csdev, - enum cs_mode mode, void *data) + enum cs_mode mode, struct perf_output_handle *handle) { - struct coresight_path *cs_path = (struct coresight_path *)data; - struct perf_output_handle *handle = cs_path->handle; struct etr_perf_buffer *etr_perf; switch (mode) { @@ -1643,14 +1641,13 @@ tmc_update_etr_buffer(struct coresight_device *csdev, return size; } -static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, void *data) +static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, + struct perf_output_handle *handle) { int rc = 0; pid_t pid; unsigned long flags; struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - struct coresight_path *cs_path = (struct coresight_path *)data; - struct perf_output_handle *handle = cs_path->handle; struct etr_perf_buffer *etr_perf = etm_perf_sink_config(handle); spin_lock_irqsave(&drvdata->spinlock, flags); @@ -1698,13 +1695,13 @@ static int tmc_enable_etr_sink_perf(struct coresight_device *csdev, void *data) } static int tmc_enable_etr_sink(struct coresight_device *csdev, - enum cs_mode mode, void *data) + enum cs_mode mode, struct perf_output_handle *handle) { switch (mode) { case CS_MODE_SYSFS: return tmc_enable_etr_sink_sysfs(csdev); case CS_MODE_PERF: - return tmc_enable_etr_sink_perf(csdev, data); + return tmc_enable_etr_sink_perf(csdev, handle); default: return -EINVAL; } diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h index 2671926be62a..e991afd43742 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -336,7 +336,7 @@ struct coresight_device *tmc_etr_get_catu_device(struct tmc_drvdata *drvdata); void tmc_etr_set_catu_ops(const struct etr_buf_operations *catu); void tmc_etr_remove_catu_ops(void); struct etr_buf *tmc_etr_get_buffer(struct coresight_device *csdev, - enum cs_mode mode, void *data); + enum cs_mode mode, struct perf_output_handle *handle); extern const struct attribute_group coresight_etr_group; #endif diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c index 97ef36f03ec2..ccf463ac7bf5 100644 --- a/drivers/hwtracing/coresight/coresight-tpiu.c +++ b/drivers/hwtracing/coresight/coresight-tpiu.c @@ -75,7 +75,7 @@ static void tpiu_enable_hw(struct csdev_access *csa) } static int tpiu_enable(struct coresight_device *csdev, enum cs_mode mode, - void *__unused) + struct perf_output_handle *__unused) { struct tpiu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index 5005efd88a66..997d5976d2d2 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -1009,12 +1009,10 @@ static int __arm_trbe_enable(struct trbe_buf *buf, } static int arm_trbe_enable(struct coresight_device *csdev, enum cs_mode mode, - void *data) + struct perf_output_handle *handle) { struct trbe_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); struct trbe_cpudata *cpudata = dev_get_drvdata(&csdev->dev); - struct coresight_path *cs_path = (struct coresight_path *)data; - struct perf_output_handle *handle = cs_path->handle; struct trbe_buf *buf = etm_perf_sink_config(handle); WARN_ON(cpudata->cpu != smp_processor_id()); diff --git a/drivers/hwtracing/coresight/ultrasoc-smb.c b/drivers/hwtracing/coresight/ultrasoc-smb.c index 9be88394b3bb..1574b5067206 100644 --- a/drivers/hwtracing/coresight/ultrasoc-smb.c +++ b/drivers/hwtracing/coresight/ultrasoc-smb.c @@ -213,11 +213,9 @@ static void smb_enable_sysfs(struct coresight_device *csdev) coresight_set_mode(csdev, CS_MODE_SYSFS); } -static int smb_enable_perf(struct coresight_device *csdev, void *data) +static int smb_enable_perf(struct coresight_device *csdev, struct perf_output_handle *handle) { struct smb_drv_data *drvdata = dev_get_drvdata(csdev->dev.parent); - struct coresight_path *cs_path = (struct coresight_path *)data; - struct perf_output_handle *handle = cs_path->handle; struct cs_buffers *buf = etm_perf_sink_config(handle); pid_t pid; @@ -241,7 +239,7 @@ static int smb_enable_perf(struct coresight_device *csdev, void *data) } static int smb_enable(struct coresight_device *csdev, enum cs_mode mode, - void *data) + struct perf_output_handle *handle) { struct smb_drv_data *drvdata = dev_get_drvdata(csdev->dev.parent); int ret = 0; @@ -262,7 +260,7 @@ static int smb_enable(struct coresight_device *csdev, enum cs_mode mode, smb_enable_sysfs(csdev); break; case CS_MODE_PERF: - ret = smb_enable_perf(csdev, data); + ret = smb_enable_perf(csdev, handle); break; default: ret = -EINVAL; diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 87f9baa7fefe..a859fc00eef9 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -353,7 +353,7 @@ enum cs_mode { */ struct coresight_ops_sink { int (*enable)(struct coresight_device *csdev, enum cs_mode mode, - void *data); + struct perf_output_handle *handle); int (*disable)(struct coresight_device *csdev); void *(*alloc_buffer)(struct coresight_device *csdev, struct perf_event *event, void **pages, From patchwork Fri Jan 31 16:36:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13955577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86504C02190 for ; Fri, 31 Jan 2025 16:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EMx2YnOlJPDXeo1XJnfHHROuTOY3+drwNmWAuq+4lIg=; b=26CLsNVa9+IyUe++LjuFHWRvT3 lABW/VCURQ8lRH67UBqL4p+vUrrPk64BnCvInXhyouQbDq8JJpGkpfSodL6wpZMmjKh3Gw10pE8xC hleUXbJTGZiwdCz8/hkwG/3ZojsLLx7Rr/q9YUdWXSvI24g5BwtspKbrJeBGCUn9k+CVFT4SlI3Xu BEwkvEiMCyvERfH7eJDMI/wldDcE/YPkKqxayXyHCIpQh0F+MfwZUY5HLA8wnoz7O1KnUNzJyr+Go VK5rOT6oR/FB0pNJsW2EvdxYxvLzA86vbbnDlfjGGwvAFTEciJXeVkdFxRcvlYAC17CSPMo9R8W4f YYeZu5Aw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdu9o-0000000B20Z-0pA2; Fri, 31 Jan 2025 16:46:16 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tdu19-0000000B0K7-2eei for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 16:37:20 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4361f796586so26115695e9.3 for ; Fri, 31 Jan 2025 08:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738341438; x=1738946238; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EMx2YnOlJPDXeo1XJnfHHROuTOY3+drwNmWAuq+4lIg=; b=AgGy2kYeymNfvPFiZqK/VcEIRKAaIM/gl5rZf420b81g7X8DxpBYdaomRPuHnkdinZ rNYhbdnRMGSFKCtdDXm2R3OTIgCF/uRLqxNUyg7l2s12VRO1qTSpAkn5M5SPKhbvAv0T DB/5L915Ey40m6J0vruwPiCHJiyG0nwTELy6oqboS6AfFWBoswvO5c7kXjC3sHmV9gaW 267YYOKkIchHO+pN7SqRHoLTattqRcvGNFZAYNO0aYh8EFVyBXdbtPxBrZzr32FVbAo+ dRxnUCDrUNy0wIwHyvOZwwL/PgJsPlgMqtfZ5W5rTCgEQDtw3AOy68xf4wQtZhriGTTJ w7Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738341438; x=1738946238; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EMx2YnOlJPDXeo1XJnfHHROuTOY3+drwNmWAuq+4lIg=; b=hjlfNqPwOPVf5+pOTGnboEXi6EfUIswFtzawQtxUMKUw2GNBU7WYC5vfii0c4YBA8h hw2wD/vLTXOTX6WXvATX3bhyLLBEiZLtWodt5onkftFAaaoBFwZt95iLjabkDMQyWWxk 5gsaL8V4isnY8u4dBwn3SDI0hPWCy8Vnt4L0HWgrkw5dEyRjiUA4WS0tJtuDTHu9JXO1 1XPS3GM+bz9Jwcr81zLkmupMRLGPkMhJh3j+obfjqlvhN0B2ASri1BMotc1PZIBoJOEu KCzypnabLY2FO/Pl2UexN7QvLaf/x2BpFDxeaC3hNrhqNVqM6ekRivoSuZUPnPC4ByP3 KKnA== X-Forwarded-Encrypted: i=1; AJvYcCXgbtcI7B67OM5b/M893BlfdonGAHQSKbimMW62VrC7JIxaXQg1ldDyiTP4HTwaWCiyWu9sXBfzjLMWEkngof/8@lists.infradead.org X-Gm-Message-State: AOJu0YyWahPlwuDPLnEzlLgKOeWX3p+3ABoboqTv4irmsqZbnm87ksbe XlsHkI55hUFBjhTldTwN8PCuZQk0m9rjWzVQqUsy7cMdDEpypdtwxvvncYHYEHM= X-Gm-Gg: ASbGncu3uJZhByYwIFOgcPtPEmfzumjP+y1gTYGs2PXw69+VMlky5oBLxEqM1VvEW64 vV4lZbompugLHKRaN8VdpBe7FIzFrkneXqf9Bh1PZTEvvz+OLbhLIpmMf0wfWm6rwYsnEDbE5hW OVR73lr1mzVazwQcR/JBLm3U/k0NpjaQzqJgVtw2KNngT04XpLGh/7/OzTvnwkVeJfF6t4tATIo aL0H0Z8kxhgU8XJAp1azwyRs5Q0mWB3Y/t0qXDWZNENjWucboaT9fyQYVzFAXRtOGsspZuYGxHU 5VFrmpG+u1KgNYs= X-Google-Smtp-Source: AGHT+IEK8aXASXk07qexYhvsAde0vZ0pJEgD444D81jkJ1PplRhBIzhtI0G4gtXUjh/qBfrt6nphdA== X-Received: by 2002:a05:600c:4ec7:b0:436:e751:e436 with SMTP id 5b1f17b1804b1-438dc40d574mr116288475e9.19.1738341437975; Fri, 31 Jan 2025 08:37:17 -0800 (PST) Received: from pop-os.. ([145.224.90.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c5c1e8f53sm4975118f8f.100.2025.01.31.08.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 08:37:11 -0800 (PST) From: James Clark To: quic_jiegan@quicinc.com Cc: quic_tingweiz@quicinc.com, quic_jinlmao@quicinc.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, suzuki.poulose@arm.com, mike.leach@linaro.org, alexander.shishkin@linux.intel.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andersson@kernel.org, konradybcio@kernel.org, James Clark Subject: [PATCH 2/3] coresight: Export coresight_get_sink() Date: Fri, 31 Jan 2025 16:36:14 +0000 Message-Id: <20250131163617.1730505-3-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250131163617.1730505-1-james.clark@linaro.org> References: <20250131163617.1730505-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250131_083719_666382_F9EDD917 X-CRM114-Status: UNSURE ( 8.27 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 253ef02fde12..f31c8477f7b7 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -526,6 +526,7 @@ struct coresight_device *coresight_get_sink(struct list_head *path) return csdev; } +EXPORT_SYMBOL_GPL(coresight_get_sink); u32 coresight_get_sink_id(struct coresight_device *csdev) { From patchwork Fri Jan 31 16:36:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13955578 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9209CC02190 for ; Fri, 31 Jan 2025 16:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/EiIivNlSBmjlWurf1sXALCWljLg28qpqIa3tfnSxfs=; b=AKZebSv2DcRgyZ15clHuHLWTAO SH1+njjFH8+ZLWYuS0ixK5ShNi9NgBL+1xs+6N//kZt/fTZeZATROdsNDBL9VhiirGh4msRpnferT 19y2c4IzRKgac9TyI53ExylxsQNRNk5eiTUGVIDKUmB2Og65lsUYdvX86MVl3RxpWGEFfXQEgmbae CwO823TsR+s/YKqw1PFMYj0NGSbKBO6xn6Jv0BWelOL0Tnj9elQJk6F7oOJCNSd9VSR8NudN0VkFW 40EHlZVpfJ0ZPoYXLnuBPk45MdR7PKnFmg1DIN11B/rXjtCce8nrRv8rD0K0MRS9rpXNnEbGIuPwj 4OPmGQUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tduB5-0000000B2ER-3p9M; Fri, 31 Jan 2025 16:47:35 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tdu1M-0000000B0Ns-19ta for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 16:37:33 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-385deda28b3so1205063f8f.0 for ; Fri, 31 Jan 2025 08:37:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738341450; x=1738946250; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/EiIivNlSBmjlWurf1sXALCWljLg28qpqIa3tfnSxfs=; b=aONMnhjYKpWMWI56Yh2BwQWR9VWVVqZvNTsRioLwRl8ue6LeSnXIVqOQrtnIqZREqX tX6KNSuXddZw/eC2EFT9CuJwc80i//0A2A2FRL4M4tn9jZTsF7t0LAz/eb27Px7sPQga B57Ne22p6qwmiMaS7a0H7h+kvZUoj8F7wiMhCExnJAd125vHEas5dWLoWVTB1MUCLwfs 0iNAVAQxHNMuQZsqzPlpl65q/2udiDsyjZCJkbtp/RTRO7njFhQjU0qnqojn38owsayN wyYUPzSTOFoFKTSJnAUeUR+TYdmNQ/B/p57jEePEKhytWmKYzk6bR5Dq2Rbfi7aUzrv8 pNRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738341450; x=1738946250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/EiIivNlSBmjlWurf1sXALCWljLg28qpqIa3tfnSxfs=; b=l8fR8qaEOVL/CTzD88exMPIKSfxYjRA3gV14psidLpIfrO+GQy1w/opkp6YDcOt7Ca hl8Eh+SCh3wawVVDxPI13AsHUbKbz/vQ7fJAEJor6Yii4JCByMZTxdQwM3XmhMh4R7x9 8vBe9UfoRyX8D+QoFjGTIXpSAAgS7PKIg+cVGKYtZcxcWAhLC1TxVl666X4OEOuBgbYE KHW9qAESgJeZ2u5WRGyKcC6vLS+4UCpA5yBQFMuIRnxK948sijHkxr/J25MBG8LV5C5P fmFYeG4SwNWKbUvjCEn+g24uZqUoob7LSWYOmDSZlM711JG8Ibl64brFx9aDcWpWdr3Z 2PdA== X-Forwarded-Encrypted: i=1; AJvYcCVha/NMUxGWDjRCZzsel/oCrBudXXuBJKz8eWyX/kBT6dms5+ME1tkqoSg1zuANpt2ZeAAyObQOnNSVafo3NX3+@lists.infradead.org X-Gm-Message-State: AOJu0YyhTkL2yqVCxMFJzOrgeqfKBMZAQYIHkzLTeeNSv7Aat5NfrsIr fgAsDv0Z2r1iD4g4uNisl/4+A1EGuzZBOtLYXSJ0Wc7lfiolAX83gR8qU7XXgiI= X-Gm-Gg: ASbGncvlVZI4iBAugud+OOFzVo0mQmtsryacxA1K3zo6CKcfYHJaNMufHKWod1zB0/h red7VeVpU7jFhJIG/BS0P/zJsnbHWpkroFDmilitHgM2x/eci2CUCW36hVKbKVec8fBuoTw6UGC VR/2qaGIGlrLq+yFkkl0tIBulZ9SxD8BLWLavcEnJeH9z8cGPE1UhwKxEFoa+eYzIN38/J50koA DaqvOJ3YlsETaoeq0R+FUmefDD3P7VfafSd1qwmcoiXTC4ybeF/E3JlZ93OlQej3BidJziC91TD AKytympNn2CB9ic= X-Google-Smtp-Source: AGHT+IENp+rSeJRmG7qEFTxdRSKZm4Az560mKJ70dcuv6E5dHaMJ2QNoB38Or7CB4zxFd39142+2aw== X-Received: by 2002:a05:6000:1fac:b0:386:3329:6a04 with SMTP id ffacd0b85a97d-38c51e8de63mr11672284f8f.39.1738341450438; Fri, 31 Jan 2025 08:37:30 -0800 (PST) Received: from pop-os.. ([145.224.90.107]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c5c1e8f53sm4975118f8f.100.2025.01.31.08.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 08:37:22 -0800 (PST) From: James Clark To: quic_jiegan@quicinc.com Cc: quic_tingweiz@quicinc.com, quic_jinlmao@quicinc.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, suzuki.poulose@arm.com, mike.leach@linaro.org, alexander.shishkin@linux.intel.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, andersson@kernel.org, konradybcio@kernel.org, James Clark Subject: [PATCH 3/3] coresight: Alloc trace ID after building the path Date: Fri, 31 Jan 2025 16:36:15 +0000 Message-Id: <20250131163617.1730505-4-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250131163617.1730505-1-james.clark@linaro.org> References: <20250131163617.1730505-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250131_083732_322736_78AF7FA5 X-CRM114-Status: GOOD ( 32.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This reduces the number of places that the ID allocation happens to just sysfs trctraceid_show() and when the path is built. And it consolidates some duplicate code by doing everything the same way whether it's sysfs mode, Perf mode, or if the trace ID is needed in advance for helper devices like CTCUs. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-core.c | 96 ++++++++++++++----- drivers/hwtracing/coresight/coresight-dummy.c | 7 +- .../hwtracing/coresight/coresight-etm-perf.c | 17 ++-- drivers/hwtracing/coresight/coresight-etm.h | 1 - .../coresight/coresight-etm3x-core.c | 84 ++-------------- .../coresight/coresight-etm3x-sysfs.c | 3 +- .../coresight/coresight-etm4x-core.c | 83 ++-------------- .../coresight/coresight-etm4x-sysfs.c | 4 +- drivers/hwtracing/coresight/coresight-etm4x.h | 1 - drivers/hwtracing/coresight/coresight-priv.h | 13 +-- drivers/hwtracing/coresight/coresight-stm.c | 5 +- drivers/hwtracing/coresight/coresight-sysfs.c | 4 + drivers/hwtracing/coresight/coresight-tpda.c | 3 +- drivers/hwtracing/coresight/coresight-tpdm.c | 3 +- include/linux/coresight.h | 23 ++++- 15 files changed, 129 insertions(+), 218 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index f31c8477f7b7..88041000c0e9 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -657,6 +657,51 @@ static void coresight_drop_device(struct coresight_device *csdev) } } +/** + * Links or sources will read their existing or alloc a trace ID, if their ID + * callback is set. + */ +static int coresight_get_trace_id(struct coresight_device *csdev, + enum cs_mode mode, + struct coresight_device *sink) +{ + if (csdev->type == CORESIGHT_DEV_TYPE_LINK && link_ops(csdev)->trace_id) + return link_ops(csdev)->trace_id(csdev, mode, sink); + + if (csdev->type == CORESIGHT_DEV_TYPE_SOURCE && source_ops(csdev)->trace_id) + return source_ops(csdev)->trace_id(csdev, mode, sink); + + return 0; +} + +/** + * Call this after creating the path and before enabling it. This leaves + * the trace ID set on the path and returns the ID, or an error if it + * couldn't be assigned. + */ +int coresight_path_assign_trace_id(struct coresight_path *path, + enum cs_mode mode) +{ + struct coresight_device *sink = coresight_get_sink(path->path); + struct coresight_node *nd; + int ret; + + list_for_each_entry(nd, path->path, link) { + /* Assign a trace ID to the path for the first device that wants to do it */ + ret = coresight_get_trace_id(nd->csdev, mode, sink); + + /* + * 0 in this context is that it didn't want to assign so keep searching. + * Non 0 is either success or fail, return it either way. + */ + if (ret != 0) { + path->trace_id = ret; + return ret; + } + } + return 0; +} + /** * _coresight_build_path - recursively build a path from a @csdev to a sink. * @csdev: The device to start from. @@ -691,15 +736,6 @@ static int _coresight_build_path(struct coresight_device *csdev, } } - /* Attempt to read the trace_id from TPDA device */ - if (!IS_VALID_CS_TRACE_ID(cs_path->trace_id) && - (csdev->type == CORESIGHT_DEV_TYPE_LINK) && - (link_ops(csdev)->trace_id != NULL)) { - ret = link_ops(csdev)->trace_id(csdev); - if (IS_VALID_CS_TRACE_ID(ret)) - cs_path->trace_id = ret; - } - /* Not a sink - recursively explore each port found on this element */ for (i = 0; i < csdev->pdata->nr_outconns; i++) { struct coresight_device *child_dev; @@ -762,22 +798,6 @@ struct coresight_path *coresight_build_path(struct coresight_device *source, INIT_LIST_HEAD(path); cs_path->path = path; - /* - * Since not all source devices have a defined trace_id function, - * make sure to check for it before use. - * - * Assert the mode is CS_MODE_SYSFS, the trace_id will be assigned - * again later if the mode is CS_MODE_PERF. - */ - if (source_ops(source)->trace_id != NULL) { - rc = source_ops(source)->trace_id(source, CS_MODE_SYSFS, NULL); - if(IS_VALID_CS_TRACE_ID(rc)) - cs_path->trace_id = rc; - else - cs_path->trace_id = 0; - } - else - cs_path->trace_id = 0; rc = _coresight_build_path(source, source, sink, cs_path); if (rc) { @@ -1555,6 +1575,32 @@ void coresight_remove_driver(struct amba_driver *amba_drv, } EXPORT_SYMBOL_GPL(coresight_remove_driver); +int coresight_etm_get_trace_id(struct coresight_device *csdev, enum cs_mode mode, + struct coresight_device *sink) +{ + int trace_id; + int cpu = source_ops(csdev)->cpu_id(csdev); + + switch (mode) { + case CS_MODE_SYSFS: + trace_id = coresight_trace_id_get_cpu_id(cpu); + break; + case CS_MODE_PERF: + trace_id = coresight_trace_id_get_cpu_id_map(cpu, &sink->perf_sink_id_map); + break; + default: + trace_id = -EINVAL; + break; + } + + if (!IS_VALID_CS_TRACE_ID(trace_id)) + dev_err(&csdev->dev, + "Failed to allocate trace ID on CPU%d\n", cpu); + + return trace_id; +} +EXPORT_SYMBOL_GPL(coresight_etm_get_trace_id); + MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Pratik Patel "); MODULE_AUTHOR("Mathieu Poirier "); diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c index 6f86d33efef4..a8a991e81725 100644 --- a/drivers/hwtracing/coresight/coresight-dummy.c +++ b/drivers/hwtracing/coresight/coresight-dummy.c @@ -22,9 +22,8 @@ struct dummy_drvdata { DEFINE_CORESIGHT_DEVLIST(source_devs, "dummy_source"); DEFINE_CORESIGHT_DEVLIST(sink_devs, "dummy_sink"); -static int dummy_source_enable(struct coresight_device *csdev, - struct perf_event *event, enum cs_mode mode, - __maybe_unused struct coresight_trace_id_map *id_map) +static int dummy_source_enable(struct coresight_device *csdev, struct perf_event *event, + enum cs_mode mode, struct coresight_path *path) { if (!coresight_take_mode(csdev, mode)) return -EBUSY; @@ -42,7 +41,7 @@ static void dummy_source_disable(struct coresight_device *csdev, } static int dummy_source_trace_id(struct coresight_device *csdev, enum cs_mode mode, - struct coresight_trace_id_map *id_map) + struct coresight_device *sink) { struct dummy_drvdata *drvdata; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 0fad9968c2c0..e5bd8d577259 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -407,17 +407,16 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, cpumask_clear_cpu(cpu, mask); continue; } - /* ensure we can allocate a trace ID for this CPU */ - trace_id = coresight_trace_id_get_cpu_id_map(cpu, &sink->perf_sink_id_map); - if (!IS_VALID_CS_TRACE_ID(trace_id)) { + trace_id = coresight_path_assign_trace_id(cs_path, CS_MODE_PERF); + + /* Can be 0 and valid, ETE doesn't need an ID */ + if (trace_id < 0) { cpumask_clear_cpu(cpu, mask); coresight_release_path(cs_path); continue; } - coresight_trace_id_perf_start(&sink->perf_sink_id_map); - cs_path->trace_id = trace_id; *etm_event_cpu_path_ptr(event_data, cpu) = cs_path; } @@ -463,7 +462,6 @@ static void etm_event_start(struct perf_event *event, int flags) struct coresight_device *sink, *csdev = per_cpu(csdev_src, cpu); struct coresight_path *cs_path; u64 hw_id; - u8 trace_id; if (!csdev) goto fail; @@ -506,8 +504,7 @@ static void etm_event_start(struct perf_event *event, int flags) goto fail_end_stop; /* Finally enable the tracer */ - if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF, - &sink->perf_sink_id_map)) + if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF, cs_path)) goto fail_disable_path; /* @@ -517,13 +514,11 @@ static void etm_event_start(struct perf_event *event, int flags) if (!cpumask_test_cpu(cpu, &event_data->aux_hwid_done)) { cpumask_set_cpu(cpu, &event_data->aux_hwid_done); - trace_id = coresight_trace_id_read_cpu_id_map(cpu, &sink->perf_sink_id_map); - hw_id = FIELD_PREP(CS_AUX_HW_ID_MAJOR_VERSION_MASK, CS_AUX_HW_ID_MAJOR_VERSION); hw_id |= FIELD_PREP(CS_AUX_HW_ID_MINOR_VERSION_MASK, CS_AUX_HW_ID_MINOR_VERSION); - hw_id |= FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, trace_id); + hw_id |= FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, cs_path->trace_id); hw_id |= FIELD_PREP(CS_AUX_HW_ID_SINK_ID_MASK, coresight_get_sink_id(sink)); perf_report_aux_output_id(event, hw_id); diff --git a/drivers/hwtracing/coresight/coresight-etm.h b/drivers/hwtracing/coresight/coresight-etm.h index e02c3ea972c9..171f1384f7c0 100644 --- a/drivers/hwtracing/coresight/coresight-etm.h +++ b/drivers/hwtracing/coresight/coresight-etm.h @@ -284,6 +284,5 @@ extern const struct attribute_group *coresight_etm_groups[]; void etm_set_default(struct etm_config *config); void etm_config_trace_mode(struct etm_config *config); struct etm_config *get_etm_config(struct etm_drvdata *drvdata); -int etm_read_alloc_trace_id(struct etm_drvdata *drvdata); void etm_release_trace_id(struct etm_drvdata *drvdata); #endif diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/hwtracing/coresight/coresight-etm3x-core.c index 74c6a2ffd07a..cb8a30a3b48e 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -455,26 +455,6 @@ static int etm_cpu_id(struct coresight_device *csdev) return drvdata->cpu; } -int etm_read_alloc_trace_id(struct etm_drvdata *drvdata) -{ - int trace_id; - - /* - * This will allocate a trace ID to the cpu, - * or return the one currently allocated. - * - * trace id function has its own lock - */ - trace_id = coresight_trace_id_get_cpu_id(drvdata->cpu); - if (IS_VALID_CS_TRACE_ID(trace_id)) - drvdata->traceid = (u8)trace_id; - else - dev_err(&drvdata->csdev->dev, - "Failed to allocate trace ID for %s on CPU%d\n", - dev_name(&drvdata->csdev->dev), drvdata->cpu); - return trace_id; -} - void etm_release_trace_id(struct etm_drvdata *drvdata) { coresight_trace_id_put_cpu_id(drvdata->cpu); @@ -482,38 +462,22 @@ void etm_release_trace_id(struct etm_drvdata *drvdata) static int etm_enable_perf(struct coresight_device *csdev, struct perf_event *event, - struct coresight_trace_id_map *id_map) + struct coresight_path *path) { struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - int trace_id; if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id())) return -EINVAL; /* Configure the tracer based on the session's specifics */ etm_parse_event_config(drvdata, event); - - /* - * perf allocates cpu ids as part of _setup_aux() - device needs to use - * the allocated ID. This reads the current version without allocation. - * - * This does not use the trace id lock to prevent lock_dep issues - * with perf locks - we know the ID cannot change until perf shuts down - * the session - */ - trace_id = coresight_trace_id_read_cpu_id_map(drvdata->cpu, id_map); - if (!IS_VALID_CS_TRACE_ID(trace_id)) { - dev_err(&drvdata->csdev->dev, "Failed to set trace ID for %s on CPU%d\n", - dev_name(&drvdata->csdev->dev), drvdata->cpu); - return -EINVAL; - } - drvdata->traceid = (u8)trace_id; + drvdata->traceid = path->trace_id; /* And enable it */ return etm_enable_hw(drvdata); } -static int etm_enable_sysfs(struct coresight_device *csdev) +static int etm_enable_sysfs(struct coresight_device *csdev, struct coresight_path *path) { struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); struct etm_enable_arg arg = { }; @@ -521,10 +485,7 @@ static int etm_enable_sysfs(struct coresight_device *csdev) spin_lock(&drvdata->spinlock); - /* sysfs needs to allocate and set a trace ID */ - ret = etm_read_alloc_trace_id(drvdata); - if (ret < 0) - goto unlock_enable_sysfs; + drvdata->traceid = path->trace_id; /* * Configure the ETM only if the CPU is online. If it isn't online @@ -545,7 +506,6 @@ static int etm_enable_sysfs(struct coresight_device *csdev) if (ret) etm_release_trace_id(drvdata); -unlock_enable_sysfs: spin_unlock(&drvdata->spinlock); if (!ret) @@ -554,7 +514,7 @@ static int etm_enable_sysfs(struct coresight_device *csdev) } static int etm_enable(struct coresight_device *csdev, struct perf_event *event, - enum cs_mode mode, struct coresight_trace_id_map *id_map) + enum cs_mode mode, struct coresight_path *path) { int ret; struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); @@ -566,10 +526,10 @@ static int etm_enable(struct coresight_device *csdev, struct perf_event *event, switch (mode) { case CS_MODE_SYSFS: - ret = etm_enable_sysfs(csdev); + ret = etm_enable_sysfs(csdev, path); break; case CS_MODE_PERF: - ret = etm_enable_perf(csdev, event, id_map); + ret = etm_enable_perf(csdev, event, path); break; default: ret = -EINVAL; @@ -697,39 +657,11 @@ static void etm_disable(struct coresight_device *csdev, coresight_set_mode(csdev, CS_MODE_DISABLED); } -static int etm_trace_id(struct coresight_device *csdev, enum cs_mode mode, - struct coresight_trace_id_map *id_map) -{ - struct etm_drvdata *drvdata; - int trace_id; - - if (csdev == NULL) - return -EINVAL; - - drvdata = dev_get_drvdata(csdev->dev.parent); - switch (mode) { - case CS_MODE_SYSFS: - trace_id = etm_read_alloc_trace_id(drvdata); - break; - case CS_MODE_PERF: - trace_id = coresight_trace_id_read_cpu_id_map(drvdata->cpu, id_map); - if (IS_VALID_CS_TRACE_ID(trace_id)) - drvdata->traceid = (u8)trace_id; - break; - default: - trace_id = -EINVAL; - break; - } - - return trace_id; -} - - static const struct coresight_ops_source etm_source_ops = { .cpu_id = etm_cpu_id, .enable = etm_enable, .disable = etm_disable, - .trace_id = etm_trace_id, + .trace_id = coresight_etm_get_trace_id, }; static const struct coresight_ops etm_cs_ops = { diff --git a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c index 68c644be9813..b9006451f515 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-sysfs.c @@ -1190,10 +1190,9 @@ static DEVICE_ATTR_RO(cpu); static ssize_t traceid_show(struct device *dev, struct device_attribute *attr, char *buf) { - int trace_id; struct etm_drvdata *drvdata = dev_get_drvdata(dev->parent); + int trace_id = coresight_etm_get_trace_id(drvdata->csdev, CS_MODE_SYSFS, NULL); - trace_id = etm_read_alloc_trace_id(drvdata); if (trace_id < 0) return trace_id; diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 0ca8868a7ebf..d7e7703123d2 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -232,25 +232,6 @@ static int etm4_cpu_id(struct coresight_device *csdev) return drvdata->cpu; } -int etm4_read_alloc_trace_id(struct etmv4_drvdata *drvdata) -{ - int trace_id; - - /* - * This will allocate a trace ID to the cpu, - * or return the one currently allocated. - * The trace id function has its own lock - */ - trace_id = coresight_trace_id_get_cpu_id(drvdata->cpu); - if (IS_VALID_CS_TRACE_ID(trace_id)) - drvdata->trcid = (u8)trace_id; - else - dev_err(&drvdata->csdev->dev, - "Failed to allocate trace ID for %s on CPU%d\n", - dev_name(&drvdata->csdev->dev), drvdata->cpu); - return trace_id; -} - void etm4_release_trace_id(struct etmv4_drvdata *drvdata) { coresight_trace_id_put_cpu_id(drvdata->cpu); @@ -753,9 +734,9 @@ static int etm4_parse_event_config(struct coresight_device *csdev, static int etm4_enable_perf(struct coresight_device *csdev, struct perf_event *event, - struct coresight_trace_id_map *id_map) + struct coresight_path *path) { - int ret = 0, trace_id; + int ret = 0; struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id())) { @@ -768,22 +749,7 @@ static int etm4_enable_perf(struct coresight_device *csdev, if (ret) goto out; - /* - * perf allocates cpu ids as part of _setup_aux() - device needs to use - * the allocated ID. This reads the current version without allocation. - * - * This does not use the trace id lock to prevent lock_dep issues - * with perf locks - we know the ID cannot change until perf shuts down - * the session - */ - trace_id = coresight_trace_id_read_cpu_id_map(drvdata->cpu, id_map); - if (!IS_VALID_CS_TRACE_ID(trace_id)) { - dev_err(&drvdata->csdev->dev, "Failed to set trace ID for %s on CPU%d\n", - dev_name(&drvdata->csdev->dev), drvdata->cpu); - ret = -EINVAL; - goto out; - } - drvdata->trcid = (u8)trace_id; + drvdata->trcid = path->trace_id; /* And enable it */ ret = etm4_enable_hw(drvdata); @@ -792,7 +758,7 @@ static int etm4_enable_perf(struct coresight_device *csdev, return ret; } -static int etm4_enable_sysfs(struct coresight_device *csdev) +static int etm4_enable_sysfs(struct coresight_device *csdev, struct coresight_path *path) { struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); struct etm4_enable_arg arg = { }; @@ -809,10 +775,7 @@ static int etm4_enable_sysfs(struct coresight_device *csdev) spin_lock(&drvdata->spinlock); - /* sysfs needs to read and allocate a trace ID */ - ret = etm4_read_alloc_trace_id(drvdata); - if (ret < 0) - goto unlock_sysfs_enable; + drvdata->trcid = path->trace_id; /* * Executing etm4_enable_hw on the cpu whose ETM is being enabled @@ -829,7 +792,6 @@ static int etm4_enable_sysfs(struct coresight_device *csdev) if (ret) etm4_release_trace_id(drvdata); -unlock_sysfs_enable: spin_unlock(&drvdata->spinlock); if (!ret) @@ -838,7 +800,7 @@ static int etm4_enable_sysfs(struct coresight_device *csdev) } static int etm4_enable(struct coresight_device *csdev, struct perf_event *event, - enum cs_mode mode, struct coresight_trace_id_map *id_map) + enum cs_mode mode, struct coresight_path *path) { int ret; @@ -849,10 +811,10 @@ static int etm4_enable(struct coresight_device *csdev, struct perf_event *event, switch (mode) { case CS_MODE_SYSFS: - ret = etm4_enable_sysfs(csdev); + ret = etm4_enable_sysfs(csdev, path); break; case CS_MODE_PERF: - ret = etm4_enable_perf(csdev, event, id_map); + ret = etm4_enable_perf(csdev, event, path); break; default: ret = -EINVAL; @@ -1025,38 +987,11 @@ static void etm4_disable(struct coresight_device *csdev, coresight_set_mode(csdev, CS_MODE_DISABLED); } -static int etm4_trace_id(struct coresight_device *csdev, enum cs_mode mode, - struct coresight_trace_id_map *id_map) -{ - struct etmv4_drvdata *drvdata; - int trace_id; - - if (csdev == NULL) - return -EINVAL; - - drvdata = dev_get_drvdata(csdev->dev.parent); - switch (mode) { - case CS_MODE_SYSFS: - trace_id = etm4_read_alloc_trace_id(drvdata); - break; - case CS_MODE_PERF: - trace_id = coresight_trace_id_read_cpu_id_map(drvdata->cpu, id_map); - if (IS_VALID_CS_TRACE_ID(trace_id)) - drvdata->trcid = (u8)trace_id; - break; - default: - trace_id = -EINVAL; - break; - } - - return trace_id; -} - static const struct coresight_ops_source etm4_source_ops = { .cpu_id = etm4_cpu_id, .enable = etm4_enable, .disable = etm4_disable, - .trace_id = etm4_trace_id, + .trace_id = coresight_etm_get_trace_id, }; static const struct coresight_ops etm4_cs_ops = { diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c index a9f19629f3f8..922c63477db1 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c @@ -4,6 +4,7 @@ * Author: Mathieu Poirier */ +#include #include #include #include @@ -2402,10 +2403,9 @@ static ssize_t trctraceid_show(struct device *dev, struct device_attribute *attr, char *buf) { - int trace_id; struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent); + int trace_id = coresight_etm_get_trace_id(drvdata->csdev, CS_MODE_SYSFS, NULL); - trace_id = etm4_read_alloc_trace_id(drvdata); if (trace_id < 0) return trace_id; diff --git a/drivers/hwtracing/coresight/coresight-etm4x.h b/drivers/hwtracing/coresight/coresight-etm4x.h index 9e9165f62e81..d70f52ff4606 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.h +++ b/drivers/hwtracing/coresight/coresight-etm4x.h @@ -1066,6 +1066,5 @@ static inline bool etm4x_is_ete(struct etmv4_drvdata *drvdata) return drvdata->arch >= ETM_ARCH_ETE; } -int etm4_read_alloc_trace_id(struct etmv4_drvdata *drvdata); void etm4_release_trace_id(struct etmv4_drvdata *drvdata); #endif diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 7bd43304f461..979b1ae18b55 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -105,17 +105,6 @@ struct cs_buffers { void **data_pages; }; -/** - * struct coresight_path - data needed by enable/disable path - * @handle: perf aux handle for ETM. - * @path: path from source to sink. - * @trace_id: trace_id of the whole path. - */ -struct coresight_path { - struct list_head *path; - u8 trace_id; -}; - static inline void coresight_insert_barrier_packet(void *buf) { if (buf) @@ -160,6 +149,8 @@ int coresight_make_links(struct coresight_device *orig, void coresight_remove_links(struct coresight_device *orig, struct coresight_connection *conn); u32 coresight_get_sink_id(struct coresight_device *csdev); +int coresight_path_assign_trace_id(struct coresight_path *path, + enum cs_mode mode); #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM3X) extern int etm_readl_cp14(u32 off, unsigned int *val); diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 13efd5c2e0c4..3dc85c1a2f7e 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -194,8 +194,7 @@ static void stm_enable_hw(struct stm_drvdata *drvdata) } static int stm_enable(struct coresight_device *csdev, struct perf_event *event, - enum cs_mode mode, - __maybe_unused struct coresight_trace_id_map *trace_id) + enum cs_mode mode, struct coresight_path *path) { struct stm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); @@ -282,7 +281,7 @@ static void stm_disable(struct coresight_device *csdev, } static int stm_trace_id(struct coresight_device *csdev, enum cs_mode mode, - struct coresight_trace_id_map *id_map) + struct coresight_device *sink) { struct stm_drvdata *drvdata; diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c index f9a6b838726c..09506ca5207e 100644 --- a/drivers/hwtracing/coresight/coresight-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-sysfs.c @@ -209,6 +209,10 @@ int coresight_enable_sysfs(struct coresight_device *csdev) goto out; } + ret = coresight_path_assign_trace_id(cs_path, CS_MODE_SYSFS); + if (ret < 0) + goto err_path; + ret = coresight_enable_path(cs_path, CS_MODE_SYSFS, NULL); if (ret) goto err_path; diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtracing/coresight/coresight-tpda.c index 3632c1791c96..829dc804d573 100644 --- a/drivers/hwtracing/coresight/coresight-tpda.c +++ b/drivers/hwtracing/coresight/coresight-tpda.c @@ -241,7 +241,8 @@ static void tpda_disable(struct coresight_device *csdev, dev_dbg(drvdata->dev, "TPDA inport %d disabled\n", in->dest_port); } -static int tpda_trace_id(struct coresight_device *csdev) +static int tpda_trace_id(struct coresight_device *csdev, enum cs_mode mode, + struct coresight_device *sink) { struct tpda_drvdata *drvdata; diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c index c38f9701665e..f0880a62028f 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.c +++ b/drivers/hwtracing/coresight/coresight-tpdm.c @@ -439,8 +439,7 @@ static void __tpdm_enable(struct tpdm_drvdata *drvdata) } static int tpdm_enable(struct coresight_device *csdev, struct perf_event *event, - enum cs_mode mode, - __maybe_unused struct coresight_trace_id_map *id_map) + enum cs_mode mode, struct coresight_path *path) { struct tpdm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); diff --git a/include/linux/coresight.h b/include/linux/coresight.h index a859fc00eef9..e4d32a239ae5 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -330,6 +330,16 @@ static struct coresight_dev_list (var) = { \ #define to_coresight_device(d) container_of(d, struct coresight_device, dev) +/** + * struct coresight_path - data needed by enable/disable path + * @path: path from source to sink. + * @trace_id: trace_id of the whole path. + */ +struct coresight_path { + struct list_head *path; + u8 trace_id; +}; + enum cs_mode { CS_MODE_DISABLED, CS_MODE_SYSFS, @@ -369,7 +379,7 @@ struct coresight_ops_sink { * Operations available for links. * @enable: enables flow between iport and oport. * @disable: disables flow between iport and oport. - * @trace_id: Collect the traceid. + * @trace_id: alloc or read the traceid. */ struct coresight_ops_link { int (*enable)(struct coresight_device *csdev, @@ -378,7 +388,8 @@ struct coresight_ops_link { void (*disable)(struct coresight_device *csdev, struct coresight_connection *in, struct coresight_connection *out); - int (*trace_id)(struct coresight_device *csdev); + int (*trace_id)(struct coresight_device *csdev, enum cs_mode mode, + struct coresight_device *sink); }; /** @@ -388,16 +399,16 @@ struct coresight_ops_link { * is associated to. * @enable: enables tracing for a source. * @disable: disables tracing for a source. - * @trace_id: collect the traceid. + * @trace_id: alloc or read the traceid. */ struct coresight_ops_source { int (*cpu_id)(struct coresight_device *csdev); int (*enable)(struct coresight_device *csdev, struct perf_event *event, - enum cs_mode mode, struct coresight_trace_id_map *id_map); + enum cs_mode mode, struct coresight_path *path); void (*disable)(struct coresight_device *csdev, struct perf_event *event); int (*trace_id)(struct coresight_device *csdev, enum cs_mode mode, - struct coresight_trace_id_map *id_map); + struct coresight_device *sink); }; /** @@ -703,4 +714,6 @@ int coresight_init_driver(const char *drv, struct amba_driver *amba_drv, void coresight_remove_driver(struct amba_driver *amba_drv, struct platform_driver *pdev_drv); +int coresight_etm_get_trace_id(struct coresight_device *csdev, enum cs_mode mode, + struct coresight_device *sink); #endif /* _LINUX_COREISGHT_H */