From patchwork Tue Dec 16 00:10:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 5498501 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 6EFD99F30B for ; Tue, 16 Dec 2014 00:11:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8FBAF20A18 for ; Tue, 16 Dec 2014 00:11:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BD42B20A01 for ; Tue, 16 Dec 2014 00:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751492AbaLPALE (ORCPT ); Mon, 15 Dec 2014 19:11:04 -0500 Received: from mail-ie0-f172.google.com ([209.85.223.172]:62934 "EHLO mail-ie0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751248AbaLPALC (ORCPT ); Mon, 15 Dec 2014 19:11:02 -0500 Received: by mail-ie0-f172.google.com with SMTP id tr6so11884728ieb.31 for ; Mon, 15 Dec 2014 16:11:01 -0800 (PST) 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:mime-version :content-type:content-disposition:user-agent; bh=zg/phVgU8lxTy2vLuOyMQsW05g1oplbwrxfiTwYSGxI=; b=ATgP0qoYP8u6oCiYVGjon3I05bRQSEbxyecByj4qldUSfNUOB1uEllohPAHQjlApy8 xlPg446wy2dwzftfTmgtxADecoliVBcPWzVOvM+Ym95UPocPc0WuzN9cEYcb9fS+IncI YhbumGYLcIMQrOO7NTVkphjh7y7HAD0DV7Z/qBUHHTdNoSkkPKDM8xuCAyahz9OPP04p RoiL0gbkJkBz/eBU0VhbF040tES3OKPxr8hCaKv+77qttp0EuC9UB7zV8mM4LZNYGmDd qHt6Nxrhm/5Z1ScAVBkZ2sxOfQdvODzwPyoeBE3DicCEGRV/CF0ViMSZ6nmNJdEeoDCy 2tRA== X-Gm-Message-State: ALoCoQluhxQ6vf1KiC2WyvPINLLAh0BVm2F5pXo01LmdroJqNaOp/QUEZ+IIlaRF7C1e03VcZ4FM X-Received: by 10.42.39.6 with SMTP id f6mr29615794ice.14.1418688661578; Mon, 15 Dec 2014 16:11:01 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1301:edc3:4b7a:3f05:ce06]) by mx.google.com with ESMTPSA id f1sm2236118iga.1.2014.12.15.16.11.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 15 Dec 2014 16:11:00 -0800 (PST) Date: Mon, 15 Dec 2014 16:10:58 -0800 From: Dmitry Torokhov To: "Rafael J. Wysocki" Cc: Viresh Kumar , Lucas Stach , Santosh Shilimkar , Thomas Petazzoni , Geert Uytterhoeven , Stefan Wahren , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq-dt: defer probing if OPP table is not ready Message-ID: <20141216001058.GA31286@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 cpufreq-dt driver supports mode when OPP table is provided by platform code and not device tree. However on certain platforms code that fills OPP table may run after cpufreq driver tries to initialize, so let's report -EPROBE_DEFER if we do not find any entires in OPP table for the CPU. Signed-off-by: Dmitry Torokhov Reviewed-by: Viresh Kumar --- drivers/cpufreq/cpufreq-dt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c index f56147a..4f874fa 100644 --- a/drivers/cpufreq/cpufreq-dt.c +++ b/drivers/cpufreq/cpufreq-dt.c @@ -211,6 +211,19 @@ static int cpufreq_init(struct cpufreq_policy *policy) /* OPPs might be populated at runtime, don't check for error here */ of_init_opp_table(cpu_dev); + /* + * But we need OPP table to function so if it is not there let's + * give platform code chance to provide it for us. + */ + rcu_read_lock(); + ret = dev_pm_opp_get_opp_count(cpu_dev); + rcu_read_unlock(); + if (ret <= 0) { + pr_debug("OPP table is not ready, deferring probe\n"); + ret = -EPROBE_DEFER; + goto out_free_opp; + } + priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) { ret = -ENOMEM;