From patchwork Wed Oct 28 21:19:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lina Iyer X-Patchwork-Id: 55722 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp180688lbr; Wed, 28 Oct 2015 14:20:00 -0700 (PDT) X-Received: by 10.66.158.201 with SMTP id ww9mr36731418pab.33.1446067200393; Wed, 28 Oct 2015 14:20:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zl1si72937854pbc.95.2015.10.28.14.20.00; Wed, 28 Oct 2015 14:20:00 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756211AbbJ1VT7 (ORCPT + 11 others); Wed, 28 Oct 2015 17:19:59 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36072 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756195AbbJ1VT6 (ORCPT ); Wed, 28 Oct 2015 17:19:58 -0400 Received: by pacfv9 with SMTP id fv9so18433832pac.3 for ; Wed, 28 Oct 2015 14:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=yMtLD+A4X1w/pn6LX/lyFhmzXWgm8oFegmVhp0hm2dY=; b=yhwIScLRKbCO8HqZvknrg1xty67+q7g94OsOsrknfx8+MrHJj00OYVuqg4colDNjha WkDiKAt6k1gm6OnQnups4kDr06CWl/tIfm2XpH3Q4qyw1jfaS2iqIoOP/1EtBW2hnPfH 6b8X/BOQY7e1vXN22L7GHjZVHES/qS8MDueFc1cWvdZg9QJclVQFWHTWv8cayuvnSKrw Zn+3YBuSDDS1hnKW5bXg2Ut7MsDtwYCSC7YrhL+cU8VXB5EqAwXi5fL6odjW8oT1hIoo Av9VljxHYOd2HrqR/YDPwVdVNLI86iW+ng7DR3fIwgEhiEjgo5NiJeQOYPfdHTJZbLXQ PnEg== 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:mime-version :content-type:content-transfer-encoding; bh=yMtLD+A4X1w/pn6LX/lyFhmzXWgm8oFegmVhp0hm2dY=; b=XZgsp1hkzJRh/xNhCMTysGXGF7ecQHQXaN0cGv+UXsBU37c5i/D8UVFPq0vuBfiHwX 7zNTPcSd1XLcALVFSsco8yEJ+KD0tZnNREUwwe/lO0ha7R78NkXQ4KTv4BMgKS3A0Rb6 AvyGXWR5eghKG/vBlYinOKo1rNUz520T5JzPR9CdfAaUM3/waLwAxHZVcQ1EFyYueZXB V0a7wutGjzAMq9VnAhqfpfkPhMkAXpiFhXfZpYuN3pQPDLvzfxx2n2s9yKyCrdiA0r5M RPb5WY0FGF0QQDXHbOli+v8Umjfs0Ww8SL1VOIxkYEqR1PoAAY06TeBMGn1U6tDfFQlY fhWg== X-Gm-Message-State: ALoCoQks2hWCqGOX/IZdG1vKhhaj7zbLZ8hzBYnLQg/EkjqMo8ZBqwePmkho/+N/vDhTb6LjTFTf X-Received: by 10.66.168.228 with SMTP id zz4mr35791886pab.133.1446067198073; Wed, 28 Oct 2015 14:19:58 -0700 (PDT) Received: from ubuntu.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id l16sm47148948pbq.22.2015.10.28.14.19.56 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Oct 2015 14:19:56 -0700 (PDT) From: Lina Iyer To: rjw@rjwysocki.net, linux-pm@vger.kernel.org Cc: ulf.hansson@linaro.org, Lina Iyer , Kevin Hilman , Geert Uytterhoeven , =?UTF-8?q?Krzysztof=20Koz=C5=82owski?= Subject: [PATCH] PM / Domains: Allocate memory outside domain locks Date: Wed, 28 Oct 2015 15:19:50 -0600 Message-Id: <1446067190-42583-1-git-send-email-lina.iyer@linaro.org> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 6483a92..6f3b145 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1306,13 +1306,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); @@ -1322,18 +1326,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; @@ -1344,7 +1343,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; } EXPORT_SYMBOL_GPL(pm_genpd_add_subdomain);