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 42E0EC48BEB for ; Thu, 15 Feb 2024 10:55:50 +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-Type: Content-Transfer-Encoding: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=h8IABZCo6+X4nMfL7RPQtgZ5ewORrs9NCwy6yv4g3uk=; b=gz7HQ/+CFJq2Ch MqtqCIPt7Cz0MKUDSA6GUVXRDYAXAS+x9bWChTiQ2/ejFwiJ01Vn8945oaqYXFJS1u9LT7/bT3H3P iAkfIUpO1gkauOgRnBbVKJYcwBsLPo0akMnsFOJxCyCh48qdRI0+TqYw1GJvKM4stl6vcHBBXLuge wFDVY8zrBRwDQdEFUlEOkZuIBYtL9/owLloff+il2IfolTsbyDVBQL5Fxt67Y7LrJx8A9xT1k/oww 0WYtXS73Mx5X9A2v6HVvYzieian/6Wa8J0asrJmtjhdCZv/xsuv8aMM3rmrXvxePMtvOND4zJ+xx7 4WaTAuGFzPT7+/Z+DOkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raZP1-0000000FtuK-1QK9; Thu, 15 Feb 2024 10:55:39 +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 1raZOz-0000000Ftth-1iZq for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2024 10:55:38 +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 2108D1FB; Thu, 15 Feb 2024 02:56:16 -0800 (PST) Received: from [10.57.49.250] (unknown [10.57.49.250]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AABD83F7B4; Thu, 15 Feb 2024 02:55:33 -0800 (PST) Message-ID: <56d56f85-6172-4fb1-a002-fe82ffc8a66a@arm.com> Date: Thu, 15 Feb 2024 10:55:32 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V4 02/11] coresight: stm: Extract device name from AMBA pid based table lookup Content-Language: en-GB To: Anshuman Khandual , linux-arm-kernel@lists.infradead.org Cc: Lorenzo Pieralisi , Sudeep Holla , Mike Leach , James Clark , Maxime Coquelin , Alexandre Torgue , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org, linux-stm32@st-md-mailman.stormreply.com References: <20240123054608.1790189-1-anshuman.khandual@arm.com> <20240123054608.1790189-3-anshuman.khandual@arm.com> From: Suzuki K Poulose In-Reply-To: <20240123054608.1790189-3-anshuman.khandual@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_025537_590343_FAE2091E X-CRM114-Status: GOOD ( 20.27 ) 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23/01/2024 05:45, Anshuman Khandual wrote: > Instead of using AMBA private data field, extract the device name from AMBA > pid based table lookup using new coresight_get_uci_data_from_amba() helper. > > Cc: Suzuki K Poulose > Cc: Mike Leach > Cc: James Clark > Cc: coresight@lists.linaro.org > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-stm32@st-md-mailman.stormreply.com > Signed-off-by: Anshuman Khandual > --- > drivers/hwtracing/coresight/coresight-priv.h | 10 ++++++++++ > drivers/hwtracing/coresight/coresight-stm.c | 14 +++++++++++++- > 2 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h > index 767076e07970..68cbb036cec8 100644 > --- a/drivers/hwtracing/coresight/coresight-priv.h > +++ b/drivers/hwtracing/coresight/coresight-priv.h > @@ -221,6 +221,16 @@ static inline void *coresight_get_uci_data(const struct amba_id *id) > return uci_id->data; > } > > +static inline void *coresight_get_uci_data_from_amba(const struct amba_id *table, u32 pid) > +{ > + while (table->mask) { > + if ((table->id & table->mask) == pid) Why are we masking table->id ? table->id is a static value that the driver wants to check for "variants" of a given device. The table->mask is there to filter out the "irrelevant" bits of the PID that we read from the device. So this should instead be: if ((table->mask & pid) == table->id) > + return coresight_get_uci_data(table); > + table++; > + }; > + return NULL; > +} > + > void coresight_release_platform_data(struct coresight_device *csdev, > struct device *dev, > struct coresight_platform_data *pdata); > diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c > index a1c27c901ad1..9cdca4f86cab 100644 > --- a/drivers/hwtracing/coresight/coresight-stm.c > +++ b/drivers/hwtracing/coresight/coresight-stm.c > @@ -804,6 +804,18 @@ static void stm_init_generic_data(struct stm_drvdata *drvdata, > drvdata->stm.set_options = stm_generic_set_options; > } > > +#define STM_AMBA_MASK 0xfffff > + > +static const struct amba_id stm_ids[]; > + > +static char *stm_csdev_name(struct coresight_device *csdev) > +{ > + u32 stm_pid = coresight_get_pid(&csdev->access) & STM_AMBA_MASK; Similar to above: Why do we apply a "custom" mask to the PID and later check the PID with that of the table->pid. The way it is supposed work is : (table->mask & dev_pid) == table->pid the table->mask is there for a reason: i.e., to get the relevant bits from the device_pid and compare it against "the" expected value (table->pid). Suzuki > + void *uci_data = coresight_get_uci_data_from_amba(stm_ids, stm_pid); > + > + return uci_data ? (char *)uci_data : "STM"; > +} > + > static int stm_probe(struct amba_device *adev, const struct amba_id *id) > { > int ret, trace_id; > @@ -900,7 +912,7 @@ static int stm_probe(struct amba_device *adev, const struct amba_id *id) > pm_runtime_put(&adev->dev); > > dev_info(&drvdata->csdev->dev, "%s initialized\n", > - (char *)coresight_get_uci_data(id)); > + stm_csdev_name(drvdata->csdev)); > return 0; > > cs_unregister: _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel