From patchwork Sat Jun 27 03:02:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 6684541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 05442C05AD for ; Sat, 27 Jun 2015 03:07:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F1A0206FB for ; Sat, 27 Jun 2015 03:07:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B56F5206E8 for ; Sat, 27 Jun 2015 03:06:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z8gOo-00070j-Vs; Sat, 27 Jun 2015 03:03:22 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z8gOY-0006v1-MG for linux-arm-kernel@lists.infradead.org; Sat, 27 Jun 2015 03:03:07 +0000 Received: by paceq1 with SMTP id eq1so77110177pac.3 for ; Fri, 26 Jun 2015 20:02:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tu4L0gnK6CA7x3p7FCwGNCDbnbyDNcwR3dB2l6A9faw=; b=CsrAFFoYGG5lgsb6DB+OLSloXpM2Fb3aYyHYirAh3JuFUayaeBATFJc1OKxqUbejPb tQdKHwYr7IF0ydYgRVExwHc5h/YAhR5YirnM4n/bmoqOg3TDvPI4lbZSsDd8vmvF/eGl 1nrBEOTyG8ongWIHi3Yw6TxmFYZTBEGyakYg/Q0u86Wxe8g9Omp1b3rV1I5+OSiCtuE4 J2fIhJfqHvVJZ22plnIwbu8VhcWSNgfd1U28mA9zPEDkL97z2p8VlnXjQKZan2iUiBfK wKHFYmbUz+HzxN9QFDTUWUhnsarqwGgCGiCd8248Y8W20d+336vgpyZTmbNwzVfyvaRr ifBw== X-Gm-Message-State: ALoCoQnAoVPcCtKlOgjwgKlr0fOtU5jrGmxX6Rtd3LIn+7LeX/Q1RTPQJE2BaJnvGkr3QnFP/WVW X-Received: by 10.70.123.136 with SMTP id ma8mr9263349pdb.33.1435374165201; Fri, 26 Jun 2015 20:02:45 -0700 (PDT) Received: from ubuntu.localdomain (c-24-8-37-141.hsd1.co.comcast.net. [24.8.37.141]) by mx.google.com with ESMTPSA id j7sm34787756pdp.83.2015.06.26.20.02.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jun 2015 20:02:44 -0700 (PDT) From: Lina Iyer To: rjw@rjwysocki.net, ulf.hansson@linaro.org, khilman@linaro.org Subject: [PATCH RFC v2 01/16] PM / Domains: Allocate memory outside domain locks Date: Fri, 26 Jun 2015 21:02:21 -0600 Message-Id: <1435374156-19214-2-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435374156-19214-1-git-send-email-lina.iyer@linaro.org> References: <1435374156-19214-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150626_200306_757939_469CCF7F X-CRM114-Status: GOOD ( 13.15 ) X-Spam-Score: -2.6 (--) Cc: k.kozlowski@samsung.com, linux-pm@vger.kernel.org, msivasub@codeaurora.org, geert@linux-m68k.org, Lina Iyer , agross@codeaurora.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 In preparation for supporting IRQ-safe domains, allocate domain data outside the domain locks. These functions are not called in an atomic context, so we can always allocate memory using GFP_KERNEL. By allocating memory before the locks, we can safely lock the domain using spinlocks instead of mutexes. Cc: Ulf Hansson Cc: Rafael J. Wysocki Cc: Kevin Hilman Signed-off-by: Lina Iyer --- Changes in v2: - Modify commit text --- drivers/base/power/domain.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 87d405a..44af889 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1379,13 +1379,17 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd, int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, struct generic_pm_domain *subdomain) { - struct gpd_link *link; + struct gpd_link *link, *itr; int ret = 0; if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain) || genpd == subdomain) return -EINVAL; + link = kzalloc(sizeof(*link), GFP_KERNEL); + if (!link) + return -ENOMEM; + mutex_lock(&genpd->lock); mutex_lock_nested(&subdomain->lock, SINGLE_DEPTH_NESTING); @@ -1395,18 +1399,13 @@ int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, goto out; } - list_for_each_entry(link, &genpd->master_links, master_node) { - if (link->slave == subdomain && link->master == genpd) { + list_for_each_entry(itr, &genpd->master_links, master_node) { + if (itr->slave == subdomain && itr->master == genpd) { ret = -EINVAL; goto out; } } - link = kzalloc(sizeof(*link), GFP_KERNEL); - if (!link) { - ret = -ENOMEM; - goto out; - } link->master = genpd; list_add_tail(&link->master_node, &genpd->master_links); link->slave = subdomain; @@ -1508,17 +1507,17 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state) if (IS_ERR_OR_NULL(genpd) || state < 0) return -EINVAL; + cpuidle_data = kzalloc(sizeof(*cpuidle_data), GFP_KERNEL); + if (!cpuidle_data) + return -ENOMEM; + mutex_lock(&genpd->lock); if (genpd->cpuidle_data) { ret = -EEXIST; - goto out; - } - cpuidle_data = kzalloc(sizeof(*cpuidle_data), GFP_KERNEL); - if (!cpuidle_data) { - ret = -ENOMEM; - goto out; + goto err_drv; } + cpuidle_drv = cpuidle_driver_ref(); if (!cpuidle_drv) { ret = -ENODEV;