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: 50384 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A79D8228FD for ; Sat, 27 Jun 2015 03:02:56 +0000 (UTC) Received: by lagx9 with SMTP id x9sf4968654lag.2 for ; Fri, 26 Jun 2015 20:02:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=dOvpdWDaZItp4mDNm5KR9tmu42ZXN8qoolHaniqU91k=; b=Ueg8wEs3rIY+k3zROYYET2drbESIyzu/ud1psQKO6jNkUtclZTkzgPXQV3Esc1//O4 pCaveNAfzCWHzT2VxfUu2N+1bfoCtZfF9vxK74uW6t3Y6MQxJuSbPKTY0dlfFB92jWSu uP7nJIijkJxzO8C4VksOhTgTAk2g0W9b4OYf9lX19Qek5IPX04GjSKX9V9Pd+sVQQGw7 GELQu/xKx1csAsBuywLvMICf8m9ita4vyWsoHph2ByhtOP4nVPX9ZWbI5RANNLW4NAKX m5pF5OKGjcRXKpna2BBFmymf4YajMaVhplbm6Ut2naQp2nN8HhKDAYnZWAXDBuYUkSLE HjaA== X-Gm-Message-State: ALoCoQlBSTRYxusEvYy03cI49oJZTaLdYDzmD7ANcyWiwL7IDW8kkLjc5gDs4QOUxgkfsG33yPzM X-Received: by 10.152.87.146 with SMTP id ay18mr3223208lab.6.1435374174899; Fri, 26 Jun 2015 20:02:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.1 with SMTP id n1ls500397laa.87.gmail; Fri, 26 Jun 2015 20:02:54 -0700 (PDT) X-Received: by 10.112.125.166 with SMTP id mr6mr4271768lbb.83.1435374174492; Fri, 26 Jun 2015 20:02:54 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id w5si28974915laj.65.2015.06.26.20.02.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2015 20:02:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lacny3 with SMTP id ny3so74381940lac.3 for ; Fri, 26 Jun 2015 20:02:54 -0700 (PDT) X-Received: by 10.112.234.200 with SMTP id ug8mr4258577lbc.117.1435374173948; Fri, 26 Jun 2015 20:02:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp295107lbb; Fri, 26 Jun 2015 20:02:52 -0700 (PDT) X-Received: by 10.68.226.131 with SMTP id rs3mr9237710pbc.60.1435374169906; Fri, 26 Jun 2015 20:02:49 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si51225212pat.122.2015.06.26.20.02.48; Fri, 26 Jun 2015 20:02:49 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbbF0DCq (ORCPT + 11 others); Fri, 26 Jun 2015 23:02:46 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35676 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbbF0DCp (ORCPT ); Fri, 26 Jun 2015 23:02:45 -0400 Received: by pactm7 with SMTP id tm7so77090712pac.2 for ; Fri, 26 Jun 2015 20:02:45 -0700 (PDT) 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 Cc: geert@linux-m68k.org, k.kozlowski@samsung.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, msivasub@codeaurora.org, agross@codeaurora.org, Lina Iyer 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> Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lina.iyer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;