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 D4396C4167B for ; Tue, 5 Dec 2023 03:57:12 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:Subject: From: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=CgWpTcqozEGwAom09zQsObsaYYzdqYLDd9R3bafDeZM=; b=aNR/mDVrJT+DOT 9FW6ywQIVix/ZEHhuE1Tl+2wsjfN9vFI1GAQQrU1R+5pE/VoAK/SEOu4dN2fkm6YEN98m5awrrgkS q9S+wuSyvQajiMV2F+JnCBWW3165lJqTPZ9PhMQ5awkhkg7608+YuDAdLZjRoIpAiMYQwHNzzVAfF IuF3jJ2+txoccurqUFjvRrQ7kUknxJ38zHlg6VwfLGW0tdLRjbIZRbqGba72qxRtwcoF0WSWb1oXO 3s/wrQXKgtcfqtASmYPZx16LKmWuO1rjrIGw8jJfyRLdsX8VKVLDmCN4Flj41kil5xtp6yg8npH4f jMzbITqaDxEeIYMD0Vnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAMYC-006Auc-1h; Tue, 05 Dec 2023 03:56:48 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAMY8-006AtH-30 for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 03:56:46 +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 C30B31474; Mon, 4 Dec 2023 19:57:27 -0800 (PST) Received: from [10.163.35.139] (unknown [10.163.35.139]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 890513F5A1; Mon, 4 Dec 2023 19:56:35 -0800 (PST) Message-ID: <604b5b56-9f48-434e-b328-0b9616b47ec8@arm.com> Date: Tue, 5 Dec 2023 09:26:30 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Anshuman Khandual Subject: Re: [PATCH V2 5/7] coresight: tmc: Move ACPI support from AMBA driver to platform driver 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: <20231201062053.1268492-1-anshuman.khandual@arm.com> <20231201062053.1268492-6-anshuman.khandual@arm.com> Content-Language: en-US In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231204_195645_062242_6818EFFC X-CRM114-Status: GOOD ( 19.71 ) 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 12/4/23 16:24, 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. >> > [...] >> -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); >> + if (ret) { >> + pm_runtime_put_noidle(&pdev->dev); >> + pm_runtime_disable(&pdev->dev); >> + } > > I'm not sure if these pm_runtime()s are right because there is already a > put inside of __tmc_probe() if it fails. If you unload and then reload Actually there is a pm_runtime_put() on the success path, not when it fails. So pm_runtime_put() gets called when __tmc_probe() returns 0. __tmc_probe() { .... ret = misc_register(&drvdata->miscdev); if (ret) coresight_unregister(drvdata->csdev); else pm_runtime_put(dev); out: return ret; } tmc_platform_probe() { .... pm_runtime_get_noresume(&pdev->dev); pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); ret = __tmc_probe(&pdev->dev, res, NULL); if (ret) { pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); } return ret; } tmc_probe() { .... return __tmc_probe(&adev->dev, &adev->res, coresight_get_uci_data(id)); } Currently pm_runtime_put() gets called - In success path both for AMBA and platform drivers - In error path only for platform driver Although the problem might be with pm_runtime_disable() instead - pm_runtime_disable() is not required in the platform driver probe() path - But might be required in tmc_platform_remove() along with a clk_put() > all the coresight modules with these patches you get these errors which > are new: > > coresight-tpiu-platform ARMHC979:00: Unbalanced pm_runtime_enable! The code is similar in TPIU platform driver as well. > CSCFG registered etm0 > coresight etm0: CPU0: etm v4.2 initialized > CSCFG registered etm1 > coresight etm1: CPU1: etm v4.2 initialized > CSCFG registered etm2 > coresight etm2: CPU2: etm v4.2 initialized > CSCFG registered etm3 > coresight etm3: CPU3: etm v4.2 initialized > coresight-tmc-platform ARMHC97C:00: Unbalanced pm_runtime_enable! > coresight-tmc-platform ARMHC97C:01: Unbalanced pm_runtime_enable! > coresight-tmc-platform ARMHC97C:02: Unbalanced pm_runtime_enable! > coresight-tmc-platform ARMHC97C:03: Unbalanced pm_runtime_enable! > > It might be worth testing all of these pm_runtime()s, including the > error case ones, because loading and unloading the modules doesn't even > include the error scenarios, so there are probably more bad ones in > there too. The code is very similar in CATU, STM as well but debug_platform_remove() seems to be doing this right. I am not very familiar with all the power management aspects in coresight, please do let me know if I missing something here. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel