Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3810908rdb; Sun, 10 Dec 2023 23:51:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IFA6L1ePaL5ivQaiPJOFawysEcwhoQNQlsU8xgEEesAXEml1mKlakwX48pTlcM0TYqRhcpK X-Received: by 2002:a17:903:32d0:b0:1d0:8be8:bb6a with SMTP id i16-20020a17090332d000b001d08be8bb6amr4558193plr.67.1702281118243; Sun, 10 Dec 2023 23:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702281118; cv=none; d=google.com; s=arc-20160816; b=RZ/O3Xex0nGEFlBQPMr6/EeCn6hA5K4B+8qu8QCmGnDBpHaz2egShyJHigLmeiAdSW 1a/ZU4I3BRCbpzD//CK4vuDAKle26Z/bN67TExJXM+VrukaaREGgySmzoMD8xU5tOueG vl005jYrV19zIhM8Gx6451KfBTGsuF2cUsNmcy3eryiSCBPlxYXuU3wvXUDFGgCKDw1O gkIThP1/631RAkFiSgJYctllpwTVhGxYUy8OBi9GPDrTnqZ4a/bXjBw6m8JSFlFuZksD ggEF302gKKBfiWxCdS71f+q0/VDSB/wnlDGROs3pcQ0lScfb4XBaizlAUUslCdPRqTVA tfeg== 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=dtsFSmH1H393EnAtUIFYclELZadc5ZFh8X/1TQq2dvI=; fh=pJldCCXU66bvOOTLCMb00MQ+Gs2BuIEVkx1NE+lNugU=; b=vHhKP/NUXBz1tNZeEePxZIySB/x2fiMymmi1e9FESBgxx82s++HIr9OpvFVUnNjq3A S5y3dDTp1BTyGHup22Bjd0y8AeNcx9WDpq4qow9+wKRB/AbagEDHNJX5WLKLGtvX9YQo JSboIlhu8CXfdnMRNZevrVEto5esHq9/N5cmMF3sDuoccm/f6WcED8ZlMeqv0SbX/uMN 9e4ZnWowlB5qmJTPmcqQlHyAa2GSmeCPjU+obAAGuDh5GxS0wm9hI7HoCmUcKB5Qionj usdVL0FRFoc3zBYbIoyKhCqUHTCfkjQ3mnQ7XX7US9Ce8FgtyaF8M1gRux++otOLDcDZ Oc+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id n3-20020a170902e54300b001d005539ab3si5902616plf.360.2023.12.10.23.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 23:51:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id BE6718093576; Sun, 10 Dec 2023 23:51:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229520AbjLKHvm (ORCPT + 99 others); Mon, 11 Dec 2023 02:51:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232227AbjLKHvl (ORCPT ); Mon, 11 Dec 2023 02:51:41 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E50DAFC; Sun, 10 Dec 2023 23:51:46 -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 170881007; Sun, 10 Dec 2023 23:52:33 -0800 (PST) Received: from [10.162.41.8] (a077893.blr.arm.com [10.162.41.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2E31B3F7C5; Sun, 10 Dec 2023 23:51:42 -0800 (PST) Message-ID: <862afccb-e9c5-4fcb-abdf-45a5eb9aa6d8@arm.com> Date: Mon, 11 Dec 2023 13:21:40 +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: linux-arm-kernel@lists.infradead.org, suzuki.poulose@arm.com 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: <20231208053939.42901-1-anshuman.khandual@arm.com> <20231208053939.42901-5-anshuman.khandual@arm.com> From: Anshuman Khandual In-Reply-To: <20231208053939.42901-5-anshuman.khandual@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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 10 Dec 2023 23:51:55 -0800 (PST) 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.