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 32CCAC3600C for ; Thu, 3 Apr 2025 06:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pC80/EMb0o3/LGUq4/eTGOi9uEr++HU5fyvqZZEc6rc=; b=O5eMVXC41MzLp4YsFFIQpvT1w+ PYW+OmMuji1cvOo678M6C5xAYTmNk4EUMO3tX+6nSrWdGbZVgh8nHIpHzZc0pjWGHKleC8jt1+APj Zgc3OtNJsuhadOoWfa0pi4YXvzHK8tLzJLD+C4m+Vow83EELFikpxSy/GeLl/Z/bYLD22FBWNp2Vc Omj8ixeHrAcgzSBVbTIqe3SKgNG1xuaN3K61VVmYG8fEy0N3Unyt/r08JCCxH/NBci3jwirODEaeN BlUkKVirZjZ5hOeZQpVtA3a4m6x23MoYrcWQ4ACQpvHPGoKjopx92/7UEcOSpkASw3aDUH+t+3Er/ Dd8P/Baw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1u0ERH-00000007zBF-431e; Thu, 03 Apr 2025 06:52:35 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1u0ENu-00000007yWL-0Jca for linux-arm-kernel@lists.infradead.org; Thu, 03 Apr 2025 06:49:08 +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 2F605106F; Wed, 2 Apr 2025 23:49:07 -0700 (PDT) Received: from [10.163.48.25] (unknown [10.163.48.25]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9444B3F59E; Wed, 2 Apr 2025 23:48:59 -0700 (PDT) Message-ID: <5a8aaa17-cc36-4e03-95b3-24c3a16dd987@arm.com> Date: Thu, 3 Apr 2025 12:18:56 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 5/9] coresight: Avoid enable programming clock duplicately To: Leo Yan , Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Maxime Coquelin , Alexandre Torgue , Greg Kroah-Hartman , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com References: <20250327113803.1452108-1-leo.yan@arm.com> <20250327113803.1452108-6-leo.yan@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: <20250327113803.1452108-6-leo.yan@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250402_234906_234358_7A827176 X-CRM114-Status: GOOD ( 20.25 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 3/27/25 17:07, Leo Yan wrote: > The programming clock is enabled by AMBA bus driver before a dynamic > probe. As a result, a CoreSight driver may redundantly enable the same > clock. > > To avoid this, add a check for device type and skip enabling the > programming clock for AMBA devices. The returned NULL pointer will be > tolerated by the drivers. > > Fixes: 73d779a03a76 ("coresight: etm4x: Change etm4_platform_driver driver for MMIO devices") > Signed-off-by: Leo Yan > --- > include/linux/coresight.h | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/include/linux/coresight.h b/include/linux/coresight.h > index b888f6ed59b2..26eb4a61b992 100644 > --- a/include/linux/coresight.h > +++ b/include/linux/coresight.h > @@ -476,15 +476,18 @@ static inline bool is_coresight_device(void __iomem *base) > * Returns: > * > * clk - Clock is found and enabled > + * NULL - Clock is not needed as it is managed by the AMBA bus driver > * ERROR - Clock is found but failed to enable > */ > static inline struct clk *coresight_get_enable_apb_pclk(struct device *dev) > { > - struct clk *pclk; > + struct clk *pclk = NULL; > > - pclk = devm_clk_get_enabled(dev, "apb_pclk"); > - if (IS_ERR(pclk)) > - pclk = devm_clk_get_enabled(dev, "apb"); > + if (!dev_is_amba(dev)) { > + pclk = devm_clk_get_enabled(dev, "apb_pclk"); > + if (IS_ERR(pclk)) > + pclk = devm_clk_get_enabled(dev, "apb"); > + } > > return pclk; > } coresight_get_enable_apb_pclk() mostly gets called in the platform driver probe paths but they are also present in some AMBA probe paths. Hence why cannot the callers in AMBA probe paths get fixed instead ? Besides return value never gets checked for NULL, which would have to be changed as well if coresight_get_enable_apb_pclk() starts returning NULL values for AMBA devices. drvdata->pclk = coresight_get_enable_apb_pclk(&pdev->dev); if (IS_ERR(drvdata->pclk)) return -ENODEV; I guess this redundancy should be fixed at the AMBA probe callers.