From patchwork Tue Jan 12 09:52:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 361154 Delivered-To: patch@linaro.org Received: by 2002:a02:ccad:0:0:0:0:0 with SMTP id t13csp210701jap; Tue, 12 Jan 2021 01:53:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkrNYrLIUdsqAogTwGWd6SZbJonq8Gif9BsL2EVZOvvuo9tbhDQs8gUhACU+fddVyrhuw+ X-Received: by 2002:a05:6402:1748:: with SMTP id v8mr2810645edx.136.1610445230042; Tue, 12 Jan 2021 01:53:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610445230; cv=none; d=google.com; s=arc-20160816; b=e/LjtyZmKyuHnrjpi7M87ZNTguLE9woes6HB98x1Mp6Sv9RfYb1CFRRI8aGpC3nFAs wWb1LS94ZMXSeZjM7C+QKD7H7FK+HfcmjmmOct5ngVv4E8TYvwodyGy9Laj7HqMTxn0L IRDS5DBJDIGrrzNuTWxPDXAE4kzT4ZPZ8mm6CSP44B6tG0KmLjf6236Dkb94yrp8fRzl Uy2aSAFkynX2qRSTIa3OcZVAIyEF7hb/2PuMSyJq+AklbwGsk1BtjYV8ulyxGBF7pHd+ OhiDMCbO7vcDqMZH2GcRwbIuTTMmbsjHhj7fQBa09sTr3dF+IjqXRyedOS29Acger8t9 MJPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=srYJmug92j0OsKq39q/OswiRd1JmfW8IEDQEUNljHnU=; b=uDxKE9VevNdK33xDAvB3J88kO1amilrjsDM+jaT7Oq1NYQW3WuwMsu7fYokuLzTqpV da9GNOvrh/rbQyBw/YASC5Qf1L/Uy5N2aK+pPpq7mT6VX9ybQPZJ6wz8xQjiKf93bBsK w+4bvNM8fQPZ0Q4EUwPQKnUu3cZ6ZXkpEq+CMLZp2tE9DN6aFbxL4EhiOc6tRovOp9II Ht7ejErT62Uhj/91G8Av8J3zLvAzZScfi5dY9SAFUvz1GwbuN1V8SDSpvENcMk0tN+Dg d2fYZdkvXeWAo58HVp9xhIJJi3vzIn2+XR8GnkdJpTUGmSVZQFXSMV+OZNJGUXZyqSmA Lzfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v6QHWUWm; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si1095172edy.18.2021.01.12.01.53.49; Tue, 12 Jan 2021 01:53:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v6QHWUWm; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392797AbhALJxg (ORCPT + 15 others); Tue, 12 Jan 2021 04:53:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392796AbhALJxf (ORCPT ); Tue, 12 Jan 2021 04:53:35 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E426C061794 for ; Tue, 12 Jan 2021 01:52:55 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id g15so1084738pgu.9 for ; Tue, 12 Jan 2021 01:52:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=srYJmug92j0OsKq39q/OswiRd1JmfW8IEDQEUNljHnU=; b=v6QHWUWmXwSiWv4vsGTQ7GLUJJSixC5ZJAFb0Ut+X0+S5gVu2soDHqYqyZSm9NdZ06 TsQlgU5yqykIXGSkOMbu7FfpwdPG6VtkbbjfsDhA54xrd/RqXRr+2N5FD8JWLKpoYveJ mm9jkMf5XDGphd7fswb2vlhv5MFmordwqOBnBIQtwOQVtxtq+TIsNc9whBv2p+xTJ8EY kfcZigdbZs1g2f5PSev6nA9/cCnMKeqZEGXPK56wyRaLl8/ev5tx5qbHV2bCqSthIOk0 xJ6Gnb4rz8lk6BGwViTNBqqT1ie/UZyl/D4KojcKuf3rSeOgFzSwxo6Kesv71i0D5VhQ AcvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=srYJmug92j0OsKq39q/OswiRd1JmfW8IEDQEUNljHnU=; b=lVJFw75eN16sadAGbgl6P506nxGfllIR+njYzWJ7/u9KbnavZ9gsvzrV5DKKSeASzQ sDJQLs+lZDj24RInJBypei5lOCrtmahhD3KbDRJsWdVQIPQp122LIjT+EU0xcbJEMpzw V0k8bKeoAU85suH5oWoWLdAASwoghfy5qkYR2Duyot7WZj/fbvWqijsc/HB/Y4dO1BCo BkRFMcLLLKg2P5TgGeOnpkuRgOzEM4KX0CGRKEQYPX7gLXPaOWDP5JCot0Txn59VRl51 d345HUparHxQzLTgbAUKD5dyxWoRX4ChvZQBEHfUa//SyxH8BMofXaiS0FIt9/M/C/W3 6jeQ== X-Gm-Message-State: AOAM532MLiuGLrPf3MEzSIRdiHdoJ7uWIrVKdadEwkJVMq8vIwZ4kqZO lNePcdH1uHIM6qwNT30zSk3orA== X-Received: by 2002:a62:64d2:0:b029:19e:662e:5e99 with SMTP id y201-20020a6264d20000b029019e662e5e99mr3845537pfb.17.1610445173548; Tue, 12 Jan 2021 01:52:53 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id b6sm2464174pfd.43.2021.01.12.01.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 01:52:52 -0800 (PST) From: Shawn Guo To: "Rafael J . Wysocki" , Viresh Kumar Cc: Bjorn Andersson , Andy Gross , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, Shawn Guo Subject: [PATCH] cpufreq: qcom-hw: add missing devm_release_mem_region() call Date: Tue, 12 Jan 2021 17:52:36 +0800 Message-Id: <20210112095236.20515-1-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On SDM845/850, running the following commands to put all cores in freq-domain1 offline and then get one core back online, there will be a request region error seen from qcom-hw driver. $ echo 0 > /sys/devices/system/cpu/cpu4/online $ echo 0 > /sys/devices/system/cpu/cpu5/online $ echo 0 > /sys/devices/system/cpu/cpu6/online $ echo 0 > /sys/devices/system/cpu/cpu7/online $ echo 1 > /sys/devices/system/cpu/cpu4/online [ 3395.915416] CPU4: shutdown [ 3395.938185] psci: CPU4 killed (polled 0 ms) [ 3399.071424] CPU5: shutdown [ 3399.094316] psci: CPU5 killed (polled 0 ms) [ 3402.139358] CPU6: shutdown [ 3402.161705] psci: CPU6 killed (polled 0 ms) [ 3404.742939] CPU7: shutdown [ 3404.765592] psci: CPU7 killed (polled 0 ms) [ 3411.492274] Detected VIPT I-cache on CPU4 [ 3411.492337] GICv3: CPU4: found redistributor 400 region 0:0x0000000017ae0000 [ 3411.492448] CPU4: Booted secondary processor 0x0000000400 [0x516f802d] [ 3411.503654] qcom-cpufreq-hw 17d43000.cpufreq: can't request region for resource [mem 0x17d45800-0x17d46bff] The cause is that the memory region requested in .init hook doesn't get released in .exit hook, and the subsequent call to .init will always fail on this error. Let's break down the devm_platform_ioremap_resource() call a bit, so that we can have the resource pointer to release memory region from .exit hook. Signed-off-by: Shawn Guo --- drivers/cpufreq/qcom-cpufreq-hw.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.17.1 Tested-by: Ionela Voinescu diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 9ed5341dc515..315ee987d2d3 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -32,6 +32,7 @@ struct qcom_cpufreq_soc_data { struct qcom_cpufreq_data { void __iomem *base; + struct resource *res; const struct qcom_cpufreq_soc_data *soc_data; }; @@ -280,6 +281,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) struct of_phandle_args args; struct device_node *cpu_np; struct device *cpu_dev; + struct resource *res; void __iomem *base; struct qcom_cpufreq_data *data; int ret, index; @@ -303,7 +305,8 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) index = args.args[0]; - base = devm_platform_ioremap_resource(pdev, index); + res = platform_get_resource(pdev, IORESOURCE_MEM, index); + base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) return PTR_ERR(base); @@ -315,6 +318,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) data->soc_data = of_device_get_match_data(&pdev->dev); data->base = base; + data->res = res; /* HW should be in enabled state to proceed */ if (!(readl_relaxed(base + data->soc_data->reg_enable) & 0x1)) { @@ -358,11 +362,13 @@ 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 platform_device *pdev = cpufreq_get_driver_data(); + struct resource *res = data->res; dev_pm_opp_remove_all_dynamic(cpu_dev); dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); kfree(policy->freq_table); devm_iounmap(&pdev->dev, data->base); + devm_release_mem_region(&pdev->dev, res->start, resource_size(res)); return 0; }