From patchwork Thu Jun 4 22:29:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 6539481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7557F9F1CC for ; Wed, 3 Jun 2015 15:56:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9AC2D2063B for ; Wed, 3 Jun 2015 15:56:23 +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 BC0DF20625 for ; Wed, 3 Jun 2015 15:56:22 +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 1Z0AzM-0002Cj-VG; Wed, 03 Jun 2015 15:53:56 +0000 Received: from mail-pa0-f50.google.com ([209.85.220.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z0Az7-00024x-CH for linux-arm-kernel@lists.infradead.org; Wed, 03 Jun 2015 15:53:42 +0000 Received: by pabqy3 with SMTP id qy3so9858391pab.3 for ; Wed, 03 Jun 2015 08:53:20 -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=Iz7m/PJIP6mqsCJp4w8r72HtBt9O7cJbDy78hbpCD04=; b=SxaKTRz70APRQdecuhxPl8H53YJCQrxBQOCuDTUetFm/fhrzzv4N8IWFfCinW58e4a T1rYAx+VgEB06VF1MWbIc2eiyEeTKAg3DM8QysBucaJDeyV/NWziMcUr7nqUMF0cVTZW e9c2U4F9NrLjuUyzgx+WDFz0588/y4qzblZQdi+OLqn6MAGV4tjCAt2cKtcl0oRQR4yu TyPnbG7Qsd1CU4rxwJ96Cu6zLuj7IGehp18LY+1Rws15dC92siroj4CrfxgwNt55Nlhw HcAzElzBbeXMb6tm5HpUOOmrM0QLpVOkK3NPZQAlV43x3soWEKihVZIvyiMxblNLuQyO w5Ew== X-Gm-Message-State: ALoCoQlOpTI+kuvJ6i+CbokDQivuOBuZBtwUJe3RyK8c5NMSfXk+ovTHuol9upREfkM/Ui469qre X-Received: by 10.67.11.98 with SMTP id eh2mr59976749pad.21.1433346800313; Wed, 03 Jun 2015 08:53:20 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by mx.google.com with ESMTPSA id q3sm1216066pdr.10.2015.06.03.08.53.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jun 2015 08:53:19 -0700 (PDT) From: Lina Iyer To: rjw@rjwysocki.net, ulf.hansson@linaro.org, khilman@linaro.org Subject: [PATCH RFC 1/3] PM / Domains: Allocate memory outside domain locks Date: Thu, 4 Jun 2015 16:29:04 -0600 Message-Id: <1433456946-53296-2-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433456946-53296-1-git-send-email-lina.iyer@linaro.org> References: <1433456946-53296-1-git-send-email-lina.iyer@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150603_085341_456843_09A7964D X-CRM114-Status: GOOD ( 10.79 ) X-Spam-Score: 0.5 (/) Cc: mathieu.poirier@linaro.org, linux-pm@vger.kernel.org, galak@codeaurora.org, msivasub@codeaurora.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=-2.2 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_24_48, RCVD_IN_DNSWL_MED, T_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 order for domains to be powered on/off in irq locked context, the domain locks could either be a spinlock or a mutex, depending on the domain. In preparation for atomic support, allocate domain data outside the domain locks, so the allocation calls dont have to be context sensitive. Cc: Ulf Hansson Cc: Rafael J. Wysocki Cc: Kevin Hilman Signed-off-by: Lina Iyer --- drivers/base/power/domain.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 3b3367b..dfd7595 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1367,13 +1367,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); @@ -1383,18 +1387,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; @@ -1496,17 +1495,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; - } + cpuidle_drv = cpuidle_driver_ref(); if (!cpuidle_drv) { ret = -ENODEV;