From mboxrd@z Thu Jan 1 00:00:00 1970 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 3D5BAC77B7A for ; Wed, 7 Jun 2023 13:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MVtBdlVcsdKinNQAIWUxbImK6EpdlMUrkRxmOiwn6HI=; b=jSRSdeQqyzfiOt tIrGxFm8Lh8SmQS/tq2/l218z5424V0WOqMZ8UoBmQfPMXibzjI+nlI96tHHuOuyoeawnWZxE/pBr uAg7eS2cLIcEdzA4sgMGlNxsJw5B18uKLN0RYXxqkGdU2ChhJJWjrnTKzrCypFXAli76EvTp5CZBd 1Pe5zudXbkAqf5nZYETVpwfBw3pPBYqX/ORYmmTSi7IKBmpEHtBDmyru2K5fAoBKJ/5RvmHdfbls0 OTG2wWNxZKJ4hQFhQwxkBPcAW8bUX5PtMiEg/jrTjWzYsrVXkorLKuQx8z2AYbKWbP2Vh0DzOGCxV 59/m6upohY7R3jXldzkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6tXd-006944-2a; Wed, 07 Jun 2023 13:49:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6tXb-00692r-1w for linux-arm-kernel@bombadil.infradead.org; Wed, 07 Jun 2023 13:49:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=sGjeBJdPgpOaGz5axPE4yJTdC/ZTW7+SftWuRdijnGw=; b=eecBNxnll2tzVRKetWYhs4aWOO OsA+CWnCskKYND6tG26y9LCfHkiYjJkBMaqbxVRAW7hFFfWu3oqjrso+uANVEQGNfuu7Qc6NDN9qZ 9ek1XhTp/PzIaHzN9NAsvhIVpWDBomYr1L5yZ/ZT8hBDSicxxeQA/mWPYIdKzoHFBLS+Fdwft3jlb ZicFQnInAiX+32ZH2pAgREVeM3r13f1QvgtozMZ+7HjFXlZ+365E1FjnQm0VV0ceUWk5zJHG9j+2w uK+1Et9pZcpx7ltFsMqt7Z9lH3RF0Mvo2yBOeF2pZ+KR7laZ97Lk1p9UphS0q8ctxn/ZDtKWFhN5u joslBEKA==; Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6sZK-0059Rj-01 for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 12:47:19 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f63006b4e3so3115153e87.1 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=FGNf+AqBRmvFoK1fzjL/YI+EaBkywh5k2lPqqT+52Rln/39iTLESNwKCq7n9FwDGBK SP9sCzwzWjjODBGeozRkQ+tGlQWc+keMCe3so50fJrpI/00AgwbAy1Mv4x1BhqvqwK0j zADtpVwCmch45URE1GQ/wRi3WO29lU9l7abLii57ezaiMB4hWtQVoKPLort97zJH57/L ZfYhUW4bGblzPt2zXwxH1BfYRdY/4VdOe4UY9XUpqJNtDepbdnal/vXRNFExZrFIPJSv lO6BbMsTmPdlbwKTZbR/7NNUU4GR0SGHSC8DvcvJEz9x/djp21znRQoPVZ47hJssxDWw B1QA== X-Gm-Message-State: AC+VfDyUZvSbb9Itri/MgB97XJ1ThvAN9wLvEIuxMxna38TiLdCMaHKQ 7pMmhoy0jrRLX8ELzN88XbBGoQ== X-Google-Smtp-Source: ACHHUZ5gTklOwjvOofwGZaihoVmls0o7/kAM9MgICb3wsd0mnMkP7hrhOgNnZgkaFaScq2dXEcyutw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_134718_134292_9C92892D X-CRM114-Status: GOOD ( 17.90 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel