From patchwork Wed Oct 2 12:22:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 13819757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FF28CF31B4 for ; Wed, 2 Oct 2024 12:29:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xcqYYVpLlj10i0qHI4tc+kYUPF8iaIvwsza/wsplKHw=; b=Li9LPelRPEnxuNI0u4uJpkmKNC RlXcNQ6fr46tJ3i1bjBB072AuKoGaXvNsY6PcYbUBqU5GZpW4q5/f9l22onPbaqB8wmVTOcLW7OlZ NK0iNavz/STEcWW/LE/DaLzKPULId6iQL35DQHg1h7SD/hBWiWxEz/7Rq6x4kv4qSdz8z1WPSpigs nGgumTZNueAF28H50FMZUt3GVJeCpI6XJnW11BCifiRCrhdhJ5q77N/w6MiB2xaArgIgIveA8IDgm isw1VJdXIX4jRvrQRCmDe1NYMEaDxddEPFCZ7ydqS3hUOOGoK52R0QFx4AwAZn594Iycjt7B5dihb Vn6YUSDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svyTZ-00000005sqG-2307; Wed, 02 Oct 2024 12:29:05 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svyNV-00000005qVz-2CLe for linux-arm-kernel@lists.infradead.org; Wed, 02 Oct 2024 12:22:50 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5398cc2fcb7so4764834e87.1 for ; Wed, 02 Oct 2024 05:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727871767; x=1728476567; darn=lists.infradead.org; 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=xcqYYVpLlj10i0qHI4tc+kYUPF8iaIvwsza/wsplKHw=; b=L6af93Ldhl/TosZz2AUcqJwZ777LN2CQ6KRr6/8FxQmyUNhPmTIRJQKX3uqasfCXk2 NOaqIjAzin4IkFtGWcRNOh8aFfj6uI4LxeCeNrHiI2LzapqW7Yn8R76f5NUrp6qXXtXs Pumj6WYs9ICSHhtZNUFflGSrN76iSIQRiseDYFFUOdweFsIXvjEc4lqFyD1u/c/0inFP nFm96wcBnX2xj4767D33woG9AoU/x3BYTQAuTf/Ip8eF+/jT8jio6Wr08nuItnoE9oJw hseI7ef4cmd3NlVE3P4+4VgzNw5YU1W5jZ0ZlwMzI3JKKpgDoVhDUHZCCAsUl/9yVpzY QbTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727871767; x=1728476567; 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=xcqYYVpLlj10i0qHI4tc+kYUPF8iaIvwsza/wsplKHw=; b=t5JVolKrd5o4GeUmUwJjoD/wEv9sDmKWd78naIJvZazlmRxW0sm10csfnhFoeJudZj iNqk+EJ/r2cT0i6bSI0s1HAXulu1c2iohkSEssKzXWkEFnAR0rV3YdYIqOyXHMN4MQi3 /xCP0SHZkFQVRyNUE+SFEjOJuJAoLjhdRfEOL8fnjaIse4rNH1aZZJSBfj2zfwZAIkS0 q3wQ0lsxXA+cnL96mg48JBjxh21kBvBTe9FwaQrUObKCoKE2FU293WL38UnNTqxnEGcD XYIUABsLESVT89VS3GmmdfOJm3PlG6et/5g2GCiHY5axH+rtW5QwIdCtu2DguAje0a3B +KdQ== X-Forwarded-Encrypted: i=1; AJvYcCVmbdD/7wAEImEhIPU+iE1SUbEixKsPmXHhU5dhi/KNsp/VD4+ou5muruSZYI4KQL7cVI0X+QQrUhpXUhR3JW6p@lists.infradead.org X-Gm-Message-State: AOJu0YzxE1eJZ5pYXAP1Tc9TwnDLnwqNUt8khCXKGQerD5bhsglOYKf1 ixHGl+wG4Fcn4/niudgru8cUMDK7IK6umlbWR2JJ80np+NuQntyo6ZrEG+qEuHw= X-Google-Smtp-Source: AGHT+IHBll4ncIEBYGqKdaxs69HtCnmoAhR+84ep9dXSOAPhQjdXaNEiv/qua/AGSiyj5o8AWkwt0A== X-Received: by 2002:a05:6512:12d3:b0:530:aea3:4659 with SMTP id 2adb3069b0e04-539a0658b50mr1838434e87.9.1727871767496; Wed, 02 Oct 2024 05:22:47 -0700 (PDT) Received: from uffe-tuxpro14.. (h-178-174-189-39.A498.priv.bahnhof.se. [178.174.189.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-538a043204fsm1912659e87.165.2024.10.02.05.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Oct 2024 05:22:46 -0700 (PDT) From: Ulf Hansson To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: "Rafael J . Wysocki" , Dikshita Agarwal , Vedang Nagar , Bjorn Andersson , Konrad Dybcio , Nikunj Kela , Bryan O'Donoghue , Thierry Reding , Mikko Perttunen , Jonathan Hunter , Stephan Gerhold , Ilia Lin , Stanimir Varbanov , Vikash Garodia , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/11] PM: domains: Support required OPPs in dev_pm_domain_attach_list() Date: Wed, 2 Oct 2024 14:22:25 +0200 Message-Id: <20241002122232.194245-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241002122232.194245-1-ulf.hansson@linaro.org> References: <20241002122232.194245-1-ulf.hansson@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241002_052249_615885_6CBC7DEF X-CRM114-Status: GOOD ( 22.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In the multiple PM domain case we need platform code to specify the index of the corresponding required OPP in DT for a device, which is what *_opp_attach_genpd() is there to help us with. However, attaching a device to its PM domains is in general better done with dev_pm_domain_attach_list(). To avoid having two different ways to manage this and to prepare for the removal of *_opp_attach_genpd(), let's extend dev_pm_domain_attach|detach_list() to manage the required OPPs too. Signed-off-by: Ulf Hansson --- Changes in v4: - New patch. --- drivers/base/power/common.c | 21 ++++++++++++++++++++- include/linux/pm_domain.h | 8 ++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index cca2fd0a1aed..781968a128ff 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "power.h" @@ -222,13 +223,15 @@ int dev_pm_domain_attach_list(struct device *dev, if (!pds) return -ENOMEM; - size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links); + size = sizeof(*pds->pd_devs) + sizeof(*pds->pd_links) + + sizeof(*pds->opp_tokens); pds->pd_devs = kcalloc(num_pds, size, GFP_KERNEL); if (!pds->pd_devs) { ret = -ENOMEM; goto free_pds; } pds->pd_links = (void *)(pds->pd_devs + num_pds); + pds->opp_tokens = (void *)(pds->pd_links + num_pds); if (link_flags && pd_flags & PD_FLAG_DEV_LINK_ON) link_flags |= DL_FLAG_RPM_ACTIVE; @@ -244,6 +247,19 @@ int dev_pm_domain_attach_list(struct device *dev, goto err_attach; } + if (pd_flags & PD_FLAG_REQUIRED_OPP) { + struct dev_pm_opp_config config = { + .required_dev = pd_dev, + .required_dev_index = i, + }; + + ret = dev_pm_opp_set_config(dev, &config); + if (ret < 0) + goto err_link; + + pds->opp_tokens[i] = ret; + } + if (link_flags) { struct device_link *link; @@ -264,9 +280,11 @@ int dev_pm_domain_attach_list(struct device *dev, return num_pds; err_link: + dev_pm_opp_clear_config(pds->opp_tokens[i]); dev_pm_domain_detach(pd_dev, true); err_attach: while (--i >= 0) { + dev_pm_opp_clear_config(pds->opp_tokens[i]); if (pds->pd_links[i]) device_link_del(pds->pd_links[i]); dev_pm_domain_detach(pds->pd_devs[i], true); @@ -361,6 +379,7 @@ void dev_pm_domain_detach_list(struct dev_pm_domain_list *list) return; for (i = 0; i < list->num_pds; i++) { + dev_pm_opp_clear_config(list->opp_tokens[i]); if (list->pd_links[i]) device_link_del(list->pd_links[i]); dev_pm_domain_detach(list->pd_devs[i], true); diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index b637ec14025f..92f9d56f623d 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -30,9 +30,16 @@ * supplier and its PM domain when creating the * device-links. * + * PD_FLAG_REQUIRED_OPP: Assign required_devs for the required OPPs. The + * index of the required OPP must correspond to the + * index in the array of the pd_names. If pd_names + * isn't specified, the index just follows the + * index for the attached PM domain. + * */ #define PD_FLAG_NO_DEV_LINK BIT(0) #define PD_FLAG_DEV_LINK_ON BIT(1) +#define PD_FLAG_REQUIRED_OPP BIT(2) struct dev_pm_domain_attach_data { const char * const *pd_names; @@ -43,6 +50,7 @@ struct dev_pm_domain_attach_data { struct dev_pm_domain_list { struct device **pd_devs; struct device_link **pd_links; + u32 *opp_tokens; u32 num_pds; };