From patchwork Tue Aug 4 23:35:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 51930 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by patches.linaro.org (Postfix) with ESMTPS id 993BD229FD for ; Tue, 4 Aug 2015 23:36:12 +0000 (UTC) Received: by lbcjf8 with SMTP id jf8sf7872203lbc.0 for ; Tue, 04 Aug 2015 16:36:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=wQsCD4vtk3GAEekAQj4Z8O0WEZKY/bmijQpqyPJST98=; b=O/MZ53fAi3mSTQvRcSMnQwm5HIFbqjeH/TLxmSwZiINFiH+O2QHYpg18na7hQP7hiQ RQ/M3vrYliaap8IOhJ7m+afRppk0/ubvS/mhwFSykTFS+Atj11/SulZl1idCva7t7gIJ 5QI7A/gkJ/RDvVMzwIWbMf5Do87yVlDlCeF7x5dzADLj7RSeZ+5mvz1+jNNc8slBuHx6 KazY3QFatI1jX1n82NI0x8lH6TpTMI7aO+BCd/0th31R0kCZg3Wk+0lVoXm6LQGBNVmM Oxd4qNMVg5kU7KHz4t+SdtkYJKzM34kZ66AUpVGvudsG2RBoZYUdGNtHM9y/I9RojeM0 M1fg== X-Gm-Message-State: ALoCoQnkJGeA9iacYYTm87WyLfmRliBCaHZCKaESAcit5DYRAOxRnFM7CsfC1W2hZHkxyU2th0+Q X-Received: by 10.113.3.8 with SMTP id bs8mr1801261lbd.23.1438731371235; Tue, 04 Aug 2015 16:36:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.201 with SMTP id t9ls120380laa.95.gmail; Tue, 04 Aug 2015 16:36:10 -0700 (PDT) X-Received: by 10.152.6.102 with SMTP id z6mr6595532laz.95.1438731370967; Tue, 04 Aug 2015 16:36:10 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id 7si903863law.133.2015.08.04.16.36.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2015 16:36:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by labjt7 with SMTP id jt7so239514lab.0 for ; Tue, 04 Aug 2015 16:36:10 -0700 (PDT) X-Received: by 10.152.36.161 with SMTP id r1mr6775888laj.88.1438731370861; Tue, 04 Aug 2015 16:36:10 -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.7.198 with SMTP id l6csp50373lba; Tue, 4 Aug 2015 16:36:09 -0700 (PDT) X-Received: by 10.66.138.16 with SMTP id qm16mr13302884pab.29.1438731369540; Tue, 04 Aug 2015 16:36:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mi8si1794926pdb.134.2015.08.04.16.36.07; Tue, 04 Aug 2015 16:36:09 -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 S1754567AbbHDXgG (ORCPT + 12 others); Tue, 4 Aug 2015 19:36:06 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35664 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754663AbbHDXgF (ORCPT ); Tue, 4 Aug 2015 19:36:05 -0400 Received: by pabxd6 with SMTP id xd6so2465678pab.2 for ; Tue, 04 Aug 2015 16:36:05 -0700 (PDT) X-Received: by 10.68.173.97 with SMTP id bj1mr13025260pbc.122.1438731365260; Tue, 04 Aug 2015 16:36:05 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id to5sm527525pac.33.2015.08.04.16.36.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Aug 2015 16:36:04 -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, sboyd@codeaurora.org, Lina Iyer Subject: [PATCH 1/9] PM / Domains: Allocate memory outside domain locks Date: Tue, 4 Aug 2015 17:35:31 -0600 Message-Id: <1438731339-58317-2-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438731339-58317-1-git-send-email-lina.iyer@linaro.org> References: <1438731339-58317-1-git-send-email-lina.iyer@linaro.org> MIME-Version: 1.0 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.42 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 Cc: Geert Uytterhoeven Cc: Krzysztof Kozłowski Signed-off-by: Lina Iyer Acked-by: Ulf Hansson --- drivers/base/power/domain.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 7666a1c..5fd1306 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1382,13 +1382,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); @@ -1398,18 +1402,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; @@ -1420,7 +1419,8 @@ int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, out: mutex_unlock(&subdomain->lock); mutex_unlock(&genpd->lock); - + if (ret) + kfree(link); return ret; } @@ -1511,17 +1511,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;