From patchwork Tue Dec 24 01:41:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 22740 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7A1AF20555 for ; Tue, 24 Dec 2013 01:41:15 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id lx4sf26552487iec.6 for ; Mon, 23 Dec 2013 17:41:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type:content-transfer-encoding; bh=4lD2F0NMtYVViKYBwkhRgvJqtVsK5VboUfvouWcbm4w=; b=dSqWGkE90EdxhzKhoxypTRm7KX5+kB5LW/+XoT9uGKnSlJD1uuzbeB0uCuq3pyZz4u yeIUZtDqwmgDg9MQqCgppbknUhZWWbxKmCcJrXd36XRofAp/MI83dBNInQmZgghNIPcz b+2T09MpkNeOWGxs9iavHKeirWyrp3/RhtWAPDT+jnvop88m3p1qavGFTA87EILIT9/O Bgy7pISimYehJQbzBTO2dTNt4d7kOU+FzG7e2vUSccI3UgvC8IUtPS4oz9VIU5A8+xds nKLa0SUSiY4/MxAK75O72NCJqkBneEYP4YoST3ddrnX1CgJpYA7mJkj5zmvHTIA2YjG+ v6ww== X-Gm-Message-State: ALoCoQkZGslIwljCrOO2DNXElZrJNjmRWJYo5tJg7On9r1+qnMJJta41ImJW7fI7+59zNM8qydB1 X-Received: by 10.183.3.36 with SMTP id bt4mr11614687obd.29.1387849274348; Mon, 23 Dec 2013 17:41:14 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.196 with SMTP id e4ls1790962qeg.6.gmail; Mon, 23 Dec 2013 17:41:14 -0800 (PST) X-Received: by 10.58.100.197 with SMTP id fa5mr195519veb.24.1387849274235; Mon, 23 Dec 2013 17:41:14 -0800 (PST) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id we7si5411385vcb.7.2013.12.23.17.41.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Dec 2013 17:41:14 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id la4so3232739vcb.29 for ; Mon, 23 Dec 2013 17:41:14 -0800 (PST) X-Received: by 10.220.58.1 with SMTP id e1mr15201029vch.0.1387849273899; Mon, 23 Dec 2013 17:41:13 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp264502ved; Mon, 23 Dec 2013 17:41:13 -0800 (PST) X-Received: by 10.69.19.225 with SMTP id gx1mr29632800pbd.62.1387849272637; Mon, 23 Dec 2013 17:41:12 -0800 (PST) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by mx.google.com with ESMTPS id ya10si14103379pab.124.2013.12.23.17.41.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Dec 2013 17:41:12 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.44 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.44; Received: by mail-pa0-f44.google.com with SMTP id fa1so5921574pad.17 for ; Mon, 23 Dec 2013 17:41:12 -0800 (PST) X-Received: by 10.66.119.136 with SMTP id ku8mr29279723pab.121.1387849272094; Mon, 23 Dec 2013 17:41:12 -0800 (PST) Received: from localhost ([122.167.204.159]) by mx.google.com with ESMTPSA id vn10sm37385378pbc.21.2013.12.23.17.41.08 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 23 Dec 2013 17:41:11 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn@mork.no, Viresh Kumar Subject: [PATCH 1/2] cpufreq: try to resume policies which failed on last resume Date: Tue, 24 Dec 2013 07:11:00 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e MIME-Version: 1.0 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , __cpufreq_add_dev() can fail sometimes while we are resuming our system. Currently we are clearing all sysfs nodes for cpufreq's failed policy as that could make userspace unstable. But if we suspend/resume again, we should atleast try to bring back those policies. This patch fixes this issue by clearing fallback data on failure and trying to allocate a new struct cpufreq_policy on second resume. Reported-and-tested-by: Bjørn Mork Signed-off-by: Viresh Kumar Acked-by: Viresh Kumar --- These are sent again (earlier sent as reply to emails), so that people can give inputs if they have any. Tested on my thinkpad T420. drivers/cpufreq/cpufreq.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 16d7b4a..0a48e71 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1016,16 +1016,24 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, read_unlock_irqrestore(&cpufreq_driver_lock, flags); #endif - if (frozen) + if (frozen) { /* Restore the saved policy when doing light-weight init */ policy = cpufreq_policy_restore(cpu); - else + + /* + * As we failed to resume cpufreq core last time, lets try to + * create a new policy. + */ + if (!policy) + frozen = false; + } + + if (!frozen) policy = cpufreq_policy_alloc(); if (!policy) goto nomem_out; - /* * In the resume path, since we restore a saved policy, the assignment * to policy->cpu is like an update of the existing policy, rather than @@ -1118,8 +1126,14 @@ err_get_freq: if (cpufreq_driver->exit) cpufreq_driver->exit(policy); err_set_policy_cpu: - if (frozen) + if (frozen) { + /* + * Clear fallback data as we should try to make things work on + * next suspend/resume + */ + per_cpu(cpufreq_cpu_data_fallback, cpu) = NULL; cpufreq_policy_put_kobj(policy); + } cpufreq_policy_free(policy); nomem_out: