From patchwork Tue Mar 21 06:06:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95598 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1287558qgd; Mon, 20 Mar 2017 23:14:07 -0700 (PDT) X-Received: by 10.98.17.200 with SMTP id 69mr37403937pfr.210.1490076847709; Mon, 20 Mar 2017 23:14:07 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34si20169463plz.66.2017.03.20.23.14.07; Mon, 20 Mar 2017 23:14:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1756528AbdCUGOG (ORCPT + 21 others); Tue, 21 Mar 2017 02:14:06 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:34581 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752189AbdCUGOF (ORCPT ); Tue, 21 Mar 2017 02:14:05 -0400 Received: by mail-pg0-f47.google.com with SMTP id 21so55750552pgg.1 for ; Mon, 20 Mar 2017 23:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=C2yJxYRq/pbYopEAFRD6etkX4KfH7Mjs193fOUar9tw=; b=WLzNYKWNJ8ttwtlGKRWxoRAr1ToHng6mbL5hAxSK3jB1Sh5Ej8RdX/NWXbGkJp30vm 7KbrcPSKcK0ZWugc5kKkJC/aXBt1akKii3C7iabGReXphgBo1s1ug3COigB3JP5Q0tqG YoliSbfQ26e2s5z/dkd59ICk/l/6WhojH4tU0= 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=C2yJxYRq/pbYopEAFRD6etkX4KfH7Mjs193fOUar9tw=; b=CfsX6igHl3s2NsS+9yQQnDGDEqgL9cR99/SpDIefpvMmqouXO3XVZ8MryXujs9XOgi 3/0SEryTLeqyMyseySRWIKlRP2qielB6uuyQlQBUf5+rezOkxb7WY2FM2N4uuExXhTY0 bfRzHIIcriMmrh2T7zhSt6FqfMprEV7rCy3w6Oh4bX4OEe0fuP9ui+iuZnRt4OYqRrfh 0Q8z5jxTHIcPcWxqwWj9OUSvH6pZLKxQTD7J0bhN2dfwoAnqq9hOx0UbAk0z4JybOE2E sCEE5Sx2RzF4BNG2/sLrgi9haey6pcJ8Yx/2RxdHhXLeo4y3DeruUcbQ44uipK/jTWG7 xAUA== X-Gm-Message-State: AFeK/H0lMD7MSsQFOW9wwXXFYZOJH6CcoCsyxe4bzVxaYLfnN7UrdIHR81UD0/C6/dmMh4Pc X-Received: by 10.99.147.16 with SMTP id b16mr35593864pge.126.1490076375694; Mon, 20 Mar 2017 23:06:15 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id l29sm26819998pfb.118.2017.03.20.23.06.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Mar 2017 23:06:14 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" Subject: [PATCH V3] cpufreq: Restore policy min/max limits on CPU online Date: Tue, 21 Mar 2017 11:36:06 +0530 Message-Id: <96b7044b50a37b3c4c302e6e22d3cbc6e8864cd4.1490076285.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On CPU online the cpufreq core restores the previous governor (or the previous "policy" setting for ->setpolicy drivers), but it does not restore the min/max limits at the same time, which is confusing, inconsistent and real pain for users who set the limits and then suspend/resume the system (using full suspend), in which case the limits are reset on all CPUs except for the boot one. Fix this by making cpufreq_online() restore the limits when an inactive policy is brought online. The commit log and patch are inspired from Rafael's earlier work. Reported-by: Rafael J. Wysocki Signed-off-by: Viresh Kumar --- V1 and V2 were sent by Rafael and were trying to fix this differently. drivers/cpufreq/cpufreq.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.12.0.432.g71c3a4f4ba37 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 38b9fdf854a4..87e7b9d0db1b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1182,6 +1182,9 @@ static int cpufreq_online(unsigned int cpu) for_each_cpu(j, policy->related_cpus) per_cpu(cpufreq_cpu_data, j) = policy; write_unlock_irqrestore(&cpufreq_driver_lock, flags); + } else { + policy->min = policy->user_policy.min; + policy->max = policy->user_policy.max; } if (cpufreq_driver->get && !cpufreq_driver->setpolicy) {