Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

clk: qcom: lpass-sc7180: Fix pm_runtime usage

The sc7180 lpass clock controller's pm_runtime usage wasn't broken
quite as spectacularly as the sc7280's pm_runtime usage, but it was
still broken. Putting some printouts in at boot showed me this (with
serial console enabled, which makes the prints slow and thus changes
timing):
[ 3.109951] DOUG: my_pm_clk_resume, usage=1
[ 3.114767] DOUG: my_pm_clk_resume, usage=1
[ 3.664443] DOUG: my_pm_clk_suspend, usage=0
[ 3.897566] DOUG: my_pm_clk_suspend, usage=0
[ 3.910137] DOUG: my_pm_clk_resume, usage=1
[ 3.923217] DOUG: my_pm_clk_resume, usage=0
[ 4.440116] DOUG: my_pm_clk_suspend, usage=-1
[ 4.444982] DOUG: my_pm_clk_suspend, usage=0
[ 14.170501] DOUG: my_pm_clk_resume, usage=1
[ 14.176245] DOUG: my_pm_clk_resume, usage=0

...or this w/out serial console:
[ 0.556139] DOUG: my_pm_clk_resume, usage=1
[ 0.556279] DOUG: my_pm_clk_resume, usage=1
[ 1.058422] DOUG: my_pm_clk_suspend, usage=-1
[ 1.058464] DOUG: my_pm_clk_suspend, usage=0
[ 1.186250] DOUG: my_pm_clk_resume, usage=1
[ 1.186292] DOUG: my_pm_clk_resume, usage=0
[ 1.731536] DOUG: my_pm_clk_suspend, usage=-1
[ 1.731557] DOUG: my_pm_clk_suspend, usage=0
[ 10.288910] DOUG: my_pm_clk_resume, usage=1
[ 10.289496] DOUG: my_pm_clk_resume, usage=0

It seems to be doing roughly the right sequence of calls, but just
like with sc7280 this is more by luck than anything. Having a usage of
-1 is just not OK.

Let's fix this like we did with sc7280.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Fixes: ce8c195e652f ("clk: qcom: lpasscc: Introduce pm autosuspend for SC7180")
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20221104064055.2.I49b25b9bda9430fc7ea21e5a708ca5a0aced2798@changeid

authored by

Douglas Anderson and committed by
Bjorn Andersson
ff1ccf59 d470be3c

+16 -8
+16 -8
drivers/clk/qcom/lpasscorecc-sc7180.c
··· 356 356 .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs), 357 357 }; 358 358 359 - static int lpass_create_pm_clks(struct platform_device *pdev) 359 + static int lpass_setup_runtime_pm(struct platform_device *pdev) 360 360 { 361 361 int ret; 362 362 ··· 375 375 if (ret < 0) 376 376 dev_err(&pdev->dev, "failed to acquire iface clock\n"); 377 377 378 - return ret; 378 + return pm_runtime_resume_and_get(&pdev->dev); 379 379 } 380 380 381 381 static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) ··· 384 384 struct regmap *regmap; 385 385 int ret; 386 386 387 - ret = lpass_create_pm_clks(pdev); 387 + ret = lpass_setup_runtime_pm(pdev); 388 388 if (ret) 389 389 return ret; 390 390 ··· 392 392 desc = &lpass_audio_hm_sc7180_desc; 393 393 ret = qcom_cc_probe_by_index(pdev, 1, desc); 394 394 if (ret) 395 - return ret; 395 + goto exit; 396 396 397 397 lpass_core_cc_sc7180_regmap_config.name = "lpass_core_cc"; 398 398 regmap = qcom_cc_map(pdev, &lpass_core_cc_sc7180_desc); 399 - if (IS_ERR(regmap)) 400 - return PTR_ERR(regmap); 399 + if (IS_ERR(regmap)) { 400 + ret = PTR_ERR(regmap); 401 + goto exit; 402 + } 401 403 402 404 /* 403 405 * Keep the CLK always-ON ··· 417 415 ret = qcom_cc_really_probe(pdev, &lpass_core_cc_sc7180_desc, regmap); 418 416 419 417 pm_runtime_mark_last_busy(&pdev->dev); 418 + exit: 420 419 pm_runtime_put_autosuspend(&pdev->dev); 421 420 422 421 return ret; ··· 428 425 const struct qcom_cc_desc *desc; 429 426 int ret; 430 427 431 - ret = lpass_create_pm_clks(pdev); 428 + ret = lpass_setup_runtime_pm(pdev); 432 429 if (ret) 433 430 return ret; 434 431 435 432 lpass_core_cc_sc7180_regmap_config.name = "lpass_hm_core"; 436 433 desc = &lpass_core_hm_sc7180_desc; 437 434 438 - return qcom_cc_probe_by_index(pdev, 0, desc); 435 + ret = qcom_cc_probe_by_index(pdev, 0, desc); 436 + 437 + pm_runtime_mark_last_busy(&pdev->dev); 438 + pm_runtime_put_autosuspend(&pdev->dev); 439 + 440 + return ret; 439 441 } 440 442 441 443 static const struct of_device_id lpass_hm_sc7180_match_table[] = {