From patchwork Wed Oct 16 14:16:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 176483 Delivered-To: patches@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp7230366ocf; Wed, 16 Oct 2019 07:16:55 -0700 (PDT) X-Received: by 2002:a2e:9707:: with SMTP id r7mr4716771lji.219.1571235415672; Wed, 16 Oct 2019 07:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571235415; cv=none; d=google.com; s=arc-20160816; b=pNQu9j6EHqICmmNnsf/vxZy5DyDzTPNTuoy0W5j3KfB7KE2mxhrSB6DYYKdM81qsE8 Zem1NBAPpS8prkigH3nNrq9sho3XQPvymYd6NSdkXaphkXIycM4R63RTSJ9ojmgvt5iI R6DO4/XP1y+nBFGjI/WRHoyUvhguldMZKGdgS2LNRnSxtaR5uz7aBFV9qWZ5qi1zZQBq Bc8KATyPEs0zgy8vrE/jULsX8h5MmvvMCbDO0wExqSEXGTrxodOrx3FRBqbAiXUTfzxT xLgIas+QUHyhsYR1unPMekh4t6XU/SJQUXEwtY8t4KGDYh78d+9hWdLKk3+fsuwz8Whb enEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=eeLcXye21fwck1PxjwVtam0tQFv4RcmovQRy0QMBXHw=; b=jzND4dx5FiCLlNRTcsh//OGtktnnbESpoNA3kObb2h/mtA6B6TdmRoaGxp3tDhig7X Lo5pAmNKLWQ4yzeOvsT8HjqQjTsd2h24nxV5CC7bQ3f30WKWaU0Ffzi1oPFLjgAhCfy1 2wUpXs8OALTd8NYnv2vVMCiDfGJicnRwGF+dinoSo8KVbU84nN8BQwOmVScnuigsJ4c4 RSC3WDIzBlw8rNA7ytN7XWvQs0dHYYFObalAZPg7GuLVYcMPlkU8NXGBDWEmOWSwRIm8 BqwJVvHuEuhp+Md4MF6JQMn+tMsmwJ0t6OP/aY86q93iSJdHN3TNg58REOxkpFyIzB9r HPtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FAaOc31r; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r12sor14107496ljm.33.2019.10.16.07.16.55 for (Google Transport Security); Wed, 16 Oct 2019 07:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FAaOc31r; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=eeLcXye21fwck1PxjwVtam0tQFv4RcmovQRy0QMBXHw=; b=FAaOc31rfSgjMHeG2OKLyn80vynf5gqx4YVOK6/VK0nQcCgKxq+qT6Fafo/JIwGa8D JGQ69S4tdCE9Q+yoaWqWOUl8Op6kDVkwxH9cQuYMmaaD+D2jQgpZYiLCYaPE9ilzW/sC Eu6pXuT8jSL5VhoUjJ71QxIoV4AuHJOY9uH2uG8uCjuikaGt0Ki4DVgycgH26uTQYtUo 65r6n783evKzySrXlDH4ZT0Mh30jusykfi/DKTsKucP06B6+DBMXibKlNR89ehDtydsW 8bg4UprqR5bdsEioIJ8Z8bNXR9fIQomPRDx6xWXMhRaUuGb/hd9DBCZc1JJfo1xrdEU2 OLug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=eeLcXye21fwck1PxjwVtam0tQFv4RcmovQRy0QMBXHw=; b=ITigZ8TRHBBMBJKv48wdkqxYvNXrUrd8ZRcZ198H8FAdFevGfYDfdymzzUjNFHnstW 9JJvl83qXMmsDOds89G3imydxxIr7F7b7oSf4uMN5veMTiKxqbqXd8bAO9JNmdWSURUJ 6H/V/G1NOi0ts7c4UPhr76AJeiXXsycVv6o4ryH+uAQx4hTXcfdi+YJzQL7G7j5eGktW VK9E2S/9WFeJP6bjKAZNL7Mz2vih2DVFIUiix0vc53RiEAlTYuJNdmItmGQHdnvQtH0w 1WJBEGTjMrVK6Eh81liVu0lo8bW2es+3LGf7ymPJqzJhtqN9zNtmcIzipCkw6pM1tSCB mdfg== X-Gm-Message-State: APjAAAUF1MAS2WCakwK77QvrcLzEqpsOwMKjyZ2tqWaV0kIew1lPIXM6 dbpC+nUSYv8rV8LLVBMvi/Tq9ngw7O9LLA== X-Google-Smtp-Source: APXvYqwo++c0TSTQCzieWu4Q5IIL3hXX7xz2RgT88Hx1XnCoIdJicZx8YrPzsbOMtFsVb5oPxXFWjg== X-Received: by 2002:a05:651c:150:: with SMTP id c16mr1204692ljd.222.1571235415146; Wed, 16 Oct 2019 07:16:55 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id i128sm6022504lji.49.2019.10.16.07.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 07:16:54 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Geert Uytterhoeven , Ulf Hansson , Kevin Hilman Subject: [PATCH] PM / Domains: Convert to dev_to_genpd_safe() in genpd_syscore_switch() Date: Wed, 16 Oct 2019 16:16:49 +0200 Message-Id: <20191016141649.18690-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 The intent with walking the gpd_list via calling genpd_present() from genpd_syscore_switch(), is to make sure the dev->pm_domain pointer belongs to a registered genpd. However, as a genpd can't be removed if there is a device attached to it, let's convert to use the quicker dev_to_genpd_safe() instead. Due to the above change, this allows us to cleanup genpd_present() and move it inside CONFIG_PM_GENERIC_DOMAINS_OF, so let's do that as well. Signed-off-by: Ulf Hansson --- drivers/base/power/domain.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) -- 2.17.1 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index cc85e87eaf05..600ea78d6b71 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -922,24 +922,6 @@ static int __init genpd_power_off_unused(void) } late_initcall(genpd_power_off_unused); -#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_GENERIC_DOMAINS_OF) - -static bool genpd_present(const struct generic_pm_domain *genpd) -{ - const struct generic_pm_domain *gpd; - - if (IS_ERR_OR_NULL(genpd)) - return false; - - list_for_each_entry(gpd, &gpd_list, gpd_list_node) - if (gpd == genpd) - return true; - - return false; -} - -#endif - #ifdef CONFIG_PM_SLEEP /** @@ -1354,8 +1336,8 @@ static void genpd_syscore_switch(struct device *dev, bool suspend) { struct generic_pm_domain *genpd; - genpd = dev_to_genpd(dev); - if (!genpd_present(genpd)) + genpd = dev_to_genpd_safe(dev); + if (!genpd) return; if (suspend) { @@ -2020,6 +2002,16 @@ static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate, return 0; } +static bool genpd_present(const struct generic_pm_domain *genpd) +{ + const struct generic_pm_domain *gpd; + + list_for_each_entry(gpd, &gpd_list, gpd_list_node) + if (gpd == genpd) + return true; + return false; +} + /** * of_genpd_add_provider_simple() - Register a simple PM domain provider * @np: Device node pointer associated with the PM domain provider.