From patchwork Sun Jul 28 22:11:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rafael Wysocki X-Patchwork-Id: 2834737 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 047B59F4E2 for ; Sun, 28 Jul 2013 22:01:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0CE972012D for ; Sun, 28 Jul 2013 22:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9F81B20119 for ; Sun, 28 Jul 2013 22:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752597Ab3G1WBN (ORCPT ); Sun, 28 Jul 2013 18:01:13 -0400 Received: from hydra.sisk.pl ([212.160.235.94]:45252 "EHLO hydra.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752396Ab3G1WBN convert rfc822-to-8bit (ORCPT ); Sun, 28 Jul 2013 18:01:13 -0400 Received: from vostro.rjw.lan (afcg54.neoplus.adsl.tpnet.pl [95.49.58.54]) by hydra.sisk.pl (Postfix) with ESMTPSA id D27DFE3DBD; Sun, 28 Jul 2013 23:56:26 +0200 (CEST) From: "Rafael J. Wysocki" To: Toralf =?ISO-8859-1?Q?F=F6rster?= Cc: cpufreq@vger.kernel.org, Linux PM list , "Srivatsa S. Bhat" Subject: Re: stable 3-10-3: strange output of "lsmod | grep ^acpi_cpufreq" Date: Mon, 29 Jul 2013 00:11:18 +0200 Message-ID: <2111514.pxW5saG1J3@vostro.rjw.lan> User-Agent: KMail/4.9.5 (Linux/3.10.0+; KDE/4.9.5; x86_64; ; ) In-Reply-To: <51F4F0A2.1070705@gmx.de> References: <51F40612.2050403@gmx.de> <4531734.kTFAPunoch@vostro.rjw.lan> <51F4F0A2.1070705@gmx.de> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sunday, July 28, 2013 12:21:22 PM Toralf Förster wrote: > On 07/28/2013 01:39 AM, Rafael J. Wysocki wrote: > > On Saturday, July 27, 2013 07:40:34 PM Toralf Förster wrote: > >> it gives at a ThinkPad T420: > >> > >> tfoerste@n22 ~/tmp $ lsmod | grep ^acpi_cpufreq > >> acpi_cpufreq 12902 2147483647 > > > > That is -1, which indicates some module refcount woes. > > yes, ofc. > > The issue apears after 1 s2ram/resume cycle, before s2ram the refcount is 1. > > > I definitely can't see that with the mainline on my machines. > > It is in mainline too. Does the appended patch help? Rafael --- From: Rafael J. Wysocki Subject: cpufreq: Fix cpufreq driver module refcount balance after suspend/resume Since cpufreq_cpu_put() called by __cpufreq_remove_dev() drops the driver module refcount, the latter has to bump up that refcount to start with to balance the drop, or the cpufreq driver refcount will become negative after a suspend/resume cycle. Reported-by: Toralf Förster Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -1016,6 +1016,9 @@ static int __cpufreq_remove_dev(struct d pr_debug("%s: unregistering CPU %u\n", __func__, cpu); + if (!try_module_get(cpufreq_driver->owner)) + return -EINVAL; + write_lock_irqsave(&cpufreq_driver_lock, flags); data = per_cpu(cpufreq_cpu_data, cpu); @@ -1025,7 +1028,8 @@ static int __cpufreq_remove_dev(struct d if (!data) { pr_debug("%s: No cpu_data found\n", __func__); - return -EINVAL; + ret = -EINVAL; + goto err; } if (cpufreq_driver->target) @@ -1063,9 +1067,9 @@ static int __cpufreq_remove_dev(struct d unlock_policy_rwsem_write(cpu); - ret = sysfs_create_link(&cpu_dev->kobj, &data->kobj, + sysfs_create_link(&cpu_dev->kobj, &data->kobj, "cpufreq"); - return -EINVAL; + goto err; } WARN_ON(lock_policy_rwsem_write(cpu)); @@ -1110,6 +1114,10 @@ static int __cpufreq_remove_dev(struct d per_cpu(cpufreq_policy_cpu, cpu) = -1; return 0; + + err: + module_put(cpufreq_driver->owner); + return ret; }