From patchwork Wed Nov 23 19:50:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 13054257 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 41F22C4332F for ; Wed, 23 Nov 2022 20:28:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tvBaZeSQB8nT7ZYHYYtmSdX5Z8gYMA1KjFCuddJ7uuM=; b=u8wJly76loqC2g Rtoe93z1PEQGEXPDKnNckP4VI6A5nJ0H4qAte0yz8Hk1aVlTAfqnTfyyCIgOEooIUysR4Us4C1eTm QPKpJDEKG5aTp+vB2ZSSOPBJRDZPU8oKBekJGKGSRcrbgf6xsCWY4fLyYmPCNOwVRHb5rieUK5hil yU1HGCmaMjtbgDbm9ptKJz2eGm2YKk3rSl1isSaM9lby+5XYmo5BS8O8lWO1F5QnxGWIyC2sueIVj b9Y+G1xCmEDh3jp+pTuv6NlG+T2jD3flkUcdww+uuNWjrx68cja+bvuQU+mx2MsU1HVe/fRcoY/Nb Uz2kIjaLQOVxXmZ9Nt5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxwKo-002G1n-Ul; Wed, 23 Nov 2022 20:27:07 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxwKb-002FuA-1q for linux-arm-kernel@bombadil.infradead.org; Wed, 23 Nov 2022 20:26:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=References:In-Reply-To:Message-Id:Date :Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Msiba57uIoQyW0yBXGfGPLCUUWKUrx8bYCzahjs4eQE=; b=Ie71Uuq3R3LWEsleWgkA2j5l2/ k0CfOEYq1YuwMb30hOmJZy1wR+6Qgn6yBelK+YIuQXtErhlvGKlMT1BxZEaHYlYe8qIPmWCnvLnnA cMuk+ekYvD55DoTELxEbmiig4u52gDBG4Fq4YkNCZMEAaWhZzg08NOOZwXgUVqOUCgBBW1Yn7bDX3 /RnUbAAHzki1QMUVtzGOAW18zYnvaQTIj+HWsgoJ+BRDnO3RF83T1r2qwAmCcbyEkzJa5VIw7q8pD SE5ZoTFurhcZ6tzIakEaksYe9wB28adLjMv4dBb9Jv1IMWUIJWjATMJtWU2VIzcZZXbjKAKqs28eZ Nd4wn6DQ==; Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oxvlS-003unY-08 for linux-arm-kernel@lists.infradead.org; Wed, 23 Nov 2022 19:50:39 +0000 Received: by mail-wm1-x331.google.com with SMTP id p13-20020a05600c468d00b003cf8859ed1bso2058842wmo.1 for ; Wed, 23 Nov 2022 11:50:26 -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=MXB1jGCmfUHw4ekjpgzWiJDLBOFelfcfIsTgcjt+m3SaajVC2QvoRCKxX+QxtleoDH iUc0VocvdnIItR0SvDD6Y7HCNSrAUXvSJNrcpmDv+kdtnHS54hwva8ggwr1FG6wntbyO 99RrMd3c7uwAB3Gjs96z0cf/5Fv2OlVb7Zj4MzbeT/xl5T+glGPFVNMf9WpskFvxS8BW z/toUrSagHcirCf4wVIk179pROdutmJ5vFymDGo9o8TtpFeE2iY6fgHHqlQ3n2PV3IIZ GCNc5TXMZwNwffkiPAgVIbJovzoYHOsL2P2CDmGJZRMp7agRKvBF4T3D48JBM3MhQlnu ahPA== 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=uiX36gYVNF7QIP8iFyYH9jl9MrieYkGCpqglbiuH88K8KMrt1IY5ND7z9bWQb2c/Iw +Ko3rCPFkr80CFrIVEVJQlIJdFK2S1DKquOu5/CUNr2eNt2d5aWYb1TZsidca3t3gC4L htDRACk54kN7qvw5NOJZPJaSh/ZJUHdH1F32z09DSDv7MwSaOeynNt2kEVFP2L4RVc2v 0nJEcIDBbeyfi45q4bTF5gi4oZsthutbGOFY5dayNv6/DoU7JFc7xY8HuqKh4LXxVoXg U/XDhoBicJEf/zIjlHH63wCjj2LqiHRtQ4MrZn0aOhnoRF7extr7P1ox8UdJtqriaYIg Y3Jg== X-Gm-Message-State: ANoB5pm2wNUppHEydA6kvrIiJHKFtjQgLXN0fbprTRY4/F5HncxyIKo/ Nn6XSNSVCUuSv/D0dr6po8doJg== X-Google-Smtp-Source: AA0mqf4SxI1FHU824IE2lweG4VRy9wGzePSg/hnLe24uw62BkEOVr0cTBWjO5/zYcpzH+Cev4VTxQA== X-Received: by 2002:a05:600c:a14:b0:3c7:a5:6113 with SMTP id z20-20020a05600c0a1400b003c700a56113mr11177850wmp.129.1669233025035; Wed, 23 Nov 2022 11:50:25 -0800 (PST) Received: from linaro.org ([2a00:23c5:6809:2201:fcbc:7b5d:8d6c:43a4]) by smtp.gmail.com with ESMTPSA id w5-20020a5d6805000000b002364c77bcacsm7267414wru.38.2022.11.23.11.50.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Nov 2022 11:50:24 -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 v6 04/14] coresight: stm: Update STM driver to use Trace ID API Date: Wed, 23 Nov 2022 19:50:00 +0000 Message-Id: <20221123195010.6859-5-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221123195010.6859-1-mike.leach@linaro.org> References: <20221123195010.6859-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221123_195034_278126_DDEAF859 X-CRM114-Status: GOOD ( 20.00 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);