From patchwork Tue Nov 1 16:30:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 13027204 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 87B31C4332F for ; Tue, 1 Nov 2022 16:33:29 +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=PukZeMY0txpcxW 6EVwd0Rnq8S2A9CKnql7c/tkKYWVq3nxdZ0iR0Qi8QCC2NXH1MilGD8NGP8/SJqA5mxQccEzgOYus moxBEcH/IFoeadbRfndoSIKgBsFrpbZuXOPGpbS5a/hIXFJ5x9+B6iD8H/YQN/bB7///3zpg+CapS YvJ0dZ2hrirDpj8JBcVY3a74CSmfTF3Ff2KOhd3sTUxTwZMTjmUY6A3/JJ+92w/PCZZQfDyI4BLf4 DgK/UZ9VTAw/skA8xc5r8qTCUO7+84BvegkUsaDNzlUBSwI/kzDa/Nw6CWp/XNkjzZgUaNZvDDR94 Kjhrz8KhJ3t1pAcSVBsg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1opuBf-0060Cd-Mo; Tue, 01 Nov 2022 16:32:27 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1opuAj-005zlm-7p for linux-arm-kernel@lists.infradead.org; Tue, 01 Nov 2022 16:31:33 +0000 Received: by mail-wm1-x331.google.com with SMTP id t4so9166613wmj.5 for ; Tue, 01 Nov 2022 09:31:26 -0700 (PDT) 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=xkyBzfZ/qvkEPYtJJ/tFUtt+SWB31CHZL+J6ISL9W6kDJX8DVF3+em0wRmakkx6MuM WmwIvJYHGsHMWupgFn7jAboL8vHCQY6RnelTi0f4yTtVWVcvcm22Bc8O5lJt90WGWAsw 2FP5qpprfmQFsZiffssNrcgM7tk8enOExuCMgahoXQNUZh79ZfcSpcuZVPpY/fmXqjOI ANTd3DjQXD/IUkO0l938KH2H3QBjNjvO2pyJGTb2fGL3qvpZJUgED/ImvnLknz/R+22N nUfhxy9EosSi+aoslQVGlRFn7N15w+SmF2WnF1DAakF91VB1a1pq42qcjM0tauX0r0Xq M02Q== 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=iIrLatocLEaeL0mWv5xnbcewGLpKzqBZG/gsIUQE6W3G8k69OxxPoLM4Q1+xy9ofo7 vEyrKtLYUxA2W6UB2uxzXLtfRb4AP1XbJmxm1Fv7rriMdhlIL4QPfpx9kAAHKRb8vTSn DnDWGhoL12SNPSigqwg4LHMrRu0vHA0cn6z1ubtCopUelmzuzW1Kn+EwozTjAx7NGlN1 O0hzeh5RAXqbo8TcvWd6RkbIUzJwm/O+FewcYcwAntuGu8i0rcrg4jaB6Ku5IqSE4z9j YKDlkpLV+6jMEfaBq/qEgvBsfz4TEw3BVg+qYCRpsW5YCeTvTn5wt7tdBTGi28523i8M DFgw== X-Gm-Message-State: ACrzQf3JcOqCMxLdlY2hG9obzvz7XWQCptMNQBdGUZt9qUxNwpOEeQW8 bC3ewnLf55FzZWbEY4hSQWrFNipg8Pdm6w== X-Google-Smtp-Source: AMsMyM7grgGro5gge+919nXbiGqekcFAHp1UnOzkqrFAXyKsjkMilBLOMtfANRNkXVrpvkyH0qY2IQ== X-Received: by 2002:a05:600c:4252:b0:3cf:678a:d189 with SMTP id r18-20020a05600c425200b003cf678ad189mr11653758wmm.51.1667320285595; Tue, 01 Nov 2022 09:31:25 -0700 (PDT) Received: from linaro.org ([2a00:23c5:6809:2201:e844:18b6:fc5:bbc9]) by smtp.gmail.com with ESMTPSA id bu15-20020a056000078f00b0022ac1be009esm8339844wrb.16.2022.11.01.09.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 09:31:24 -0700 (PDT) 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 v5 04/14] coresight: stm: Update STM driver to use Trace ID API Date: Tue, 1 Nov 2022 16:30:53 +0000 Message-Id: <20221101163103.17921-5-mike.leach@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221101163103.17921-1-mike.leach@linaro.org> References: <20221101163103.17921-1-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221101_093129_356120_AC71FA3D X-CRM114-Status: GOOD ( 20.64 ) 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);