linux/drivers/soc
Stephan Gerhold dd461cd918 opp: Allow dev_pm_opp_get_opp_table() to return -EPROBE_DEFER
The OPP core manages various resources, e.g. clocks or interconnect paths.
These resources are looked up when the OPP table is allocated once
dev_pm_opp_get_opp_table() is called the first time (either directly
or indirectly through one of the many helper functions).

At this point, the resources may not be available yet, i.e. looking them
up will result in -EPROBE_DEFER. Unfortunately, dev_pm_opp_get_opp_table()
is currently unable to propagate this error code since it only returns
the allocated OPP table or NULL.

This means that all consumers of the OPP core are required to make sure
that all necessary resources are available. Usually this happens by
requesting them, checking the result and releasing them immediately after.

For example, we have added "dev_pm_opp_of_find_icc_paths(dev, NULL)" to
several drivers now just to make sure the interconnect providers are
ready before the OPP table is allocated. If this call is missing,
the OPP core will only warn about this and then attempt to continue
without interconnect. This will eventually fail horribly, e.g.:

    cpu cpu0: _allocate_opp_table: Error finding interconnect paths: -517
    ... later ...
    of: _read_bw: Mismatch between opp-peak-kBps and paths (1 0)
    cpu cpu0: _opp_add_static_v2: opp key field not found
    cpu cpu0: _of_add_opp_table_v2: Failed to add OPP, -22

This example happens when trying to use interconnects for a CPU OPP
table together with qcom-cpufreq-nvmem.c. qcom-cpufreq-nvmem calls
dev_pm_opp_set_supported_hw(), which ends up allocating the OPP table
early. To fix the problem with the current approach we would need to add
yet another call to dev_pm_opp_of_find_icc_paths(dev, NULL).
But actually qcom-cpufreq-nvmem.c has nothing to do with interconnects...

This commit attempts to make this more robust by allowing
dev_pm_opp_get_opp_table() to return an error pointer. Fixing all
the usages is trivial because the function is usually used indirectly
through another helper (e.g. dev_pm_opp_set_supported_hw() above).
These other helpers already return an error pointer.

The example above then works correctly because set_supported_hw() will
return -EPROBE_DEFER, and qcom-cpufreq-nvmem.c already propagates that
error. It should also be possible to remove the remaining usages of
"dev_pm_opp_of_find_icc_paths(dev, NULL)" from other drivers as well.

Note that this commit currently only handles -EPROBE_DEFER for the
clock/interconnects within _allocate_opp_table(). Other errors are just
ignored as before. Eventually those should be propagated as well.

Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
[ Viresh: skip checking return value of dev_pm_opp_get_opp_table() for
	  EPROBE_DEFER in domain.c, fix NULL return value and reorder
	  code a bit in core.c, and update exynos-asv.c ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2020-08-25 11:08:54 +05:30
..
actions treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
amlogic soc: amlogic: meson-gx-socinfo: Fix S905X3 and S905D3 ID's 2020-06-29 16:00:53 -07:00
aspeed treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
atmel drivers: soc: atmel: move sam9x60 under its own config flag 2019-12-10 00:44:53 +01:00
bcm soc: bcm: brcmstb: biuctrl: Update programming for 7211 2020-01-05 13:44:04 -08:00
dove treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
fsl ARM/SoC: drivers for v5.7 2020-06-04 19:56:20 -07:00
gemini
imx ARM: SoC driver updates for v5.9 2020-08-03 19:30:59 -07:00
ixp4xx soc: ixp4xx: Protect IXP4xx SoC drivers by ARCH_IXP4XX || COMPILE_TEST 2019-08-29 17:34:38 +02:00
kendryte riscv: K210: Add a built-in device tree 2020-05-18 11:38:06 -07:00
lantiq soc: lantiq: convert to devm_platform_ioremap_resource 2020-01-10 11:44:52 -08:00
mediatek soc: mediatek: cmdq: add set event function 2020-06-22 13:21:00 +02:00
qcom Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-08-07 21:14:30 -07:00
renesas soc: renesas: rcar-rst: Add support for RZ/G2H 2020-07-13 10:34:41 +02:00
rockchip ARM: SoC-related driver updates 2019-07-19 17:13:56 -07:00
samsung opp: Allow dev_pm_opp_get_opp_table() to return -EPROBE_DEFER 2020-08-25 11:08:54 +05:30
sifive soc: sifive: l2 cache: Mark l2_get_priv_group as static 2020-05-28 15:57:49 -07:00
sunxi treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
tegra soc/tegra: fuse: Fix typo in APB MISC warning 2020-07-17 15:47:35 +02:00
ti ARM: SoC driver updates for v5.9 2020-08-03 19:30:59 -07:00
ux500 soc: ux500: Use custom soc attribute group instead of device_create_file 2020-07-06 09:48:06 +01:00
versatile soc: integrator: Use custom soc attribute group instead of device_create_file 2020-07-06 09:48:05 +01:00
xilinx firmware: xilinx: Remove eemi ops for set_requirement 2020-04-28 15:45:09 +02:00
zte treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
Kconfig riscv: Add Kendryte K210 SoC support 2020-04-03 10:49:52 -07:00
Makefile RISC-V Patches for the 5.7 Merge Window, Part 1 2020-04-09 10:51:30 -07:00