From mboxrd@z Thu Jan 1 00:00:00 1970 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 8B115C433FE for ; Thu, 6 Oct 2022 13:56:12 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NLD0Nv24s7aWbqaV3X+rPmQhvxkZDfYg3od+lWFpTbg=; b=ch8PKGVdfcog6J UaNdjf/F453Dfux8AtzLUbaG+yZDcKGKnT6sxo0Twvez2S+4NdflAOi2K9rpEPV3ULSVyScc78r77 IboT4HUvjI9DY4Daa/wYXvr7UmgFrM3ajMfKuBIxg88GNyIW4Ei/kWhwEZRYVyg278n5OFuEyxbGB YOLjkKwPdEKL5Dt26D2yttyuhDZe+PyZ9q3Nuc7DANLC6Bdiw0Zv0/tidHlEMyrJWDmopLGL/7gEI 1kB776TDjlRX31R1dqY7tqoQwV2AkmX2Hvks0HLGFIEV30gc1/zJOQUqII9SEdE7fY7CSjKL2Ttfj 9NiFMPgxICB3qfnKYwlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogRLA-002pJ1-AN; Thu, 06 Oct 2022 13:55:08 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogRL6-002pHV-UD for linux-arm-kernel@lists.infradead.org; Thu, 06 Oct 2022 13:55:06 +0000 Received: by mail-pl1-x633.google.com with SMTP id l1so1748144pld.13 for ; Thu, 06 Oct 2022 06:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=GNscnZawRSDQzcarRuJ7ggWN/Upkivk6LJB9jm7BUAk=; b=BESDIcpUHn+E7ivOxrUkidOviXvpwCq2MRue2gIuswNndgRPzvFaivL7Nd/p1iV567 GGf+EpEIp2KMxGEW8fruwQ5jFG4mI6Ft4KsjARUxSyClS/fQ5tpsSyS2jQu4twNEtGj4 f5cMJJjiuan4QmcrS0jyt8ImhHWj2q1DeED+5wyeDI/23l/hmv9mUQTkC99Afu8Jzw0j No8dK2IvE+tfUf69ikOdnNMPU5mVzos+Jubf1afaQynbFwOMlGK8MAetpYMaC5CZpscb ywjTc613OjeDjt07y9JvAz6R7QfECG5j8qGLy1E11EiT70KDdHpzQg4I7TZqAT1wO+4w k34w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=GNscnZawRSDQzcarRuJ7ggWN/Upkivk6LJB9jm7BUAk=; b=7y/xPmRzbejn9LUOE82elk6z5QXikf49UtBp7eKJlf3M8hj80qPrbcfynj3fbPtskq +OjYkRXxy6N/lrg71sBm07lyvGIBWA90n1o21xYCXPfIqAyF4of8K05aMYMwBGutnJC0 Z2sI4v8IRhgDb99vYT7d7SJJ+Jo76+GGHTkBR4O1/Kqpdx9SAfommTeGyyS7cc2xuH6N 7GxLhqhZuxEdurtzOgsbVd5Bs2i9P03NuWVIUxlUU6Qrln8nMzrqbfukWvnZvyUY/jRD nmQNbEvbH08Rw5O+GjX31c8FeErPrxWtM3qwjjzvpOBlJ1qwkOzx6dl8Y73M17kr/v9g M10A== X-Gm-Message-State: ACrzQf3NtWO2SxeT9SSv7cOL6q2nJfQDF+ft7mwm/+pO5saZQbuZhES2 dSKS4gjEHf7LuqQ2wLSMLDNscfP2Uw/lBO3c/xhP+Ne1s0X13g== X-Google-Smtp-Source: AMsMyM7w4WLaVjg1vKq7SIEJAdDjx6f75uDM8/Fw5Cc0L0xz/tWLHg/d+3Q1BFthTdn8Fc8zlzyJHq4Chz0n4BUZ7zY= X-Received: by 2002:a17:902:6b04:b0:17a:15a:1229 with SMTP id o4-20020a1709026b0400b0017a015a1229mr4651252plk.24.1665064502039; Thu, 06 Oct 2022 06:55:02 -0700 (PDT) MIME-Version: 1.0 References: <20220809223401.24599-1-mike.leach@linaro.org> <20220809223401.24599-4-mike.leach@linaro.org> <65e70db9-9f85-7285-0602-f2d29887550a@arm.com> In-Reply-To: <65e70db9-9f85-7285-0602-f2d29887550a@arm.com> From: Mike Leach Date: Thu, 6 Oct 2022 14:54:50 +0100 Message-ID: Subject: Re: [PATCH v3 03/13] coresight: stm: Update STM driver to use Trace ID API To: Suzuki K Poulose Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-perf-users@vger.kernel.org, leo.yan@linaro.org, quic_jinlmao@quicinc.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221006_065505_004642_B4DA6AE8 X-CRM114-Status: GOOD ( 32.80 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Suzuki, On Mon, 3 Oct 2022 at 10:04, Suzuki K Poulose wrote: > > On 09/08/2022 23:33, Mike Leach wrote: > > 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 bb14a3a8a921..9ef3e923a930 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); > > > > #define coresight_stm_reg(name, offset) \ > > coresight_simple_reg32(struct stm_drvdata, name, offset) > > @@ -819,14 +803,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); > > } > > @@ -854,7 +830,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; > > @@ -938,12 +914,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) { > > The above API returns "INVALID_ID" and not a negative error status. > I think it is better to fix the API to return: > > ret < 0 - If there is any error > - Otherwise a positive integer > And the users should be kept unaware of which ID is valid or invalid. > coresight_trace_id_get_system_id() returns the ID if one can be allocated or -EINVAL if not. Not sure what you are looking at here. Mike > Suzuki -- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel