From patchwork Thu Mar 27 11:37:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 14031093 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 1E9BCC3600E for ; Thu, 27 Mar 2025 11:50:18 +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: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0ABEUS5kQjkGVS0O1oF2mH+cqfmE60UJxyt5ckRjx/w=; b=kEaZTIEQ/p8xdYfiCwj7dc7JYg gixIFlkou0wrxuBmOOngQXNevM5Vr0gxcx6YelSG9koD1pOx+2XS/pYs7jLrTl2zJCcmFhIBDtUwL zkfclkR55+rFJ7x8p62Xr/9k0lzmMzJoAj+gLL5uwpoK9Jl+7phOGEuPDHN1pd7wxScU2YQqTnyZn weokkxElF7Tn64HmsL7sUGLy7vi3OXl3p0V8CrBlG+DaCuHmKQVTnbmQiK5VDQ2BvTv6wgRlJnulk EVZ8XPGlM/Bcw37p/U9yS97B2raQMsZ+vU4ksZCxq5jElLZLRILL0/VxnyLwLpt3NvJBm3eQeSb9i /By9tXcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.1 #2 (Red Hat Linux)) id 1txlkN-0000000AsWT-2oCY; Thu, 27 Mar 2025 11:50:07 +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 1txlZA-0000000AqIN-3rw3 for linux-arm-kernel@lists.infradead.org; Thu, 27 Mar 2025 11:38:34 +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 BC4A71762; Thu, 27 Mar 2025 04:38:37 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A16C83F58B; Thu, 27 Mar 2025 04:38:30 -0700 (PDT) From: Leo Yan To: Suzuki K Poulose , Mike Leach , James Clark , Anshuman Khandual , 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 Cc: Leo Yan Subject: [PATCH v1 5/9] coresight: Avoid enable programming clock duplicately Date: Thu, 27 Mar 2025 11:37:59 +0000 Message-Id: <20250327113803.1452108-6-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250327113803.1452108-1-leo.yan@arm.com> References: <20250327113803.1452108-1-leo.yan@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250327_043833_008788_93DCD42A X-CRM114-Status: GOOD ( 11.74 ) 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 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; }