Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7919367rwb; Wed, 23 Nov 2022 12:36:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf4KQPpS+EtJqBgc/5dQkfgNtDgRSTfVcq5brb4cEGKolIdp8/ls4TC2ERQR44PWb6BbLBTr X-Received: by 2002:a63:902:0:b0:470:f04:5ca5 with SMTP id 2-20020a630902000000b004700f045ca5mr8890894pgj.323.1669235818616; Wed, 23 Nov 2022 12:36:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669235818; cv=none; d=google.com; s=arc-20160816; b=UIFHnVnw27XGWlJhzzyXFi4iwbj7zoDCX+i7lR0MwIEL1gRLgcNHpciY67jLNzKcoB o+KBWvt8hRUtEBFOwlZ+Q++HhV6DcPavx2/37fO4swK0y+DNMI2mjcivnGkCsLxXxK+Z o9STCNykD/aXLSyPmcESjLvGz1wNEj5s7iDafP2Hg226V0tceLowge4Z/QBixH5WtUWV 8H1Qcjs8wRiZRtGY3BRxv8QAm2hdj67eWYei9tnDYsx98FSieCu89Pon0WDDaIAO5fLc 4EJFvFonr3RkOJM8PP7KyUJCr1XRPS1BpPZX4vvEzMhcUTf9HNoYVjlt5ND2wKvI1I8n ldBQ== 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=mtjAlTf5SHIR+sLbTqTmZsDkkg7zFKEwgvrRwWFG45aTxNVK9Qdp0Vuabl79PL4yky 2XJu8eR6TC5mNwdaZAMTkgPA6kYgz6ySbPu1V2DhWTuI464vUZrjxppii3aGvipbbCfh ky/cGlUPOLuWJNP00dBQjK6bke+IvvbN+qD/+w7nKtG/lSao2CBjv5Q39B0EQrMCgP7L 0mStAEWJt4RI8qFHQb3hGw4mrB4a9CEgeOcLpbIg6Odpt7uignvanW+V1L+Y9uoJrban j2buxeWintveePadh+0Vb2EThN45QrZ4z7kwxgs7fQEI8SlYCHDcwPMb0pNPt40SGYT4 j7Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MXB1jGCm; 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 c192-20020a624ec9000000b0056ec4a6babasi15680134pfb.381.2022.11.23.12.36.45; Wed, 23 Nov 2022 12:36:58 -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=MXB1jGCm; 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 S235714AbiKWTut (ORCPT + 88 others); Wed, 23 Nov 2022 14:50:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238103AbiKWTu3 (ORCPT ); Wed, 23 Nov 2022 14:50:29 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81078786D2 for ; Wed, 23 Nov 2022 11:50:26 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id a11-20020a05600c2d4b00b003cf6f5fd9f1so2053112wmg.2 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=1CmNID+XzgZeC7psboKoC1OdO3VMW7XWO6n+RrCEWJWm3oJKqHtQIPjqbAvrMyV+8H w7aGkxMQGJzxwQtydGQ16vk6PifRTRsoHnpAakSQfOGx5s3AUpI/j6syelfT7lBc4Dba dXQnyq7nPSLqrfZ6RLr9vNJboysOGMmtRYCISbxLemBKnCl0RWip8Swj7sAuUMEdhPuH T6p5ViYHyiO3wnqacOvtv3oDA7F+BjtB06YVji/kPebmqrx1bNzYdzbp0Tp5IlLAr89+ T8e53ibooK08gvBZw1MvbcS5wHSBkZeXhWMJKJSvJexUS4c1crCCcCladVfOm5e3IHHu bbuQ== X-Gm-Message-State: ANoB5pnqQuH4a247PgTJ4oLZNYDDUTabQEDzB9cdeSbl7xjPBx3/4foI iniv/cV8zBQSeSa80+qtprL6sA== 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-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