Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1430156rdh; Mon, 25 Sep 2023 12:31:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9epUEfhvgIzw5oJKuxR7xDDkNcjDmKnUWj7JaO0R0MKcrWZ/dM0AOUDy1O0WenmfshkHZ X-Received: by 2002:a17:90a:950b:b0:273:dffd:664a with SMTP id t11-20020a17090a950b00b00273dffd664amr5060230pjo.20.1695670315262; Mon, 25 Sep 2023 12:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695670315; cv=none; d=google.com; s=arc-20160816; b=peqp9fZjCDr7c51E5wzyo0UQjTAsJNZdWkrWnS8raUMrhOV38XVIPAbB4vaIpWHNfn bULzsebfrmDKQTS+nHXHN7u+clSCVfrNV39FaNZKI0PNsJuj8wrSMH2V3x1Hm8UXbqrC zzeugobxutBtXW+TGulviirpGfAM1wkolOdRPjvuA/MhC6rZ/J0MaUN0UvHE4ZWILC9r BG25l9vODlcbPxUi6BySzt90DLvAoyPiv+X/pB9KFtle0wW1csaxTt30iXgL2xegRs8t g3z7Q4xSxzZXDgkK3C2XQS4r33AnqH59MWkGYv7D3TgqI93NA/iVyOw80BLyIKikJ2FQ LoUg== 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=fsWOr9mWvmZX2dTzJ+FE4Q2Az+t23E8t0uKEFGAoZOI=; fh=0iKC8n1xKtkvw+5RDzSud32j7h9ilf6Mvh4d+L1hSv0=; b=vtno0dNru3hjHFnwEe6pvMYx1cdSLHbmNLAabzazpeWz2Ef/s2vdxmtZ+HjsxCM+Kv /EXeWOHU6M1lSMzZK1asWb3dENwoX5GmjdyHfSpxdF8ICb6LhB2YP1nsszPzNBHroU/4 Jobyb11Pa6ZnWmbxHQy9IXsZWpiL7TorEJt74lOL4xxQTGpuOMgqrj3FcGew+UakT0lq tuhQl1WcDbNHkPvuiXU5uQ+W9KrZaT5+CsL5mh83WGEmPWzj1wpPXYlTDFMC/D9ny22R 80rhK2sVi5hl6W1zsbLU3dxhfV3wfnZutTIClpMNuQYYM+vjK/j3CDgs9t0CmuWprpnS mMCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U+lFD7sQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id fw19-20020a17090b129300b0026f51be8d51si10883966pjb.82.2023.09.25.12.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 12:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U+lFD7sQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 0936B81CDBAC; Mon, 25 Sep 2023 06:18:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231845AbjIYNS0 (ORCPT + 99 others); Mon, 25 Sep 2023 09:18:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231829AbjIYNSO (ORCPT ); Mon, 25 Sep 2023 09:18:14 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A753112A for ; Mon, 25 Sep 2023 06:18:07 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 38308e7fff4ca-2bff936e10fso90935011fa.1 for ; Mon, 25 Sep 2023 06:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647886; x=1696252686; darn=vger.kernel.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=fsWOr9mWvmZX2dTzJ+FE4Q2Az+t23E8t0uKEFGAoZOI=; b=U+lFD7sQe5sx6HhehOqSxkdj/OGzQTs4Dbqn7qRYWEWfrhW83gX2ZKRMQ+w9tKJzfR 9/NzaYUqQgVNtB0JX1JBZsie8+5jpsnjzh22dFDGf4L5u51F/8ijM7XhlV6Gg9npz2Jf 7iKIWHcysRbDb6B8c4FRdYsZMV2gMIOopWSshEmWl6mockpkPVTRMhoUwAv3EgDQsUkT zu62iSCjhU4zuQjyN6EeYuNbIBlOMuf6flDKWqRR+HhdY1QjnhlkOoQxfofse393fwA7 JXUX/Jd90HAB2eb8ebuNRvdLEyq93/2cp0jGt+ueJHR/GhHrLSxo9ahGY3pxMNCfRsN8 L26w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647886; x=1696252686; 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=fsWOr9mWvmZX2dTzJ+FE4Q2Az+t23E8t0uKEFGAoZOI=; b=u/xO/7xY5H4U4SzQ7aAwNwlBj9AkNFOlnKblXIRktlgN9W7Vx8xEqn8KQy7tw0fFW+ iysjDeL/SeKy/MwKIV11bIMlkSMahgbwFfsp3+y0AZAkpih6cO6w3yS339hIdqoCgnnM CxnyvWy/RtxCyPxwBo3gHEh+u8edTuCb9xIToWy8YYMsEqqHCOQ8kCpMYha4Ht+/EVoU lsM7bIb6SCaW6qaHdDmH6IPka7v1gAilN0F+xY/QYo4QY3nKkDL6ZPF9sx1o6LNGACJ1 DI/fv9tikyo9FPrYKADd/I8bPl0kaDp+WltrdR+qLbScg1ni5ywluJ/0T8hH3+brRLtW 1Jcg== X-Gm-Message-State: AOJu0Yx7oVoGZUOvsNOdejstIhm4LxTQaeXBYrD10DToBHgI7Mg0TEQM TsqUJqRsuxpD4GT5DxTt+jdOsw== X-Received: by 2002:ac2:5110:0:b0:502:a964:84b1 with SMTP id q16-20020ac25110000000b00502a96484b1mr2196692lfb.25.1695647886003; Mon, 25 Sep 2023 06:18:06 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id m29-20020a056512015d00b004fe10276bbfsm1823583lfo.296.2023.09.25.06.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:18:05 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , "Rafael J . Wysocki" Cc: Nishanth Menon , Stephen Boyd , Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 9/9] firmware: arm_scmi: Add generic OPP support to the SCMI performance domain Date: Mon, 25 Sep 2023 15:17:15 +0200 Message-Id: <20230925131715.138411-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org> References: <20230925131715.138411-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 25 Sep 2023 06:18:27 -0700 (PDT) To allow a consumer driver to use the OPP library to scale the performance for its device, let's dynamically add the OPP table when the device gets attached to its SCMI performance domain. Signed-off-by: Ulf Hansson --- drivers/pmdomain/arm/scmi_perf_domain.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/pmdomain/arm/scmi_perf_domain.c b/drivers/pmdomain/arm/scmi_perf_domain.c index aa100270500f..bc3f78abb6da 100644 --- a/drivers/pmdomain/arm/scmi_perf_domain.c +++ b/drivers/pmdomain/arm/scmi_perf_domain.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,37 @@ scmi_pd_set_perf_state(struct generic_pm_domain *genpd, unsigned int state) return ret; } +static int +scmi_pd_attach_dev(struct generic_pm_domain *genpd, struct device *dev) +{ + struct scmi_perf_domain *pd = to_scmi_pd(genpd); + int ret; + + /* + * Allow the device to be attached, but don't add the OPP table unless + * the performance level can be changed. + */ + if (!pd->info->set_perf) + return 0; + + ret = pd->perf_ops->device_opps_add(pd->ph, dev, pd->domain_id); + if (ret) + dev_warn(dev, "failed to add OPPs for the device\n"); + + return ret; +} + +static void +scmi_pd_detach_dev(struct generic_pm_domain *genpd, struct device *dev) +{ + struct scmi_perf_domain *pd = to_scmi_pd(genpd); + + if (!pd->info->set_perf) + return; + + dev_pm_opp_remove_all_dynamic(dev); +} + static int scmi_perf_domain_probe(struct scmi_device *sdev) { struct device *dev = &sdev->dev; @@ -95,6 +127,8 @@ static int scmi_perf_domain_probe(struct scmi_device *sdev) scmi_pd->genpd.flags = GENPD_FLAG_ALWAYS_ON | GENPD_FLAG_OPP_TABLE_FW; scmi_pd->genpd.set_performance_state = scmi_pd_set_perf_state; + scmi_pd->genpd.attach_dev = scmi_pd_attach_dev; + scmi_pd->genpd.detach_dev = scmi_pd_detach_dev; ret = pm_genpd_init(&scmi_pd->genpd, NULL, false); if (ret) -- 2.34.1