From patchwork Tue Apr 30 14:32:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 16533 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 13BC120065 for ; Tue, 30 Apr 2013 14:32:52 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id t59sf939475yho.5 for ; Tue, 30 Apr 2013 07:32:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:in-reply-to:references:x-gm-message-state :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe; bh=r5bX4FV99vVNIMIu8gYa+gH9YhVt/BelU+WS0jeJ4hA=; b=k78ka2os5uGPRa4aomILkMVb5L4rnHSqR7t3OeDakgrW6EEyc7/MU3PxSJfTUc3i2I uFhNoEE4gZ5f45r2tHirAztkhDotAkGQk5MIEA+3OAa1xOlkpxMPta6UOUo8oNcozWPk pnMoXNfLZUZh/hO+rNXvYRbuqSkKxyT7TgtjPHVmqxd4g0ncHx6CR+xpWFmLJ3yz0R4r V+AkTL3his7dd229Uib/A1iv22bxjalWgvi8KFM33AMAuQrBan2DLw3jqnD8rXhfOhkM vI5Nms113jOLYLPX1AzrHqw02hcighhi6OKjdYJ56UmBQXoz7f8mlub5ltv4uUMzG7Ab Aweg== X-Received: by 10.58.4.137 with SMTP id k9mr20428183vek.1.1367332368721; Tue, 30 Apr 2013 07:32:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.37 with SMTP id lh5ls229030qeb.66.gmail; Tue, 30 Apr 2013 07:32:48 -0700 (PDT) X-Received: by 10.52.93.10 with SMTP id cq10mr1684658vdb.36.1367332368461; Tue, 30 Apr 2013 07:32:48 -0700 (PDT) Received: from mail-ve0-x22b.google.com (mail-ve0-x22b.google.com [2607:f8b0:400c:c01::22b]) by mx.google.com with ESMTPS id b4si12137135vdw.148.2013.04.30.07.32.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 07:32:48 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22b is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22b; Received: by mail-ve0-f171.google.com with SMTP id oy12so441635veb.30 for ; Tue, 30 Apr 2013 07:32:48 -0700 (PDT) X-Received: by 10.52.66.101 with SMTP id e5mr2739067vdt.57.1367332368296; Tue, 30 Apr 2013 07:32:48 -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.58.127.98 with SMTP id nf2csp109536veb; Tue, 30 Apr 2013 07:32:47 -0700 (PDT) X-Received: by 10.68.229.138 with SMTP id sq10mr76420412pbc.38.1367332367341; Tue, 30 Apr 2013 07:32:47 -0700 (PDT) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by mx.google.com with ESMTPS id tc4si20845314pbc.4.2013.04.30.07.32.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 07:32:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.47 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.47; Received: by mail-pa0-f47.google.com with SMTP id bj3so384198pad.20 for ; Tue, 30 Apr 2013 07:32:47 -0700 (PDT) X-Received: by 10.66.232.230 with SMTP id tr6mr66797712pac.83.1367332366936; Tue, 30 Apr 2013 07:32:46 -0700 (PDT) Received: from localhost ([122.167.112.160]) by mx.google.com with ESMTPSA id yp2sm30869909pab.10.2013.04.30.07.32.42 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 30 Apr 2013 07:32:46 -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, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, arvind.chauhan@arm.com, Viresh Kumar Subject: [PATCH 2/2] cpufreq: Issue CPUFREQ_GOV_POLICY_EXIT notifier before dropping policy refcount Date: Tue, 30 Apr 2013 20:02:18 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlk7IrAgJ8Cj/DRJhyom6yPyGWKYmXVU4RLjeDv44J0xFpCmgh3+rajI0sUE0z3MvAP5pSR X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22b 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: , We must call __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT) before calling cpufreq_cpu_put(data), so that policy kobject have valid fields. Otherwise, removing last online cpu of policy->cpus causes this crash for ondemand/conservative governor. [ 146.386064] [] (sysfs_find_dirent+0xe/0xa8) from [] (sysfs_get_dirent+0x21/0x58) [ 146.413440] [] (sysfs_get_dirent+0x21/0x58) from [] (sysfs_remove_group+0x85/0xbc) [ 146.441338] [] (sysfs_remove_group+0x85/0xbc) from [] (cpufreq_governor_dbs+0x369/0x4a0) [ 146.470795] [] (cpufreq_governor_dbs+0x369/0x4a0) from [] (__cpufreq_governor+0x2b/0x8c) [ 146.500254] [] (__cpufreq_governor+0x2b/0x8c) from [] (__cpufreq_remove_dev.isra.12+0x15b/0x250) [ 146.531799] [] (__cpufreq_remove_dev.isra.12+0x15b/0x250) from [] (cpufreq_cpu_callback+0x2f/0x3c) [ 146.563860] [] (cpufreq_cpu_callback+0x2f/0x3c) from [] (notifier_call_chain+0x45/0x54) [ 146.593059] [] (notifier_call_chain+0x45/0x54) from [] (__cpu_notify+0x1d/0x34) [ 146.620177] [] (__cpu_notify+0x1d/0x34) from [] (_cpu_down+0x63/0x1ac) [ 146.644948] [] (_cpu_down+0x63/0x1ac) from [] (cpu_down+0x1b/0x30) [ 146.668675] [] (cpu_down+0x1b/0x30) from [] (store_online+0x27/0x54) [ 146.692922] [] (store_online+0x27/0x54) from [] (dev_attr_store+0x11/0x18) [ 146.718733] [] (dev_attr_store+0x11/0x18) from [] (sysfs_write_file+0xed/0x114) [ 146.745847] [] (sysfs_write_file+0xed/0x114) from [] (vfs_write+0x65/0xd8) [ 146.771656] [] (vfs_write+0x65/0xd8) from [] (sys_write+0x2f/0x50) [ 146.795384] [] (sys_write+0x2f/0x50) from [] (ret_fast_syscall+0x1/0x52) Of course this only impacted drivers which have have_governor_per_policy set to true. i.e. big LITTLE cpufreq driver. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 1b8a48e..b7acfd1 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1075,14 +1075,14 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif __func__, cpu_dev->id, cpu); } + if ((cpus == 1) && (cpufreq_driver->target)) + __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); + pr_debug("%s: removing link, cpu: %d\n", __func__, cpu); cpufreq_cpu_put(data); /* If cpu is last user of policy, free policy */ if (cpus == 1) { - if (cpufreq_driver->target) - __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT); - lock_policy_rwsem_read(cpu); kobj = &data->kobj; cmp = &data->kobj_unregister;