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 58661C4829B for ; Mon, 12 Feb 2024 12:13:20 +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=uCOXsbE4vcuXUBi8JVCplgWIii80LVXU3G/j4sk1mwo=; b=utZN/xbGplpwYO GjuwHDsQ/OCwaU2HxznbW9P776mOTINsC8Josd9QaCR9gKz4WpUQla5fYC5SeDHbOuZaAn7lgb0l3 ziq5dAUtod3akeNynFLEnOz2boUOlyWi2ma4LC8+fCMdDBPKCIHPtwlPIK5r1RU8lLIXGL/wY+j3d fFwzCgg6NNGjQiY82GuOg85i1w3xpGxJ9JvT+e92mxHqB9imLC5pvygLBk0cPixTLDJYRsQCELXz8 sc6T52GgXk9ozk3r2y7euGd+Xfof+KnizhsnE0e3320X7p+yAgPI28uSm7J1zyPfIbUb+0S3Fbc24 WX5HN8LhRqjN9OkMRY6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rZVBP-00000005DYo-1e9d; Mon, 12 Feb 2024 12:13:11 +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 1rZVBK-00000005DWl-2tM9 for linux-arm-kernel@lists.infradead.org; Mon, 12 Feb 2024 12:13:08 +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 5A3EADA7; Mon, 12 Feb 2024 04:13:44 -0800 (PST) Received: from [10.57.47.180] (unknown [10.57.47.180]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6ED6F3F7BD; Mon, 12 Feb 2024 04:13:01 -0800 (PST) Message-ID: <44597c9a-79bd-40f8-87a7-b53582132583@arm.com> Date: Mon, 12 Feb 2024 12:13:00 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V4 03/11] coresight: tmc: Extract device properties 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-4-anshuman.khandual@arm.com> From: Suzuki K Poulose In-Reply-To: <20240123054608.1790189-4-anshuman.khandual@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240212_041306_933916_C5EEE248 X-CRM114-Status: GOOD ( 17.69 ) 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:46, Anshuman Khandual wrote: > This extracts device properties from AMBA pid based table lookup. This also > defers tmc_etr_setup_caps() after the coresight device has been initialized > so that PID value can be read. > > 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 > Signed-off-by: Anshuman Khandual > --- > .../hwtracing/coresight/coresight-tmc-core.c | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c > index 7ec5365e2b64..e71db3099a29 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-core.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c > @@ -370,16 +370,24 @@ static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata) > return (auth & TMC_AUTH_NSID_MASK) == 0x3; > } > > +#define TMC_AMBA_MASK 0xfffff > + > +static const struct amba_id tmc_ids[]; > + > /* Detect and initialise the capabilities of a TMC ETR */ > -static int tmc_etr_setup_caps(struct device *parent, u32 devid, void *dev_caps) > +static int tmc_etr_setup_caps(struct device *parent, u32 devid) > { > int rc; > - u32 dma_mask = 0; > + u32 tmc_pid, dma_mask = 0; > struct tmc_drvdata *drvdata = dev_get_drvdata(parent); > + void *dev_caps; > > if (!tmc_etr_has_non_secure_access(drvdata)) > return -EACCES; > > + tmc_pid = coresight_get_pid(&drvdata->csdev->access) & TMC_AMBA_MASK; > + dev_caps = coresight_get_uci_data_from_amba(tmc_ids, tmc_pid); > + > /* Set the unadvertised capabilities */ > tmc_etr_init_caps(drvdata, (u32)(unsigned long)dev_caps); > > @@ -497,10 +505,6 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) > desc.type = CORESIGHT_DEV_TYPE_SINK; > desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM; > desc.ops = &tmc_etr_cs_ops; > - ret = tmc_etr_setup_caps(dev, devid, > - coresight_get_uci_data(id)); > - if (ret) > - goto out; > idr_init(&drvdata->idr); > mutex_init(&drvdata->idr_mutex); > dev_list = &etr_devs; > @@ -539,6 +543,9 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) > goto out; > } > > + if (drvdata->config_type == TMC_CONFIG_TYPE_ETR) > + ret = tmc_etr_setup_caps(dev, devid); > + With this change, we silently accept an ETR that may only have "SECURE" access only and crash later while we try to enable tracing. You could pass in the "access" (which is already in 'desc.access' in the original call site and deal with it ? Suzuki > drvdata->miscdev.name = desc.name; > drvdata->miscdev.minor = MISC_DYNAMIC_MINOR; > drvdata->miscdev.fops = &tmc_fops; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel