Re: [PATCH v1 1/1] cpufreq: mediatek-hw: Fix double devm_remap in hotplug case

From: Viresh Kumar
Date: Mon Nov 01 2021 - 23:48:28 EST


On 29-10-21, 19:42, Hector Yuan wrote:
> From: "Hector.Yuan" <hector.yuan@xxxxxxxxxxxx>
>
> When hotpluging policy cpu, cpu policy init will be called multiple times.
> Unplug CPU7 -> CPU6 -> CPU5 -> CPU4, then plug CPU4 again.
> In this case, devm_remap will double remap and resource allocate fail.
> So replace devm_remap to ioremap and release resources in cpu policy exit.
>
> Signed-off-by: Hector.Yuan <hector.yuan@xxxxxxxxxxxx>
> ---
> drivers/cpufreq/mediatek-cpufreq-hw.c | 33 ++++++++++++++++++++++++++++++---
> 1 file changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/mediatek-cpufreq-hw.c b/drivers/cpufreq/mediatek-cpufreq-hw.c
> index 0cf18dd..25317d7 100644
> --- a/drivers/cpufreq/mediatek-cpufreq-hw.c
> +++ b/drivers/cpufreq/mediatek-cpufreq-hw.c
> @@ -36,6 +36,8 @@ enum {
> struct mtk_cpufreq_data {
> struct cpufreq_frequency_table *table;
> void __iomem *reg_bases[REG_ARRAY_SIZE];
> + struct resource *res;
> + void __iomem *base;
> int nr_opp;
> };
>
> @@ -156,6 +158,7 @@ static int mtk_cpu_resources_init(struct platform_device *pdev,

pdev specific initializations shouldn't be done from policy->init(),
but instead do those only once from mtk_cpufreq_hw_driver_probe().

That way such bugs won't occur again.

--
viresh