From patchwork Tue Apr 23 12:51:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 238903 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9DA1D2C0150 for ; Tue, 23 Apr 2013 22:52:07 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUchN-0005GP-Hr; Tue, 23 Apr 2013 12:51:53 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUchK-00085b-NU; Tue, 23 Apr 2013 12:51:50 +0000 Received: from mail-ee0-f48.google.com ([74.125.83.48]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UUchH-000858-TA for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2013 12:51:48 +0000 Received: by mail-ee0-f48.google.com with SMTP id d49so201917eek.7 for ; Tue, 23 Apr 2013 05:51:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding:x-gm-message-state; bh=jQVHYdcfvFnCqECv8biSlFGGCesr4EU/ovxXi4QOxdw=; b=ksKSY+gaTLxTAkCUA9pT43FLL7/ZPnbYtUP5fQTwkpGgojEjAcApRoy3FyZEh44WeK nG3COYmz8GL8fkg/eXPG66J0OdwC2MKo/8kAn43AYIfQ6FEqjK0cXMsoUxALNFObIbgL +4Wi+1zG3MwVIcXbluClQe1dRuWUmz/amfd5lDasYy2GLyIJdDGEXASH6nDz/VJIYsa9 gdsc2X7+MJyQyjKQcEjAaNhK/qGmiGcoijrDGprhp5eVwDh9NeCWxgzuhCmJ4zbBCB0w 77jry8/1dR8kfgqSHncJ56SHD4ekobSEY9kuxr9zobemm92fXS9ezrBaVVgJQqgqDQXg b9qw== X-Received: by 10.15.31.197 with SMTP id y45mr51039716eeu.18.1366721505551; Tue, 23 Apr 2013 05:51:45 -0700 (PDT) Received: from [192.168.1.150] (AToulouse-654-1-479-219.w86-201.abo.wanadoo.fr. [86.201.194.219]) by mx.google.com with ESMTPS id b5sm46755056eew.16.2013.04.23.05.51.42 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Apr 2013 05:51:44 -0700 (PDT) Message-ID: <517683DD.6060805@linaro.org> Date: Tue, 23 Apr 2013 14:51:41 +0200 From: Daniel Lezcano User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Santosh Shilimkar Subject: Re: [V4 patch 03/15] cpuidle: make a single register function for all References: <1366707285-12179-1-git-send-email-daniel.lezcano@linaro.org> <1366707285-12179-4-git-send-email-daniel.lezcano@linaro.org> <51767F57.7060809@ti.com> In-Reply-To: <51767F57.7060809@ti.com> X-Gm-Message-State: ALoCoQmG1q5bUS1HKyMGcnXjH0StRu5/jLUnW8RVFaMUEDjE1hJKL2bZDx+jGEOQ+Js3sl8Fp+Ln X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130423_085148_068197_BB76D679 X-CRM114-Status: GOOD ( 20.64 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.83.48 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: andrew@lunn.ch, khilman@deeprootsystems.com, nsekhar@ti.com, josephl@nvidia.com, kgene.kim@samsung.com, patches@linaro.org, magnus.damm@gmail.com, tony@atomide.com, plagnioj@jcrosoft.com, linaro-kernel@lists.linaro.org, jason@lakedaemon.net, swarren@wwwdotorg.org, rob.herring@calxeda.com, rjw@sisk.pl, horms@verge.net.au, linux@maxim.org.za, linux-arm-kernel@lists.infradead.org, deepthi@linux.vnet.ibm.com, jkosina@suse.cz, linux-pm@vger.kernel.org, lethal@linux-sh.org, kernel@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org On 04/23/2013 02:32 PM, Santosh Shilimkar wrote: > On Tuesday 23 April 2013 02:24 PM, Daniel Lezcano wrote: >> The usual scheme to initialize a cpuidle driver on a SMP is: >> >> cpuidle_register_driver(drv); >> for_each_possible_cpu(cpu) { >> device = &per_cpu(cpuidle_dev, cpu); >> cpuidle_register_device(device); >> } >> >> This code is duplicated in each cpuidle driver. >> >> On UP systems, it is done this way: >> >> cpuidle_register_driver(drv); >> device = &per_cpu(cpuidle_dev, cpu); >> cpuidle_register_device(device); >> >> On UP, the macro 'for_each_cpu' does one iteration: >> >> #define for_each_cpu(cpu, mask) \ >> for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask) >> >> Hence, the initialization loop is the same for UP than SMP. >> >> Beside, we saw different bugs / mis-initialization / return code unchecked in >> the different drivers, the code is duplicated including bugs. After fixing all >> these ones, it appears the initialization pattern is the same for everyone. >> >> Please note, some drivers are doing dev->state_count = drv->state_count. This is >> not necessary because it is done by the cpuidle_enable_device function in the >> cpuidle framework. This is true, until you have the same states for all your >> devices. Otherwise, the 'low level' API should be used instead with the specific >> initialization for the driver. >> >> Let's add a wrapper function doing this initialization with a cpumask parameter >> for the coupled idle states and use it for all the drivers. >> >> That will save a lot of LOC, consolidate the code, and the modifications in the >> future could be done in a single place. Another benefit is the consolidation of >> the cpuidle_device variable which is now in the cpuidle framework and no longer >> spread accross the different arch specific drivers. >> >> Signed-off-by: Daniel Lezcano >> --- > > I don't see you have addressed the comment on V3 [1] i gave for the subject patch > Any reason ? Yes, sorry for not answering. This modification should be handled in the __cpuidle_register_device function. per_cpu(cpuidle_devices, dev->cpu) = dev; Thus, the cpuidle_register function is not impacted by this as it will always do cpuidle_register_driver, followed by cpuidle_register_device. -- Daniel diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 49e8d30..936d862 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -372,7 +372,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev) int ret; struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); - if (!try_module_get(drv->owner)) + if (!drv || !try_module_get(drv->owner)) return -EINVAL;