Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4471755rdb; Mon, 11 Dec 2023 23:31:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbD1t/QKarKhddnpTA2Sr7tLwBd32Hcta7pPWVPqFA+fMj/siawP57dAmcDl6OZ1PKOFHW X-Received: by 2002:a05:6a20:918b:b0:18f:97c:8a34 with SMTP id v11-20020a056a20918b00b0018f097c8a34mr8044334pzd.95.1702366312925; Mon, 11 Dec 2023 23:31:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702366312; cv=none; d=google.com; s=arc-20160816; b=fzQ/JJJ3Z+VnCMf5WHlbqJdL+B/H+eKIAlS8qXcBWh7sHDSjDicSyBXDXRTmDYZmrt Z7WgBl74t3tb7DI4XIuFzLdR1UTppAeUqGuVa0e7eifdC1qU4MHZ3zZTogJRqbwQp/x4 foJUaRcTj7dbfpobQCDxLk5TErOtXqCu30r8E/0qYBTAtmiFNOde918RQJ8Z5lyVps2e +j+cEzU6scqAr9pODHz0ZE2NpzqbRWlSxW/qrZ8L3vbvREiatKOGdWxuH33/335hu2rV yJIuS0lRGjRUFT9JTO3cuCxA/EF8otBrDoVYKpSF+5r4mW3QlIHMCZYidsdJ+ljuN72h vqPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=1Dfi9U2qdh0jDu11kEY9C3XeHDVDucMK9+cb2z+fqDY=; fh=bYYeCqBxkLtl1kWsk8OOCkbj3abGxVAJF1rZR07HU1c=; b=uDv++rzswC+IySaqLuuQX/ZT/T47cmQpZGmwVU8cPAL9UxAT8TgH7z+WaEMZd5L1Za z2LouIN4yhq95SRV9g5mYxwUsRbaGYMb2Y8iPXKp/5q7/5D7xJT2S7iJHniacscAxK0c 4LXNpEYHQwPuDICwKFRO125r4LbCTraYQ1/4ZWmQkKa4+ZnJoz9zbDNSkP2C56y9+bBb XTZDQ6tc/7qXb/mTWq3fDfjHepyy5D775BbWSuyctRuBZXNnjjju+m/fpXJ0V4FUqBXq E7+gNRLIOv+hr219xlxFNJZQ6eJm97Nr0ApD7Eo7/sOQnAhNHEl6QCW4OUGuQMHVv18h ppgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id k2-20020a63f002000000b005bdf597ed49si7498099pgh.56.2023.12.11.23.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 23:31:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0246680A0565; Mon, 11 Dec 2023 23:31:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345915AbjLLHb3 (ORCPT + 99 others); Tue, 12 Dec 2023 02:31:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbjLLHb1 (ORCPT ); Tue, 12 Dec 2023 02:31:27 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AF15BBE; Mon, 11 Dec 2023 23:31:33 -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 DF112143D; Mon, 11 Dec 2023 23:32:18 -0800 (PST) Received: from [10.163.33.206] (unknown [10.163.33.206]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B056B3F5A1; Mon, 11 Dec 2023 23:31:28 -0800 (PST) Message-ID: Date: Tue, 12 Dec 2023 13:01:26 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V3 04/10] coresight: replicator: Move ACPI support from AMBA driver to platform driver Content-Language: en-US To: James Clark , linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com 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: <20231208053939.42901-1-anshuman.khandual@arm.com> <20231208053939.42901-5-anshuman.khandual@arm.com> <862afccb-e9c5-4fcb-abdf-45a5eb9aa6d8@arm.com> <6c3d9c5c-8185-bcdf-2897-0db13c00a843@arm.com> From: Anshuman Khandual In-Reply-To: <6c3d9c5c-8185-bcdf-2897-0db13c00a843@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 23:31:50 -0800 (PST) On 12/11/23 15:42, James Clark wrote: > > > On 11/12/2023 07:51, Anshuman Khandual wrote: >> >> >> On 12/8/23 11:09, Anshuman Khandual wrote: >>> Add support for the dynamic replicator device in the platform driver, which >>> can then be used on ACPI based platforms. This change would now allow >>> runtime power management for repliacator devices on ACPI based systems. >>> >>> The driver would try to enable the APB clock if available. Also, rename the >>> code to reflect the fact that it now handles both static and dynamic >>> replicators. >>> >>> 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 >>> Tested-by: Sudeep Holla # Boot and driver probe only >>> Acked-by: Sudeep Holla # For ACPI related changes >>> Signed-off-by: Anshuman Khandual >>> --- >>> Changes in V3: >>> >>> - Added commnets for 'drvdata->pclk' >>> - Used coresight_init_driver()/coresight_remove_driver() helpers instead >>> - Dropped pm_runtime_put() from replicator_probe() >>> - Added pm_runtime_put() on success path in dynamic_replicator_probe() >>> - Added pm_runtime_put() on success/error paths in >>> replicator_platform_probe() >>> >>> drivers/acpi/arm64/amba.c | 1 - >>> .../coresight/coresight-replicator.c | 81 ++++++++++--------- >>> 2 files changed, 42 insertions(+), 40 deletions(-) >>> >>> diff --git a/drivers/acpi/arm64/amba.c b/drivers/acpi/arm64/amba.c >>> index 171b5c2c7edd..270f4e3819a2 100644 >>> --- a/drivers/acpi/arm64/amba.c >>> +++ b/drivers/acpi/arm64/amba.c >>> @@ -27,7 +27,6 @@ static const struct acpi_device_id amba_id_list[] = { >>> {"ARMHC503", 0}, /* ARM CoreSight Debug */ >>> {"ARMHC979", 0}, /* ARM CoreSight TPIU */ >>> {"ARMHC97C", 0}, /* ARM CoreSight SoC-400 TMC, SoC-600 ETF/ETB */ >>> - {"ARMHC98D", 0}, /* ARM CoreSight Dynamic Replicator */ >>> {"ARMHC9CA", 0}, /* ARM CoreSight CATU */ >>> {"ARMHC9FF", 0}, /* ARM CoreSight Dynamic Funnel */ >>> {"", 0}, >>> diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c >>> index b6be73034996..125b256cb8db 100644 >>> --- a/drivers/hwtracing/coresight/coresight-replicator.c >>> +++ b/drivers/hwtracing/coresight/coresight-replicator.c >>> @@ -31,6 +31,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); >>> * @base: memory mapped base address for this component. Also indicates >>> * whether this one is programmable or not. >>> * @atclk: optional clock for the core parts of the replicator. >>> + * @pclk: APB clock if present, otherwise NULL >>> * @csdev: component vitals needed by the framework >>> * @spinlock: serialize enable/disable operations. >>> * @check_idfilter_val: check if the context is lost upon clock removal. >>> @@ -38,6 +39,7 @@ DEFINE_CORESIGHT_DEVLIST(replicator_devs, "replicator"); >>> struct replicator_drvdata { >>> void __iomem *base; >>> struct clk *atclk; >>> + struct clk *pclk; >>> struct coresight_device *csdev; >>> spinlock_t spinlock; >>> bool check_idfilter_val; >>> @@ -243,6 +245,10 @@ static int replicator_probe(struct device *dev, struct resource *res) >>> return ret; >>> } >>> >>> + drvdata->pclk = coresight_get_enable_apb_pclk(dev); >>> + if (IS_ERR(drvdata->pclk)) >>> + return -ENODEV; >>> + >>> /* >>> * Map the device base for dynamic-replicator, which has been >>> * validated by AMBA core >>> @@ -285,7 +291,6 @@ static int replicator_probe(struct device *dev, struct resource *res) >>> } >>> >>> replicator_reset(drvdata); >>> - pm_runtime_put(dev); >>> >>> out_disable_clk: >>> if (ret && !IS_ERR_OR_NULL(drvdata->atclk)) >>> @@ -301,29 +306,31 @@ static int replicator_remove(struct device *dev) >>> return 0; >>> } >>> >>> -static int static_replicator_probe(struct platform_device *pdev) >>> +static int replicator_platform_probe(struct platform_device *pdev) >>> { >>> + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >>> int ret; >>> >>> pm_runtime_get_noresume(&pdev->dev); >>> pm_runtime_set_active(&pdev->dev); >>> pm_runtime_enable(&pdev->dev); >>> >>> - /* Static replicators do not have programming base */ >>> - ret = replicator_probe(&pdev->dev, NULL); >>> - >>> - if (ret) { >>> - pm_runtime_put_noidle(&pdev->dev); >>> - pm_runtime_disable(&pdev->dev); >>> - } >>> + ret = replicator_probe(&pdev->dev, res); >>> + pm_runtime_put(&pdev->dev); >> >> I believe pm_runtime_disable() would still be needed on the error path. Otherwise >> pm_runtime_enable() will remain unbalanced on this error path when the replicator >> module could not be loaded. >> >> --- a/drivers/hwtracing/coresight/coresight-replicator.c >> +++ b/drivers/hwtracing/coresight/coresight-replicator.c >> @@ -317,6 +317,8 @@ static int replicator_platform_probe(struct platform_device *pdev) >> >> ret = replicator_probe(&pdev->dev, res); >> pm_runtime_put(&pdev->dev); >> + if (ret) >> + pm_runtime_disable(&pdev->dev); >> >> return ret; >> } >> >> Similar constructs in this error path are also required in all other drivers (except >> cpu debug) as well. > > Would that not need to be done as a fixes commit first with more detail > about the issue if that's true? Maybe simulate the error and paste any > error logs. For example etm4 already has this: There are existing inconsistencies e.g between etm4 and replicator regarding whether pm_runtime_disable() is called or not. So the idea here was to get all remaining devices in line with replicator and debug devices method. I don't have continuous access to an ACPI based coresight platform, creating some challenges - although still trying to get access to such a system. But wondering - it might be possible to simulate these success and error paths, without having real ACPI based coresight platform devices. > > pm_runtime_get_noresume(&pdev->dev); > pm_runtime_set_active(&pdev->dev); > pm_runtime_enable(&pdev->dev); > > ret = etm4_probe(&pdev->dev); > > pm_runtime_put(&pdev->dev); > > I'm wondering if the disable is already covered by the platform code if > the probe fails so no change is required? AFAICT pm_runtime_enable()/pm_runtime_disable() goes in a pair for them to remain balanced, there is a increasing/decreasing counter to ensure such a balance is established and so without a corresponding pm_runtime_disable() above etm4 path looks problematic. I guess this might just need fixing, as a pre-requisite. > > if (drv->probe) { > ret = drv->probe(dev); > if (ret) > dev_pm_domain_detach(_dev, true); > }