From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46DC92AD32 for ; Fri, 2 May 2025 06:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746167946; cv=none; b=M0Uzvv8mbmeIE8yIf56AbPTV8iYofNBV8FLRChF3O4ce6DPowZbCU1JAcq//wjxn8gCR/UzOTE6BXJm1SAs5Sa/2mdvosyvQTGB/4/cv0h0kXcPvtvlfi7Xhngq/bCfKS6c0KPzR006dk17yiyat6F7BTr7O5D/bMRO3jfjfrqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746167946; c=relaxed/simple; bh=O6nmuomLYTknJOUevxoWSl+W7UzIdX0FAfhKsSaQYOc=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=P0gd2xw5Ao5vnJJHS3gwc0WdYTAOJrR38FF6uZ+EGNhYDS8dxx5OBP4hAR46RhHkIP8YUCM4Yx6HPywMZftI6ET8wSPT/Lx8/DvHGwTviGGu8I9uLWCZPR3SDp7W2cOR//Rn4aQX5IZzOxxRThwuExUzDh+RYhfccqz8r7DyZug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 8CD9C106F; Thu, 1 May 2025 23:38:55 -0700 (PDT) Received: from [10.163.80.122] (unknown [10.163.80.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 20E023F66E; Thu, 1 May 2025 23:38:58 -0700 (PDT) Message-ID: <063577a4-1530-4658-9838-934b0606e8e0@arm.com> Date: Fri, 2 May 2025 12:08:55 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 6/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: <20250423151726.372561-1-leo.yan@arm.com> <20250423151726.372561-7-leo.yan@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: <20250423151726.372561-7-leo.yan@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/23/25 20:47, 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. Are you sure AMBA bus driver always enables such clocks in all scenarios ? Even if that is true - why cannot coresight_get_enable_apb_pclk() ensured to be called only for the platform drivers cases via code re-organization, rather than changing the coresight_get_enable_apb_pclk() helper itself. > > 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; > }