Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3197138rwb; Mon, 16 Jan 2023 05:08:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXvfY7qHhGfOx1fW5dCsbi6hqG1sl8vs6LR+lWDNkWNa84JSsUpqrYptudgBYYaljGxA47Z6 X-Received: by 2002:a17:907:9a98:b0:7c1:d4c:f08c with SMTP id km24-20020a1709079a9800b007c10d4cf08cmr82647092ejc.4.1673874534260; Mon, 16 Jan 2023 05:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673874534; cv=none; d=google.com; s=arc-20160816; b=EtEzUcKPiQ/utBpOswOxMKmCVaLyyLxaUvlobErCoZv1xIxUM7FZ/oN3XGfjpJ6cjc IrKtm5NWO8EkKnAjHv6z20pabTNAkYx1nrNQPY9Ju7655YuwGJ5kY0aOg6ilnM3N3ELT f+e5mbqa2epbHS2JVzueMR4pJcqleFOypX60owrvLh8r1zw/3K1qJ1wGJ17ulaTUtgs7 UVogeGfGSQ6jYT2sM1j1FhArr9hriXPZ27pVw8GQTZoKXurqFDJYtuV1QVWoUtw5aTPF 6e6t55+JOzeuK/2ahFvv3CirWSAdU917tvx3r8rrfRrM1Mkfjuv2T+ciO8R2VN6mHyNL iUxQ== 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:dkim-signature; bh=Msiba57uIoQyW0yBXGfGPLCUUWKUrx8bYCzahjs4eQE=; b=zzMfIQrbQrXZ+Qsq7I4OMUvwlBMg4riHwBEGA1n+j/cXRvDjkGiF0CzHmBhZw0rPfl iRbNGCzuX/2BcbUB1ClAaOtvw7HFuod90j+o6z+bITbszRfiQ2nTzUCtOSIMwW/4X8Bg 5v0H2og4m5owt7v6o658FIygNxPK7WtUqSMSu7rQyPR8t9rl0Iw9iY1TuoJH9Sw79ZBN zZXLbMV2p/9isPtHPwemqFILjkF+C1KVawsw/8asBKWGKaicJlUE5kgm7nPjsw/TxMTe OKX2ZbMhXDkKmdmVSX6MMcm50VuE+yZD1lRtmn9b6ReQdfcevxDGv+agWzjMO6C0x9vR 7eiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ULf73b4P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go9-20020a1709070d8900b0086ea1c7ae27si6682406ejc.241.2023.01.16.05.08.41; Mon, 16 Jan 2023 05:08:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ULf73b4P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231128AbjAPMuF (ORCPT + 51 others); Mon, 16 Jan 2023 07:50:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230451AbjAPMto (ORCPT ); Mon, 16 Jan 2023 07:49:44 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CD3A1E5F5 for ; Mon, 16 Jan 2023 04:49:40 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id f25-20020a1c6a19000000b003da221fbf48so5753388wmc.1 for ; Mon, 16 Jan 2023 04:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Msiba57uIoQyW0yBXGfGPLCUUWKUrx8bYCzahjs4eQE=; b=ULf73b4PZTSIvU+sVWArVsZHvItjOzh0GNp/PpJOHEEi45+pehABGahBQCZ3y56/Eh 1oPwuCCm/wYSiG0a1hQ/9844+4hnI/UdOV6jWzg7wy7Fhc7e1EjWXJ8ZcqcOKibbl78/ cVrfQbH9Y4nFOC7au/C1JO9SaA1joWMrmdwlOjv8y3t59PrRLDdigHyifs2by7Sebn7W XDMImkGSouEXgjucrxCA72WM+CcE0wVpq6gAS/0jz6woduY9vg3gIsPHDTm8vrI2qpLr Vh0fWxZTg3cwcHJIcnilRJNi8wswqPj7X2VHd9ttwgSeuZmPY5d15dU+FOqxZledl8cl sxWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=Msiba57uIoQyW0yBXGfGPLCUUWKUrx8bYCzahjs4eQE=; b=5XPN6wmag/pebC8Wu5vDMNta2ETei2v1jxz69dq1dL5SeH42XeUH5UC4NceYvXc2O1 L/GRl8wbJ07TTyYnI9jCn8+FDohVZId6eNWY5CtY+b93HN0Hi/oDWz9ITLHoeb8DcrJW ax9bOtHJVCjlE/mWAUiGHDtQVKduPYoT4c2sCCH9geYToj8FavxOXqtYu61WmYUFxnqY nHNuBcNMHd7K08d+/ZIl7dbfkXftrFFr/992R5hmyOhbdOou1P1pR4SHUqxkbV9oT8GI 6ILAu3XMIyKF+B63hO8vypDhosGOdf1EA4uCh2OWcM1Q2qgWlxVWsYWQyqOI3GLZJ1GD V1/A== X-Gm-Message-State: AFqh2kotIn5A+5yjuxgCsb8zEYwWglMV586Rr3ZnP6oRDatCpN+CkLPS 3Caa7e0b46N9iFSVxJxtVYXlhw== X-Received: by 2002:a7b:cc1a:0:b0:3da:fbcd:cdd2 with SMTP id f26-20020a7bcc1a000000b003dafbcdcdd2mr2978788wmh.9.1673873378751; Mon, 16 Jan 2023 04:49:38 -0800 (PST) Received: from linaro.org ([2a00:23c5:6809:2201:6c91:710d:9433:e868]) by smtp.gmail.com with ESMTPSA id fl12-20020a05600c0b8c00b003dab40f9eafsm6896832wmb.35.2023.01.16.04.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jan 2023 04:49:38 -0800 (PST) From: Mike Leach To: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: mathieu.poirier@linaro.org, suzuki.poulose@arm.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-perf-users@vger.kernel.org, leo.yan@linaro.org, quic_jinlmao@quicinc.com, Mike Leach Subject: [PATCH v7 04/15] coresight: stm: Update STM driver to use Trace ID API Date: Mon, 16 Jan 2023 12:49:17 +0000 Message-Id: <20230116124928.5440-5-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230116124928.5440-1-mike.leach@linaro.org> References: <20230116124928.5440-1-mike.leach@linaro.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Updates the STM driver to use the trace ID allocation API. This uses the _system_id calls to allocate an ID on device poll, and release on device remove. The sysfs access to the STMTRACEIDR register has been changed from RW to RO. Having this value as writable is not appropriate for the new Trace ID scheme - and had potential to cause errors in the previous scheme if values clashed with other sources. Signed-off-by: Mike Leach Reviewed-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-stm.c | 41 +++++++-------------- 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 463f449cfb79..6af1b996af6f 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -31,6 +31,7 @@ #include #include "coresight-priv.h" +#include "coresight-trace-id.h" #define STMDMASTARTR 0xc04 #define STMDMASTOPR 0xc08 @@ -615,24 +616,7 @@ static ssize_t traceid_show(struct device *dev, val = drvdata->traceid; return sprintf(buf, "%#lx\n", val); } - -static ssize_t traceid_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - int ret; - unsigned long val; - struct stm_drvdata *drvdata = dev_get_drvdata(dev->parent); - - ret = kstrtoul(buf, 16, &val); - if (ret) - return ret; - - /* traceid field is 7bit wide on STM32 */ - drvdata->traceid = val & 0x7f; - return size; -} -static DEVICE_ATTR_RW(traceid); +static DEVICE_ATTR_RO(traceid); static struct attribute *coresight_stm_attrs[] = { &dev_attr_hwevent_enable.attr, @@ -803,14 +787,6 @@ static void stm_init_default_data(struct stm_drvdata *drvdata) */ drvdata->stmsper = ~0x0; - /* - * The trace ID value for *ETM* tracers start at CPU_ID * 2 + 0x10 and - * anything equal to or higher than 0x70 is reserved. Since 0x00 is - * also reserved the STM trace ID needs to be higher than 0x00 and - * lowner than 0x10. - */ - drvdata->traceid = 0x1; - /* Set invariant transaction timing on all channels */ bitmap_clear(drvdata->chs.guaranteed, 0, drvdata->numsp); } @@ -838,7 +814,7 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata, static int stm_probe(struct amba_device *adev, const struct amba_id *id) { - int ret; + int ret, trace_id; void __iomem *base; struct device *dev = &adev->dev; struct coresight_platform_data *pdata = NULL; @@ -922,12 +898,22 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) goto stm_unregister; } + trace_id = coresight_trace_id_get_system_id(); + if (trace_id < 0) { + ret = trace_id; + goto cs_unregister; + } + drvdata->traceid = (u8)trace_id; + pm_runtime_put(&adev->dev); dev_info(&drvdata->csdev->dev, "%s initialized\n", (char *)coresight_get_uci_data(id)); return 0; +cs_unregister: + coresight_unregister(drvdata->csdev); + stm_unregister: stm_unregister_device(&drvdata->stm); return ret; @@ -937,6 +923,7 @@ static void stm_remove(struct amba_device *adev) { struct stm_drvdata *drvdata = dev_get_drvdata(&adev->dev); + coresight_trace_id_put_system_id(drvdata->traceid); coresight_unregister(drvdata->csdev); stm_unregister_device(&drvdata->stm); -- 2.17.1