Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2411957rdb; Mon, 12 Feb 2024 04:15:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXg2iFQ8wEkDpRFzmI+xU6cIVc0rO21879S6ZQpm/ZlB4RLFaOoFxL/Ymu7/MidDLCrZqDlDA1t/KE1T2KkkfsZGbUU1S9F0U7puFGDSA== X-Google-Smtp-Source: AGHT+IEd5OzGMjiAvkpeDhJXWVtGyecfyl3mlOiOGud3/qMJ7Bx/Bm4+SGuz81nCOvEHqxO3hcmb X-Received: by 2002:a05:6402:1512:b0:561:a59f:a3cd with SMTP id f18-20020a056402151200b00561a59fa3cdmr2813022edw.23.1707740126040; Mon, 12 Feb 2024 04:15:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707740126; cv=pass; d=google.com; s=arc-20160816; b=pb1UQQbwE5ExFcs9VuS1NmnF/oFt1ErfzWTdLOSpUMVYQ9eVnDyNGu8xh16/D6sh/w 5bDprkYs68QkIoY+lZF08SBJHpwGxaH26rrtL+5QbToDPX+tAkug4Wo8hDJgjKxgHsIc Ol2VpkhNlNvNxJflyo6MZymhV7QBnuPqlciwXvctRGso1ItgTkAnf08cMR/HrKn7T8k0 N8aYgmjredWrJ3A/YH+YoXvgq8uuqmvRBkc1CPnWiXjztZhKpxbV+63975xcK37rbdki InbrQfhhqrr5FWfOeZ93/1xaq5c/XTQo98qcHiJHTdGKQyvst+Oc0c4qmj+XQJWChvef mj8g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=jDntueKEoowVdXCsSH7uK7VdyAlaXlTiI7m6Hkk4RWo=; fh=Yv6A+RuLIBee3nzuPLwm7hpqOw7bNTpz0oradaNG5Lk=; b=SHv5p1BRUB/GQ/yGYvQxc69oFmaUUZowOpS5g/m4TKqo/8NmSjEv+NYyq84LkE4hTn 72zSTKdhgZmKF4CEnGIC19kQw/QmysD7ZBM4xvxDISq3SiF0IMoaz7sD9v4omkzBUPG+ aysASl0pnlxFL2cWNU62v6pw4UJimxnAw60shJBeBQMTO4bJ3ZImunmDpFJJwm7h02BZ h3A0ZiUebplChMEqArsGBx8zCS9ptOvrwML1ldxgY5JApl8RACMg8jk25NR+daG+0kai qbmYg5aZmRQdbO5xdUFHEjYtZopfQCYiK4TLW5qPxG6IYT6p60OFpVzQXEy89iPiF5AT WBxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-61529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCUY9jchL9rk/Q6D0LvWj0694MA8s4+QVJ2767mHlDoFkTNNbYmNFyBm6tRfhmikXMXn9Bb5bifh1UHhqRZLkrHsLZUosL+OsiCISdtLbw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cm18-20020a0564020c9200b0055ced896819si2765686edb.212.2024.02.12.04.15.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:15:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-61529-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61529-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BACF91F2400E for ; Mon, 12 Feb 2024 12:15:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 666603A8EE; Mon, 12 Feb 2024 12:13:06 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C16EE3A8DD; Mon, 12 Feb 2024 12:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707739985; cv=none; b=K4uWSUuHowLcB4xpnVGpCxbaUrR8iH6837NcUG7BWPOvv5hEJ/8eK+orPbqVNXehky8zP99ho5ltkIYF27+UJNwomUPJG+jAqQ0glBQWIVHXaAit/Stx2+NoxkV99awaLJoQ7kXOGRyHd3GJw/Y7mRw/nKPC0RNPC54xHyh95xo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707739985; c=relaxed/simple; bh=h0Qj55goct6MBaVRkw88CxVyaIdkbG/vw09bMzZ0028=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=D0P2FXEA8Z4oCVrSv0wIH7ypAEKbsMoQfude9tMhe5IEa7sNtNOO7n9oAIS5SLz1MeUHzblhh9FsUWUSCVg2zverrzhKbNLJ2spextsJRjPX4Nn2AdKMlyzRkhT1mezqr+ZQVU3idRWpAapeX2DSNg2EnwFM63rK+pnaZA6Izes= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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;