From patchwork Thu May 16 09:28:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 16984 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E1F462391B for ; Thu, 16 May 2013 09:31:39 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id f13sf124438vbg.9 for ; Thu, 16 May 2013 02:31:01 -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=5+PD7O+i4tw07JPRT/uvdMoRVI33mNNbr5DUtRlVmuI=; b=B2cG/5RTuitcxyLt8dPQXc7/LkuQlhEaB0bN2PKqDFpTa7C0tjFKWrKMfmtaHRSYIk pBqbTbygMnGXF2GdE4fMCAlUkDU+7R4DRBDfxc5yRuLTlrXKyT5DmzAIh8Oe4KmBU6q3 hzGxuzMtZR+/gfjbKc+Yroj/Wev6rxnj3StrNztYxWX5wG8MIm+nIso9Feg0OSMW/95N pnWhp8xgVLeio8gHxJ11gO7aEPha2LshT2AIw3uqgTAljz7ZmVHuUnW8PxvwIFnW/61u +mL7/Wol0apr+ztwXVkexjtjhH6Iy/hDwl0D/giba66dI2rWAa4mir6XFbUSUsWustLc Erhw== X-Received: by 10.236.150.98 with SMTP id y62mr7920891yhj.9.1368696661076; Thu, 16 May 2013 02:31:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.97.4 with SMTP id dw4ls5868qeb.58.gmail; Thu, 16 May 2013 02:31:00 -0700 (PDT) X-Received: by 10.58.168.208 with SMTP id zy16mr27546733veb.3.1368696660904; Thu, 16 May 2013 02:31:00 -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 cf3si3486253vcb.72.2013.05.16.02.31.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 May 2013 02:31:00 -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 m1so2793620ves.16 for ; Thu, 16 May 2013 02:31:00 -0700 (PDT) X-Received: by 10.220.92.195 with SMTP id s3mr27720318vcm.9.1368696660695; Thu, 16 May 2013 02:31:00 -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.126.138 with SMTP id c10csp56003vcs; Thu, 16 May 2013 02:31:00 -0700 (PDT) X-Received: by 10.68.172.36 with SMTP id az4mr41974810pbc.211.1368696659777; Thu, 16 May 2013 02:30:59 -0700 (PDT) Received: from mail-pb0-x22d.google.com (mail-pb0-x22d.google.com [2607:f8b0:400e:c01::22d]) by mx.google.com with ESMTPS id yu7si4424065pac.102.2013.05.16.02.30.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 May 2013 02:30:59 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c01::22d is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=2607:f8b0:400e:c01::22d; Received: by mail-pb0-f45.google.com with SMTP id mc8so2156610pbc.32 for ; Thu, 16 May 2013 02:30:59 -0700 (PDT) X-Received: by 10.66.148.132 with SMTP id ts4mr43775784pab.19.1368696659182; Thu, 16 May 2013 02:30:59 -0700 (PDT) Received: from localhost ([106.197.193.133]) by mx.google.com with ESMTPSA id k2sm6871031pat.7.2013.05.16.02.30.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 May 2013 02:30:58 -0700 (PDT) From: Viresh Kumar To: toddpoynor@google.com Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, arvind.chauhan@arm.com, android-kernel@googlegroups.com, viresh.kumar@linaro.org Subject: [PATCH 07/16] cpufreq: Issue CPUFREQ_GOV_POLICY_EXIT notifier before dropping policy refcount Date: Thu, 16 May 2013 14:58:45 +0530 Message-Id: <249f2705b882167233868af8d31df4dc6f20cf27.1368696171.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQlh4z5W3fQwWyhkiww4mS1OhNev3erleQtMx/Ax/I/nnFMqpFsNo1o7kWNWe98l2AZd3LOB 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. [] (sysfs_find_dirent+0xe/0xa8) from [] (sysfs_get_dirent+0x21/0x58) [] (sysfs_get_dirent+0x21/0x58) from [] (sysfs_remove_group+0x85/0xbc) [] (sysfs_remove_group+0x85/0xbc) from [] (cpufreq_governor_dbs+0x369/0x4a0) [] (cpufreq_governor_dbs+0x369/0x4a0) from [] (__cpufreq_governor+0x2b/0x8c) [] (__cpufreq_governor+0x2b/0x8c) from [] (__cpufreq_remove_dev.isra.12+0x15b/0x250) [] (__cpufreq_remove_dev.isra.12+0x15b/0x250) from [] (cpufreq_cpu_callback+0x2f/0x3c) [] (cpufreq_cpu_callback+0x2f/0x3c) from [] (notifier_call_chain+0x45/0x54) [] (notifier_call_chain+0x45/0x54) from [] (__cpu_notify+0x1d/0x34) [] (__cpu_notify+0x1d/0x34) from [] (_cpu_down+0x63/0x1ac) [] (_cpu_down+0x63/0x1ac) from [] (cpu_down+0x1b/0x30) [] (cpu_down+0x1b/0x30) from [] (store_online+0x27/0x54) [] (store_online+0x27/0x54) from [] (dev_attr_store+0x11/0x18) [] (dev_attr_store+0x11/0x18) from [] (sysfs_write_file+0xed/0x114) [] (sysfs_write_file+0xed/0x114) from [] (vfs_write+0x65/0xd8) [] (vfs_write+0x65/0xd8) from [] (sys_write+0x2f/0x50) [] (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 Signed-off-by: Rafael J. Wysocki --- 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 95a6b14..bb1169d 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;