From patchwork Wed Aug 24 13:13:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 74608 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp310848qga; Wed, 24 Aug 2016 06:13:26 -0700 (PDT) X-Received: by 10.98.93.25 with SMTP id r25mr5598573pfb.122.1472044406691; Wed, 24 Aug 2016 06:13:26 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o75si9689015pfj.22.2016.08.24.06.13.26; Wed, 24 Aug 2016 06:13:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753140AbcHXNNZ (ORCPT + 14 others); Wed, 24 Aug 2016 09:13:25 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:35222 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805AbcHXNNY (ORCPT ); Wed, 24 Aug 2016 09:13:24 -0400 Received: by mail-pf0-f176.google.com with SMTP id x72so6909463pfd.2 for ; Wed, 24 Aug 2016 06:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QmghaFRyJK3EFmxRoJyYWrYediIjRsKf4llnpDihX38=; b=X1vDk1F4YJYYL6UVjTU41/sXAUAlFqmPe5/sxwWuGUVQJ1TPASrhbvO5gqOmnYJCw0 4FQunWGXGFu7bfsbIpCCKhyyAXvlq10XCkXi9t3Hcouh7Vr6m7PR+BD8rqFmlwkednLC wejX1sKgcrjRenv1eEJ4kVDycwnoC6TUjPkdQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QmghaFRyJK3EFmxRoJyYWrYediIjRsKf4llnpDihX38=; b=JhYIldTq4F8b/+hIaL/8c+fquExX/B0CGQnHh4TZgu1y21XW8t3LDzIoiHviiOzKUX z09aGqqUQT/GMbe4pQ2d1sm3H1q4VxBqkAR5sq6h4tJlfrdC4jjYw1HLlWLinwPAQB/u KXv52HbzF8NOlidBLIZbJJ0ZxwowzaGeCiPug91exeYqZHHnNAKmeLjM/ba3ROv0UdmU 1EbMBL/npi5bpzerdYW7vheR8kLDhqF018jM2485S1kuSo7mHxGW60euqhasLBaoiU4q R5NPJtS03+ath568tMDHZsQhlNEVL2HIlW3lt7ddsh8bq47BNtus9DImkCFcW4BTbL7n 7FXA== X-Gm-Message-State: AE9vXwOh4GdnU2qhAqSlexWa0UTpn3NlV0amdaRONjRO6FG1dHGOiODw8C5kyupdlWcDWqVL X-Received: by 10.98.10.157 with SMTP id 29mr5665825pfk.62.1472044403732; Wed, 24 Aug 2016 06:13:23 -0700 (PDT) Received: from localhost ([122.172.53.201]) by smtp.gmail.com with ESMTPSA id dz13sm13731063pac.44.2016.08.24.06.13.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2016 06:13:22 -0700 (PDT) Date: Wed, 24 Aug 2016 18:43:16 +0530 From: Viresh Kumar To: "Rafael J. Wysocki" Cc: Russell King - ARM Linux , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: Kernel warning in cpufreq_add_dev() Message-ID: <20160824131316.GI25143@ubuntu> References: <20160819110032.GM1041@n2100.armlinux.org.uk> <1601399.OxUAWWKTJN@vostro.rjw.lan> <20160820014634.GA25143@ubuntu> <2310664.2BksGViL4r@vostro.rjw.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2310664.2BksGViL4r@vostro.rjw.lan> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 22-08-16, 19:32, Rafael J. Wysocki wrote: > But it will be called in that path during physical CPU hot-add, won't it? What about something like this instead (completely untested) ? @Russell: Can you please try this ?? -- viresh -------------------------8<------------------------- -- 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 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 3dd4884c6f9e..a702d6246385 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -916,20 +916,11 @@ static struct kobj_type ktype_cpufreq = { .release = cpufreq_sysfs_release, }; -static int add_cpu_dev_symlink(struct cpufreq_policy *policy, int cpu) +static int add_cpu_dev_symlink(struct cpufreq_policy *policy, + struct device *dev) { - struct device *cpu_dev; - - pr_debug("%s: Adding symlink for CPU: %u\n", __func__, cpu); - - if (!policy) - return 0; - - cpu_dev = get_cpu_device(cpu); - if (WARN_ON(!cpu_dev)) - return 0; - - return sysfs_create_link(&cpu_dev->kobj, &policy->kobj, "cpufreq"); + dev_dbg(dev, "%s: Adding symlink\n", __func__); + return sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq"); } static void remove_cpu_dev_symlink(struct cpufreq_policy *policy, int cpu) @@ -948,12 +939,17 @@ static void remove_cpu_dev_symlink(struct cpufreq_policy *policy, int cpu) /* Add/remove symlinks for all related CPUs */ static int cpufreq_add_dev_symlink(struct cpufreq_policy *policy) { + struct device *cpu_dev; unsigned int j; int ret = 0; /* Some related CPUs might not be present (physically hotplugged) */ for_each_cpu(j, policy->real_cpus) { - ret = add_cpu_dev_symlink(policy, j); + cpu_dev = get_cpu_device(j); + if (WARN_ON(!cpu_dev)) + continue; + + ret = add_cpu_dev_symlink(policy, cpu_dev); if (ret) break; } @@ -1073,13 +1069,9 @@ static void handle_update(struct work_struct *work) static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) { - struct device *dev = get_cpu_device(cpu); struct cpufreq_policy *policy; int ret; - if (WARN_ON(!dev)) - return NULL; - policy = kzalloc(sizeof(*policy), GFP_KERNEL); if (!policy) return NULL; @@ -1355,7 +1347,7 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) if (!policy || cpumask_test_and_set_cpu(cpu, policy->real_cpus)) return 0; - return add_cpu_dev_symlink(policy, cpu); + return add_cpu_dev_symlink(policy, dev); } static void cpufreq_offline(unsigned int cpu)