Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9515312rwd; Wed, 21 Jun 2023 08:21:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ62CWfLqqEp5X7civJbA5OJDN/porNZMxJBjtB3jfbOxlghAgBAGJUr3OEc2wFPuMloyePH X-Received: by 2002:a05:6830:4ac:b0:6b4:d3b6:574c with SMTP id l12-20020a05683004ac00b006b4d3b6574cmr6643803otd.31.1687360879696; Wed, 21 Jun 2023 08:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687360879; cv=none; d=google.com; s=arc-20160816; b=a44inJBLzV7B6e4rcpw3vHhCu72WQjpfjEcJvQ+qZzxEWrxe74mjnV9z5BdNTwNqvy lmjG5w1Zyy8o1iKoRdNuYweI2jOZ4g9lOflSJ0qcM72ayuXDtxSVhJ4NIhoocGBwvUp6 6ktDHAPyu0cYnx2FvSqss0eHjxUGshRd03XGRM7nz7KHw8tahiQLA1kh0E8Si8e40T7I RwvwlfbmEmgRJMgolOyP/neGOVc1u2dBq6q86gMXsemw20rbF58rGPbjMl1tvWSj69CR s9UffOMXs5/ASvSALLfZS08vIfTLvqiSxzB8dGXAmxv+wTge/lAIVAE6zLo4Z/uQZpLy zh+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XmB7aafZYu+t3l7iCsSmX4rGYeW4d39sw8kiK1MfRbc=; b=SAhOVEuNaKvEedZx6NSNaF9fbazEJPh5pNz6yWjz/TU9wGV6s2uP6CVr5j/EO+XgjB G+pbn21zdH3YJMwLAW+conxs3KHrfQ2DlSo53P2BTGu8hZtRSFBB+pWX6nb+4fRx8aX4 oSUOD7conHt5JbYccgJ2baddyoe877u6KmVQ7aK67HNy3JQyij2PGjCOIDoAvyCT/I1m dD/U7iuVYz+XCCOhzjxAmtMBkbZ8A3AYUZWacPv7sj9xAzAS14uUUYuGo4AfoTZ3o44a oAn043pxVtfBTe6X2HfIEKvR50+iFlKfUmVAErIs26BFNYDpCnPd9k+28W5pXQOXKFLq C0fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vbFeL6g/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020a6566c5000000b0054fd35b2dbcsi4336981pgw.350.2023.06.21.08.21.07; Wed, 21 Jun 2023 08:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vbFeL6g/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231346AbjFUOks (ORCPT + 99 others); Wed, 21 Jun 2023 10:40:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbjFUOkc (ORCPT ); Wed, 21 Jun 2023 10:40:32 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08D8E1739 for ; Wed, 21 Jun 2023 07:40:30 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-51bdc87feb1so875333a12.3 for ; Wed, 21 Jun 2023 07:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687358428; x=1689950428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XmB7aafZYu+t3l7iCsSmX4rGYeW4d39sw8kiK1MfRbc=; b=vbFeL6g/0gsnlVG3qe4dFQ8UgIqumpBG61md5jata02BeIpTUP5kaC99ThhE7dmF4O I7Y6Zk5tYifXsAurwx4LMPSIMFpU9Uu6yDlI+EBdE6mOHSG1vQP3bEWFSAODNm5tMAIz LsRijdo+V3NVq1ZT/fxLXgfSryujgdNMA1JxE9gWEwTMz1pUqJLzarZBXWf44s239bLm TdB9UU5sroVO28ey88uuV0uMfBQwyLW+RskbylYy58Ok9Xk4xzMLpNXO98g5W5m1cRPx iD8aORPz8tkdFjxBJk6+5sw+YR+XVIlM9Clkc1SXJc9guWiefmUzSYaphjxgmLinhgdV +6xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687358428; x=1689950428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XmB7aafZYu+t3l7iCsSmX4rGYeW4d39sw8kiK1MfRbc=; b=IJa/pIFNkG7mtilM+VPcHMdt8AmQ3L3/LGfJog0LCHrX39Eah597ayNQh7Rmig+3mE ifpdjjxMyfl6od36HAlwKQ+x8LW1iS6XkqcmgdxvJdbuzUEnixuBiey1KlvmBXpW4b1Q icZfNK8VyPA2Ls3xHc9HmcanN1sPPSmiF4zj903KjVEmIspj9uphHw0tahjBRDMqB1qS Apn1+6qx6XstedUYflh4ToW/hMp8dZeuPQd0+bU0zYhrcE4yLUx0mIWzCjDP1USQPCDc oaTNnaGokle9ketMo3zTFLpKfUSRrq7HK/CJawJFEApDZytqPsPhaAqa7TUuhyUV6gRx /kZw== X-Gm-Message-State: AC+VfDxlmXXs4c31h92kqfbjCv5A/slkB5gZrN5HHuCdS3jKQNE6rT9F bXAt0f/1tkGU+WQVpq/pqkx2nw== X-Received: by 2002:aa7:c90f:0:b0:51a:50f2:4e7a with SMTP id b15-20020aa7c90f000000b0051a50f24e7amr7153676edt.13.1687358428418; Wed, 21 Jun 2023 07:40:28 -0700 (PDT) Received: from hackbox.lan ([82.79.124.17]) by smtp.gmail.com with ESMTPSA id l13-20020a056402344d00b0051879c4f598sm2689505edc.66.2023.06.21.07.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 07:40:28 -0700 (PDT) From: Abel Vesa To: "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Len Brown , Pavel Machek , Greg Kroah-Hartman , Saravana Kannan Cc: Bjorn Andersson , linux-pm@vger.kernel.org, Linux Kernel Mailing List , linux-arm-msm@vger.kernel.org, Dmitry Baryshkov Subject: [RFC PATCH v5 4/4] PM: domains: Add and set generic sync state callback Date: Wed, 21 Jun 2023 17:40:19 +0300 Message-Id: <20230621144019.3219858-5-abel.vesa@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230621144019.3219858-1-abel.vesa@linaro.org> References: <20230621144019.3219858-1-abel.vesa@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For every provider that doesn't register a sync_state callback, register a generic one. This new generic sync_state callback queues up a power off request. Signed-off-by: Abel Vesa --- drivers/base/power/domain.c | 23 +++++++++++++++++++++++ include/linux/pm_domain.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 5967ade160e2..ec16db0599ac 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -654,6 +654,27 @@ static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) queue_work(pm_wq, &genpd->power_off_work); } +/** + * pm_genpd_power_off_unused_sync_state - Power off all domains for provider. + * @dev: Provider's device. + * + * Request power off for all unused domains of the provider. + * This should be used exclusively as sync state callback for genpd providers. + */ +void pm_genpd_power_off_unused_sync_state(struct device *dev) +{ + struct generic_pm_domain *genpd; + + mutex_lock(&gpd_list_lock); + + list_for_each_entry(genpd, &gpd_list, gpd_list_node) + if (genpd->provider && genpd->provider->dev == dev) + genpd_queue_power_off_work(genpd); + + mutex_unlock(&gpd_list_lock); +} +EXPORT_SYMBOL_GPL(pm_genpd_power_off_unused_sync_state); + /** * genpd_keep_on - Tells if the domain should skip the power 'off' request * @genpd: PM domain to be checked. @@ -2329,6 +2350,8 @@ static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate, cp->xlate = xlate; fwnode_dev_initialized(&np->fwnode, true); + dev_set_drv_sync_state(np->fwnode.dev, pm_genpd_power_off_unused_sync_state); + mutex_lock(&of_genpd_mutex); list_add(&cp->link, &of_genpd_providers); mutex_unlock(&of_genpd_mutex); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 3eb32c4b6d4f..78164244b89f 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -279,6 +279,9 @@ static inline int pm_genpd_remove(struct generic_pm_domain *genpd) return -EOPNOTSUPP; } +static inline void pm_genpd_power_off_unused_sync_state(struct device *dev) +{ } + static inline int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state) { -- 2.34.1