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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 795A7C10DC1 for ; Mon, 4 Dec 2023 10:50:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232842AbjLDKuu (ORCPT ); Mon, 4 Dec 2023 05:50:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343887AbjLDKul (ORCPT ); Mon, 4 Dec 2023 05:50:41 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 50013C3; Mon, 4 Dec 2023 02:50:47 -0800 (PST) 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 47520139F; Mon, 4 Dec 2023 02:51:34 -0800 (PST) Received: from [10.1.197.1] (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D08A3F6C4; Mon, 4 Dec 2023 02:50:43 -0800 (PST) Message-ID: Date: Mon, 4 Dec 2023 10:50:42 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver Content-Language: en-US To: James Clark , Anshuman Khandual , linux-arm-kernel@lists.infradead.org Cc: Lorenzo Pieralisi , Sudeep Holla , Mike Leach , 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: <20231201062053.1268492-1-anshuman.khandual@arm.com> <20231201062053.1268492-6-anshuman.khandual@arm.com> <12a9c5da-4b96-78de-4007-211989bdcfa3@arm.com> From: Suzuki K Poulose In-Reply-To: <12a9c5da-4b96-78de-4007-211989bdcfa3@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/12/2023 10:42, James Clark wrote: > > > On 01/12/2023 06:20, Anshuman Khandual wrote: >> Add support for the tmc devices in the platform driver, which can then be >> used on ACPI based platforms. This change would now allow runtime power >> management for ACPI based systems. The driver would try to enable the APB >> clock if available. >> >> Cc: Lorenzo Pieralisi >> Cc: Sudeep Holla >> Cc: Suzuki K Poulose >> Cc: Mike Leach >> Cc: James Clark >> Cc: linux-acpi@vger.kernel.org >> Cc: linux-arm-kernel@lists.infradead.org >> Cc: linux-kernel@vger.kernel.org >> Cc: coresight@lists.linaro.org >> Signed-off-by: Anshuman Khandual >> --- >> drivers/acpi/arm64/amba.c | 2 - >> .../hwtracing/coresight/coresight-tmc-core.c | 130 +++++++++++++++--- >> drivers/hwtracing/coresight/coresight-tmc.h | 1 + >> 3 files changed, 115 insertions(+), 18 deletions(-) >> > [...] >> -static int tmc_probe(struct amba_device *adev, const struct amba_id *id) >> +static int __tmc_probe(struct device *dev, struct resource *res, void *dev_caps) >> { >> int ret = 0; >> u32 devid; >> void __iomem *base; >> - struct device *dev = &adev->dev; >> struct coresight_platform_data *pdata = NULL; >> - struct tmc_drvdata *drvdata; >> - struct resource *res = &adev->res; >> + struct tmc_drvdata *drvdata = dev_get_drvdata(dev); >> struct coresight_desc desc = { 0 }; >> struct coresight_dev_list *dev_list = NULL; >> >> ret = -ENOMEM; >> - drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); >> - if (!drvdata) >> - goto out; >> - >> - dev_set_drvdata(dev, drvdata); >> >> /* Validity for the resource is already checked by the AMBA core */ >> base = devm_ioremap_resource(dev, res); >> @@ -487,8 +482,7 @@ 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)); >> + ret = tmc_etr_setup_caps(dev, devid, dev_caps); >> if (ret) >> goto out; > [...] >> -module_amba_driver(tmc_driver); >> +static int tmc_platform_probe(struct platform_device *pdev) >> +{ >> + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >> + struct tmc_drvdata *drvdata; >> + int ret = 0; >> + >> + drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); >> + if (!drvdata) >> + return -ENOMEM; >> + >> + drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev); >> + if (IS_ERR(drvdata->pclk)) >> + return -ENODEV; >> + >> + dev_set_drvdata(&pdev->dev, drvdata); >> + pm_runtime_get_noresume(&pdev->dev); >> + pm_runtime_set_active(&pdev->dev); >> + pm_runtime_enable(&pdev->dev); >> + >> + ret = __tmc_probe(&pdev->dev, res, NULL); > > What effect does passing NULL here have? It seems like the dev_caps did > something useful when it's set to CORESIGHT_SOC_600_ETR_CAPS. Maybe > Suzuki knows as he added it? That was supposed to initialise the capabilities of the TMC-ETR, which are not discoverable by ID registers. (e.g., SAVE restore of RRP/RWP). I guess, we could get rid of that cap and use the "PID" register match to figure out the capabilities. Suzuki