Skip to content

Commit 8a79026

Browse files
Leo-YanSuzuki K Poulose
authored andcommitted
coresight: tmc: Support atclk
The atclk is an optional clock for the CoreSight TMC, but the driver misses to initialize it. In most cases, TMC shares the atclk clock with other CoreSight components. Since these components enable the clock before the TMC device is initialized, the TMC continues properly, which is why we don’t observe any lockup issues. This change enables atclk in probe of the TMC driver. Given the clock is optional, it is possible to return NULL if the clock does not exist. IS_ERR() is tolerant for this case. Dynamically disable and enable atclk during suspend and resume. The clock pointers will never be error values if the driver has successfully probed, and the case of a NULL pointer case will be handled by the clock core layer. The driver data is always valid after probe. Therefore, remove the related checks. Also in the resume flow adds error handling. Fixes: bc4bf7f ("coresight-tmc: add CoreSight TMC driver") Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com> Tested-by: James Clark <james.clark@linaro.org> Signed-off-by: Leo Yan <leo.yan@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20250731-arm_cs_fix_clock_v4-v6-1-1dfe10bb3f6f@arm.com
1 parent dcdc42f commit 8a79026

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

drivers/hwtracing/coresight/coresight-tmc-core.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,10 @@ static int __tmc_probe(struct device *dev, struct resource *res)
779779
struct coresight_desc desc = { 0 };
780780
struct coresight_dev_list *dev_list = NULL;
781781

782+
drvdata->atclk = devm_clk_get_optional_enabled(dev, "atclk");
783+
if (IS_ERR(drvdata->atclk))
784+
return PTR_ERR(drvdata->atclk);
785+
782786
ret = -ENOMEM;
783787

784788
/* Validity for the resource is already checked by the AMBA core */
@@ -1010,18 +1014,26 @@ static int tmc_runtime_suspend(struct device *dev)
10101014
{
10111015
struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
10121016

1013-
if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
1014-
clk_disable_unprepare(drvdata->pclk);
1017+
clk_disable_unprepare(drvdata->atclk);
1018+
clk_disable_unprepare(drvdata->pclk);
1019+
10151020
return 0;
10161021
}
10171022

10181023
static int tmc_runtime_resume(struct device *dev)
10191024
{
10201025
struct tmc_drvdata *drvdata = dev_get_drvdata(dev);
1026+
int ret;
10211027

1022-
if (drvdata && !IS_ERR_OR_NULL(drvdata->pclk))
1023-
clk_prepare_enable(drvdata->pclk);
1024-
return 0;
1028+
ret = clk_prepare_enable(drvdata->pclk);
1029+
if (ret)
1030+
return ret;
1031+
1032+
ret = clk_prepare_enable(drvdata->atclk);
1033+
if (ret)
1034+
clk_disable_unprepare(drvdata->pclk);
1035+
1036+
return ret;
10251037
}
10261038
#endif
10271039

drivers/hwtracing/coresight/coresight-tmc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ struct tmc_resrv_buf {
210210

211211
/**
212212
* struct tmc_drvdata - specifics associated to an TMC component
213+
* @atclk: optional clock for the core parts of the TMC.
213214
* @pclk: APB clock if present, otherwise NULL
214215
* @base: memory mapped base address for this component.
215216
* @csdev: component vitals needed by the framework.
@@ -244,6 +245,7 @@ struct tmc_resrv_buf {
244245
* Used by ETR/ETF.
245246
*/
246247
struct tmc_drvdata {
248+
struct clk *atclk;
247249
struct clk *pclk;
248250
void __iomem *base;
249251
struct coresight_device *csdev;

0 commit comments

Comments
 (0)