From patchwork Tue Aug 20 06:38:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 19341 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D15CF25BDE for ; Tue, 20 Aug 2013 06:40:06 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id 3sf19606qeb.11 for ; Mon, 19 Aug 2013 23:40:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=oeMfioQDmkdvckJJAshRApmn4DmsVB+ewg883pKQBWc=; b=NyG4/Nyy9nN1IbVtlq4znMt1K0EiKjYFMYvid6UaXSjBFmLlqAWh10hYtRkmWbvpTB gPJuEAMvYduuwWSV9N0k7Bpa68lgrJmOd8Ttr7xNwmkgUqcdu0SftfQLeVFPr3onpbLg Ia1Nt9RgBVV+DVbQW7V8gtNiBQkdHF/Sj7uNoHZ1+xSUzIA8jn3qe0nuQGw/efcU0fUN ZaQE6hNdpCINn93bAoBKkXvXmGp7oEI5UatfJ5QmLkFi49y1VIcdG5dF7HfzBX2cKb8a jx5FNDO7vJJ4KXbJFDmyPCWPo5wNRM1l6hryKgZjkd+Fk9ipGBhgIPtVn9aGMV3azDLh Xw9g== X-Received: by 10.236.68.193 with SMTP id l41mr13956yhd.19.1376980806693; Mon, 19 Aug 2013 23:40:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.244 with SMTP id u20ls137856qeq.74.gmail; Mon, 19 Aug 2013 23:40:06 -0700 (PDT) X-Received: by 10.52.89.143 with SMTP id bo15mr14198vdb.113.1376980806568; Mon, 19 Aug 2013 23:40:06 -0700 (PDT) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id n6si13216ven.79.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 23:40:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.46; Received: by mail-vb0-f46.google.com with SMTP id p13so11761vbe.33 for ; Mon, 19 Aug 2013 23:40:06 -0700 (PDT) X-Gm-Message-State: ALoCoQlYmr1Dvk28UkjLYn6N7ibomZIzCL+85J98gMW+Kz86HVo1WxdLMhKp8UoI1q/9wnb9MLZ2 X-Received: by 10.220.164.202 with SMTP id f10mr14166vcy.25.1376980806488; Mon, 19 Aug 2013 23:40:06 -0700 (PDT) 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.220.174.196 with SMTP id u4csp138852vcz; Mon, 19 Aug 2013 23:40:05 -0700 (PDT) X-Received: by 10.66.161.229 with SMTP id xv5mr1878239pab.87.1376980805496; Mon, 19 Aug 2013 23:40:05 -0700 (PDT) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by mx.google.com with ESMTPS id zy6si47281pbc.196.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Aug 2013 23:40:05 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.43 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.43; Received: by mail-pa0-f43.google.com with SMTP id hz10so333079pad.2 for ; Mon, 19 Aug 2013 23:40:05 -0700 (PDT) X-Received: by 10.68.203.105 with SMTP id kp9mr27856pbc.78.1376980805073; Mon, 19 Aug 2013 23:40:05 -0700 (PDT) Received: from localhost ([106.200.1.10]) by mx.google.com with ESMTPSA id oj6sm1759468pab.9.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 19 Aug 2013 23:40:04 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 2/5] cpufreq: remove policy from cpufreq_policy_list in system suspend Date: Tue, 20 Aug 2013 12:08:23 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: 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.212.46 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_policy_list is a list of active policies. We do remove policies from this list when all CPUs belonging to that policy are removed. But during suspend we don't really free a policy struct as it will be used again during resume. And so we didn't remove it from cpufreq_policy_list as well.. This is incorrect. We are saying this policy isn't valid anymore and must not be referenced (though we haven't freed it), but it can still be used by code that iterates over cpufreq_policy_list. Lets remove policy from this list even in case of suspend as well.. Similarly we must add it back whenever the first cpu belonging to that policy turns up. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index fedc842..0302121 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -950,12 +950,6 @@ err_free_policy: static void cpufreq_policy_free(struct cpufreq_policy *policy) { - unsigned long flags; - - write_lock_irqsave(&cpufreq_driver_lock, flags); - list_del(&policy->policy_list); - write_unlock_irqrestore(&cpufreq_driver_lock, flags); - free_cpumask_var(policy->related_cpus); free_cpumask_var(policy->cpus); kfree(policy); @@ -1069,12 +1063,12 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, ret = cpufreq_add_dev_interface(policy, dev); if (ret) goto err_out_unregister; - - write_lock_irqsave(&cpufreq_driver_lock, flags); - list_add(&policy->policy_list, &cpufreq_policy_list); - write_unlock_irqrestore(&cpufreq_driver_lock, flags); } + write_lock_irqsave(&cpufreq_driver_lock, flags); + list_add(&policy->policy_list, &cpufreq_policy_list); + write_unlock_irqrestore(&cpufreq_driver_lock, flags); + cpufreq_init_policy(policy); kobject_uevent(&policy->kobj, KOBJ_ADD); @@ -1280,6 +1274,11 @@ static int __cpufreq_remove_dev(struct device *dev, if (cpufreq_driver->exit) cpufreq_driver->exit(policy); + /* Remove policy from list of active policies */ + write_lock_irqsave(&cpufreq_driver_lock, flags); + list_del(&policy->policy_list); + write_unlock_irqrestore(&cpufreq_driver_lock, flags); + if (!frozen) cpufreq_policy_free(policy); } else {