From patchwork Mon Jan 16 12:49:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 13102971 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 2E931C46467 for ; Mon, 16 Jan 2023 12:51:23 +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=lvhFJbarkkdE+I BcVjbaLllDyh1y4q8Uk+apjzkOrgVTDiRxSf+MFmH9TnQhAI5Z7kfcabWO3vvooGMuLV1HIrLnfcs kMkhzAG3miGaedzY0tWGW+NLynuJ875Dqt3riEObS6gSNyoF3TF1pGNWl4r5MnzMdOkEgpOIy03rE //9MNzPz98SMOOk1INk7j+ktMd3L1Q/mDIPKNY0zPGlkAG95xrBRDP8Uza+4eqDua8cRdtx5mgcdu ErQAX3Pa329Q8VwDYiXVuqwdXajy49y4ewwwskRNds3UYRB2B4bUOF1XTgwNWI7gbbozbV42kBLIX 803ZVD1Fd6SDm5hx2K2g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHOwO-00A9yX-RC; Mon, 16 Jan 2023 12:50:21 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHOvk-00A9hD-7s for linux-arm-kernel@lists.infradead.org; Mon, 16 Jan 2023 12:49:44 +0000 Received: by mail-wm1-x32c.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso7053wmq.5 for ; Mon, 16 Jan 2023 04:49:39 -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=Djb41/OlIsZ4lsXxe/XhD0+R05Thto5iUSBWaT1J36bEp0K7pb5gmuDukqUZHAu2il kHMvlvic0WUfgWL7wUnd6AE/WOQx21VCd+kihESQLmHuHXeioVc+SCDvaBdo6H0StW6K hr0ypCFlJIo8EEpKicjLtG4tGKWmKHFjgj8uKwI5q+vxB0Lgz5NO5PQ5dGge5lCmKLUj QI2Hrtjr3JVnE4FfoizyRsCe6f9/w46IVaZEsuoOctCKRUbIGdS87biQeDGDl4Y45nEe SKp+tX6tICjyuchM69zq29WRiXXsjnFmVsRSgRxeDlnHcP3irVYZTyEPjhdCDaoHulPr 26KA== X-Gm-Message-State: AFqh2kqDcodGgcH9phNRC664aXuvckOsm529bs09MVwswHtfxQikksPQ WrBEHmbF89Xyv2W03hF34GpQSlzkDTEfJYeY X-Google-Smtp-Source: AMrXdXsxxVfGf3gHw0mUCjrgel3qxJbvLg1EMMy4ZQ5RKo54Bpvm/njlgYYxAUYq6mj/Tk+dIBcLrA== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230116_044940_297639_04E892F1 X-CRM114-Status: GOOD ( 19.75 ) 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);