From patchwork Thu Sep 3 19:58:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 53053 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 6D8C622E23 for ; Thu, 3 Sep 2015 19:58:51 +0000 (UTC) Received: by lanb10 with SMTP id b10sf75401lan.3 for ; Thu, 03 Sep 2015 12:58:50 -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=HXdYUxuyEZ8rXkcBt2hCeSWJin5ZN4k6VtaVjJ9IOoQ=; b=K5nqWVDSIqyPv8vAiYG/5aClgb/rNcr7hlkTWFBWAtTqSTSQgpmLwM9UcagT5PC6Wo wE0nZ847WjV5+y/coCugOnporWZJdFH7F9I9Q/icAgpFJS4UBxxxxVvoOh2qoJ8RHyD5 H0iDM+beI3lgLzO8tsmU2Cs5ssZ6Au0G5QMeuWCyYrAu6633N4l6weJFRxZAxmA1Uzqs Yc7rVk3tBvN8ByYmbwk6obdcpVbQfTQ4pkfFkdLCax3NCWXrQJI0bH5KA5Fu1PG6N4ie d8+UwWpCH4wFCZlYOlIu9nLKyp3p7dQuk22V961+fRf8jQ0Rz4p2zcDS7YNv+L6notSg iq6g== X-Gm-Message-State: ALoCoQnOVUh9phHVyyW9n881m0rR4xokhEXLyi5frc9oxACzyGA7UyUgREdncI1jHSgtyl5H8djQ X-Received: by 10.180.99.196 with SMTP id es4mr235435wib.1.1441310330484; Thu, 03 Sep 2015 12:58:50 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.9 with SMTP id ku9ls224608lac.37.gmail; Thu, 03 Sep 2015 12:58:50 -0700 (PDT) X-Received: by 10.152.5.40 with SMTP id p8mr24119222lap.10.1441310330315; Thu, 03 Sep 2015 12:58:50 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id kv10si21720080lac.152.2015.09.03.12.58.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2015 12:58:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by laeb10 with SMTP id b10so228731lae.1 for ; Thu, 03 Sep 2015 12:58:49 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr24471717lbc.32.1441310329858; Thu, 03 Sep 2015 12:58:49 -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.164.42 with SMTP id yn10csp1491207lbb; Thu, 3 Sep 2015 12:58:48 -0700 (PDT) X-Received: by 10.50.30.226 with SMTP id v2mr17141559igh.11.1441310328547; Thu, 03 Sep 2015 12:58:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hn3si43263170pdb.66.2015.09.03.12.58.47; Thu, 03 Sep 2015 12:58:48 -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 S1752159AbbICT6r (ORCPT + 13 others); Thu, 3 Sep 2015 15:58:47 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34814 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750779AbbICT6q (ORCPT ); Thu, 3 Sep 2015 15:58:46 -0400 Received: by padfa1 with SMTP id fa1so274545pad.1 for ; Thu, 03 Sep 2015 12:58:46 -0700 (PDT) X-Received: by 10.66.241.2 with SMTP id we2mr70945753pac.99.1441310325891; Thu, 03 Sep 2015 12:58:45 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id a17sm13396430pbu.55.2015.09.03.12.58.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Sep 2015 12:58:45 -0700 (PDT) From: Lina Iyer To: ulf.hansson@linaro.org, khilman@linaro.org, linux-pm@vger.kernel.org Cc: rjw@rjwysocki.net, geert@linux-m68k.org, k.kozlowski@samsung.com, linux-arm-kernel@lists.infradead.org, msivasub@codeaurora.org, agross@codeaurora.org, sboyd@codeaurora.org, Lina Iyer Subject: [PATCH v2 1/7] PM / Domains: Allocate memory outside domain locks Date: Thu, 3 Sep 2015 13:58:28 -0600 Message-Id: <1441310314-8857-2-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441310314-8857-1-git-send-email-lina.iyer@linaro.org> References: <1441310314-8857-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.41 as permitted sender) smtp.mailfrom=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 Reviewed-by: Kevin Hilman Acked-by: Ulf Hansson Signed-off-by: Lina Iyer --- 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 e45a0ef..ef8d19f 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1381,13 +1381,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); @@ -1397,18 +1401,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; @@ -1419,7 +1418,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; } @@ -1510,17 +1510,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;