Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp700074rwd; Wed, 7 Jun 2023 05:55:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4qVDHqpwdqMOaYh0ZssojHT1eGAZE8fuhlxj5Z/4OGDEOc5hB46qk6fxdk8kSHkgi5055F X-Received: by 2002:a05:6a20:8e08:b0:10f:1d33:d667 with SMTP id y8-20020a056a208e0800b0010f1d33d667mr4017985pzj.5.1686142553780; Wed, 07 Jun 2023 05:55:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686142553; cv=none; d=google.com; s=arc-20160816; b=jFpef2er1RT4ywGFcKKuCWBBkQlWTdYIFXAtYbpn96cdskaoCW7JXg3K2qbzlwIacO nFwd+Divl1/JWMSHo6wAdsuz2CazjQdrCG5mqwNYxqhDx+lWUveoBtPUSydyLAzZhd7B AfIZtwp0JAQV+6nTiPxpeHG5XRZbVQGx9pbWQbeUdgd/riQcPhuWpPbzUlXQ50sk2OUH I/crUQBCfyA4Oi1ExTcn53gic8ZooGcApgfoXVufkQAuEQhTEsrN6dCeCoru+SQRZcTE x/7y3M0MQ+KNcrghce+p2EBB3w5LotPQoN156+BAbUySKZXKGjqmNwxzFB9q3UVYPnQh Sj0g== 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=sGjeBJdPgpOaGz5axPE4yJTdC/ZTW7+SftWuRdijnGw=; b=N4PYNRyl9UG3RtlwOHGSr/5b6OfPbIA6gaWsf7tQIRu7xBBHiWxHryQBagO4yrpKBC IKuSpaaeVZJx/R/S+bJIwFyeEmow9D+gfDLwkOjCuXEt7WYOugj20FfhiTPL4oJInZrh ug8hfZ5wmXF1WHLosZPvbs8K7o2+KMS0n0lnGa8H0JRwiMFY99tE8ZzNaNugQE5XJCJL gJC08awkJTD/anz/rZ5jIaIo8mnvbDlSbUK23QRkCuBycn+Q+J3k1P+LxYRY6JdrN6dc q7vV0npqAUNwC0f+51qHB1rwHs4NsPfxPz2JWjT3qIENR/Y7tt2r/ij8YDlvXGFqSQJH BLaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VhYSwRGw; 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 e6-20020a17090301c600b0019c354055d0si9104151plh.304.2023.06.07.05.55.40; Wed, 07 Jun 2023 05:55:53 -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=VhYSwRGw; 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 S240726AbjFGMsQ (ORCPT + 99 others); Wed, 7 Jun 2023 08:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241072AbjFGMre (ORCPT ); Wed, 7 Jun 2023 08:47:34 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE322115 for ; Wed, 7 Jun 2023 05:47:18 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f3b5881734so9101635e87.0 for ; Wed, 07 Jun 2023 05:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686142036; x=1688734036; 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=sGjeBJdPgpOaGz5axPE4yJTdC/ZTW7+SftWuRdijnGw=; b=VhYSwRGwS2Sjs65Fop8qjr5mb66J9YNLa2a4RVeqznMNY8oO0QyaMsQCuzvqLszHNH +m+3Z2jKOhP8JcJry3+rXyqTJwH9JWmQ5P+HiZPCTfHMTkmGy+dnKDCQHQgLsemnl5B3 R1ZOy7rmwRXi+6NSUARdAclEsYiigmQA5dXPRTqwC9WawsqQxWNrzIEvt5e9mAp5FnGY Giliu/jZ0fun/02VZ81sjzagUR7E8YFJ2uuTBXJXS/dlWSd/GmKEQV520EUk5BDxtiC8 0exykeNw/LlLVWVwXf2patkeFJ8kk3m4CrnIZLeyNNbeQTcgIOu7AMhrUJ1zKH5zWWA+ il2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686142036; x=1688734036; 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=sGjeBJdPgpOaGz5axPE4yJTdC/ZTW7+SftWuRdijnGw=; b=FYXhwcH1vv2OqY9cPesX2a0pJeGzCnX+UZxtZz1uy9qLgLvQSsA7HoeWnnVApJv33d BPA8IAJW7M3N2J53EHT4VWJddNV6zahoZzgsHYi5E1KYVWIjqOCcp2547dAqOIL3hPgG zdYamFReBt2Acs9/fk2eqr5OIBaL5SAI+5e5kVSuoGg2SHEJRL9glFC4NVNZXZIAznoO RUvJSeY1H6zdTqF3oWYC65qaTrOYmO5iQlnkMGLpFoD32Sl/ZXoRaf9hUhOk9QtJ4OdY S63be8s0oQx2PcmVH921vcsGYxCZnlnhuiCPYpevtd/FQpiswI5+Uv0jKSrBRawe75sY hiVw== X-Gm-Message-State: AC+VfDzO6JgnpuEaJ4P0lS1CyzzsU8Lj4oe0YrFBHk4OK3PAqLLBvYqA /SRieMHGKa+UjXMqKvoNSgY3ZA== X-Received: by 2002:ac2:5ded:0:b0:4f6:3000:4d4d with SMTP id z13-20020ac25ded000000b004f630004d4dmr2388353lfq.38.1686142036186; Wed, 07 Jun 2023 05:47:16 -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 z7-20020a19f707000000b004f4b3e9e0cesm1781708lfe.297.2023.06.07.05.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 05:47:15 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: 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 16/16] firmware: arm_scmi: Add generic OPP support to the SCMI performance domain Date: Wed, 7 Jun 2023 14:46:28 +0200 Message-Id: <20230607124628.157465-17-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607124628.157465-1-ulf.hansson@linaro.org> References: <20230607124628.157465-1-ulf.hansson@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 To allow a consumer driver to use the generic OPP library to scale the performance for its device, let's dynamically add the OPP table when the device gets attached to the SCMI performance domain. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/scmi_perf_domain.c | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/firmware/arm_scmi/scmi_perf_domain.c b/drivers/firmware/arm_scmi/scmi_perf_domain.c index 9be90a7d94de..e9767ca1d34f 100644 --- a/drivers/firmware/arm_scmi/scmi_perf_domain.c +++ b/drivers/firmware/arm_scmi/scmi_perf_domain.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,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->can_level_set) + return 0; + + ret = pd->perf_ops->device_opps_add(pd->ph, dev, pd->domain_id, true); + 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->can_level_set) + return; + + dev_pm_opp_remove_all_dynamic(dev); +} + static int scmi_perf_domain_probe(struct scmi_device *sdev) { struct device *dev = &sdev->dev; @@ -92,6 +124,8 @@ static int scmi_perf_domain_probe(struct scmi_device *sdev) scmi_pd->genpd.name = perf_ops->name_get(ph, i); scmi_pd->genpd.flags = 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 = perf_ops->level_get(ph, i, &perf_level, false); if (ret) { -- 2.34.1