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 A7340C25B74 for ; Thu, 16 May 2024 13:23:38 +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:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QM7c+8oZJQ6QEmk27xq5K1p0DxmsgFOKKcQcTcPA0hU=; b=q4ekb8qByGuIG2 1dXLzPgHoCPUTVRCDHZ4Hn1NU+cyZ/xK5MFVXD31phwvBCuhKcraQM16LHJXaPoB3bJbqZMxPf+QK NBFmmSg6JzeuWr/WUnqTmYHrmVFpoubcPfdeIsBBILxXI5SnBGhcz64jca0NHveUIY9iD0inF/kuI Ia5HBYEe3WW7FqiRzLy9qnIgKSz+A/RVldg/MekIgXQdzBcbsFFJ6FJ/fGXbXs905eno7hLMfssjf Dva2lt3Vqt+V6lh+KLEnNtLjXTpjf6prueybYJ2d/KqILQrgK8X1CfGZm+0YhIOCI8CRGW8Hv8InE 8ijLnNCwMhpdtCvFJtpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7b4s-00000004zvZ-1eId; Thu, 16 May 2024 13:23:22 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7b4p-00000004zuX-09Hm for linux-arm-kernel@lists.infradead.org; Thu, 16 May 2024 13:23:21 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5FDA3DA7; Thu, 16 May 2024 06:23:38 -0700 (PDT) Received: from [10.91.2.16] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B7B0C3F7A6; Thu, 16 May 2024 06:23:11 -0700 (PDT) Message-ID: <34e8c1b9-e351-46c9-abbc-2cef9d0a71db@arm.com> Date: Thu, 16 May 2024 15:23:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 2/3] coresight: Add reserve trace id support To: Mao Jinlong Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Tingwei Zhang , Yuanfang Zhang , Tao Zhang , songchai , Suzuki K Poulose , Mike Leach , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexander Shishkin References: <20240516025644.4383-1-quic_jinlmao@quicinc.com> <20240516025644.4383-3-quic_jinlmao@quicinc.com> Content-Language: en-US From: James Clark In-Reply-To: <20240516025644.4383-3-quic_jinlmao@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_062319_285036_A0E4EEA6 X-CRM114-Status: GOOD ( 19.47 ) 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 On 16/05/2024 04:56, Mao Jinlong wrote: > Dynamic trace id was introduced in coresight subsystem so trace id is > allocated dynamically. However, some hardware ATB source has static trace > id and it cannot be changed via software programming. Reserve trace id > for this kind of hardware source. > > Signed-off-by: Mao Jinlong > --- > .../hwtracing/coresight/coresight-platform.c | 26 +++++++++++++++++++ > .../hwtracing/coresight/coresight-trace-id.c | 24 +++++++++++++++++ > .../hwtracing/coresight/coresight-trace-id.h | 11 ++++++++ > include/linux/coresight.h | 1 + > 4 files changed, 62 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c > index 9d550f5697fa..d3e22a2608df 100644 > --- a/drivers/hwtracing/coresight/coresight-platform.c > +++ b/drivers/hwtracing/coresight/coresight-platform.c > @@ -183,6 +183,17 @@ static int of_coresight_get_cpu(struct device *dev) > return cpu; > } > > +/* > + * of_coresight_get_trace_id: Get the atid of a source device. > + * > + * Returns 0 on success. > + */ > +static int of_coresight_get_trace_id(struct device *dev, u32 *id) > +{ > + > + return of_property_read_u32(dev->of_node, "trace-id", id); > +} > + > /* > * of_coresight_parse_endpoint : Parse the given output endpoint @ep > * and fill the connection information in @pdata->out_conns > @@ -315,6 +326,12 @@ static inline int of_coresight_get_cpu(struct device *dev) > { > return -ENODEV; > } > + > +static int of_coresight_get_trace_id(struct device *dev, u32 *id) > +{ > + return -ENODEV; > +} > + > #endif > > #ifdef CONFIG_ACPI > @@ -794,6 +811,15 @@ int coresight_get_cpu(struct device *dev) > } > EXPORT_SYMBOL_GPL(coresight_get_cpu); > > +int coresight_get_trace_id(struct device *dev, u32 *id) > +{ > + if (!is_of_node(dev->fwnode)) > + return -EINVAL; > + > + return of_coresight_get_trace_id(dev, id); > +} > +EXPORT_SYMBOL_GPL(coresight_get_trace_id); > + > struct coresight_platform_data * > coresight_get_platform_data(struct device *dev) > { > diff --git a/drivers/hwtracing/coresight/coresight-trace-id.c b/drivers/hwtracing/coresight/coresight-trace-id.c > index af5b4ef59cea..536a34e9de6f 100644 > --- a/drivers/hwtracing/coresight/coresight-trace-id.c > +++ b/drivers/hwtracing/coresight/coresight-trace-id.c > @@ -110,6 +110,24 @@ static int coresight_trace_id_alloc_new_id(struct coresight_trace_id_map *id_map > return id; > } > > +static int coresight_trace_id_set(int id, struct coresight_trace_id_map *id_map) > +{ > + unsigned long flags; > + > + spin_lock_irqsave(&id_map_lock, flags); > + > + if (WARN(!IS_VALID_CS_TRACE_ID(id), "Invalid Trace ID %d\n", id)) > + return -EINVAL; > + if (WARN(test_bit(id, id_map->used_ids), "ID is already used: %d\n", id)) > + return -EINVAL; Do these returns not skip unlocking the spinlock? It might be slightly fewer changes if we update the existing coresight_trace_id_alloc_new_id() to add a new "only_preferred" option. Then use the existing system id allocator which already handles the lock and unlock properly: static int coresight_trace_id_map_get_system_id(struct coresight_trace_id_map *id_map, int id, bool only_preferred) { ... spin_lock_irqsave(&id_map_lock, flags); /* prefer odd IDs for system components to avoid legacy CPU IDS id = coresight_trace_id_alloc_new_id(id_map, id, true, only_preferred); spin_unlock_irqrestore(&id_map_lock, flags); ... I suppose the end result is the same as your implementation, but it trades making one existing function slightly more complicated instead of adding some new ones. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel