Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp863007rwl; Fri, 24 Mar 2023 03:06:30 -0700 (PDT) X-Google-Smtp-Source: AKy350ZDYL5ZLB7JAsSVo4tOSv3eugAx+VBBA3p65mruofBgT44vAfGSxk+Yn1Ga319inJeoNgOe X-Received: by 2002:a17:906:4d8b:b0:92f:7c42:8631 with SMTP id s11-20020a1709064d8b00b0092f7c428631mr2025052eju.16.1679652390152; Fri, 24 Mar 2023 03:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679652390; cv=none; d=google.com; s=arc-20160816; b=D/EdGeLkYKKsF1OG+hP1qVj5XlJyO/u3vA2OHQCcWsGjSi/OOZtgaMIcD9DAw+tClI z3AQrd1OpYD8bkvKBFhLdZf4OEsTxD7WuYUy9pjd0Xlamhd2eCK4Sggw4aeFqKexczQY G1mamyYg9fe3d+BeZvsJZZE+qU//9wrLnM6a0snbSxq1Tq2UdE/fdaDS0+9mCNm9WXTo Y/UkvkhjZs0B/Wc8T0IyExywAsNFF98PiWoVU+cG3aL4ns48cBeZ1fyyInTmAAKCb5Mz tRO+aT7IQLErc54cmZhQZ73b0LV/VRag7RzWRgaG7gl/v2j/ur09kx0+O3iqAqTZudcS 2gmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=97v8IS33tb1ofaWxxJHZyjrYcNk0lin73TLFNWDZT2U=; b=TqHonHXFA1RekRGIyFnLCsTJJ2Fapqsm0LGX6cOBBgKyYF5JeRaIgs5+AScbJ3F8S4 MyrjwY3NZv2qgI07RVfLktxlZAJRUmgs5WR1gsx6y4JTdHUnazZ48+orbVgsXfJast9r KhLcDBk11iYB1ygYOLr+UXUrjXBF9PH12fSaO2LmeFVX1iSFVXwa5dwH//sWFKltmpwm BWs6cJ8iMil4GEsl2iPIHhITl6tboeFocIyYAVtTVq7mY+7ALLfPlaEQaGRokpFQROkp WyrudPRSQOXkwd4LV6TNqljmS4pSVg8KubCN+2VBM1+6Vb3ONR04ALUCG+5SlVRsmlwo dIZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cJuAyXXk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a170906194e00b008c8165f7c25si11742252eje.951.2023.03.24.03.06.05; Fri, 24 Mar 2023 03:06:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cJuAyXXk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231329AbjCXKEZ (ORCPT + 99 others); Fri, 24 Mar 2023 06:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231254AbjCXKEX (ORCPT ); Fri, 24 Mar 2023 06:04:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8BF11A4BF; Fri, 24 Mar 2023 03:04:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8DDCDB82357; Fri, 24 Mar 2023 10:04:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73DCEC433D2; Fri, 24 Mar 2023 10:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679652260; bh=8+n/g8D7fA39riz19Ut1Cr74s9l1rB4rM9KIMmbszOQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cJuAyXXkH9p46rBWBlX4YTit8Ot5+QQH4LlLtMVOsjdpjRUnWTDc+EFM9xJL1OhKe FkJe+v48Vr9XCKvaMg6YoUXF/3dwgQXkzH3Ff7JCEur9AI+fG/acjEXEpkwE5QW939 8vR/Ezsbq2/nGAD2ttYxhpgp4T3cxaDe+uAigtlhJ2EMNdRmI2Dz1Ayzt+cGDP2T0c QSc4oYp4aO9OnMMKPnRR8jyTNQjTQeLUt5fhA8KyZUOP1SF1aMzvdCXQc3eEgRmuX8 JfZL4keo0VvY02LHg36MUqA8x4qy7PNcloF0vBHVkrvZ0qv9DqJ8q16HpAmGvR5L+p W/M8uO6d2BQ8g== Date: Fri, 24 Mar 2023 15:34:07 +0530 From: Manivannan Sadhasivam To: Krzysztof Kozlowski Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , "Rafael J. Wysocki" , Viresh Kumar , linux-arm-msm@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] cpufreq: qcom-cpufreq-hw: fix double IO unmap and resource release on exit Message-ID: <20230324100407.GA4259@thinkpad> References: <20230323174026.950622-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230323174026.950622-1-krzysztof.kozlowski@linaro.org> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 23, 2023 at 06:40:26PM +0100, Krzysztof Kozlowski wrote: > Commit 054a3ef683a1 ("cpufreq: qcom-hw: Allocate qcom_cpufreq_data > during probe") moved getting memory resource and iomap from > qcom_cpufreq_hw_cpu_init() to the probe function, however it left > untouched cleanup in qcom_cpufreq_hw_cpu_exit(). > > During device unbind this will lead to doule release of resource and > double iounmap(), first by qcom_cpufreq_hw_cpu_exit() and second via > managed resources: > > resource: Trying to free nonexistent resource <0x0000000018593000-0x0000000018593fff> > Trying to vunmap() nonexistent vm area (0000000088a7d4dc) > ... > vunmap (mm/vmalloc.c:2771 (discriminator 1)) > iounmap (mm/ioremap.c:60) > devm_ioremap_release (lib/devres.c:19) > devres_release_all (drivers/base/devres.c:506 drivers/base/devres.c:535) > device_unbind_cleanup (drivers/base/dd.c:523) > device_release_driver_internal (drivers/base/dd.c:1248 drivers/base/dd.c:1263) > device_driver_detach (drivers/base/dd.c:1300) > unbind_store (drivers/base/bus.c:243) > drv_attr_store (drivers/base/bus.c:127) > sysfs_kf_write (fs/sysfs/file.c:137) > kernfs_fop_write_iter (fs/kernfs/file.c:334) > vfs_write (include/linux/fs.h:1851 fs/read_write.c:491 fs/read_write.c:584) > ksys_write (fs/read_write.c:637) > __arm64_sys_write (fs/read_write.c:646) > invoke_syscall (arch/arm64/include/asm/current.h:19 arch/arm64/kernel/syscall.c:57) > el0_svc_common.constprop.0 (arch/arm64/include/asm/daifflags.h:28 arch/arm64/kernel/syscall.c:150) > do_el0_svc (arch/arm64/kernel/syscall.c:194) > el0_svc (arch/arm64/include/asm/daifflags.h:28 arch/arm64/kernel/entry-common.c:133 arch/arm64/kernel/entry-common.c:142 arch/arm64/kernel/entry-common.c:638) > el0t_64_sync_handler (arch/arm64/kernel/entry-common.c:656) > el0t_64_sync (arch/arm64/kernel/entry.S:591) > > Fixes: 054a3ef683a1 ("cpufreq: qcom-hw: Allocate qcom_cpufreq_data during probe") > Cc: > Cc: Manivannan Sadhasivam > Signed-off-by: Krzysztof Kozlowski Reviewed-by: Manivannan Sadhasivam Thanks, Mani > --- > drivers/cpufreq/qcom-cpufreq-hw.c | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > index 2f581d2d617d..b2d2907200a9 100644 > --- a/drivers/cpufreq/qcom-cpufreq-hw.c > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c > @@ -43,7 +43,6 @@ struct qcom_cpufreq_soc_data { > > struct qcom_cpufreq_data { > void __iomem *base; > - struct resource *res; > > /* > * Mutex to synchronize between de-init sequence and re-starting LMh > @@ -590,16 +589,12 @@ static int qcom_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy) > { > struct device *cpu_dev = get_cpu_device(policy->cpu); > struct qcom_cpufreq_data *data = policy->driver_data; > - struct resource *res = data->res; > - void __iomem *base = data->base; > > dev_pm_opp_remove_all_dynamic(cpu_dev); > dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); > qcom_cpufreq_hw_lmh_exit(data); > kfree(policy->freq_table); > kfree(data); > - iounmap(base); > - release_mem_region(res->start, resource_size(res)); > > return 0; > } > @@ -718,17 +713,15 @@ static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) > for (i = 0; i < num_domains; i++) { > struct qcom_cpufreq_data *data = &qcom_cpufreq.data[i]; > struct clk_init_data clk_init = {}; > - struct resource *res; > void __iomem *base; > > - base = devm_platform_get_and_ioremap_resource(pdev, i, &res); > + base = devm_platform_ioremap_resource(pdev, i); > if (IS_ERR(base)) { > - dev_err(dev, "Failed to map resource %pR\n", res); > + dev_err(dev, "Failed to map resource index %d\n", i); > return PTR_ERR(base); > } > > data->base = base; > - data->res = res; > > /* Register CPU clock for each frequency domain */ > clk_init.name = kasprintf(GFP_KERNEL, "qcom_cpufreq%d", i); > -- > 2.34.1 > -- மணிவண்ணன் சதாசிவம்